Wireless Sensor Guide lines

Communication API

In this section we will have two option

1. ncd generic Communication API ( could be used in cellular communication or wired communication or point to point communication) 

2. ncd Mesh Communication API

We will have different structure for LoraWAN.

our main aim for having standard(LoraWAN) api is so that our device can work with any LoraWAN gateway in the world. its very important to build a device which can work with generic  gateway.

User should be able to select between mesh or standard communication. by default all device will come with standard API.

ncd generic Communication API — The API data format will be like this one 

7E 00 1F 10 01 00 13 A2 00 41 99 6F F7 FF FE 00 00 7F 00 01 03 FF 01 00 18 00 FF F1 00 00 FF F1 00 00 81

7E — Start Delimiter

00 1F — Length 

10 — Frame Type

00 13 A2 00 41 99 6F F7 — Destination Address ( check destination source address)

FF FE — Reserved in old setup but in our new comm layer this byte will be used to represent RSSI

00 — Broadcast Radius 

00 — Option — in our new comm layer this byte will be used to represent SNR

7F 00 01 03 FF 01 00 18 00 FF F1 00 00 FF F1 00 00 — Payload

Payload — We will have some standard payload Structures like

  1. Sensor type
  2. Command Type
  3. Just Payload

Destination Address — This is where we want to send data. In the current module when the receiver gets the data it replaces this address with the source address. By doing this we will know who sent the data. 

In order to comply with most platforms i believe we should replace it with source address. So in the API we will send the MAC address of the device which is sending data.

ncd generic Communication API— This is exact structure we have right now in our mutitech git repo

7E 00 1F 10 01 00 13 A2 00 41 99 6F F7 FF FE 00 00 7F 00 01 03 FF 01 00 18 00 FF F1 00 00 FF F1 00 00 81

7E — Start Delimiter

00 1F — Length 

10 — Frame Type

00 13 A2 00 41 99 6F F7 — MAC Address of the node ( check destination source address)

FF FE — Reserved in old setup but in our new comm layer this byte will be used to represent RSSI

00 — Broadcast Radius 

00 — Option — in our new comm layer this byte will be used to represent SNR

7F 00 01 03 FF 01 00 18 00 FF F1 00 00 FF F1 00 00 — Payload

Payload — We will have some standard payload Structures like

  1. Sensor type
  2. Command Type
  3. Just Payload

Destination Address — This is where we want to send data. In the current module when the receiver gets the data it replaces this address with the source address. By doing this we will know who sent the data. 

In order to comply with most platforms i believe we should replace it with source address. So in the API we will send the MAC address of the device which is sending data.

This is communication layer we will use if user is using our transmitter and our receiver

ncd mesh communication API — This is API w will use when user usages our transmitter and our receiver

The “Data API” will look like this 

7E 00 1F 10 01 00 13 A2 00 41 99 6F F7 FF FE 00 00 7F 00 01 03 FF 01 00 18 00 FF F1 00 00 FF F1 00 00 81

7E — Start Delimiter

00 1F — Length 

10 — Frame Type

00 13 A2 00 41 99 6F F7 — Destination Address

FF FE — Reserved in old setup but in our new comm layer this byte will be used to represent RSSI

00 — Broadcast Radius 

00 — Option  — in our new comm layer this byte will be used to represent SNR

7F 00 01 03 FF 01 00 18 00 FF F1 00 00 FF F1 00 00 — Payload

But over the Air RF packet will look like this

(Mesh Hash Key)(Network ID)(Source Address) (Data API)

One the receiver gets this. It will do following

  1. Check if it has received this hash key in last 256 transmission. We will store 255 hash key. if it hasn’t received this hash key then go to step two
  2. Check if data passes the network ID test. this makes sure transmitter and receiver are on same network. if it does generate the new API

for the user the receiver side data will look like this 

The “Data API” will look like this 

7E 00 1F 10 01 00 13 A2 00 41 33 47 12 FF FE 00 00 7F 00 01 03 FF 01 00 18 00 FF F1 00 00 FF F1 00 00 F4

7E — Start Delimiter

00 1F — Length 

10 — Frame Type

01 — Frame ID 

00 13 A2 00 41 33 47 12– Source Address

FF FE — Reserved in old setup but in our new comm layer this byte will be used to represent RSSI

00 — Broadcast Radius 

00 — Option — in our new comm layer this byte will be used to represent SNR

7F 00 01 03 FF 01 00 18 00 FF F1 00 00 FF F1 00 00 — Payload

Source address is the address from where data is coming.

What is Hash Key — Hash key is a key which is generated using (Encryption key)(Network ID)(Source Address) (Data API)

What is the use of has key — Lets say we have 5 sensors, one repeater and one gateway. This key will be used to eliminate the duplicate data. We will store 255 hash keys and will match the new coming packet with this hash key to eliminate the RF duplication 

ACK — acknowledgement will also have two formats. One is Standard API and other one is ncd mesh communication API

ACK — Standard API ACK is used to make sure data gets to the destination

The ACK packet will look like this

7E 00 15 10 01 00 13 20 00 41 23 46 83 FF FE 00 00 7B 0D 41 43 4b 00 00 71

7E — Start Delimiter

00 1F — Length 

10 — Frame Type

01 — Frame ID

00 13 20 00 41 23 46 83– Source Address

FF FE — Reserved in old setup but in our new comm layer this byte will be used to represent RSSI

00 — Broadcast Radius 

00 — Option  –in our new comm layer this byte will be used to represent SNR

7B 0D 41 43 4b 00 00 — DACK message 

ACK — ncd mesh communication ACK

Over the wireless link data will go like this

(Mesh Hash Key)(Network ID)(Source Address) (Data API)

Example data over wireless link – 

Our Example data API is this one — 7E 00 1F 10 01 00 13 A2 00 41 99 6F F7 FF FE 00 00 7F 00 01 03 FF 01 00 18 00 FF F1 00 00 FF F1 00 00 81

Our source address is — 00 13 A2 00 41 33 47 12

Our network ID is — 7F FF

Our encryption key is — 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA

Our MD5 hash key will be  — 68a3eb2efe2dfce18658cb47a7892bc7 ( we calculate this using ( Encryption key, network ID, source address, Data API)

On the receiver side data will look like this- 

68a3eb2efe2dfce18658cb47a7892bc7 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 55 AA 7F FF 00 13 A2 00 41 33 47 12 7E 00 1F 10 01 00 13 A2 00 41 99 6F F7 FF FE 00 00 7F 00 01 03 FF 01 00 18 00 FF F1 00 00 FF F1 00 00 81

The receiver will follow this process

  1. Check is this hash key was received in last 255 packets. if it wasn’t then store the key for future reference and move to second step. if the key matches to stored keys then discard the packet 
  2. Every module ( node or GW) will have a network ID. check and see if the network ID received matches the stored GW network ID. if it does the move to step 3 else discard the packet
  3. In this step the layer will create a new data API. in this API it will replace the destination address with source address and the API data packet will look like this 

7E 00 1F 10 01 00 13 A2 00 41 33 47 12 FF FE 00 00 7F 00 01 03 FF 01 00 18 00 FF F1 00 00 FF F1 00 00 F4

     4. in this step just provide the data API as output for further processing 

The data over wireless will be encrypted. so the actual data bytes over wireless link might differs based on encryption key. example RF packet for above packet
68a3eb2efe2dfce18658cb47a7892bc7 680829876709D3334B797C9CE5A5B8F029A3141C4DE1FADE2AF32FE233EDFB7FE24ABBF22413B64D67CF6ECAD5D288B1B027972914CEBBC408F67AA7752B19B5CD34E1A2296DA73C43D8FF44CDACFA3FC7DEEEE467778AF0C2FBD4093F202BC7FB342496692908F1096E7897A9788642BE656D215842AE27ECFA4D1DB6A151F4D6E99BAC6D4CDBD94FCE6F18198BFFCE
 

https://www.md5hashgenerator.com/

https://www.devglan.com/online-tools/aes-encryption-decryption

Mesh Networking

When mesh networking will come in play —

If ncd standard or mesh layer than mesh networking will come in place. 

How it works — every module which get the data will bounce the data without making any change or checking anything.

For example lets say a module receives this data

68a3eb2efe2dfce18658cb47a7892bc7  7F FF 00 13 A2 00 41 33 47 12 7E 00 1F 10 01 00 13 A2 00 41 99 6F F7 FF FE 00 00 7F 00 01 03 FF 01 00 18 00 FF F1 00 00 FF F1 00 00 81

It will check if data is for this module ( by checking destination address) if it is than data will go for further processing based on ncd standard layer and ncd mesh comm layer.

if data is not for this module then it will bounce the data and transmit this data over wireless.

NODE  >>>>>>10KM >>>>>>>>>>>>>>>>>> GW

so lets say data cant make to the gateway. so we will put one of these module in between and it will act as a repeater to establish mesh network.

NODE  >>>>> Repeater >>>>>>>>>> GW

MESH data processing —- 

TX side — 

Definitions — 

  1. Device payload — its the data which will go with API as payload. It could be sensor data, command data or any other data.
    We could have a couple of payload format
    Payload — We will have some standard payload Structures like

Sensor type ( see sensor manual for data structure )

Command Type( see sensor manual for data structure )

  1.  API construction — In this we will wrap the payload around ncd standard comm layer
    The sample API will look something like this
    7E 00 1F 10 01 00 13 A2 00 41 99 6F F7 FF FE 00 00 7F 00 01 03 FF 01 00 18 00 FF F1 00 00 FF F1 00 00 81

    7E — Start Delimiter

00 1F — Length 

10 — Frame Type

00 13 A2 00 41 99 6F F7 — MAC Address of the node ( check destination source address)

FF FE — Reserved in old setup but in our new comm layer this byte will be used to represent RSSI

00 — Broadcast Radius 

00 — Option — in our new comm layer this byte will be used to represent SNR

7F 00 01 03 FF 01 00 18 00 FF F1 00 00 FF F1 00 00 — Payload

81 — Checksum

  1. Complete RF API Construction — In this step we will add the source address and network ID in front of the step 2 (API construction). The sample API will look like this
    7F FF ( network ID) 00 13 A2 00 41 33 47 12( source Address) 7E 00 1F 10 01 00 13 A2 00 41 99 6F F7 FF FE 00 00 7F 00 01 03 FF 01 00 18 00 FF F1 00 00 FF F1 00 00 81 ( step two API)
  2. Complete RF packet construction —
    In this step we will calculate hash key and encrypt the packet. Before sending it over RF.

Basic setttings

There are few settings which can be part of the comm layer as well

  1. Encryption Key
  2. Network ID/ PAN ID
  3. Destination Address

 

Product Architecture