Skip to content

Update PJON 12.x to 13.0

Giovanni Blu Mitolo edited this page Nov 8, 2020 · 12 revisions

Version 13.0 includes a lot of changes although few modifications are generally required in software that depends on 12.x. Consider that the asynchronous acknowledgement feature has been removed, if you were using it, use the acknowledgement instead. If you need any help feel free to open an issue or chat with us on gitter.

Inclusion

In 12.x the inclusion was quite complex and less mature. Templates were used directly and a constant was required to force the right strategy inclusion:

#define PJON_INCLUDE_SWBB
#include<PJON.h>

PJON<SoftwareBitBang> bus;

In 13.0 the inclusion has been fixed and the template complexity is hidden behind a macro:

  #include <PJONSoftwareBitBang.h>
  PJONSoftwareBitBang bus;

Updating to 13.0 reduces the memory footprint of the program including only the code related to the strategy used.

Data structures

In 13.0 the contents of PJON_Packet_Info have been rearranged, for more information see data structures:

// 12.x
Serial.print(packet_info.receiver_bus_id[0]); 
// Print the first byte of the recipient's bus id 
Serial.print(packet_info.sender_id);
// Print the device id of the sender

// 13.0
Serial.print(packet_info.rx.bus_id[0]); 
// Print the first byte of the recipient's bus id 
Serial.print(packet_info.tx.id);
// Print the device id of the sender
12.x 13.0
sender_id tx.id
receiver_id rx.id
sender_bus_id tx.bus_id
receiver_bus_id rx.bus_id

Send functions

The shared version of send_packet, send_packet_blocking, send and send_repeatedly have been changed. In 13.0 it is possible to call those functions passing a PJON_Packet_Info instead of a list of parameters as it was done in 12.x.

Bus id setter and getter

In 12.x the bus id getter and setter was not present and bus_id was accessed directly. In 13.0 get_bus_id and set_bus_id have been added.

ThroughSerial

ThroughSerial now uses the 12.x ThroughSerialAsync implementation, the 12.x ThroughSerial implementation has been removed because of its poor performance. The updated implementation is more reliable and has a default timing configuration able to operate with longer latency.

SoftwareBitBang

In 13.0 SoftwareBitBang implements PJDL 5.0. Only mode 1 and 2 preserved backward-compatibility. SoftwareBitBang does not require anymore a timeout configuration as it was done in 12.x with the constant SWBB_TIMEOUT. PJDL now specifies to derive the timeout from the length of the frame and SoftwareBitBang does that automatically.