Skip to main content

Sending an array via BLE

DA14530 and DA14531

3 months ago

Posted by StandJa 25 points 1 reply
0 upvotes

Hello Dialog Support,

i am using the DA14530/1 Development Kit-Pro. I have used the "DA14531-DA14585-586_Measuring_Temperature" project from here.

I managed to rewrite the example to read values from my sensor via I2C and send one at a time via BLE. However, I have to send 3 values at the same time. 

Now, I have already experimented with storing values in an array and sending this, but nothing is displayed in the BLE Scanner app on my smartphone for Value. When sending single values, the correct values were always displayed there. 

Is there an error in the code below? Is it even possible to send an array like this or is it just not displayed in the app? If it is only not displayed in the app, what are the possibilities to check if the correct data is sent? 

Thanks Jakob

 

This function fills the array with values

void I2C_get_all_values(float* data){
	i2c_test();
	
	data[0] = values[0];
	data[1] = values[1];
	data[2] = values[2];	
}

 

In this function the above function is called and the array should be sent

void user_send_temperature_ntf(void)
{
    uint8_t length = 6;
    
#if defined (CFG_USE_INTERNAL_TEMP_SENSOR) && (__DA14531__)
    
        adc_config_t temp_config = {
        .input_mode = ADC_INPUT_MODE_SINGLE_ENDED,
        .input = ADC_INPUT_SE_TEMP_SENS,
    };
        
    adc_init(&temp_config);
    
    int8_t temperature = adc_get_temp();
    
    adc_disable();
#else
		float data[3] = {0};
		I2C_get_all_values(data);
#endif
		struct custs1_val_ntf_ind_req* req = KE_MSG_ALLOC_DYN(CUSTS1_VAL_NTF_REQ,
															prf_get_task_from_id(TASK_ID_CUSTS1),
															TASK_APP,
															custs1_val_ntf_ind_req,
															length);
																
		req->conidx = 0;                                       
		req->notification = true;                       
		req->handle = USER_IDX_TEMPERATURE_VAL_VAL;          
		req->length = length;                          		  
				
		memcpy(req->value, data, length);			
		
		ke_msg_send(req);                                     
	

    
	timer_temperature_ntf = app_easy_timer(NOTIFICATION_DELAY/10, user_send_temperature_ntf); 																														
}

 

accepted answer!

3 months ago

PM_Dialog

Hi StandJa,

Thanks for your question online.

The problem might be the float point format…

I used the ble_app_peripheral example of the SDK in order to send an array of integers over notifications in the ADC 1 characteristic. This is working fine..

uint16_t data[3] = {0};

          

data[0] = 1;

data[1] = 2;

data[2] = 3;     



//req->conhdl = app_env->conhdl;

req->handle = SVC1_IDX_ADC_VAL_1_VAL;

req->length = DEF_SVC1_ADC_VAL_1_CHAR_LEN;

req->notification = true;



memcpy(req->value, data, DEF_SVC1_ADC_VAL_1_CHAR_LEN);    

If you replace the uint16_t with float, the DA14531 is still sending notifications to the mobile app..

DEF_SVC1_ADC_VAL_1_CHAR_LEN is defined to 6.

Can you please try to test this with the ble_app_peripheral example of the SDK and check if you are getting the correct data? Please check app_adcval1_timer_cb_handler callback

Keep in mind that req->value is an uint8_t array as defined in custs1_val_ntf_ind_req…

You can also take a look at the following example from our GIT repo :

https://github.com/dialog-semiconductor/BLE_SDK6_examples/tree/main/connectivity/ble_temperature_ntf

Thanks, PM_Dialog