Pairing Module

Description

The Pairing Module is used by applications to assign dynamic addresses to new devices wanting to join a given network.

Pairing Features

SPARK Address Terminology

The Coordinator and Node address are 2-byte long. The MSB is used for the Network ID and the LSB is used for the Device ID (Coordinator ID or Node ID).

Coordinator / Node Address

Network ID

Device ID

1 byte

1 byte

Network ID

The Network ID is used to group multiple devices into a Network Group. Devices from different Network Groups are not able to communicate with each other.

The Network ID is also used by the WPS Concurrency feature which helps to avoid packet collisions with Devices from other Network Groups.

The Network ID ranges from 0x01 to 0xFE. ID 0x00 is reserved for un-configured Network Groups and 0xFF is reserved for the Broadcast feature. This means that there are 254 Network IDs to choose from.

Device ID

The Device ID is used to differentiate devices inside the same Network Group. There are two types of Device IDs, Coordinator IDs and Node IDs. Every Device ID must be unique in the same Network Group.

The Device ID ranges from 0x00 to 0xFE where ID 0x00 is reserved for un-configured devices, ID 0xFF is used by the Broadcast feature, and ID 0x01 is reserved for the Coordinator ID. This implies that a Network Group can support up to 253 Devices.

Broadcast Address

The Broadcast Address is a special-purpose address. Sending a frame with 0xFFFF as the destination address makes a Network Broadcast to all Devices in every Network Group. The address 0xXXFF is a Network Group Broadcast; it broadcasts to every node inside the Network Group XX.

The Network Broadcast is used by the Pairing Procedure when the Coordinator starts a Pairing Request. Since the Coordinator does not know the Node Address, it uses the Network Broadcast address to communicate with it.

Pairing Address

Default Address

When booting a Coordinator or a Node device, its default address is 0x0000. Before a Coordinator pairs with a Node, it must first generate its address. A Node has its default destination address to 0xDEAD to avoid connecting it to an un-configured Coordinator.

Default Address Generation

A default address is internally generated by each device prior to device pairing. Such addresses are generated using a CRC16-CITT scheme which uses the 5-byte SPARK Radio Unique ID as its seed. As described earlier, the following addresses are reserved: 0x0000, 0x**01, 0xFF00, 0x00FF and 0xFFFF. If the Address Generator lands on a reserved address, it starts again using a different seed until a valid address is found.

For a Coordinator device, only the Network ID field is generated as the Device ID is always set to the Coordinator ID (0x01).

For a Node device, both Network ID and Device ID fields are generated. The generated address is used temporarily while waiting for a Pairing Request. The Node then changes its Network and Device ID once it receives the Pairing Request from the Coordinator.

Pairing Procedure

Pairing Procedure Diagram

Figure 4: Pairing Procedure Diagram

Pairing Request

The Pairing Request message is sent by the Coordinator to the Node. First, the Coordinator changes its Source address for the one it generated. It also changes its destination address to the Broadcast address in order to reach any device in Pairing Mode while not knowing their address. It also looks for an available address to assign to the Node and includes it in the payload.

The Coordinator then sends the Pairing Request message continuously until it receives the Node’s response. Upon receiving the Pairing Request message, the Node learns the Coordinator’s Network and Device ID and its Node’s Device Address. The Node re-configures its source and destination address accordingly. The Node then prepares its Pairing Response message.

Pairing Response

The Pairing Response message is sent by the Node to the Coordinator when it receives a Pairing Request message. This message includes the Node role and Unique ID number. Once the Node has sent the Pairing Response message, it waits for the Pairing Confirmation from the Coordinator.

When the Coordinator receives the Pairing Response, it saves the Node address along with its Unique ID in a Paired Device list with the Node Role as its index. It then sends a Pairing Confirmation message.

Pairing Confirmation

The Pairing Confirmation message is sent by the Coordinator to the Node to validate that it was added to the Paired Device list. When the Node receives this message and an acknowledgment is sent back to the Coordinator, the Pairing Process is completed. The user application can then start.

Payload Composition

Pairing Request Payload Composition

Code

Command

Network ID

Coordinator ID

Node ID

0-1

2

3

4

5

Code: 0xCAFE

Command: PAIRING_REQUEST

Network ID: The Network ID that is part of the Coordinator and Node Address used inside the same network.

Coordinator ID: The Coordinator ID that is part of the Coordinator Address.

Node ID The Node ID that is part of the Node Address.

Pairing Response Payload Composition

Code

Command

Device Role

Unique ID

0-1

2

3

4-8

Code: 0xCAFE

Command: PAIRING_RESPONSE

Device Role: The Node’s role used in a Point to Multi Point Pairing application.

Unique ID: The 5-byte Unique Identification number extracted from the SPARK Radio.

Pairing Confirmed Payload Composition

Code

Command

0-1

2

Code: 0xCAFE

Command: PAIRING_CONFIRMED

Address Exchange Example

Here is an example on how the addresses are exchanged during the Pairing Procedure:

Pairing Address Exchange Example

Figure 5: Pairing Address Exchange Example

Paired Device List

The Paired Device List is an array currently containing up to 10 devices. This number can be changed by the user by modifying the constant PAIRING_DEVICE_LIST_MAX_COUNT. A maximum of 254 Node devices is supported.

It is mainly used for Point to Multi Point Pairing applications. When the Coordinator receives the Node Device Role and Unique ID during the Pairing Response state, it adds it to the Paired Device List.

The Coordinator assigns itself to the index 0 in the array to store its address and Unique ID.

The Coordinator uses the Node Device Role to choose the index in the array when adding it to the Paired Device List. The Node Address is saved along with the Unique ID.

Here is an example of what a Paired Device List might look like in a Gaming Hub application.

Index

Device Address

Unique ID

Note

0

0xCD01

0x9834570293

Dongle (Coordinator)

1

0xCD02

0x8794358929

Headset (Node)

2

0xCD03

0x4984753489

Mouse (Node)

3

0xCD04

0x2346987609

Keyboard (Node)

If the Coordinator is reset, the Paired Device List is lost. It is the application responsibility to save it in non-volatile memory (e.g., flash memory) to make it persistent.

Timeout Mechanism

When the Pairing Procedure is initiated, a timer starts to limit the Pairing Process to 10 seconds. If the timer expires before the process is completed, the Pairing Procedure is aborted and the devices are brought back to the Application Mode of operation.

Pairing Schedule

When entering the Pairing Mode, a special Pairing Schedule is configured.

The Pairing Schedule alternates the transmissions between the Coordinator and Node every 500 us while switching on 5 different frequencies.

Pairing Schedule

Figure 6: Pairing Schedule

Once the Pairing Procedure is completed and the Application Mode starts, and the application’s schedule is re-applied.