cancel
Showing results for 
Search instead for 
Did you mean: 

Bluenrg-ms get accepted connection interval

Chalk Talk
Associate
Posted on March 06, 2018 at 18:01

Hi, I'm looking to do some timing specific code with the Bluenrg MS

It is running as a peripheral, and once a connection is established, we send an update connection request to the master, and get a response saying is was accepted.

The problem I'm running into, is what is the exact connection interval the master will use?

In the request we supply a min and max value (10ms to 20ms, 0 slave latency), but the response only says that these parameters were accepted.

Is there a procedure, or ACI type command that we can use to query the connection interval actually being used?

#ble #bluenrg
1 REPLY 1
Antonio Vilei
Senior III
Posted on March 09, 2018 at 15:35

Hi,

you can get that information by using the HCI_Event_CB() callback. The latter is called whenever you get an event from the BlueNRG-MS chip. If you need the actual connection interval chosen by the Central device, you can handle the EVT_LE_META_EVENT, where you can read out this information as the interval parameter of the evt_le_connection_complete data structure.

Below I've highlighted the part of code(uint16_t conn_interval = cc->interval)that you need to add to your existing HCI_Event_CB() callback function.

void HCI_Event_CB(void *pckt)
{
 hci_uart_pckt *hci_pckt = pckt;
 /* obtain event packet */
 hci_event_pckt *event_pckt = (hci_event_pckt*)hci_pckt->data;
 
 if(hci_pckt->type != HCI_EVENT_PKT)
 return;
 
 switch(event_pckt->evt){
 
 case EVT_DISCONN_COMPLETE:
 {
 GAP_DisconnectionComplete_CB();
 }
 break;
 
 case EVT_LE_META_EVENT:
 {
 evt_le_meta_event *evt = (void *)event_pckt->data;
 
 switch(evt->subevent){
 case EVT_LE_CONN_COMPLETE:
 {
 evt_le_connection_complete *cc = (void *)evt->data;
 /* THIS IS WHERE YOU CAN GET THE ACTUAL CONNECTION INTERVAL */
 uint16_t conn_interval = cc->interval;
 GAP_ConnectionComplete_CB(cc->peer_bdaddr, cc->handle);
 }
 break;
 }
 }
 break;

typedef __packed struct _evt_le_connection_complete{
 uint8_t status;
 uint16_t handle;
 uint8_t role;
 uint8_t peer_bdaddr_type;
 tBDAddr peer_bdaddr;
 uint16_t interval;
 uint16_t latency;
 uint16_t supervision_timeout;
 uint8_t master_clock_accuracy;
} PACKED evt_le_connection_complete;
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

Best regards,

Antonio