This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Offset while sending data

I have a project which will send the temperature from the nRF51DK to host.

The value of the temperature is an integer. As example Value:0x00000A2B -> 2603 ->26.03°C

But on the Host side I will recieve only Value:2B

The same if I change the length of the Bytes to 4

nRF51DK Value is 0x00002710, but on the host side I will recieve Value:10-00-00-00

Here the set up for the characteristic(with 4Bytes):

attr_char_value.p_uuid       = &ble_uuid;
attr_char_value.p_attr_md    = &attr_md;
attr_char_value.init_len     = 4;
attr_char_value.init_offs    = 0;
attr_char_value.max_len      = 4;
attr_char_value.p_value      = NULL;

uint32_t ble_fridge_send_temp(ble_fridge_t * p_fridge, uint8_t temp_value)
{
uint32_t err_code = NRF_SUCCESS;									
ble_gatts_value_t gatts_value;										

if(temp_value != p_fridge->temp_value_last)				
{
	memset(&gatts_value,0,sizeof(gatts_value));			
	
	
	gatts_value.len 	= 4;					
	gatts_value.offset	= 0;												
	gatts_value.p_value	= &temp_value;							
	
	p_fridge->temp_value_last = temp_value;					

	err_code = sd_ble_gatts_value_set(p_fridge->conn_handle,p_fridge->temp_char_handles.value_handle,&gatts_value);
	if(err_code != NRF_SUCCESS)
	{
		return err_code;
	}
}

Why is there an offset?

Or isnt a offset? Maybe the Byte order is false?

Parents Reply Children
No Data
Related