Question
BlueNRG stops advertising after some time
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 aSTEVAL-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