Addressing

PJON objects can operate in local or shared mode. The PJON protocol v3.2 in local mode supports connectivity for up to 254 devices using a 8bits device identifier, in shared mode supports connectivity for up to 4.294.967.295 buses (groups of devices) and up to 1.090.921.692.930 devices using a 32bits bus identifier and a 8bits device identifier.

Local mode

The simples way to instantiate PJON in local mode is the following:

  PJON<SoftwareBitBang> bus;

When the object is instantiated without passing parameters it operates in local mode and the device identifier is set to 255 or PJON_NOT_ASSIGNED. PJON objects can be instantiated passing the device identifier:

  PJON<SoftwareBitBang> bus(44);

bus receives packets for device identifier 44 and ignores all others.

Set device identifier

Device id can be set or changed after instantiation using set_id:

  bus.set_id(44);  

0 or PJON_BROADCAST is reserved for broadcasting and should not be used as a device identifier.

Get device identifier

The device identifier of an object can be read after instantiation using device_id:

  uint8_t id = bus.device_id(); // Get device id

device_id returns 255 or PJON_NOT_ASSIGNED if the instance is initialised without configuring its device identifier.

Shared mode

if the medium used is private and not accessible from the outside world (wired network in home, business, industry) any bus indexing scheme can be used without worrying about bus id collision; if instead the network uses a shared medium, such as commonly used radio frequencies like LoRa, it is strongly suggested to request a unique PJON bus id here to avoid collisions.

Instantiation in shared mode:

uint8_t bus_id[4] = {1, 2, 3, 4};
PJON<SoftwareBitBang> bus(bus_id, 44);
// Device id 44, bus id 1.2.3.4 in shared mode

Get or set bus identifier

The bus id can be read and set after initialisation using bus_id:

  bus.bus_id; // Get or set bus id

This document is automatically generated from the github repository. If you have noticed an error or an inconsistency, please report it opening an issue here

The PJON protocol handbook

This is the first publication about PJON, which contains the documentation, the specification, many application examples and troubleshooting techniques. The book is Made in Italy and within its 204 pages the whole PJON network protocol stack and its strategies are accurately described with graphs, color pictures and comments on its implementation. Choosing this handy format, you will always have PJON with you, also when not being connected to Internet.


BUY NOW!