cancel
Showing results for 
Search instead for 
Did you mean: 

BlueNRG stops advertising after some time

hardware
Associate II
Posted on September 28, 2015 at 19:19

Hi,

I'm having trouble with advertising: it seems that after some time, the module stops advertising.

The actual time after the issue appears seems to be grossly related to the Advertising_Interval_Min & Advertising_Interval_Max values. The lower the values, the shorter the time the issue appears.

Values such as 0x800 and 0x900 (default) seems to encounter the issues after days but values such as 0x20 and 0x30 encounter the issue after minutes.

When the advertisement stops, it is still possible to connect to the module, using it's address.

Below is some code to reproduce the issue, this code is running on a

STEVAL-IDB003V1 with firmware bluenrg_6_4_Mode_2-32MHz-XO32K.img Although the same issue appears on multiple prototype boards with similar firmware.

♯ Reset BlueNRG/BlueNRG-MS

RESET()

if ACI_HAL_SET_TX_POWER_LEVEL(En_High_Power=0,PA_Level = 4) != 0x00:

    ERROR(''ACI_HAL_SET_TX_POWER_LEVEL FAILED'')

♯ Set Random Address

if HCI_LE_SET_RANDOM_ADDRESS(Random_Address = 0x123) != 0x00:

    ERROR('ERROR SETTING RANDOM ADDRESS')

♯ Init GATT

if  ACI_GATT_INIT()!=0x00:

    ERROR('ACI_GATT_INIT FAILED')

♯ Init GAP as peripheral device

status,_,_,_=  ACI_GAP_INIT(Role=PERIPHERAL)

if status !=0x00:

    ERROR('ACI_GAP_INIT CALL FAILED')

♯ Add service

Status,Serv1Handle=ACI_GATT_ADD_SERVICE(Service_UUID_Type=0x02, Service_UUID_128=0x1,Service_Type=1,Max_Attribute_Records=3)

Status,CharHandle=ACI_GATT_ADD_CHAR(Service_Handle= Serv1Handle, Char_UUID_Type=0x02,Char_UUID_128=0x2,Char_Value_Length=20, Char_Properties=0x08, Security_Permissions=0x00, GATT_Evt_Mask=0x01, Enc_Key_Size=0x07,Is_Variable=0x01)

Status,Serv2Handle=ACI_GATT_ADD_SERVICE(Service_UUID_Type=0x02, Service_UUID_128=0x3,Service_Type=1,Max_Attribute_Records=8)

♯ lock

Status,Char1Handle=ACI_GATT_ADD_CHAR(Service_Handle= Serv2Handle, Char_UUID_Type=0x02,Char_UUID_128=0x4,Char_Value_Length=20, Char_Properties=0x08, Security_Permissions=0x00, GATT_Evt_Mask=0x01, Enc_Key_Size=0x07,Is_Variable=0x01)

♯ unlock

Status,Char2Handle=ACI_GATT_ADD_CHAR(Service_Handle= Serv2Handle, Char_UUID_Type=0x02,Char_UUID_128=0x5,Char_Value_Length=20, Char_Properties=0x08, Security_Permissions=0x00, GATT_Evt_Mask=0x01, Enc_Key_Size=0x07,Is_Variable=0x01)

♯ endride

Status,Char3Handle=ACI_GATT_ADD_CHAR(Service_Handle= Serv2Handle, Char_UUID_Type=0x02,Char_UUID_128=0x6,Char_Value_Length=20, Char_Properties=0x18, Security_Permissions=0x00, GATT_Evt_Mask=0x01, Enc_Key_Size=0x07,Is_Variable=0x01)

def setDisco():

    PRINT(''DISCONNECTED'')

    status = ACI_GAP_SET_DISCOVERABLE(Own_Address_Type = 0x01, Advertising_Interval_Min=0x800, Advertising_Interval_Max=0x900)

    return status

♯ Put device in connectable mode

status = setDisco()

if status !=0x00:

    ERROR('ACI_GAP_SET_DISCOVERABLE CALL FAILED')

while (True):

    event = WAIT_EVENT()

    if event.event_code == HCI_DISCONNECTION_COMPLETE:

        status = setDisco()

        if status !=0x00:

            ERROR('ACI_GAP_SET_DISCOVERABLE CALL FAILED')

#advertising #bluenrg
13 REPLIES 13
Posted on October 01, 2015 at 12:21

Hi Christian,

I don't undersant, but if you are in advertising, how can the device receives the disconnetion complere?

Maybe, you have to put the device in advertising, after another device establish a connection with it and after occurs a disconnection. Now, after the disconnetion, the device will be not more in advertising.

If you put a device in advertising (ACI_GAP_SET_DISCOVERABLE) , the device will be forever in advertising until you stop it or a connecion is established.

Regards,

GM

Posted on October 01, 2015 at 12:22

After a disconnection, it's normal that the device is not more in advertising.

hardware
Associate II
Posted on October 02, 2015 at 03:23

Hi,

Thanks for helping, however, I'm not sure you understand my code:

1. I start advertising

2. I wait for the disconnected event to put it back into advertising

So this is what will happen:

1. start advertising

2. connection is established

3. disconnection happens

goto 1.

Anyway. Even in the scenario where no connection is ever established, I encounter the bug.

Posted on October 02, 2015 at 11:25

Hi Christian,

retry all, if not already done, you could download from the following link:

http://www.st.com/web/catalog/tools/FM147/SC1870/PF261967?s_searchtype=partnumber

the last version of BluNRG DK version 1.8.0.

You could:

- Launch an instance of GlueNRG GUI

- Connect a BlueNRG/BlueNRG-MS device

- Open related COM port

- Show ACI utilies tab

- Initialized the device (Init Device.. button)

- Put device in Advertising (Advertising ... button)

Now perform scanning from another central device, you should see the BlueNRG/BlueNRG-MS device, or you could configure another BlueNRG device as scaner:

- Launch another instance of GlueNRG GUI

- Connect a BlueNRG/BlueNRG-MS device

- Open related COM port

- Show ACI utilies tab

- Initialized the device (Init Device.. button)

- Put device in Scannin(Scanning... button)

Repeat the scanning more time, you should see always the device in advertising.

Let me know if it occurs.

Regards,

GM

Posted on October 19, 2015 at 01:30

Has there been any resolution to this issue yet ?  We are seeing the same thing in our application.  After every disconnect, advertising is restarted - but sometimes it does not restart.  

We have also seen that the issue seems more prevalent with faster advertising rates.

Currently in our application we reset the BlueNRG every hour to work around this - but it is not a solution as a unit being offline for up to an hour is not acceptable in our use case.

Posted on October 23, 2015 at 16:21

Dear Customer,

how to understand that after a disconnection, the advertisng don't restart? Do you obtain a command failed or the command is send successfully but you don't see any device in ADV?

Regards,

GM 

vpalacio
Associate II
Posted on February 08, 2016 at 09:43

Hi Graziella,

I think I understand them, because I've same trouble with a modified FW for STEVAL-IDB003V1.

When looping an Init/set_discoverable/conect/modify_characteristic test, sometimes I cannot detect the device anymore, despite the set_discoverable command reports SUCCESS.

int Make_Connection(void)

{    

  Init_BadgeID_Reader();

   

  tBleStatus res_set_discoverable;

   

#ifdef BLE_LOCAL_NAME

  const char *str_local_name = BLE_LOCAL_NAME;

  char local_name[128];

  local_name[0]=AD_TYPE_COMPLETE_LOCAL_NAME;

  for (int i=0;i<strlen(str_local_name);i++){

    local_name[i+1]=str_local_name[i];

  }  

#endif

   

  /* disable scan response */

  hci_le_set_scan_resp_data(0,NULL);

  PRINTF_DBG(''General Discoverable Mode...\r\n'');

   

#ifdef BLE_LOCAL_NAME

  res_set_discoverable = aci_gap_set_discoverable(ADV_IND, ADV_MIN_INTERVAL, ADV_MAX_INTERVAL, PUBLIC_ADDR, NO_WHITE_LIST_USE, strlen(str_local_name)+1, local_name, 0, NULL, 0, 0);

#else

  res_set_discoverable = aci_gap_set_discoverable(ADV_IND, ADV_MIN_INTERVAL, ADV_MAX_INTERVAL, PUBLIC_ADDR, NO_WHITE_LIST_USE,0, NULL, 0, NULL, 0, 0);

#endif

   

  if ( res_set_discoverable==0 ){

    PRINTF_DBG(''Success!\r\n'');

  }

  else{

    PRINTF_ERR(''Error when set_discoverable(%d)\r\n'', res_set_discoverable);

    blink_led_2(200,0);

    return -1;

    //TODO: RESET??

  }

  return 0;

}

hardware
Associate II
Posted on February 17, 2016 at 18:04

Hi,

So it seems our initial issue was actually this one: https://my.st.com/public/STe2ecommunities/interface/Lists/Low%20Power%20RF%20Solutions/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2finterface%2fLists%2fLow%20Power%20RF%20Solutions%2fBlueNRG-MS%20not%20visible%20by%20android&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580008F23D8A934F45...

Although the module is advertizing, android phones cannot see it. As it represents 40% of our customers, that *is* an issue.
Posted on March 09, 2016 at 15:03

Dear Customer,

before to put the device in discoverable mode, add the following command:

Status= HCI_LE_SET_SCAN_RESPONSE_DATA(Scan_Response_Data_Length=

0

,Scan_Response_Data=

0

)

if Status!=0x00:

 PRINT('FAILED COMMAND HCI_LE_SET_SCAN_RESPONSE_DATA')

let me know

Regards,

GM

Hi,

I'm having trouble with advertising: it seems that after some time, the module stops advertising.

The actual time after the issue appears seems to be grossly related to the Advertising_Interval_Min & Advertising_Interval_Max values. The lower the values, the shorter the time the issue appears.

Values such as 0x800 and 0x900 (default) seems to encounter the issues after days but values such as 0x20 and 0x30 encounter the issue after minutes.

When the advertisement stops, it is still possible to connect to the module, using it's address.

Below is some code to reproduce the issue, this code is running on a

STEVAL-IDB003V1 with firmware bluenrg_6_4_Mode_2-32MHz-XO32K.img Although the same issue appears on multiple prototype boards with similar firmware.

# Reset BlueNRG/BlueNRG-MS

RESET()

if ACI_HAL_SET_TX_POWER_LEVEL(En_High_Power=0,PA_Level = 4) != 0x00:

    ERROR(''ACI_HAL_SET_TX_POWER_LEVEL FAILED'')

# Set Random Address

if HCI_LE_SET_RANDOM_ADDRESS(Random_Address = 0x123) != 0x00:

    ERROR('ERROR SETTING RANDOM ADDRESS')

# Init GATT

if  ACI_GATT_INIT()!=0x00:

    ERROR('ACI_GATT_INIT FAILED')

# Init GAP as peripheral device

status,_,_,_=  ACI_GAP_INIT(Role=PERIPHERAL)

if status !=0x00:

    ERROR('ACI_GAP_INIT CALL FAILED')

# Add service

Status,Serv1Handle=ACI_GATT_ADD_SERVICE(Service_UUID_Type=0x02, Service_UUID_128=0x1,Service_Type=1,Max_Attribute_Records=3)

Status,CharHandle=ACI_GATT_ADD_CHAR(Service_Handle= Serv1Handle, Char_UUID_Type=0x02,Char_UUID_128=0x2,Char_Value_Length=20, Char_Properties=0x08, Security_Permissions=0x00, GATT_Evt_Mask=0x01, Enc_Key_Size=0x07,Is_Variable=0x01)

Status,Serv2Handle=ACI_GATT_ADD_SERVICE(Service_UUID_Type=0x02, Service_UUID_128=0x3,Service_Type=1,Max_Attribute_Records=8)

# lock

Status,Char1Handle=ACI_GATT_ADD_CHAR(Service_Handle= Serv2Handle, Char_UUID_Type=0x02,Char_UUID_128=0x4,Char_Value_Length=20, Char_Properties=0x08, Security_Permissions=0x00, GATT_Evt_Mask=0x01, Enc_Key_Size=0x07,Is_Variable=0x01)

# unlock

Status,Char2Handle=ACI_GATT_ADD_CHAR(Service_Handle= Serv2Handle, Char_UUID_Type=0x02,Char_UUID_128=0x5,Char_Value_Length=20, Char_Properties=0x08, Security_Permissions=0x00, GATT_Evt_Mask=0x01, Enc_Key_Size=0x07,Is_Variable=0x01)

# endride

Status,Char3Handle=ACI_GATT_ADD_CHAR(Service_Handle= Serv2Handle, Char_UUID_Type=0x02,Char_UUID_128=0x6,Char_Value_Length=20, Char_Properties=0x18, Security_Permissions=0x00, GATT_Evt_Mask=0x01, Enc_Key_Size=0x07,Is_Variable=0x01)

def setDisco():

    PRINT(''DISCONNECTED'')

    status = ACI_GAP_SET_DISCOVERABLE(Own_Address_Type = 0x01, Advertising_Interval_Min=0x800, Advertising_Interval_Max=0x900)

    return status

# Put device in connectable mode

status = setDisco()

if status !=0x00:

    ERROR('ACI_GAP_SET_DISCOVERABLE CALL FAILED')

while (True):

    event = WAIT_EVENT()

    if event.event_code == HCI_DISCONNECTION_COMPLETE:

        status = setDisco()

        if status !=0x00:

            ERROR('ACI_GAP_SET_DISCOVERABLE CALL FAILED')