0

work around for :help with rfm9x, dropped packets?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

work around for :help with rfm9x, dropped packets?

by Rcayot on Sat May 14, 2022 11:40 am

After working this issue, I feel like the answer lies in that the CRC and ACK fro the rfm9x library is for the payload only, and not the header. The reason for this is that I have packets received that are entirely correct except for the rfm.flags information at packet[3]

So, instead of using the flags field for tagging the different sensor data streams, I would like to be able to send a packet with BOTH the data stream indicator ( 1 through 6) and the data. So instead of:

Code: Select all | TOGGLE FULL SIZE
while True:
        temperature = str(round((newsensor.temperature), 2))
        rfm9x.flags=1
         if not rfm9x.send_with_ack(temperature.encode("utf-8")):
            print("No Ack T")
        await asyncio.sleep(interval)


It would be something like:

Code: Select all | TOGGLE FULL SIZE
while True:
        temperature = str(round((newsensor.temperature), 2))
        #rfm9x.flags=1
        #print(rfm9x.flags, temperature)
temperature_ packet = str(1,temperature)       
if not rfm9x.send_with_ack(temperature_packet.encode("utf-8")):
            print("No Ack T")
        await asyncio.sleep(interval)


My question is how do I parse the packet into two variables, the number 1, and the value of 'temperature'

Roger

Rcayot
 
Posts: 244
Joined: Sat Feb 08, 2020 6:48 pm

Re: work around for :help with rfm9x, dropped packets?

by adafruit_support_mike on Sun May 15, 2022 10:21 pm

Create a data structure with the variables you want to use, then use memcpy() to move binary data from the radio into that structure:

Code: Select all | TOGGLE FULL SIZE
    struct message {
        uint8_t     id,
        float       temperature,
    }

    function import_message () {
        message m;
        byte buffer[ sizeof( m ) ];
   
        fill_buffer( buffer );
        memcpy( buffer, &m, sizeof( m ) );
    }

adafruit_support_mike
 
Posts: 64793
Joined: Thu Feb 11, 2010 2:51 pm

Re: work around for :help with rfm9x, dropped packets?

by Rcayot on Mon May 16, 2022 9:25 am

Mike,

That is C code, I am using circuit python. But your suggestion is a good one. I think I have figured it out.

Roger

Rcayot
 
Posts: 244
Joined: Sat Feb 08, 2020 6:48 pm

Please be positive and constructive with your questions and comments.