PreviousNext
Reset
Help > Custom DPA Handler > Events > Reset

The event is called just after the module was reset. It can be used to implement the custom bonding/unbonding of the [N] devices. In this case, the event handler must return TRUE and so the default internal DPA bonding/unbonding code is skipped. If [N] is bonded, the event is raised only once to allow unbonding. If the [N] is not bonded the event is called until the [N] is bonded. The code does not have to handle the setting of the NodeWasBonded variable. For details see Node events flow. See also Init event concerning the initialization options. The interrupt is enabled so the Interrupt event can be already called. [N] devices are set to the Node mode by calling the setNodeMode IQRF OS function before this event is raised. After the bonding is done the content of the bufferRF must stay intact.

 

The Reset event is also once raised at the [C] device for the sake of the same behavior of all device types. In this case, it is not used to do bonding or unbonding of course. The [C] devices are at non‑network mode because of the previous call of setNonetMode IQRF OS function.

 

Example

 

 // Illustrative code

 case DpaEvent_Reset:

        if (!doCustomBonding)

              return FALSE;

 

        if ( amIBonded() )

        {

              if ( unBondCondition )

              {

                     removeBond();

                     setLEDR();

                     waitDelay( 100 );

                     stopLEDR();

              }

        }

        else

        {

        while ( !amIBonded() )

        {

              if ( bondRequestCondition )

              {

                            bondRequestAdvanced();

                     setWDToff();

              }

        }

        }

 

       return TRUE;

 

See example code CustomDpaHandler-Bonding.c for more details.