Last active
April 14, 2021 00:33
-
-
Save jjmilburn/f91742c474af62bcfab889caa7bcaa6c to your computer and use it in GitHub Desktop.
ASP Accessory Symmetric Key Link Manager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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