Difference between revisions of "Legacy UART-RF-Protocol"
(→Setup Acknowledge Packet) |
|||
Line 76: | Line 76: | ||
=== Discover Network Command === | === Discover Network Command === | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
S00110000000000000000000000000000000105 | S00110000000000000000000000000000000105 | ||
S - sync letter | S - sync letter | ||
Line 100: | Line 90: | ||
packetHandler(SOURCE_RF, address, PACKET_TYPE_DISCOVER_NETWORK_REPLY, data, 2); | packetHandler(SOURCE_RF, address, PACKET_TYPE_DISCOVER_NETWORK_REPLY, data, 2); | ||
} | } | ||
+ | === Discover Network Reply Packet=== | ||
When nodes are discovered, a callback routine is called. The packet handler then sends this packet via uart. | When nodes are discovered, a callback routine is called. The packet handler then sends this packet via uart. | ||
The module sends to the uart a packet with PACKET_TYPE_DISCOVER_NETWORK_REPLY with the received address, the hop-count and the RSSI of the node that was discovered. | The module sends to the uart a packet with PACKET_TYPE_DISCOVER_NETWORK_REPLY with the received address, the hop-count and the RSSI of the node that was discovered. | ||
S0013FE0800000000000000000000000012340601DF | S0013FE0800000000000000000000000012340601DF | ||
This reply means that the node FE080000000000000000000000001234 is 1 hopcounts away and is received with -33dBm signal strength. | This reply means that the node FE080000000000000000000000001234 is 1 hopcounts away and is received with -33dBm signal strength. | ||
+ | |||
+ | === Board specific commads === | ||
+ | ==== LED Data Packet ==== | ||
+ | ==== Button Pressed Packet ==== | ||
+ | ==== Get Plug Data Packet ==== | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
Revision as of 20:24, 24 February 2011
Contents |
Overview
The Demo-Software implemets an UART-to-Radio protocol. For an easy use the pakets to the uart have to be send as hex-values as ASCII, meaning 0x00 ia send as "00". Only '0'-'9' and 'A'-'F' are accepted letters. Additionaly there is an 'Magic Word' - the letter 'S'. The 'S' is used as sync byte to start a packet.
UART packets to radio
The packets to the UART alway have a fixed sceme:
- first letter is the 'S'
- followed by 2 bytes length of the packet (N + 1(type) +16(address))
- followed by 16 bytes IPv6 address of the destination, the IPv6 address ::1 is reserved for the Local Host. Packets to the ocal host are not sent over radio, but they are commands to the module.
- followed by 1 type-byte, that determines the type of the packet. When a module receives the packet, it decides with the type how to handle the packet data. There are several packet types pre-defined - as seen below.
- followed by N data bytes.
Example 1 - Packet to the UART:
S0015FF0200000000000000000000000000010012345678
This commad sends an Broadcast data packet with 4 bytes of data =0x12345678.
- the length is 16Bytes(address) + 1Byte(type) + 4Bytes(data) = 21Bytes = 0x15
- the address FF020000000000000000000000000001 is the IPv6 broadcast address
- type 0x00 means that the packet is a data packet, see the pre-defined packet types below
- the data are 0x12 0x34 0x56 0x78
UART packets from radio
When the radio sends packets via UART, theese packets also have a fixed sceme:
packets from uart of the radio
- first letter is the 'S'
- followed by 2 bytes length of the packet (N + 1(type) +16(address))
- followed by 16 bytes IPv6 address of the destination, the IPv6 address ::1 is reserved for the Local Host. Packets to the ocal host are not sent over radio, but they are commands to the module.
- followed by 1 type-byte, that determines the type of the packet. When a module receives the packet, it decides with the type how to handle the packet data. There are several packet types pre-defined - as seen below
- followed by N data bytes
- followed by one byte RSSI (Radio Signal Strength Indicator) as 8-bit signed integer
NOTE: the RSSI byte is not counted to the length of the packet!
- every packet from the radio closes with an <CR><LF> (hex values 0x13 0x10). So te user can just read one line from the uart and gets the hole packet.
Example 2 - Packet from the UART:
S0014FE80000000000000001FE001000000030600C901C9
The Radio received a packet from node FE80000000000000001FE00100000003 with type=0x06 and data 0x00C901. The RSSI of the received packet was 0xC9= -55dBm
- the length is 16bytes(source address) + 1byte(type) + 3Bytes(data) = 20Bytes = 0x14 (the RSSI is not counted to the length of the packet)
- the address FE80000000000000001FE00100000003 is the IPv6 address of the sender
- type 0x00 means that the packet is a data packet, see the pre-defined packet types below
- the data are 0x12 0x34 0x56 0x78
Implemented Commands / Packet Types
The UART-RF-protocol pre-defines several types of packets (type byte in the packets). Pre-defined packet types are:
typedef enum { PACKET_TYPE_DATA = 0x00, PACKET_TYPE_BIND = 0x01, PACKET_TYPE_BINDACK = 0x02, PACKET_TYPE_UNBIND = 0x03, PACKET_TYPE_SETUP = 0x04, PACKET_TYPE_SETUP_ACK = 0x0C, PACKET_TYPE_DISCOVER_NETWORK = 0x05, PACKET_TYPE_DISCOVER_NETWORK_REPLY = 0x06, //board specific commands for ADB2001 PACKET_TYPE_LED_DATA = 0x07, PACKET_TYPE_BTN_DATA = 0x08, //board specific commands for ICradioPlug PACKET_TYPE_PLUG_GET = 0xF0, } PACKET_TYPE_t;
Data Packet
Binding Commands
Bind Command
Bind Acknowledge Packet
Un-Bind Command
Setup Command
not yet implemented
Setup Acknowledge Packet
not yet implemented
Discover Network Command
S00110000000000000000000000000000000105 S - sync letter 0011 - length = 0x11 = 17 bytes 00000000000000000000000000000001 - address = ::1 (IPv6 Local Host) 05 - type is 0x05 = discover-network command
This is the commad 0x05 to the Local Host. It is the command to discover the network - see below for available commands. The module executes the stack-command for scanning the network.
void rf_CallbackDiscover( unsigned char hopCount, char rssi, unsigned char addrCount, ZWIR_IPv6Address_t* address ) { uint8_t data[2]; data[0] = hopCount; data[1] = rssi; packetHandler(SOURCE_RF, address, PACKET_TYPE_DISCOVER_NETWORK_REPLY, data, 2); }
Discover Network Reply Packet
When nodes are discovered, a callback routine is called. The packet handler then sends this packet via uart. The module sends to the uart a packet with PACKET_TYPE_DISCOVER_NETWORK_REPLY with the received address, the hop-count and the RSSI of the node that was discovered.
S0013FE0800000000000000000000000012340601DF
This reply means that the node FE080000000000000000000000001234 is 1 hopcounts away and is received with -33dBm signal strength.
Board specific commads
LED Data Packet
Button Pressed Packet
Get Plug Data Packet
Some special commands are also implemented and have to be sent via UART to the LOCAL-HOST (::1)
- scanning the network
S00110000000000000000000000000000000105
- getting the module's IPv6 address
S00110000000000000000000000000000000109
- setting the module's LED's
S001300000000000000000000000000000001070100 (set LED1=on, LED2=off) S001300000000000000000000000000000001070001 (set LED1=off, LED2=on)