Hi, I wrote simple transport for MySensors based on PJON protocol (single wire multimaster bus system). Actually this implementation is beta version but in my test enviroment on 3 nodes is working stable.
https://github.com/4ib3r/MyTransportPJON
Best posts made by 4ib3r
-
Transport based on single wire PJON protocol
-
RE: Transport based on single wire PJON protocol
@hek Indeed I forgot about the RS485, but PJON don't require additional elements.
Ok, I try to port this transport to development branch. -
RE: Transport based on single wire PJON protocol
I write new version based on development branch: https://github.com/4ib3r/Arduino
Unfortunately in this version new transport is integral part of library, but use of this is much easier.
Now I use synchronous send method with check acknowledge, and loop 500 times with random 100-600us sleep time for ACK, in tests this method is better than async.
Self PJON library is still required to run this transport and is not included. -
RE: Transport based on single wire PJON protocol
Sory, I forgot commit MySensors.h file, with definitions.
Definition "MY_PJON" sets transport to PJON./* Simple serial gateway with PJON transport and error handling */ // Enable and select radio type attached //#define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_PJON //select PJON transport #define PJON_PIN 12 //optional to change pin (12 is default) #define MY_GATEWAY_SERIAL #include <MySensor.h> void before() { //bus object is not initialized in this method } void setup() { bus.set_error(error_handler); //direct bus object access } void presentation() { } void loop() { } void error_handler(uint8_t code, uint8_t data) { if(code == CONNECTION_LOST) { Serial.print("Connection with device ID "); Serial.print(data); Serial.println(" is lost."); } if(code == PACKETS_BUFFER_FULL) { Serial.print("Packet buffer is full, has now a length of "); Serial.println(data, DEC); Serial.println("Possible wrong bus configuration!"); Serial.println("higher MAX_PACKETS in PJON.h if necessary."); } if(code == MEMORY_FULL) { Serial.println("Packet memory allocation failed. Memory is full."); } if(code == CONTENT_TOO_LONG) { Serial.print("Content is too long, length: "); Serial.println(data); } if(code == ID_ACQUISITION_FAIL) { Serial.print("Can't acquire a free id "); Serial.println(data); } }
I created a pull request to PJON with change that allows define the broadcast address because in MySensors is 0xff.