Hi there,
I would like to cast out decimal values from the BLE scanner. How can I implement it? I am trying to use the arch_printf ability but I do not how to do it exactly. Since, I want the values to be in the attribute of the characteristics of ADC VAL 1, Thanks!
Here's my code:
void app_adcval1_timer_cb_handler()
{
struct custs1_val_ntf_req* req = KE_MSG_ALLOC_DYN(CUSTS1_VAL_NTF_REQ,
TASK_CUSTS1,
TASK_APP,
custs1_val_ntf_req,
DEF_CUST1_ADC_VAL_1_CHAR_LEN);
// ADC value to be sampled
static uint32_t heart_rate, sample, sample2;
adc_init (GP_ADC_SE, 0, GP_ADC_ATTN3X);
adc_enable_channel (ADC_CHANNEL_P01);
sample = adc_get_sample ();
adc_init (GP_ADC_SE, GP_ADC_SIGN, GP_ADC_ATTN3X);
adc_enable_channel (ADC_CHANNEL_P01);
sample2 = adc_get_sample ();
heart_rate = (sample + sample2);
heart_rate = heart_rate/2;
req->conhdl = app_env->conhdl;
req->handle = CUST1_IDX_ADC_VAL_1_VAL;
req->length = DEF_CUST1_ADC_VAL_1_CHAR_LEN;
memcpy(req->value, &heart_rate, DEF_CUST1_ADC_VAL_1_CHAR_LEN);
ke_msg_send(req);
if (ke_state_get(TASK_APP) == APP_CONNECTED)
{
// Set it once again until Stop command is received in Control Characteristic
timer_used = app_easy_timer(APP_PERIPHERAL_CTRL_TIMER_DELAY, app_adcval1_timer_cb_handler);
}
}
Hi herochua617,
You only need enable it and configure assoicated GPIOs for UART TX/RX. Take the sample ble_app_peripehral for instance. Define the macro CFG_PRINTF and the arch_printf will function.
Hi there,
Just to confirm with it, I will get the value output from my BLE scanner apps on my phone at the ADC VAL 1 characteristics with the decimal values? I have done configuring the UART_TX and RX and also I have defined the MACRO in user_custs1_impl.c in the ble_app_peripheral. I have written my code like this:
req->conhdl = app_env->conhdl;
req->handle = CUST1_IDX_ADC_VAL_1_VAL;
req->length = DEF_CUST1_ADC_VAL_1_CHAR_LEN;
memcpy(req->data, &heart_rate, DEF_CUST1_ADC_VAL_1_CHAR_LEN);
arch_printf ();
Since the req->data is point to an array which store the values in bytes and it is defined as a character values, how can use the arch_printf to allow me to get an integer values instead of hexadecimal from my smartphone BLE scanner apps? I am thinking what to put in my printf in order to do that.
Thank you very much!
Hi there,
As you can see the picture here, that I have linked. I am getting only the values in hexadecimal.
Hi herochua617,
I think I misunderstand your questions. arch_printf is to print out strings via UART.
As your question, it's always hex value sent to the air and received on the app side.Its' app to decide how to use these hex values and interpret them accordingly.
Hi LT_Dialog,
Even if I am using HRPS profile, I still need to make an apps to interpret the values? Can't I use the BLE scanner apps to get values in decimal? According to this link, they are able to obtain decimal values in the BLE scanner apps so this is why I am wondering whether it is applicable.https://github.com/ARMmbed/ble-examples/tree/master/BLE_HeartRate. Thanks!
Hi herochua671,
Data is all sent and received in hex. Apps can decide how to interpret(or show on the display) the data it receives. It's probably BLE scanner interprets in a more human-readable way characteristic values of those SIG profiles such as Heart Rate Profile.
非常感谢。顺便说一下,请参考to this link that I have commented on. Thankshttps://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bl....