Skip to content

Instantly share code, notes, and snippets.

@jjmilburn
Last active April 14, 2021 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjmilburn/f91742c474af62bcfab889caa7bcaa6c to your computer and use it in GitHub Desktop.
Save jjmilburn/f91742c474af62bcfab889caa7bcaa6c to your computer and use it in GitHub Desktop.
ASP Accessory Symmetric Key Link Manager
ASP Accessory Symmetric Key Link Manager
Unlinked
Unlinked Idle*
TICK->Broadcast Timeout Expired?
valid_asp_link_challenge_received->Computing Link Key
Broadcasting Identity
send_asp_notify_accessory_unlinked->Unlinked Idle
Broadcast Timeout Expired?
timeout expired?->Broadcasting Identity
timeout not expired?->Unlinked Idle
Linking
Computing Link Key
key_computed_ok->Store Initiator Link Parameters
key_not_computed_ok-> Error During Linking
Store Initiator Link Parameters
initiator_parameters_stored_ok->Respond Confirming Link
initiator_parameters_not_ok-> Error During Linking
Respond Confirming Link
send_asp_205_response_with_link_key->Linked
Error During Linking
send_asp_error_message->Unlinked
Linked
Linked Idle
TICK->Link Timeout Expired?
valid_unlink_command_received->Unlinking
Link Timeout Expired?
timeout expired?->Unlinked
timeout not expired?->Linked
Unlinking
# spec indicates a 2.02 response, but its non actionable, for debug only.
# so state machine can ignore it.
send_asp_002_delete_link_message->Unlinked Idle
//A function that draws individual traffic lights
function asp_link_light(color, is_illuminated){
return $('div', {style: {backgroundColor: color,
width: '20px',
height: '20px',
opacity: is_illuminated ? 1 : 0.2}});
}
//A function that draws all of our lights, based on the current state
function render(model){
var asp_state = model.active_states[0].parent.name;
return $('div',
asp_link_light('Red', asp_state === 'Unlinked'),
asp_link_light('Yellow', asp_state === 'Linking'),
asp_link_light('Green', asp_state === 'Linked'),
"Current ASP State: " + asp_state);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment