How to monitor the advertising in the Slave mode?

6 posts / 0 new
Last post
Alex Luo
Offline
Last seen:1 year 4 months ago
Expert
Joined:2014-02-28 19:16
How to monitor the advertising in the Slave mode?

Hello all and MT,

I try to monitor advertising in slave mode, I used SDK3.0.8.

I called the function of app_last_rwble_evt_get() every second and compare the return if it is BLE_EVT_RX or not. (according to MT's suggestion, see attached below). Just for advertising, and Lightblue can scan it, but the return is never BLE_EVT_RX, even I try to connect it by Lightblue and disconnect. Could you please advise how to check it?

I can't find any document/information about the function, could you please give me more info about it?

There is enum in arch_sleep.h:
enum last_ble_evt
{
BLE_EVT_SLP,
BLE_EVT_CSCNT,
BLE_EVT_RX,
BLE_EVT_TX,
BLE_EVT_END,
};
But I don't know what's meaning for.... And no specific for advertising

Thanks,
Alex
---------------------------
The arch_last_rwble_evt_get() will return the last event that the ble performed transmition, reception etc. I suppose that you can use this in order to find out if your device has some BLE activity or not. The function in previous SDK's was called , and you can check if there isn't a BLE_EVT_RX.

Device:
MT_dialog
Offline
Last seen:3 months 2 days ago
Staff
Joined:2015-06-08 11:34
Hi Alex Luo,

Hi Alex Luo,

There is no specific state for advertising, the states are:

BLE_EVT_RX - Starting of an RX event

BLE_EVT_TX - Starting of an Tx event

BLE_EVT_END - Ending of a BLE operation (you should get one after the advertising event ends)

BLE_EVT_SLP - Starting point when the exit of sleep occurs

BLE_EVT_CSCNT - This isn't very usefull it triggers about 2 slots before the radio event

You can catch the events not by polling every 1 second but by placing some code in the app_ble_poweredon callback. Please see attached the BLE_RX and TX events when they occur in the advertising event.

Thanks MT_dialog

Attachment:
Alex Luo
Offline
Last seen:1 year 4 months ago
Expert
Joined:2014-02-28 19:16
Thanks MT.

Thanks MT.

I will try it,

My purpose is that I want to check if there is any advertising event during idle mode every second (or a period). If no advertising event during the period, I assume there is somethings wrong and reset BLE stack. We met some cases, no advertising (BLE not work) from the peripheral devices, and have to reset or triggered the IO to reset the device. What I do is to monitor the advertising event to avoid stopping advertising.

Let me know if this event monitor can help or there are different way to do. Please advise.

Thanks,
Alex

MT_dialog
Offline
Last seen:3 months 2 days ago
Staff
Joined:2015-06-08 11:34
Hi Alex,

Hi Alex,

This is a proper way to monitor if you are advertising or not, you can also find an example in the beacon reference design in the app_async_trm() function in the app_sleep.h file. The beacon uses the BLE_EVT_END in order to track the ending of an advertising to count the advertising packets emmited from the device.

Thanks MT_dialog

Alex Luo
Offline
Last seen:1 year 4 months ago
Expert
Joined:2014-02-28 19:16
Hi MT,

Hi MT,

I can get the BLE_EVT_END for idle and connection state.

My question is that if the advertising or BLE stops working, BLE_EVN_END can still be got, right? If so, how to tell if the advertising/BLE stops working?

I did one more test. After I stopped Advertising, I can still get BLE_EVN_END! So, I can't identify if advertising is still there or stops. Please advise.

Thanks,
Alex

MT_dialog
Offline
Last seen:3 months 2 days ago
Staff
Joined:2015-06-08 11:34
Hi Alex,

Hi Alex,

If you stop the advertising and the 580 cease all the BLE activity and if you just call the function will return the last event which was the BLE_END_EVT (the function returns the last state the BLE was, it rolls through the states, if your last state was a BLE_END_EVT and you stop advertising your last event will again be a BLE_END_EVT). In case you are in SDK 5 please check the below snippet else you can mofify it and use it in the app_async_trm() in SDK 3, it counts the advertising messages and when it reaches up to 20 it stops advertising. After you reach up to 20 you should not see anything counting on your UART.

uint8_t app_last_ble_event; //Global variable

enum arch_main_loop_callback_ret user_on_ble_powered(void)
{
uint8_t state;
state = arch_last_rwble_evt_get();
if (app_last_ble_event != state)
{
app_last_ble_event = state;
if (app_last_ble_event == BLE_EVT_END)
{
arch_set_pxact_gpio();
count++;
arch_printf("%i", count);
arch_puts("\n\r");
if (count == 20)
app_easy_gap_advertise_stop();
}
}

return GOTO_SLEEP;
}

Thanks MT_dialog