6.6. RFD Application

RFD stands for Reduced Function Device. Typically an RFD has sensors. Most of the time the RFD sleeps to conserve power. Once in a while it wakes up to either check for incoming messages or to read sensor data. If sensor data is available, it transmits this data and goes back to sleep. The RFD can wakeup earlier in case of GPIO interrupts.

An RFD device is not capable of routing packets from neighbours. In general, RFD devices are battery powered.

Figure 1: RFD state diagram

_images/RFD-StateDiagram.png

6.6.1. Functions

These functions are not actually API but a framework for developers to build their RFD applications. These functions are called by other modules. These must be implemented by application developers. Some functions may be blank depending on the requirements of the application. You may wish to study the examples in App Examples to jumpstart your development.

void RFD_APP_wakeUpProc(void)

When an RFD wakes up, this procedure is called to process application-specific tasks. Enabling sensors or collecting sensor data can be done here. If sensor data is obtained, data can be formatted and sent to ADP layer for transmission: by calling ADP_appPyldTxReq(). RFD can then enter sleep mode by setting SYS_GLOBAL_EVT_ENTER_LPM_REQUEST in SYS_globalEvtMsk1.

void RFD_APP_init(void)

All initializations particular to the application go here. For example, sensors may be calibrated. This function is called when the system boots up.

void RFD_APP_evtHndlr(UINT16_t globalEvtId, void *params_p)

This function handles messages coming to an RFD. It could be a confirmation to sensor data sent out earlier. This confirmation comes as SYS_GLOBAL_EVT_ADP_DATA_CONFIRM set in SYS_globalEvtMsk0. Presently every transmission of sensor data requires an acknowledgement back to the RFD. This behaviour can be changed by modifying the API of ADP layer. Another possible event is due to SYS_GLOBAL_EVT_ADP_DATA_INDICATION set in SYS_globalEvtMsk1.

An application may choose to ignore these events if they are not important. At the minimum, the function should set SYS_GLOBAL_EVT_ENTER_LPM_REQUEST in SYS_globalEvtMsk1 so that the RFD returns to sleep mode. It is important to note that an RFD will not be woken up from its sleep because of an incoming message. It is only when the RFD wakes up from its sleep cycle that it will check with PAN coordinator if any messages are to be received.

Parameters:
  • globalEvtId – Identity of the event.
  • params_p – Pointer to the parameters of the event. Typically, this pointer would be typecast to the particular event’s data structure.
void RFD_APP_nodeJoinDoneInd(void)

This function is called when a node joins the network: in other words, when the node gets associated with the PAN coordinator. MAC layer sets the flag SYS_GLOBAL_EVT_MAC_ASSOC_CONFIRM in SYS_globalEvtMsk1. From the main system loop, this triggers a call to this function. Function body may be left empty.

void RFD_APP_prepareToEnterLPM(void)

Once the application has completed necessary tasks, it has to allow the MSP430 to enter low power mode (LPM). Just before going to sleep mode, some processing can take place in this function. Function call is triggered by setting SYS_GLOBAL_EVT_ENTER_LPM_REQUEST in SYS_globalEvtMsk1. Interrupts are disabled globally when entering this function. The MSP430 will go into deep sleep mode on returning from this function. Function body may be left empty.

void RFD_APP_wakeUpTimerExpEvt(void)

This function is called when SYS_GLOBAL_EVT_WAKEUP_TIMER_EXPIRY_EVT is set in SYS_globalEvtMsk1. An RFD will typically sleep for long periods of time and wake up at regular intervals. Watchdog timer is used for this purpose. Watchdog interrupt handler in platform code named PLTFRM_wakeUpTimerHndlr() keeps track of the remaining sleep time. When sleep comes to an end, the handler sets the event flag SYS_GLOBAL_EVT_WAKEUP_TIMER_EXPIRY_EVT in SYS_globalEvtMsk1. Sleep mode is then exited. An application that wants to do certain critical tasks on waking up can do so in this function. More extensive tasks such as enabling sensors or collecting sensor data should be done within RFD_APP_wakeUpProc(). Function body may be left empty.

6.6.2. Macros

#define RFD_APP_0_DFLT_WAKE_UP_INTERVAL_SECS   2
#define RFD_APP_1_DFLT_WAKE_UP_INTERVAL_SECS   5
#define RFD_APP_2_DFLT_WAKE_UP_INTERVAL_SECS   5
#define RFD_APP_5_DFLT_WAKE_UP_INTERVAL_SECS   2
#define RFD_APP_6_DFLT_WAKE_UP_INTERVAL_SECS   10
#define RFD_APP_7_DFLT_WAKE_UP_INTERVAL_SECS   2
#define RFD_APP_8_DFLT_WAKE_UP_INTERVAL_SECS   1
#define RFD_APP_9_DFLT_WAKE_UP_INTERVAL_SECS   5

6.6.3. Type Definitions

typedef enum
{
        RFD_APP_STATE_WAIT_CONVERSION,
        RFD_APP_STATE_CONVERSION_DONE
} RFD_APP_state_t;