Questions and discussions about the SDK tools used to program the TD RF modules.
arnaudw
 
Posts: 17
Joined: Fri Jun 12, 2015 8:18 pm

sending float with TD_SIGFOX_Send

by arnaudw Fri Jun 19, 2015 12:31 pm

Hello,

I don't really understand how to send float with the TD_SIGFOX_Send method.
I understood that a sigfox frame is composed with 22 digit hex byte (maximum).

If would like to know how to send for example two float and an integer.
I think i'm close and so far at once :)

Here are the steps i did :

1. Declared the frame
uint8_t sigfox_frame[12];


2. Created a structure like this
typedef struct sigfox_Frame_content {
float myFloat1;
float myFloat2;
int myInteger;
} sigfox_Frame_content;


3. Populated my structure with some values :
sigfox_Frame_content sigfox_message = {
.myFloat1 = 10.0023,
.myFloat2= 2.2424,
.myInteger= 8
};


4. This is the step unclear for me : now i have to populate my sigfox_frame with the two float and the integer before sending with TD_SIGFOX_Send(sigfox_frame, 12, 2);

i think each float will represent 4 byte and the int 4 too, so the frame should be full.
But... how ?
I if understand the principle, i should have :
sigfox_frame[0] = two hex digit from myFloat1
sigfox_frame[1] = two hex digit from myFloat1
sigfox_frame[2] = two hex digit from myFloat1
sigfox_frame[3] = two hex digit from myFloat1
sigfox_frame[4] = two hex digit from myFloat2
sigfox_frame[5] = two hex digit from myFloat2
sigfox_frame[6] = two hex digit from myFloat2
sigfox_frame[7] = two hex digit from myFloat2
sigfox_frame[8] = two hex digit for myInteger
sigfox_frame[9] = two hex digit for myInteger
sigfox_frame[10] = two hex digit for myInteger
sigfox_frame[11] = two hex digit for myInteger


Thanks.

Arnaud.
User avatar
lcheminade
 
Posts: 146
Joined: Mon May 11, 2015 7:47 am

Re: sending float with TD_SIGFOX_Send

by lcheminade Fri Jun 19, 2015 12:42 pm

Hi,

Using float type is a bad idea. Keep in mind we don't have float calculation specific hardware in the core so everyhing needs to be done via software which cost code size, time and energy.

If you want to transmit 10.245 then just transmit 10245 and divide at the server end where you have plenty of calculation power!

Depending on your expected range use uint32_t, uint16_t or uint8_t for 4, 2 or 1 byte data size.

Then coding the frame is just as simple as:

uint32_t my_value = 123456;
uint8_t sigfox_frame[12];


sigfox_frame[0] = my_value >>24;
sigfox_frame[1] = (my_value >>16)&0xFF;
sigfox_frame[2] = (my_value >>8)&0xFF;
sigfox_frame[3] = my_value&0xFF;


Regards.

Loïc
arnaudw
 
Posts: 17
Joined: Fri Jun 12, 2015 8:18 pm

Re: sending float with TD_SIGFOX_Send

by arnaudw Fri Jun 19, 2015 12:51 pm

Huge thanks Loïc !
Return to Tools

Who is online

Users browsing this forum: No registered users and 18 guests