My project target is take samples with a PIC18 microcontroller and send the samples when the gateway (connectport x4) required. I want to make a CLI so i send a command itself as (x1) and then PIC respond with a sample of the ADC and send it to idigi platform using idigi_db presentation.
I have the program in PIC interfacing with xbee in AT mode. I’m new programming python so i have some questions.
Work DIA with xbee in AT mode, API mode or both?
How can i send my PIC command from the gateway in python, i can use xbee_device_ddo_set_param or xbee_device_schedule_after()? I’m really lost here.
Can I modify the file xbee_xbib.py to adapt him to my application?
When you interact with the XBee module in AT mode from your PIC microcontroller, you can for the most part just treat it like a serial port. So from that perspective, you’ll mainly be reading the port, and then just writing to it in response to commands you have received.
With that in mind, it would probably be useful to take a look at some of the serial related drivers in the Dia. (In version 1.2.x).
There are xbee_serial_loopback.py and xbee_serial_terminal.py which both extend xbee_serial.py which gives the basic foundation for sending serial data to an XBee in a Dia device driver.
These will give you some examples of how you might send data so it will be retrieval from the serial port of the XBee, and also how you would read the data that your PIC sends through the XBee.
I would suggest starting with the xbee_serial_loopback device. From glancing at the source, it looks like every 5 seconds (based on the loop_rate_sec setting), it sends some data. Then whenever data is received from the XBee, the message_indication function is called.
Then you would just define a simple serial protocol between the gateway and the PIC that they will use to exchange messages.