Package: nexus-keycode
Nexus PythonThis repository contains server-side code for managing devices using Nexus
protocols, including Nexus Keycode.Learn more about about Angaza Nexushere!InstallationNexus Keycode will be available on PyPI. Installation will be as simple as:pipinstallnexus-keycodeThis package comes with a full suite of unit tests, which you can run like so:nose2VersioningPackage VersionThis package uses a form ofsemantic versioning. The version
number is comprised of three components: MAJOR.MINOR.PATCHMajor version numbers represent breaking internal API changes. You may need
to modify your code to accomodate these changes. Minor version numbers
represent feature additions or changes that do not break the library's API,
and are fully backward compatible. Patch version numbers represent bug fixes
or minor changes that do not add additional functionality.The package version is independent of the Nexus System Version that the
package supports.UsageGenerate keycodes for the full and small keypad protocols.Full ProtocolAdd Creditsecret_key=b"\xde\xad\xbe\xef"*4message=FullMessage.add_credit(id_=42,hours=24*7,secret_key=secret_key).to_keycode()# outputs *599 791 493 194 43#Set Creditmessage=FullMessage.set_credit(id_=43,hours=24*10,secret_key=secret_key).to_keycode()# outputs *682 070 357 093 12#Unlockmessage=FullMessage.unlock(id_=44,secret_key=secret_key).to_keycode()# outputs *578 396 697 305 45#Wipemessage=FullMessage.wipe_state(id_=45,flags=FullMessageWipeFlags.WIPE_IDS_ALL,secret_key=secret_key).to_keycode()# outputs *356 107 776 307 38#Enabled/Disabled Testmessage=FactoryFullMessage.oqc_test().to_keycode()# outputs *577 043 3#Factory Testmessage=FactoryFullMessage.allow_test().to_keycode()# outputs *406 498 3#Display PAYG IDmessage=FactoryFullMessage.display_payg_id().to_keycode()# outputs *634 776 5#Nexus Channel Origin CommandsThese commands are accepted byNexus Channel"Controller" devices using the "Full Protocol". Typically, these are used
to manage the secured link state of "Controller" and "Accessory" devices.See also:protocols/channel_origin_commands.pyCreate Nexus Channel Secured Linkfromnexus_keycode.protocols.fullimportFactoryFullMessagefromnexus_keycode.protocols.channel_origin_commandsimportChannelOriginActionmessage=FactoryFullMessage.passthrough_channel_origin_command(ChannelOriginAction.LINK_ACCESSORY_MODE_3,controller_command_count=5,accessory_command_count=2,accessory_sym_key=b"\xAB"*16,controller_sym_key=b"\xCD"*16,)message.to_keycode()# outputs *817 307 500 565 772#Delete Nexus Channel Secured Link (All Accessory Links)fromnexus_keycode.protocols.fullimportFactoryFullMessagefromnexus_keycode.protocols.channel_origin_commandsimportChannelOriginActionmessage=FactoryFullMessage.passthrough_channel_origin_command(ChannelOriginAction.UNLINK_ALL_ACCESSORIES,controller_command_count=7,controller_sym_key=b"\xCD"*16,)message.to_keycode()# outputs *810 023 592 81#Small ProtocolAdd CreditSECRET_KEY=b"\xde\xad\xbe\xef"*4AddCreditSmallMessage(id_=42,days=7,secret_key=secret_key).to_keycode()# outputs 135 242 422 455 244Set CreditSetCreditSmallMessage(id_=44,days=10,secret_key=secret_key).to_keycode()# outputs 142 522 332 234 533UnlockUnlockSmallMessage(id_=45,secret_key=secret_key).to_keycode()# outputs 152 323 254 454 322Wipe Message IDsMaintenanceSmallMessage(type_=MaintenanceSmallMessageType.WIPE_IDS_ALL,secret_key=secret_key).to_keycode()# outputs 122 324 235 545 545Wipe Custom "Restricted Flag"CustomCommandSmallMessage(id_=46,type_=CustomCommandSmallMessageType.WIPE_RESTRICTED_FLAG,secret_key=secret_key).to_keycode()# outputs 154 545 254 542 523Set Credit + Wipe Custom "Restricted Flag"# Creating a message of this type *may* lead to a 'message ID collision',# meaning the message cannot be unambiguously interpreted by the unit# (it might be mistaken for a different message if entered into the unit).# If this occurs, an `ExtendedSmallMessageIdInvalidError` error will be raised.# Typically incrementing the ID by 1 and creating the message again will# succeed.In[25]:ExtendedSmallMessage(id_=50,days=84,type_=ExtendedSmallMessageType.SET_CREDIT_WIPE_RESTRICTED_FLAG,secret_key=secret_key).to_keycode()# raises `ExtendedSmallMessageIdInvalidError: ID 50 yields MAC collision, next valid ID is 51.`In[26]:ExtendedSmallMessage(id_=51,days=84,type_=ExtendedSmallMessageType.SET_CREDIT_WIPE_RESTRICTED_FLAG,secret_key=secret_key).to_keycode()# outputs 145 545 244 442 435