Microchip® Advanced Software Framework

main.c File Reference

MAC Example Beacon Application - Device.

Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.

#include <string.h>
#include <inttypes.h>
#include <stdio.h>
#include "conf_board.h"
#include "avr2025_mac.h"
#include "delay.h"
#include "common_sw_timer.h"
#include "sio2host.h"
#include "common_hw_timer.h"
#include "beacon_app.h"
#include <asf.h>

Macros

#define APP_GUARD_TIME_US   (10000)
 
#define CHANNEL_OFFSET   (0)
 Channel Offset will give us the channel number as (CHANNEL_OFFSET + 11) More...
 
#define GTS_PAYLOAD_LEN   (18)
 
#define LED_DATA   (LED0)
 
#define LED_DATA   (LED0)
 
#define LED_NWK_SETUP   (LED0)
 
#define LED_START   (LED0)
 
#define MCU_WAKEUP_TIME   (150)
 
#define PAYLOAD_LEN   (104)
 
#define SCAN_DURATION_LONG   (6)
 Defines the long scan duration time. More...
 
#define SCAN_DURATION_SHORT   (5)
 Defines the short scan duration time. More...
 
#define TIMER_SYNC_BEFORE_ASSOC_MS   (3000)
 

Functions

static void app_alert (void)
 Alert to indicate something has gone wrong in the application. More...
 
int main (void)
 Main function of the device application. More...
 
static void network_search_indication_cb (void *parameter)
 Callback function indicating network search. More...
 
static void print_stack_app_build_features (void)
 This function shows the stack and application capabilities on terminal if SIO_HUB switch is enabled. More...
 
static void rx_data_led_off_cb (void *parameter)
 Callback function for switching off the LED after data reception. More...
 
void usr_mcps_data_conf (uint8_t msduHandle, uint8_t status, uint32_t Timestamp)
 Callback function that must be implemented by application (NHLE) for MAC service MCPS-DATA.confirm. More...
 
void usr_mcps_data_ind (wpan_addr_spec_t *SrcAddrSpec, wpan_addr_spec_t *DstAddrSpec, uint8_t msduLength, uint8_t *msdu, uint8_t mpduLinkQuality, uint8_t DSN, uint32_t Timestamp)
 
void usr_mlme_associate_conf (uint16_t AssocShortAddress, uint8_t status)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-ASSOCIATE.confirm. More...
 
void usr_mlme_beacon_notify_ind (uint8_t BSN, wpan_pandescriptor_t *PANDescriptor, uint8_t PendAddrSpec, uint8_t *AddrList, uint8_t sduLength, uint8_t *sdu)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-BEACON-NOTIFY.indication. More...
 
void usr_mlme_disassociate_conf (uint8_t status, wpan_addr_spec_t *DeviceAddrSpec)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-DISASSOCIATE.confirm. More...
 
void usr_mlme_disassociate_ind (uint64_t DeviceAddress, uint8_t DisassociateReason)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-DISASSOCIATE.indication. More...
 
void usr_mlme_get_conf (uint8_t status, uint8_t PIBAttribute, void *PIBAttributeValue)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-GET.confirm. More...
 
void usr_mlme_gts_conf (gts_char_t GtsChar, uint8_t status)
 
void usr_mlme_gts_ind (uint16_t DeviceAddr, gts_char_t GtsChar)
 
void usr_mlme_poll_conf (uint8_t status)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-POLL.confirm. More...
 
void usr_mlme_reset_conf (uint8_t status)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-RESET.confirm. More...
 
void usr_mlme_rx_enable_conf (uint8_t status)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-RX-ENABLE.confirm. More...
 
void usr_mlme_scan_conf (uint8_t status, uint8_t ScanType, uint8_t ChannelPage, uint32_t UnscannedChannels, uint8_t ResultListSize, void *ResultList)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-SCAN.confirm. More...
 
void usr_mlme_set_conf (uint8_t status, uint8_t PIBAttribute)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-SET.confirm. More...
 
void usr_mlme_sync_loss_ind (uint8_t LossReason, uint16_t PANId, uint8_t LogicalChannel, uint8_t ChannelPage)
 Callback function that must be implemented by application (NHLE) for MAC service MLME-SYNC-LOSS.indication. More...
 

Variables

app_state_t app_state = APP_IDLE
 This variable stores the current state of the node. More...
 
static uint8_t APP_TIMER
 
static uint32_t bc_rx_cnt
 
static uint32_t channels_supported
 
wpan_addr_spec_t coord_addr_spec
 
uint8_t current_channel
 
uint8_t current_channel_page
 
uint8_t default_key_source [8]
 
static uint32_t indirect_rx_cnt
 
static uint8_t msdu_payload [PAYLOAD_LEN]
 This array stores the current msdu payload. More...
 

#define APP_GUARD_TIME_US   (10000)

Referenced by main().

#define CHANNEL_OFFSET   (0)

Channel Offset will give us the channel number as (CHANNEL_OFFSET + 11)

Referenced by usr_mlme_get_conf().

#define GTS_PAYLOAD_LEN   (18)
#define LED_DATA   (LED0)
#define LED_DATA   (LED0)
#define LED_NWK_SETUP   (LED0)
#define LED_START   (LED0)

Referenced by main().

#define MCU_WAKEUP_TIME   (150)
#define PAYLOAD_LEN   (104)
#define SCAN_DURATION_LONG   (6)

Defines the long scan duration time.

Referenced by usr_mlme_get_conf(), and usr_mlme_scan_conf().

#define SCAN_DURATION_SHORT   (5)

Defines the short scan duration time.

Referenced by usr_mlme_scan_conf().

#define TIMER_SYNC_BEFORE_ASSOC_MS   (3000)

static void app_alert ( void  )
static

Alert to indicate something has gone wrong in the application.

References delay_us, LED0, and LED_Toggle.

Referenced by main().

static void network_search_indication_cb ( void *  parameter)
static

Callback function indicating network search.

Parameters
parameterPointer to callback parameter (not used in this application, but could be if desired).

References LED_NWK_SETUP, and LED_Toggle.

Referenced by usr_mlme_get_conf().

static void print_stack_app_build_features ( void  )
static

This function shows the stack and application capabilities on terminal if SIO_HUB switch is enabled.

Referenced by main().

static void rx_data_led_off_cb ( void *  parameter)
static

Callback function for switching off the LED after data reception.

Parameters
parameterPointer to callback parameter (not used in this application, but could be if desired).

References LED_DATA, and LED_Off.

Referenced by usr_mcps_data_ind().

void usr_mcps_data_ind ( wpan_addr_spec_t SrcAddrSpec,
wpan_addr_spec_t DstAddrSpec,
uint8_t  msduLength,
uint8_t *  msdu,
uint8_t  mpduLinkQuality,
uint8_t  DSN,
uint32_t  Timestamp 
)

app_state_t app_state = APP_IDLE

This variable stores the current state of the node.

Referenced by usr_mlme_associate_conf(), usr_mlme_beacon_notify_ind(), usr_mlme_reset_conf(), usr_mlme_scan_conf(), and usr_mlme_set_conf().

uint8_t APP_TIMER
static
uint32_t bc_rx_cnt
static

Referenced by usr_mcps_data_ind().

uint32_t channels_supported
static

Referenced by usr_mlme_get_conf().

wpan_addr_spec_t coord_addr_spec
uint8_t default_key_source[8]

Referenced by usr_mlme_reset_conf().

uint32_t indirect_rx_cnt
static

Referenced by usr_mcps_data_ind().

uint8_t msdu_payload[PAYLOAD_LEN]
static

This array stores the current msdu payload.

Referenced by usr_mlme_beacon_notify_ind().