Other Parts Discussed in Thread: CC2541, CC2591
I'm using CC2541 with CC2591, and ble stack is 1.4.0.
it's stop advertising after using my board a while (it happened when keep using like 1 hours or 12 hours ) and found that sniffer and mobile could not scan the CC2541.
When CC2541 stop advertising , I took debugger tool to check gapRoleState and it was GAPROLE_ADVERTISING.
At the same time , I can blink LED by long press the button(by osal timer, i think it says the system is still working).
After all , only reset or restart helps it back to work on advertising.
Here’s the code about advertising…, and LED blinking
#define DEFAULT_ADVERTISING_INTERVAL_MIN 32 // 20ms
#define DEFAULT_ADVERTISING_INTERVAL_MAX 48 // 30ms
#define DEFAULT_DISCOVERABLE_MODE GAP_ADTYPE_FLAGS_GENERAL
{
// For other hardware platforms, device starts advertising upon initialization
uint8 initial_advertising_enable = TRUE;
// By setting this to zero, the device will go into the waiting state after
// being discoverable for 30.72 second, and will not being advertising again
// until the enabler is set back to TRUE
uint16 gapRole_AdvertOffTime = 0;
}
// Set advertising interval
{
uint16 advIntMin = DEFAULT_ADVERTISING_INTERVAL_MIN;
uint16 advIntMax = DEFAULT_ADVERTISING_INTERVAL_MAX;
// GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MIN, advInt );
// GAP_SetParamValue( TGAP_LIM_DISC_ADV_INT_MAX, advInt );
GAP_SetParamValue( TGAP_GEN_DISC_ADV_INT_MIN, advIntMin );
GAP_SetParamValue( TGAP_GEN_DISC_ADV_INT_MAX, advIntMax );
}
Init I/O
{
// Default State of I/O are output and low
P0SEL = 0; // Configure Port 0 as GPIO
P1SEL = 0; // Configure Port 1 as GPIO
P2SEL = 0; // Configure Port 2 as GPIO
P0DIR = 0xFE; // Port 0 pins P0.0 as input (buttons), others as output
P1DIR = 0xF3; // All port 1 pins (P1.0-P1.7) as output
P2DIR = 0x1F; // All port 1 pins (P2.0-P2.4) as output
P0 = 0; // All pins on port 0 to low
P1 = 0; // All pins on port 1 to low
P2 = 0; // All pins on port 2 to low
}
// Enable PA/LNA
{
HCI_EXT_SetTxPowerCmd(HCI_EXT_TX_POWER_0_DBM);
HCI_EXT_SetRxGainCmd(HCI_EXT_RX_GAIN_HIGH);
HCI_EXT_ExtendRfRangeCmd();
}
// ...
uint16 SimpleBLEPeripheral_ProcessEvent( uint8 task_id, uint16 events )
{
// ...
if ( events & LED_BLINKING_EVT )
{
LED_PIN = ~LED_PIN; // 切換LED狀態
counter_led++;
if ( counter_led < led_blink_times )
{ // restart led blinking timer
osal_start_timerEx( simpleBLEPeripheral_TaskID, LED_BLINKING_EVT, LED_BLINKING_PERIOD );
}
return (events ^ LED_BLINKING_EVT);
}
}
I'm looking for the answer why it stop advertising.