xbee-python icon indicating copy to clipboard operation
xbee-python copied to clipboard

Sending HTTP request after getting packet from Xbee

Open zwitczak opened this issue 2 years ago • 1 comments

The main idea: I have a rpi zero with sensor and xbee s2 module connected (Router API) . I want to send message to the second rpi (coordinator API) every time when status on the sensor changes. When i receive that message on coordinator i want to send HTTP PUT request to my server to change status or at first create resource(if there is no such an endpoint). To send data i’m using examples/communication/SendDataSimple and to receive examples/communication/ReceiveDataSimple. The first time when i send HTTP request everything works fine but later request doesnt’t work - when i want to change change the status again. How to set condition that when we receive the message from XBee, we can trigger the sending of HTTP request?

zwitczak avatar Dec 19 '21 01:12 zwitczak

Hi @zwitczak,

The example ReceiveDataSample includes the implementation of a callback which is executed every time the local XBee receives new data (see line 33).

You can use the same mechanism to send the HTTP request.

For more information, see Data reception callback on the Python Library documentation.

Best Regards

tatianaleon avatar Feb 18 '22 18:02 tatianaleon