The EFR series of energy friendly radios have the ability to wake themselves upon detecting an RF signal. This article discusses how to use this feature with the Silicon Labs Bluetooth stack. Discussion The rfsense feature can be used to wake the device in any energy mode. This feature is accessed through a RAIL command so the first step is to initialize an additional RAIL configuration. The Bluetooth stack is also built on RAIL so the multiprotocol library is required to be used here. A simple RAIL_CONFIG_t struct can be used with most parameters left NULL. static RAIL_Config_t railCfg = { .eventsCallback = NULL, .protocol = NULL, .scheduler = &railSchedState, };
A call to RAIL_Init with a pointer to this struct is made to initialize the RAIL configuration. railHandleRfsense = RAIL_Init(&railCfg, NULL); Once the RAIL configuration is done, rfsense can be enabled. The rfsense feature in EFR32 can accessed through the RAIL command RAIL_StartRfSense(). This command takes 4 parameters : RAIL handle, the band, sensetime and callback. More specific information on this command can be found in the RAIL API reference guide which is accessible from the launcher view in SimplicityStudio. Once the call to RAIL_StartRfSense() is made, it is safe to go to EM4. Building the Application This section describes how to build the example based on the soc-empty-rail-dmp sample. This sample is used because it has all of the necessary settings to support multiprotocol.
Start by generating a copy of the soc-empty-rail-dmp sample app.
Add app.c to the project by copying it to the project folder
Add a call to appMain() just before the while loop in bluetoothAppTask()
Remove the �static� keyword from the definition of boot_to_dfu as follows to make it accessible from app.c //static uint8_t boot_to_dfu = 0;
Comment out the following call to OSTaskCreate that starts the proprietaryAppTask /* OSTaskCreate(&proprietaryAppTaskTCB, "Proprietary App Task", proprietaryAppTask, 0u, PROPRIETARY_APP_TASK_PRIO, &proprietaryAppTaskStk[0u], (PROPRIETARY_APP_TASK_STACK_SIZE / 10u), PROPRIETARY_APP_TASK_STACK_SIZE, 0u, 0u, 0u, (OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR), &err); APP_RTOS_ASSERT_DBG((RTOS_ERR_CODE_GET(err) == RTOS_ERR_NONE), 1); */
Build the project.
Example Walkthrough
In the provided example application, we start advertising for a fixed period of time. If no connection is made during this time, the device stops advertising, starts rf sense and goes into EM4 sleep mode. The system_boot event performs several tasks. The first is that begins advertising to allow connections. The second task is to initialize the RAIL configuration. At this point it is also necessary to disable RFsense to avoid problems receiving packets. Lastly, a 30 second timer is started. RAIL_StartRfSense(railHandleRfsense,RAIL_RFSENSE_OFF ,RFSENSE_TIME_MIN,rfsense_callback); gecko_cmd_hardware_set_soft_timer(INACTIVITY_TIME,1,1);
The timer will be used to stop advertising, start rf sense and go into EM4 mode. This is handled in the gecko_evt_hardware_soft_timer event.
case gecko_evt_hardware_soft_timer_id: gecko_cmd_le_gap_stop_advertising(0); RAIL_StartRfSense(railHandleRfsense,RAIL_RFSENSE_2_4GHZ,RFSENSE_TIME_MIN,rfsense_callback); EMU_EnterEM4(); break;
If a connection is formed, the gecko_evt_le_connection_opened event stops the timer to prevent going into EM4. case gecko_evt_le_connection_opened_id: // if a connection is formed, stop the timer. gecko_cmd_hardware_set_soft_timer(0,1,0); break; The easiest way to track the sleep mode is with the Energy Profiler. In EM4 the current consumption will be around 1.5 uA. To try this out, build and flash the application to your desired device, open the Energy Profiler and start the energy capture. After reset the average current will be approximately 3.8 mA. After the time expires, the device goes to EM4 and the current drops to around 2 uA. To wake the device up an RF signal > -20 dBm is required. This signal can be provided by placing a mobile phone in active discovery mode and placing it in close proximity to the EFR32. Once the signal is detected, the device wakes up and the device once again begins advertising for the time specified. The length of time the RF signal must be detected for can be adjusted with the symbol RFSENSE_TIME_MIN. In the example it is set to 500 us.
I wanted to try this sample with my Wireless Starter Kit, but I could not configure the soc-empty-rail-dmp sample app for the BRD4302A radio board with a BGM121. Please let me know how I can build it.
0
Hi Naoki,
the soc-empty-rail-dmp sample app is not made for the BRD4302A. You can build a project for the part rather than the board though.
[Deprecated] KBA_BT_1009: Waking from Deep Sleep Using RF Sense
Note: This KBA has been marked as deprecated. A more updated KBA can be found here: Waking from Deep Sleep Using RF Sense
Introduction
The EFR series of energy friendly radios have the ability to wake themselves upon detecting an RF signal. This article discusses how to use this feature with the Silicon Labs Bluetooth stack. Discussion The rfsense feature can be used to wake the device in any energy mode. This feature is accessed through a RAIL command so the first step is to initialize an additional RAIL configuration. The Bluetooth stack is also built on RAIL so the multiprotocol library is required to be used here. A simple RAIL_CONFIG_t struct can be used with most parameters left NULL. static RAIL_Config_t railCfg = { .eventsCallback = NULL, .protocol = NULL, .scheduler = &railSchedState, };
A call to RAIL_Init with a pointer to this struct is made to initialize the RAIL configuration. railHandleRfsense = RAIL_Init(&railCfg, NULL); Once the RAIL configuration is done, rfsense can be enabled. The rfsense feature in EFR32 can accessed through the RAIL command RAIL_StartRfSense(). This command takes 4 parameters : RAIL handle, the band, sensetime and callback. More specific information on this command can be found in the RAIL API reference guide which is accessible from the launcher view in SimplicityStudio. Once the call to RAIL_StartRfSense() is made, it is safe to go to EM4. Building the Application This section describes how to build the example based on the soc-empty-rail-dmp sample. This sample is used because it has all of the necessary settings to support multiprotocol.
Example Walkthrough
In the provided example application, we start advertising for a fixed period of time. If no connection is made during this time, the device stops advertising, starts rf sense and goes into EM4 sleep mode. The system_boot event performs several tasks. The first is that begins advertising to allow connections. The second task is to initialize the RAIL configuration. At this point it is also necessary to disable RFsense to avoid problems receiving packets. Lastly, a 30 second timer is started. RAIL_StartRfSense(railHandleRfsense,RAIL_RFSENSE_OFF ,RFSENSE_TIME_MIN,rfsense_callback); gecko_cmd_hardware_set_soft_timer(INACTIVITY_TIME,1,1);
The timer will be used to stop advertising, start rf sense and go into EM4 mode. This is handled in the gecko_evt_hardware_soft_timer event.
case gecko_evt_hardware_soft_timer_id: gecko_cmd_le_gap_stop_advertising(0); RAIL_StartRfSense(railHandleRfsense,RAIL_RFSENSE_2_4GHZ,RFSENSE_TIME_MIN,rfsense_callback); EMU_EnterEM4(); break;
If a connection is formed, the gecko_evt_le_connection_opened event stops the timer to prevent going into EM4. case gecko_evt_le_connection_opened_id: // if a connection is formed, stop the timer. gecko_cmd_hardware_set_soft_timer(0,1,0); break; The easiest way to track the sleep mode is with the Energy Profiler. In EM4 the current consumption will be around 1.5 uA. To try this out, build and flash the application to your desired device, open the Energy Profiler and start the energy capture. After reset the average current will be approximately 3.8 mA. After the time expires, the device goes to EM4 and the current drops to around 2 uA. To wake the device up an RF signal > -20 dBm is required. This signal can be provided by placing a mobile phone in active discovery mode and placing it in close proximity to the EFR32. Once the signal is detected, the device wakes up and the device once again begins advertising for the time specified. The length of time the RF signal must be detected for can be adjusted with the symbol RFSENSE_TIME_MIN. In the example it is set to 500 us.
We have a forum post relating to this article:
RfSense appears extremely unreliable - what are we doing wrong?
https://www.silabs.com/community/wireless/bluetooth/forum.topic.html/rfsense_appears_extremelyunreliable-whatarewe-jAC9
Hi!
I wanted to try this sample with my Wireless Starter Kit, but I could not configure the soc-empty-rail-dmp sample app for the BRD4302A radio board with a BGM121. Please let me know how I can build it.
Hi Naoki,
the soc-empty-rail-dmp sample app is not made for the BRD4302A. You can build a project for the part rather than the board though.
Steve