Route discovery implementation.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include "sysTimer.h"
#include "sysConfig.h"
#include "nwk.h"
#include "nwkTx.h"
#include "nwkFrame.h"
#include "nwkRoute.h"
#include "nwkGroup.h"
#include "nwkCommand.h"
#include "nwkRouteDiscovery.h"
Data Structures | |
struct | NwkRouteDiscoveryTableEntry_t |
Macros | |
#define | NWK_ROUTE_DISCOVERY_BEST_LINK_QUALITY 255 |
#define | NWK_ROUTE_DISCOVERY_NO_LINK 0 |
#define | NWK_ROUTE_DISCOVERY_TIMER_INTERVAL 100 /* ms */ |
Typedefs | |
typedef struct NwkRouteDiscoveryTableEntry_t | NwkRouteDiscoveryTableEntry_t |
Enumerations | |
enum | { NWK_RD_STATE_WAIT_FOR_ROUTE = 0x40 } |
Functions | |
static void | nwkRouteDiscoveryDone (NwkRouteDiscoveryTableEntry_t *entry, bool status) |
static NwkRouteDiscoveryTableEntry_t * | nwkRouteDiscoveryFindEntry (uint16_t src, uint16_t dst, uint8_t multicast) |
void | nwkRouteDiscoveryInit (void) |
Initializes the Route Discovery module. More... | |
static NwkRouteDiscoveryTableEntry_t * | nwkRouteDiscoveryNewEntry (void) |
bool | nwkRouteDiscoveryReplyReceived (NWK_DataInd_t *ind) |
void | nwkRouteDiscoveryRequest (NwkFrame_t *frame) |
bool | nwkRouteDiscoveryRequestReceived (NWK_DataInd_t *ind) |
static void | nwkRouteDiscoverySendReply (NwkRouteDiscoveryTableEntry_t *entry, uint8_t flq, uint8_t rlq) |
static bool | nwkRouteDiscoverySendRequest (NwkRouteDiscoveryTableEntry_t *entry, uint8_t lq) |
static void | nwkRouteDiscoveryTimerHandler (SYS_Timer_t *timer) |
static uint8_t | nwkRouteDiscoveryUpdateLq (uint8_t lqa, uint8_t lqb) |
Variables | |
static NwkRouteDiscoveryTableEntry_t | nwkRouteDiscoveryTable [NWK_ROUTE_DISCOVERY_TABLE_SIZE] |
static SYS_Timer_t | nwkRouteDiscoveryTimer |
#define NWK_ROUTE_DISCOVERY_BEST_LINK_QUALITY 255 |
Referenced by nwkRouteDiscoveryRequest(), and nwkRouteDiscoveryRequestReceived().
#define NWK_ROUTE_DISCOVERY_NO_LINK 0 |
Referenced by nwkRouteDiscoveryNewEntry().
#define NWK_ROUTE_DISCOVERY_TIMER_INTERVAL 100 /* ms */ |
Referenced by nwkRouteDiscoveryInit(), and nwkRouteDiscoveryTimerHandler().
typedef struct NwkRouteDiscoveryTableEntry_t NwkRouteDiscoveryTableEntry_t |
|
static |
References NwkRouteDiscoveryTableEntry_t::dstAddr, NwkFrame_t::header, NwkFrameHeader_t::multicast, NwkRouteDiscoveryTableEntry_t::multicast, NWK_NO_ROUTE_STATUS, NWK_RD_STATE_WAIT_FOR_ROUTE, NwkFrameHeader_t::nwkDstAddr, NwkFrameHeader_t::nwkFcf, nwkFrameNext(), nwkTxConfirm(), nwkTxFrame(), and NwkFrame_t::state.
Referenced by nwkRouteDiscoveryTimerHandler().
|
static |
References NWK_ROUTE_DISCOVERY_TABLE_SIZE.
Referenced by nwkRouteDiscoveryReplyReceived(), nwkRouteDiscoveryRequest(), and nwkRouteDiscoveryRequestReceived().
void nwkRouteDiscoveryInit | ( | void | ) |
Initializes the Route Discovery module.
References SYS_Timer_t::handler, SYS_Timer_t::interval, SYS_Timer_t::mode, NWK_ROUTE_DISCOVERY_TABLE_SIZE, NWK_ROUTE_DISCOVERY_TIMER_INTERVAL, nwkRouteDiscoveryTimerHandler(), SYS_TIMER_INTERVAL_MODE, and NwkRouteDiscoveryTableEntry_t::timeout.
Referenced by NWK_Init().
|
static |
References NwkRouteDiscoveryTableEntry_t::forwardLinkQuality, NWK_ROUTE_DISCOVERY_NO_LINK, NWK_ROUTE_DISCOVERY_TABLE_SIZE, NWK_ROUTE_DISCOVERY_TIMEOUT, NwkRouteDiscoveryTableEntry_t::reverseLinkQuality, SYS_TimerStart(), and NwkRouteDiscoveryTableEntry_t::timeout.
Referenced by nwkRouteDiscoveryRequest(), and nwkRouteDiscoveryRequestReceived().
bool nwkRouteDiscoveryReplyReceived | ( | NWK_DataInd_t * | ind | ) |
References NwkIb_t::addr, NWK_DataInd_t::data, NwkCommandRouteReply_t::dstAddr, NwkCommandRouteReply_t::forwardLinkQuality, NWK_DataInd_t::lqi, NwkCommandRouteReply_t::multicast, nwkIb, nwkRouteDiscoveryFindEntry(), nwkRouteDiscoverySendReply(), nwkRouteDiscoveryUpdateLq(), nwkRouteUpdateEntry(), NwkCommandRouteReply_t::reverseLinkQuality, NWK_DataInd_t::size, NWK_DataInd_t::srcAddr, and NwkCommandRouteReply_t::srcAddr.
Referenced by nwkRxSeriveDataInd().
void nwkRouteDiscoveryRequest | ( | NwkFrame_t * | frame | ) |
References NwkIb_t::addr, NwkRouteDiscoveryTableEntry_t::dstAddr, NwkFrame_t::header, NwkFrameHeader_t::multicast, NwkRouteDiscoveryTableEntry_t::multicast, NWK_BROADCAST_ADDR, NWK_NO_ROUTE_STATUS, NWK_RD_STATE_WAIT_FOR_ROUTE, NWK_ROUTE_DISCOVERY_BEST_LINK_QUALITY, NwkFrameHeader_t::nwkDstAddr, NwkFrameHeader_t::nwkFcf, nwkIb, nwkRouteDiscoveryFindEntry(), nwkRouteDiscoveryNewEntry(), nwkRouteDiscoverySendRequest(), nwkTxConfirm(), NwkRouteDiscoveryTableEntry_t::senderAddr, NwkRouteDiscoveryTableEntry_t::srcAddr, and NwkFrame_t::state.
Referenced by nwkRoutePrepareTx().
bool nwkRouteDiscoveryRequestReceived | ( | NWK_DataInd_t * | ind | ) |
References NwkIb_t::addr, NWK_DataInd_t::data, NwkCommandRouteRequest_t::dstAddr, NwkCommandRouteRequest_t::linkQuality, NWK_DataInd_t::lqi, NwkCommandRouteRequest_t::multicast, NWK_ROUTE_DISCOVERY_BEST_LINK_QUALITY, NWK_ROUTE_NON_ROUTING, nwkIb, nwkRouteDiscoveryFindEntry(), nwkRouteDiscoveryNewEntry(), nwkRouteDiscoverySendReply(), nwkRouteDiscoverySendRequest(), nwkRouteDiscoveryUpdateLq(), nwkRouteUpdateEntry(), NWK_DataInd_t::size, NWK_DataInd_t::srcAddr, and NwkCommandRouteRequest_t::srcAddr.
Referenced by nwkRxSeriveDataInd().
|
static |
References NwkRouteDiscoveryTableEntry_t::dstAddr, NwkCommandRouteReply_t::dstAddr, NwkCommandRouteReply_t::forwardLinkQuality, NwkFrame_t::header, NwkCommandRouteReply_t::id, NwkRouteDiscoveryTableEntry_t::multicast, NwkCommandRouteReply_t::multicast, NWK_COMMAND_ROUTE_REPLY, NWK_TX_CONTROL_DIRECT_LINK, NwkFrameHeader_t::nwkDstAddr, nwkFrameAlloc(), nwkFrameCommandInit(), nwkTxFrame(), NwkFrame_t::payload, NwkCommandRouteReply_t::reverseLinkQuality, NwkRouteDiscoveryTableEntry_t::senderAddr, NwkFrame_t::size, NwkRouteDiscoveryTableEntry_t::srcAddr, NwkCommandRouteReply_t::srcAddr, and NwkFrame_t::tx.
Referenced by nwkRouteDiscoveryReplyReceived(), and nwkRouteDiscoveryRequestReceived().
|
static |
References NwkRouteDiscoveryTableEntry_t::dstAddr, NwkCommandRouteRequest_t::dstAddr, NwkFrame_t::header, NwkCommandRouteRequest_t::id, NwkFrameHeader_t::linkLocal, NwkCommandRouteRequest_t::linkQuality, NwkRouteDiscoveryTableEntry_t::multicast, NwkCommandRouteRequest_t::multicast, NWK_BROADCAST_ADDR, NWK_COMMAND_ROUTE_REQUEST, NwkFrameHeader_t::nwkDstAddr, NwkFrameHeader_t::nwkFcf, nwkFrameAlloc(), nwkFrameCommandInit(), nwkTxFrame(), NwkFrame_t::payload, NwkFrame_t::size, NwkRouteDiscoveryTableEntry_t::srcAddr, NwkCommandRouteRequest_t::srcAddr, and NwkFrame_t::tx.
Referenced by nwkRouteDiscoveryRequest(), and nwkRouteDiscoveryRequestReceived().
|
static |
References NwkIb_t::addr, NWK_ROUTE_DISCOVERY_TABLE_SIZE, NWK_ROUTE_DISCOVERY_TIMER_INTERVAL, nwkIb, nwkRouteDiscoveryDone(), NwkRouteDiscoveryTableEntry_t::reverseLinkQuality, NwkRouteDiscoveryTableEntry_t::srcAddr, SYS_TimerStart(), and NwkRouteDiscoveryTableEntry_t::timeout.
Referenced by nwkRouteDiscoveryInit().
|
static |
Referenced by nwkRouteDiscoveryReplyReceived(), and nwkRouteDiscoveryRequestReceived().
|
static |
|
static |