Mac Application - No beacon Sleep.
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
#include <string.h>
#include "conf_board.h"
#include "avr2025_mac.h"
#include "led.h"
#include "delay.h"
#include "common_sw_timer.h"
#include "sleepmgr.h"
#include <asf.h>
Data Structures | |
struct | associated_device_tag |
Macros | |
#define | CHANNEL_OFFSET (0) |
#define | COORD_SHORT_ADDR (0x0000) |
Defines the short address of the coordinator. More... | |
#define | DATA_TX_PERIOD (2000000) |
This is the time period in micro seconds for data transmissions. More... | |
#define | DEFAULT_PAN_ID CCPU_ENDIAN_TO_LE16(0xBABE) |
Defines the PAN ID of the network. More... | |
#define | INTER_FRAME_DURATION_US (200000) |
#define | LED_DATA (LED0) |
#define | LED_NWK_SETUP (LED0) |
#define | LED_START (LED0) |
#define | MAX_NUMBER_OF_DEVICES (2) |
Defines the maximum number of devices the coordinator will handle. More... | |
#define | MAX_NUMBER_OF_SCANS (3) |
Defines the maximum number of scans before starting own network. More... | |
#define | SCAN_CHANNEL (1ul << current_channel) |
#define | SCAN_DURATION (4) |
Defines the scan duration time. More... | |
Typedefs | |
typedef struct associated_device_tag | associated_device_t |
This type definition of a structure can store the short address and the extended address of a device. More... | |
typedef enum node_status_tag | node_status_t |
Enumerations | |
enum | node_status_tag { COLD_START_RESET, PC_RUNNING, IDLE, TRANSMITTING } |
Functions | |
static void | app_alert (void) |
static void | app_task (void) |
static bool | assign_new_short_addr (uint64_t addr64, uint16_t *addr16) |
static void | awake_timer_cb (void *parameter) |
static void | data_exchange_led_off_cb (void *parameter) |
int | main (void) |
Main function. More... | |
static void | network_scan_indication_cb (void *parameter) |
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_mcps_purge_conf (uint8_t msduHandle, uint8_t status) |
Callback function that must be implemented by application (NHLE) for MAC service MCPS-PURGE.confirm. More... | |
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_associate_ind (uint64_t DeviceAddress, uint8_t CapabilityInformation) |
Callback function that must be implemented by application (NHLE) for MAC service MLME-ASSOCIATE.indication. 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_comm_status_ind (wpan_addr_spec_t *SrcAddrSpec, wpan_addr_spec_t *DstAddrSpec, uint8_t status) |
Callback function that must be implemented by application (NHLE) for MAC service MLME-COMM-STATUS.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_orphan_ind (uint64_t OrphanAddress) |
Callback function that must be implemented by application (NHLE) for MAC service MLME-ORPHAN.indication. More... | |
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_start_conf (uint8_t status) |
Callback function that must be implemented by application (NHLE) for MAC service MLME-START.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 | |
static uint32_t | channels_supported |
static associated_device_t | coord_addr |
This structure stores the short and extended address of the coordinator. More... | |
static uint8_t | current_channel |
static uint8_t | current_channel_page |
static associated_device_t | device_list [MAX_NUMBER_OF_DEVICES] |
This array stores all device related information. More... | |
volatile bool | in_sleep_mode = false |
enum sleepmgr_mode | mode = SLEEPMGR_ACTIVE |
static node_status_t | node_status |
Current status of the node. More... | |
static uint8_t | number_of_scans |
Number of done network scans. More... | |
volatile bool | timer_flag = false |
static uint8_t | TIMER_LED_OFF |
static uint8_t | WAKE_TIMER |
#define CHANNEL_OFFSET (0) |
Referenced by usr_mlme_get_conf().
#define COORD_SHORT_ADDR (0x0000) |
Defines the short address of the coordinator.
Referenced by usr_mlme_scan_conf().
#define DATA_TX_PERIOD (2000000) |
This is the time period in micro seconds for data transmissions.
Referenced by awake_timer_cb(), and usr_mlme_associate_conf().
#define DEFAULT_PAN_ID CCPU_ENDIAN_TO_LE16(0xBABE) |
Defines the PAN ID of the network.
Referenced by app_task(), usr_mlme_scan_conf(), and usr_mlme_set_conf().
#define INTER_FRAME_DURATION_US (200000) |
#define LED_DATA (LED0) |
Referenced by app_task(), data_exchange_led_off_cb(), main(), usr_mcps_data_conf(), and usr_mcps_data_ind().
#define LED_NWK_SETUP (LED0) |
Referenced by main(), network_scan_indication_cb(), usr_mlme_associate_conf(), and usr_mlme_start_conf().
#define MAX_NUMBER_OF_DEVICES (2) |
Defines the maximum number of devices the coordinator will handle.
Referenced by assign_new_short_addr().
#define MAX_NUMBER_OF_SCANS (3) |
Defines the maximum number of scans before starting own network.
Referenced by usr_mlme_scan_conf().
#define SCAN_CHANNEL (1ul << current_channel) |
Referenced by usr_mlme_get_conf(), and usr_mlme_scan_conf().
#define SCAN_DURATION (4) |
Defines the scan duration time.
Referenced by usr_mlme_get_conf(), and usr_mlme_scan_conf().
typedef struct associated_device_tag associated_device_t |
This type definition of a structure can store the short address and the extended address of a device.
typedef enum node_status_tag node_status_t |
enum node_status_tag |
|
static |
References delay_us, LED0, and LED_Toggle.
Referenced by main().
|
static |
References wpan_addr_spec_tag::Addr, ADDR_COPY_DST_SRC_16, wpan_addr_spec_tag::AddrMode, DEFAULT_PAN_ID, IDLE, in_sleep_mode, LED_DATA, LED_On, mac_ready_to_sleep(), mode, node_status, wpan_addr_spec_tag::PANId, associated_device_tag::short_addr, address_field_t::short_address, sleepmgr_enter_sleep(), sleepmgr_init(), sleepmgr_lock_mode(), timer_flag, TRANSMITTING, WPAN_ADDRMODE_SHORT, wpan_mcps_data_req(), and WPAN_TXOPT_ACK.
Referenced by main().
|
static |
References CPU_ENDIAN_TO_LE16, associated_device_tag::ieee_addr, MAX_NUMBER_OF_DEVICES, and associated_device_tag::short_addr.
Referenced by usr_mlme_associate_ind().
|
static |
References DATA_TX_PERIOD, FUNC_PTR, in_sleep_mode, SW_TIMEOUT_RELATIVE, sw_timer_start(), timer_flag, and TIMER_LED_OFF.
Referenced by usr_mlme_associate_conf().
|
static |
References LED_DATA, and LED_Off.
Referenced by usr_mcps_data_ind().
int main | ( | void | ) |
Main function.
References app_alert(), app_task(), board_init(), COLD_START_RESET, cpu_irq_enable, irq_initialize_vectors, LED_DATA, LED_NWK_SETUP, LED_Off, LED_On, LED_START, MAC_SUCCESS, node_status, sw_timer_get_id(), sw_timer_init(), sysclk_init(), TIMER_LED_OFF, WAKE_TIMER, wpan_init(), wpan_mlme_reset_req(), and wpan_task().
|
static |
References FUNC_PTR, LED_NWK_SETUP, LED_Toggle, SW_TIMEOUT_RELATIVE, sw_timer_start(), and TIMER_LED_OFF.
Referenced by usr_mlme_get_conf().
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 | ||
) |
References data_exchange_led_off_cb(), FUNC_PTR, LED_DATA, LED_On, SW_TIMEOUT_RELATIVE, sw_timer_start(), and TIMER_LED_OFF.
Referenced by mcps_data_ind().
|
static |
Referenced by usr_mlme_get_conf().
|
static |
This structure stores the short and extended address of the coordinator.
Referenced by mlme_poll_request().
|
static |
Referenced by usr_mlme_get_conf(), usr_mlme_scan_conf(), and usr_mlme_set_conf().
|
static |
Referenced by usr_mlme_get_conf(), usr_mlme_scan_conf(), and usr_mlme_set_conf().
|
static |
This array stores all device related information.
Referenced by app_task(), and awake_timer_cb().
enum sleepmgr_mode mode = SLEEPMGR_ACTIVE |
Referenced by app_task(), flashcalw_picocache_set_monitor_mode(), sleepmgr_lock_mode(), and sleepmgr_unlock_mode().
|
static |
Current status of the node.
Referenced by app_task(), main(), usr_mcps_data_conf(), usr_mlme_associate_conf(), and usr_mlme_start_conf().
|
static |
Number of done network scans.
Referenced by usr_mlme_scan_conf().
Referenced by app_task(), and awake_timer_cb().
|
static |
|
static |
Referenced by main().