Atmel Software Framework

nwk.c File Reference

Network layer management functions implementation.

Copyright (C) 2014-2015 Atmel Corporation. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. The name of Atmel may not be used to endorse or promote products derived from this software without specific prior written permission.
  4. This software may only be redistributed and used in connection with an Atmel microcontroller product.

THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "phy.h"
#include "sysConfig.h"
#include "nwkRx.h"
#include "nwkTx.h"
#include "nwkGroup.h"
#include "nwkFrame.h"
#include "nwkRoute.h"
#include "nwkSecurity.h"
#include "nwkRouteDiscovery.h"

Functions

bool NWK_Busy (void)
 Checks if network layer is ready for sleep. More...
 
void NWK_Init (void)
 Initializes all network layer modules. More...
 
uint8_t NWK_LinearizeLqi (uint8_t lqi)
 Calculates linearized value for the given value of the LQI. More...
 
void NWK_Lock (void)
 Increases the lock counter and sets a busy state. More...
 
void NWK_OpenEndpoint (uint8_t id, bool(*handler)(NWK_DataInd_t *ind))
 Registers callback ind for the endpoint endpoint. More...
 
void NWK_SetAddr (uint16_t addr)
 Sets network address of the node. More...
 
void NWK_SetPanId (uint16_t panId)
 Sets network identifier (PAN) of the node. More...
 
void NWK_SleepReq (void)
 Puts network layer to a sleeping state. More...
 
void NWK_TaskHandler (void)
 Network layer task handler. More...
 
void NWK_Unlock (void)
 Decreases the lock counter and sets a free state if counter reaches 0. More...
 
void NWK_WakeupReq (void)
 Puts network layer to an active state. More...
 

Variables

NwkIb_t nwkIb
 

bool NWK_Busy ( void  )

Checks if network layer is ready for sleep.

Returns
true if network layer is ready for sleep or false otherwise

References NwkIb_t::lock.

Referenced by APP_TaskHandler().

void NWK_Init ( void  )
uint8_t NWK_LinearizeLqi ( uint8_t  lqi)

Calculates linearized value for the given value of the LQI.

Parameters
[in]lqiLQI value as provided by the transceiver
Returns
linearized value directly proportional to the probability of delivery
void NWK_Lock ( void  )

Increases the lock counter and sets a busy state.

References NwkIb_t::lock.

Referenced by appCmdHandle().

void NWK_OpenEndpoint ( uint8_t  id,
bool(*)(NWK_DataInd_t *ind)  handler 
)

Registers callback ind for the endpoint endpoint.

Parameters
[in]idEndpoint index (1-15)
[in]handlerPointer to the callback function

References NwkIb_t::endpoint.

Referenced by APP_CommandsInit(), appCommandsInit(), appInit(), appOpenEndpoint(), and nwkRxInit().

void NWK_SetAddr ( uint16_t  addr)

Sets network address of the node.

Parameters
[in]addrAdddress to set

References NwkIb_t::addr, and PHY_SetShortAddr().

Referenced by appCommandReceived(), and appInit().

void NWK_SetPanId ( uint16_t  panId)

Sets network identifier (PAN) of the node.

Parameters
[in]panIdPAN ID to set

References NwkIb_t::panId, and PHY_SetPanId().

Referenced by appCommandReceived(), and appInit().

void NWK_SleepReq ( void  )

Puts network layer to a sleeping state.

References PHY_Sleep().

Referenced by APP_TaskHandler().

void NWK_TaskHandler ( void  )

Network layer task handler.

References nwkDataReqTaskHandler(), nwkRxTaskHandler(), and nwkTxTaskHandler().

Referenced by SYS_TaskHandler().

void NWK_Unlock ( void  )

Decreases the lock counter and sets a free state if counter reaches 0.

References NwkIb_t::lock.

Referenced by appCmdIdentifyDurationTimerHandler().

void NWK_WakeupReq ( void  )

Puts network layer to an active state.

References PHY_Wakeup().

Referenced by APP_TaskHandler().