Example-Code for a generic Server (e.g. Sensor, Display)
More...
#include <PJON.h>
Example-Code for a generic Server (e.g. Sensor, Display)
- Author
- drtrigon
- Date
- 2018-07-31
- Version
- 1.2
- make it more reliable by considering
- network delay/latency LUDP_RESPONSE_TIMEOUT (especially when on battery powered wifi)
- a lot of switches in row (3 for outdoor part of bus)
- possibility of blocked lora channels/freq (increasing delays)
- having (u)sleep in order to reduce cpu load and give os and hardware time
- clean bus from old (hanging) messages
-
1.1
- use different IDs for linux/ubuntu and raspi builds (use
make raspi
)
- status and error handling added
- debug output to stderr added
- retrying disabled in favour of the former changes
-
1.0
* OneWire PJON Generic "OWPG" scheme:
* Server e.g. linux machine or raspi
* OWPJON/LINUX/Local/LocalUDP/RemoteWorker/DeviceGeneric/ (this sketch)
* OWPJON/LINUX/Local/ThroughSerial/RemoteWorker/DeviceGeneric/
* Tunnel(er) similar to 1wire master (similar cause we are on a multi-master bus) e.g. AVR
* OWPJON/ARDUINO/Local/SoftwareBitBang/Tunneler/BlinkingSwitch/
* OWPJON/ARDUINO/Local/SoftwareBitBang/Tunneler/BlinkingSwitch_SWBB-TL/
* OWPJON/ARDUINO/Local/SoftwareBitBang/Tunneler/BlinkingSwitch_SWBB-TS/
* OWPJON/ARDUINO/Local/ThroughSerial/SoftwareBitBangSurrogate/Surrogate/ (obsolete)
* Devices e.g. AVR
* OWPJON/ARDUINO/Local/SoftwareBitBang/DeviceGeneric/
* OWPJON/ARDUINO/Local/SoftwareBitBang/OWP_DG_LCD_Sensors/
* OWPJON/ARDUINO/Local/SoftwareBitBang/OWP_DG_1w-adaptor/
* OWPJON/ATTINY/Local/SoftwareBitBang/DeviceGeneric/
* ...
*
* Reliability and connection issues:
* It seems that battery powering the notebook (connected via wifi) has heavy influence
* on UDP packet send delay (and thus PJON health).
* Increase LUDP_RESPONSE_TIMEOUT to 1000000 (1s) in @ref libraries/PJON/src/strategies/LocalUDP/LocalUDP.h
* Apply patch: .../sketchbook$ patch -p0 < OWPJON/20180731-udp_latency.patch
* Also adopting poll timings might help ... for more info in general @ee https://github.com/gioblu/PJON/issues/222
*
* Compatible with: ubuntu 14.04, raspi (look at the Makefile)
* ID 45: owpshell on linux/ubuntu (testing)
* ID 46: owpshell on raspi .41 (productive)
*
* Example sending READ_INFO 0x01 to device id 44:
* $ printf "\x01" | ./owpshell - - 44
* owp:dg:v1
* $ printf "\x11" | ./owpshell - - 44 | ../../../ThroughSerial/RemoteWorker/DeviceGeneric/unpack.py f
* 4.771999835968018,
* $ printf "\x12" | ./owpshell - - 44 | ../../../ThroughSerial/RemoteWorker/DeviceGeneric/unpack.py f
* 28.02459144592285,
* More info can be found in @ref OWPJON/README.md.
*
* Thanks to:
* gioblu - PJON 11.0 and support
* @see https://www.pjon.org/
* @see https://github.com/gioblu/PJON
* fredilarsen - support
*
#define PJON_INCLUDE_LUDP |
PJON<LocalUDP> bus |
( |
ID |
| ) |
|
void error_handler |
( |
uint8_t |
code, |
|
|
uint16_t |
data, |
|
|
void * |
custom_pointer |
|
) |
| |
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
void receiver_function |
( |
uint8_t * |
payload, |
|
|
uint16_t |
length, |
|
|
const PJON_Packet_Info & |
packet_info |
|
) |
| |