NB SCAN

NB SCAN (Neighbour Scan) is used to search for neighbouring nodes.

The node performing the search sends a broadcast request for a response. Surrounding nodes respond to this and report a list of nodes that have responded. The nodes are sorted by LQI.

Only available on SimpleNet.

Under relatively stable and low traffic conditions, the success rate of the search will be high, but if conditions deteriorate, the search may not be possible at all.

In poor conditions, the node that should announce its presence periodically sends beacon packets using broadcast communication, and the searcher receives these beacons and implements a check for the presence of neighbouring nodes.

Definitions

The searcher should define ToCoNet_USE_MOD_NBSCAN and the searched should define ToCoNet_USE_MOD_NBSCAN_SLAVE.

// define modules
#define ToCoNet_USE_MOD_NBSCAN
#define ToCoNet_USE_MOD_NBSCAN_SLAVE

// includes
#include "ToCoNet.h"
#include "ToCoNet_mod_prototype.h"

functions

ToCoNet_EnergyScan_bStart()

Start the neighbourhood search.

uint8 ToCoNet_NbScan_bStart (uint32 u32ChMask, uint16 u16Dur_ms)

Arguments

Returns

ToCoNet_NbScan_bStartToFindAddr()

A neighbourhood search is started with the aim of finding a node at a specific address.

uint8 ToCoNet_NbScan_bStartToFindAddr (uint32 u32ChMask, uint32 u32Addr)

The existence of a node on the same channel can be checked by attempting to send a packet with MAC Ack, but this is used when the node's channel configuration is unknown.

Arguments

Returns

Events

The result is reported by cbToCoNet_vNwkEvent() in the E_EVENT_TOCONET_NWK_SCAN_COMPLETE event. The event argument is the address to the tsToCoNet_NbScan_Result structure.

case E_EVENT_TOCONET_ENERGY_SCAN_COMPLETE:
    _C {
        uint8 *pu8Result = (uint8*)u32arg;
    }

the value of pu8Result

The level takes the value 0..255, with 0 being the weakest and 255 the strongest. The higher the value, the noisier the channel.

Structures

tsToCoNet_NbScan_Result

A structure to store the results of the neighbourhood search.

bitmap information of u8scanMode

tsToCoNet_NbScan_Entitiy

A structure containing information about each node found in the neighbourhood search.

Sample code

// define modules
#define ToCoNet_USE_MOD_NBSCAN
#define ToCoNet_USE_MOD_NBSCAN_SLAVE

// includes
#include "ToCoNet.h"
#include "ToCoNet_mod_prototype.h"

void cbToCoNet_vNwkEvent(teEvent eEvent, uint32 u32arg) {
	int i;
	switch(eEvent) {
	case E_EVENT_TOCONET_NWK_START:
		break;

	case E_EVENT_TOCONET_NWK_SCAN_COMPLETE:
		_C {
            tsToCoNet_NbScan_Result *pNbsc = (tsToCoNet_NbScan_Result *)u32arg;

            if (pNbsc->u8scanMode & TOCONET_NBSCAN_NORMAL_MASK) { // Results from normal search
                // All channel scan results
                for(i = 0; i < pNbsc->u8found; i++) { // Number found
                    // Extract in LQI order
                    tsToCoNet_NbScan_Entitiy *pEnt = 
                        &pNbsc->sScanResult[pNbsc->u8IdxLqiSort[i]];
                    if (pEnt->bFound) {
                        // Entry found
                        //   pEnt->u8ch(channel), 
                        //   pEnt->u32addr(long addr), 
                        //   pEnt->u16addr(short addr),
                        //   pEnt->u8lqi(LQI)
                    }
                }
            } else if (pNbsc->u8scanMode & TOCONET_NBSCAN_QUICK_EXTADDR_MASK) { // アドレス指定探索の結果
                if(pNbSc->u8found) {
                    tsToCoNet_NbScan_Entitiy *pEnt = &pNbsc->sScanResult[0];
                    // If found, there is only one, so the first element is taken out.
                    //   pEnt->u8ch,
                    //   pEnt->u8lqi(LQI)
                } else {
                    // not found
                }
            }
        }
		break;

最終更新