I have a function that accepts uint8_t* which is supposed to be a string. I want to send a double to this function. I have tried this code below but it doesn't work.
double a = 10.98
uint8_t* p = (uint8_t*) &a;
printf("p: %u \n", p);
send_data(p);
But This code below works, all I want is to replace the string "90" with a double variable ABOVE.
static const char *data[6];
data[0] = "90";
static uint8_t *test;
test = ( unsigned char *) data[dataCounter] ;
send_data(test);
So what I mean by doesn't work is that the function send_data is supposed to send a string over bluetooth to a android phone. If I do it like the first sample code, the string is passed correctly.
Note: I think its possibly because of the difference in data types that is being passed to the second argument. The function is expecting 3 arguments.
static uint32_t send_data(uint8_t data[]){
return ble_nus_string_send(&m_nus, data, 5);
}
This is the function defintion:
uint32_t ble_nus_string_send (ble_nus_t * p_nus,uint8_t * p_string,
uint16_t length
)