Dear dialog support,
is there a simple way to check if the ble stack state is free?
I would like to write a program, which always sends a numerical value via bluetooth, as soon as the old numerical value is sent.
Kind regards.
Device:
Hi DMueller,
I am sorry, but i dont quite get the question, can you please clarify ?
If you would like to do what you are describing on the second line of your post, you can use indications (the central has to confirm the reception of the message so you will get a completetion message as soon as the central receives the indication). On the other hand notifications are also used but there is no confirmation by the client for the reception on application level.
Thanks MT_dialog
Hi MT_dialog,
if i want to send two bytes, this bytes are stored on a stack. I can fill the stack like a buffer. Or is this not true?
My question was, can i recognize by means of a flag or another indicator whether this stack/buffer is full or empty?
Yes i want it to do. On the central there is notify. But i want that the server is able to recognize whether it can send or not.
Kind regards.
Hi DMueller,
处理BLE堆栈缓冲区一样很simplistic since it implements the entire BLE stack, things are not that simple and as an end user you are interfacing with the BLE concepts and not how the stack handles the RX/TX messages, but in the bottom line lets assume that we can, if you would like to send the value of a characteristic that has 2 bytes length via a notification then the stack will queue that message along with the pointer which it will be pointing to that characteristics data into a 18 length message buffer. So in case of a notification, lets take for example the custom profile which is implemented in the ble_app_peripheral, the application will send the CUSTS1_VAL_IND_REQ (application specific message) and the profile will issue a GATTC_SEND_EVT_CMD that will signal the stack to place into the TX buffer that a transmition is going to occur in the next connection interval. Now the notifications dont involve a confirmation from the other side (ACK from the master of the connection), but as soon as you send the GATTC_SEND_EVT_CMD the stack will reply with a confirmation message that the notification has been placed into the buffer. In order for the stack to let you know that the notification has entered the buffer it will reply with a GATTC_CMP_EVT and from the the gattc_cmp_evt_handler() the profile will notify the application (with a CUSTS1_VAL_NTF_CFM message) that the notification has succesfully entered the buffer and it will leave on the next connection interval. You can catch this message in the user_catch_rest_hndl().
Thanks MT_dialog
Hi MT_dialog,
thank you for the answer. Unfortunately it isn't quite what i meant, because the CUSTS1_VAL_NTF_CFM message came only after i send something. But i want to recognize if nothing is in the ble stack, too.
I want to send every time a new value, when no values are in the ble stack. At the beginn of the programm usually the ble stack is emty. I wanted to implement something like this:
if (nothing in the ble stack)
{
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);
静态uint16_t样本;
sample = (sample <= 0xffff) ? (sample + 1) : 0;
req->conhdl = app_env->conhdl;
req->handle = CUST1_IDX_ADC_VAL_1_VAL;
req->length = DEF_CUST1_ADC_VAL_1_CHAR_LEN;
memcpy(请求- >价值,&sample, 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);
}
}
Exists a way to implement this?
Kind regards.
Hi DMuller,
I am not sure i understand the reason for this kind of implementation, yes the confirmation message is send back to the application as soon as the notification is successfully placed in the TX buffer until the connection interval moment comes and the data are released. You can try to use the l2cm_get_nb_buffer_available() function which will return the available size of the data in the low level buffer.
Thanks MT_dialog
Hi MT_dialog,
i want to send one value after the next value. And the new value may not be sent until the prevous one is sent.
Many thanks for the great help. Now it works.
Kind regards.