cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any way of using ACI_HAL_END_OF_RADIO_ACTIVITY_VSEVT_CODE event to send data every connection event?

WRosé.1
Associate II

I would like to keep updating a char value with every connection event.

Im using a stm32wb15.

every time I get a

ACI_HAL_END_OF_RADIO_ACTIVITY_VSEVT_CODE with last state 0x02 which correspond to - 0x02: Connection event slave.

As I understand this means a connection event has ended and I can now update the char value again with

aci_gatt_update_char_value(...)

But it seems that ACI_HAL_END_OF_RADIO_ACTIVITY_VSEVT_CODE with last state 0x02 happens more frequently than the connection interval and I get an error from aci_gatt_update_char_value.

Is the last state 0x02 not corresponding to the connection event?

And do you have any suggestions on how to update the char value and send indication every connection event?

Best regards Wallentin

11 REPLIES 11
Remy ISSALYS
ST Employee

Hello,

Yes, it's right way to update the char value and send indication every connection event, this event is generated when the device completes a radio activity and provide information when a new radio activity will be performed. You can select which radio activity event you want to have using ACI_HAL_SET_RADIO_ACTIVITY_MASK command. Indeed, the last state 0x02 correspond to Connection slave according to STM32WB_BLE_Wireless_Interface.html documentation. You can find more information about event and command in this documentation. What is the status error code that return the aci_gatt_update_char_value command?

Best Regards

 Thanks Remy!

To clarify im sending an indication from the peripheral when a button is held, and Im sending right after the 0x02 slave connection event in radio activity callback.

So first time the

  aci_gatt_update_char_value(...)

returns success

But then the next n times (depending on the connection interval, It is around 1 second of errors) returns error 0x46

which maybe is

#define BLE_STATUS_INSUFFICIENT_RESOURCES               0x64U

but with the wrong endian format?

Because I cannot see any error code for 0x46.

So what I was thinking is that the central might not confirm the indication fast enough? But should that correspond to this problem?

Do you have any idea?

Best Regards W

Hi,

Can you share the characteristic configuration?

Once you are connected and indications are enabled, if you call aci_gatt_update_char_value command with a random value after each end of radio activity event (without managed the update with button), do you have the same error?

If you try to send notification instead of indication, is it working as expected or not? Are you able to perform air traces?

Best Regards

COPY_DIO_UUID(uuid.Char_UUID_128);
 
  ret = aci_gatt_add_char(CustomContext.CustomDataHdle,
                          UUID_TYPE_128, &uuid,
                          SizeDat,
                          CHAR_PROP_INDICATE,
                          ATTR_PERMISSION_NONE,
                          GATT_NOTIFY_ATTRIBUTE_WRITE |    GATT_NOTIFY_WRITE_REQ_AND_WAIT_FOR_APPL_RESP | GATT_NOTIFY_READ_REQ_AND_WAIT_FOR_APPL_RESP,
                          0x10,
                          CHAR_VALUE_LEN_VARIABLE,
                          &(CustomContext.CustomDatHdle));

It was no if I sent it without button press. But it does work with notification instead of indication!

I can try to perform air traces if that is the only solution!

Best regards

Hello,

It is not possible to send an indication each connection event because you have to wait the ACK from the central. The ACK will be received in the next connection event. It works with notification because there isn't ACK.

Best Regards

Thank you for all answers!

The main issue for me was actually an internal bug where I held the MX_APPE_Process() for far too long...

Which stopped the application from sending data.

I have fooled around with it and it works as expected now. The only question I have is why it normally takes more than 1 extra connection request to get the acc. So if I send on the first I cannot normally send for the the second which makes sense because of the acc. But I can never send on the third connection event and sometimes even 4rd. Do you have any Idea why the acc does not come on the connection event after?

Edit: I get error 0x0C when I cannot send indication for 2-3 connection events after the initial worked? Cannot find this error anywhere 

Best regards W

Hello,

How did you manage the indication, are you using a task to send the command? Did you add some code in while loop in main.c file?

Best Regards

So each connection event I check if data should be sent. If it does I start a task

UTIL_SEQ_SetTask(1 << CFG_TASK_SEND_DATA_ID, CFG_SCH_PRIO_0);

which calls

aci_gatt_update_char_value

Then I have to wait for

ACI_GATT_SERVER_CONFIRMATION_VSEVT_CODE

to be called.

So every time I update data I have to check that the confirmation has been received.

So it will be

conn event 1: set task to send data

conn event 2: send data on ble

conn event 3: set task to send data

conn event 4: nothing

in between: confirmation event,

conn event 5: set task

.

.

.

Maybe this is the optimal IDK.

I did saw that the first time I send after reboot the confirmation happens faster like

conn event 1: set task to send data

conn event 2: send data on ble

conn event 3: set task to send data

in between: confirmation event,

But the ones after that is slower

Hello,

What is the remote device, is it a smartphone or another WB? The confirmation event depends on the remote device.

Best Regards