Atmel Software Framework

thirdparty/wireless/avr2025_mac/apps/mac/no_beacon_sleep/main.c File Reference
#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
 This type definition of a structure can store the short address and the extended address of a device. More...
 

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 {
  IDLE = 0,
  RESETTING,
  POWER_SAVE,
  STARTING,
  ZID_CONNECTING,
  ALL_IN_ONE_START,
  WARM_STARTING,
  IDLE = 0,
  RESETTING,
  POWER_SAVE,
  STARTING,
  ZID_CONNECTING,
  ALL_IN_ONE_START,
  WARM_STARTING,
  IDLE,
  WARM_START,
  COLD_START,
  TRANSMITTING,
  SELECT_TARGET_OPTIONS,
  TARGET_PAIRING,
  TARGET_CHANGING,
  BUTTON_RELEASE_WAITING,
  TARGET_PAIRING_WAIT,
  IDLE = 0,
  RESETTING,
  POWER_SAVE,
  STARTING,
  PUSH_BUTTON_PAIRING,
  CMD_DISCOVERING,
  ALL_IN_ONE_START,
  WARM_STARTING,
  PRINTING_PAIRING_TABLE,
  UNPAIRING,
  CH_AGILITY_EXECUTION,
  BASE_CHANNEL_CHANGE,
  GETTING_CH_AG_NIBS,
  COLD_START_RESET,
  PC_RUNNING,
  IDLE,
  TRANSMITTING,
  IDLE = 0,
  RESETTING,
  POWER_SAVE,
  STARTING,
  ZID_CONNECTING,
  ALL_IN_ONE_START,
  WARM_STARTING,
  PRINTING_PAIRING_TABLE,
  UNPAIRING,
  IDLE,
  WARM_START,
  COLD_START,
  CONFIGURING_ATTRIBUTES,
  CONNECTING,
  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_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_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

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_IDLE
 
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)
#define COORD_SHORT_ADDR   (0x0000)

Defines the short address of the coordinator.

#define DATA_TX_PERIOD   (2000000)

This is the time period in micro seconds for data transmissions.

Referenced by awake_timer_cb().

#define DEFAULT_PAN_ID   CCPU_ENDIAN_TO_LE16(0xBABE)

Defines the PAN ID of the network.

Referenced by app_task(), and usr_mlme_set_conf().

#define INTER_FRAME_DURATION_US   (200000)
#define LED_DATA   (LED0)
#define LED_NWK_SETUP   (LED0)

Referenced by main(), and network_scan_indication_cb().

#define LED_START   (LED0)

Referenced by main().

#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.

#define SCAN_CHANNEL   (1ul << current_channel)
#define SCAN_DURATION   (4)

Defines the scan duration time.

This type definition of a structure can store the short address and the extended address of a device.

Enumerator
IDLE 
RESETTING 
POWER_SAVE 
STARTING 
ZID_CONNECTING 
ALL_IN_ONE_START 
WARM_STARTING 
IDLE 
RESETTING 
POWER_SAVE 
STARTING 
ZID_CONNECTING 
ALL_IN_ONE_START 
WARM_STARTING 
IDLE 
WARM_START 
COLD_START 
TRANSMITTING 
SELECT_TARGET_OPTIONS 
TARGET_PAIRING 
TARGET_CHANGING 
BUTTON_RELEASE_WAITING 
TARGET_PAIRING_WAIT 
IDLE 
RESETTING 
POWER_SAVE 
STARTING 
PUSH_BUTTON_PAIRING 
CMD_DISCOVERING 
ALL_IN_ONE_START 
WARM_STARTING 
PRINTING_PAIRING_TABLE 
UNPAIRING 
CH_AGILITY_EXECUTION 
BASE_CHANNEL_CHANGE 
GETTING_CH_AG_NIBS 
COLD_START_RESET 
PC_RUNNING 
IDLE 
TRANSMITTING 
IDLE 
RESETTING 
POWER_SAVE 
STARTING 
ZID_CONNECTING 
ALL_IN_ONE_START 
WARM_STARTING 
PRINTING_PAIRING_TABLE 
UNPAIRING 
IDLE 
WARM_START 
COLD_START 
CONFIGURING_ATTRIBUTES 
CONNECTING 
TRANSMITTING 

static void app_alert ( void  )
static

References delay_us.

static bool assign_new_short_addr ( uint64_t  addr64,
uint16_t *  addr16 
)
static
static void awake_timer_cb ( void *  parameter)
static
static void data_exchange_led_off_cb ( void *  parameter)
static

References LED_DATA.

Referenced by usr_mcps_data_ind().

static void network_scan_indication_cb ( void *  parameter)
static
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 
)

uint32_t channels_supported
static
associated_device_t coord_addr
static

This structure stores the short and extended address of the coordinator.

Referenced by handle_incoming_msg().

uint8_t current_channel
static
uint8_t current_channel_page
static

This array stores all device related information.

volatile bool in_sleep_mode = false

Referenced by app_task(), and awake_timer_cb().

node_status_t node_status
static

Current status of the node.

Referenced by app_task(), main(), and usr_mcps_data_conf().

uint8_t number_of_scans
static

Number of done network scans.

volatile bool timer_flag = false

Referenced by app_task(), and awake_timer_cb().

uint8_t TIMER_LED_OFF
static
uint8_t WAKE_TIMER
static

Referenced by main().