Ah, I hadn’t responded to some of your questions from the above comment - let me try here.
An ‘adf’ for every property.
Sounds good. Do you think it would be possible (eventually) to navigate between different Airlink ‘adfs’ for a given Airlink resource on the website, so a developer could quickly look up what format they’d need to interface with a certain device (or, someone could just include multiple ADF handlers for a given resource if they plan to connect to devices with slightly different implementations, etc).
Each device would just report the internal combination of rtr and UUID within nx/res, that way the gateway can use the rtr value to access the same bluetooth service and not require a UUID registry.
That makes sense to me. So, as long as every Airlink device knows the fixed nx/res UUID, they can use that to determine every other UUID on a device they’re connecting to (the first connection just polls the nx/res UUID, and then makes further logic decisions based on whats available). Agreed that this eliminates the need for an offline UUID registry.
I’ve split it out already in the uploaded airlink documentation as a ‘customer provisioning’ resource. I’m thinking it might also need a human-readable device serial number or payment reference added. Here’s the set proposed:
Noted - the bit that confused me here was that the customer/client info was ‘optional’, which confused me a bit.
You had mentioned that the payg resource should include a product type e.g. water pump etc. That made sense.
I think I may have misspoken here. I’m not sure I see the use case (currently) for a product type on the PAYG credit resource. That resource currently does specify credit units (gallons, hours, minutes, etc), but that doesn’t require a product type. Can you elaborate on what the product type might be used for on that specific resource?
Other potential use cases are if we allow a local authority figure in a community to act as a backup in case someone’s phone is broken, to help update their credits. This is important in productive use cases since they don’t want to miss even a day of productivity and many of the customers are living hand to mouth.
Makes sense - thanks! It sounds like the typical non-gateway device might connect to a handful of gateways over its lifetime (usually), but not ‘dozens’. Correct me if thats wrong, I’m just building a mental model here.
I probably don’t understand enough about encryption to get how this works intuitively, and clearly you have given this some thought. Is there any documentation or example code available that you could point me to?
There is a bit, but there is a larger release pending some other gates currently. The code I want to share with you is the embedded-side code used by this demo. The code that I want to share demonstrates steps 2 and onwards (below). But, the general flow is:
- Backend (or some server that is aware of the secret keys of both the ‘controller’ and ‘accessory’ you wish to securely link) generates an “Origin Command” to link the devices. This is sent to the “Controller” (e.g. gateway device)
- The “Controller” validates it against its own secret key (ensures this command is valid for the controller to accept/has a valid MAC, hasn’t previously been used, etc), and if so, extracts information from the ‘origin command’ that can be used to send a link challenge to the specified “Accessory”. The link challenge is not equivalent to ‘a token’, its information from the server mixed with a random value from the controller/gateway… but functionally, its close enough to think of it as an ‘accessory specific one time use token’.
- At this point, the controller has derived a ‘link security key’ that will be used to secure (generate authentication codes/MACS) for any secured messages sent to/from the accessory.
- The controller sends a ‘link challenge’ to the accessory, which is validated by the accessory (command has a valid MAC, is for this accessory, hasn’t been used before). The accessory uses the link challenge info and its own secret key to independently derive the same ‘link security key’ as the controller.
- The accessory sends back a response ‘proving’ that it knows the same link security key as the controller (without ever sending that key over the wire/air). The controller confirms this, and the link is established.
- All further communication between the Nexus Channel resources for these two devices can use the security layer, which will ensure that messages sent/received are not replayed (protection against MITM and replay attacks), prevents any payload tampering/modification, and protects against address spoofing (the sender has to provide their Nexus ID/some app ID which is used to look up the link security key on the receiver side)
- The message CBOR payload is secured, as well as a nonce, and the CoAP code (GET, response code, etc).
I will share the link when the more useful code is released that has can more easily be followed with that demo…
I could see where having example code for this kind of interaction would make this easier to adopt for someone designing a new device. Do you believe that this interaction is fairly optimal across different use cases and would become the de-facto standard? Or do you think manufacturers might develop their own application layer handshake (e.g. re-using the passthrough property in their own ways)?
For the use cases encountered so far, I think the example showing use of the existing app layer link handshake (Nexus Channel Redoc Wrapper), which provides authentication/integrity is likely sufficient. Its definitely extensible, though - someone could add their own link handshake which supports multi-party/group keys (right now, links are one-to-one), encryption (secrecy) in addition to integrity/authentication, etc.
We were thinking of using a uint_32 device ID per advertisement packet, would the Nexus IDs then be application layer IDs that are separate from the device ID?
Currently, Angaza has been distributing ‘universal’ PAYG IDs freely via the Nexus API that can be converted into Nexus IDs by appending a fixed 2-byte ‘authority ID’ in front of them. These PAYG IDs are used for devices regardless of what PAYG CRM they are sold on (Angaza or otherwise), but its not clear if the Airlink “Device IDs” would be a good fit for generation from this same batch of numbers or not. If not, it might make sense to just assign a new “Authority ID” for Airlink “device IDs” (which are just the IDs as specified/in use now you are describing).
Interoperable gateways from other manufacturers as well as other client’s gateways from the same manufacturer would need to report this one combined property as part of enabling crowd-sourced stolen asset detection.
So it sounds like that you could (maybe in the future) have backend logic similar to ‘tell all gateways to be on the lookout for these reported stolen devices’, and when they pop up, you can geolocate them? That is pretty neat.
For a resource model related to location, would ‘lat/long’ be sufficient, or do you want an accuracy field as well (if available)?