Microchip® Advanced Software Framework

atmel_rf4ce/examples/atmega128rfa1_avr477_target/main.c File Reference

Terminal Target application.

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

#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
#include "pal.h"
#include "app_config.h"
#include "rf4ce.h"
#include "pb_pairing.h"
#include "zrc.h"
#include "vendor_data.h"
#include "qdebug_transport.h"
#include "twi_master.h"
#include "compiler.h"

Macros

#define IEEE_ADDRESS_BYTES   8
 
#define LED_DATA   (LED_0)
 
#define LED_NWK_SETUP   (LED_0)
 
#define LED_START   (LED_0)
 
#define MAX_PAIRED_DEVICES   NWKC_MAX_PAIRING_TABLE_ENTRIES
 
#define PAIR_WAIT_PERIOD   500000
 
#define RESET_QT600_PORT   (PORTD)
 List of defines for QT600 control with STB-RCB. More...
 
#define RESET_QT600_DIR   (DDRD)
 
#define RESET_QT600_PIN   (PD5)
 
#define RESET_QT600_PIN_INIT()
 
#define RESET_QT600_ON()   RESET_QT600_PORT &= ~(1 << RESET_QT600_PIN) /* low active */
 
#define RESET_QT600_OFF()   RESET_QT600_PORT |= 1 << RESET_QT600_PIN
 
#define QT_SIGN_ON   0x21
 List of the command IDs used in QDebug. More...
 
#define QT_GLOBAL_CONFIG   0x22
 
#define QT_SENSOR_CONFIG   0x23
 
#define QT_SIGNALS   0x24
 
#define QT_REFERENCES   0x25
 
#define QT_DELTAS   0x26
 
#define QT_STATES   0x27
 

Typedefs

typedef enum node_status_tag node_status_t
 

Enumerations

enum  node_status_tag {
  IDLE,
  WARM_START,
  COLD_START,
  CONFIGURING_ATTRIBUTES,
  CONNECTING,
  TRANSMITTING,
  IDLE,
  WARM_START,
  COLD_START,
  TRANSMITTING,
  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,
  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,
  IDLE,
  WARM_START,
  COLD_START,
  TRANSMITTING,
  RESET,
  TRX_OFF_START,
  TRX_OFF_CONFIRM,
  TRX_ON_START,
  IDLE,
  WARM_START,
  COLD_START,
  CONFIGURING_ATTRIBUTES,
  CONNECTING,
  TRANSMITTING,
  IDLE,
  WARM_START,
  COLD_START,
  CONFIGURING_ATTRIBUTES,
  CONNECTING,
  TRANSMITTING,
  IDLE = 0,
  RESETTING,
  POWER_SAVE,
  STARTING,
  ZID_CONNECTING,
  ALL_IN_ONE_START,
  WARM_STARTING,
  PRINTING_PAIRING_TABLE,
  UNPAIRING
}
 

Functions

static void app_task (void)
 Application task. More...
 
 FLASH_DECLARE (uint16_t VendorIdentifier)
 
 FLASH_DECLARE (uint8_t vendor_string[7])
 
 FLASH_DECLARE (uint8_t app_user_string[15])
 
 FLASH_DECLARE (uint8_t supported_cec_cmds[32])
 
int main (void)
 Main function of the Terminal Target application. More...
 
void nlde_data_confirm (nwk_enum_t Status, uint8_t PairingRef, profile_id_t ProfileId)
 Notify the application of the status of its request for data tx (nlde-data.request) More...
 
void nlme_get_confirm (nwk_enum_t Status, nib_attribute_t NIBAttribute, uint8_t NIBAttributeIndex, void *NIBAttributeValue)
 Notify the application of the status of its request for the value of a NIB attribute. More...
 
void nlme_reset_confirm (nwk_enum_t Status)
 Notify the application of the status of its request to reset the NWK layer. More...
 
void nlme_rx_enable_confirm (nwk_enum_t Status)
 Notify the application of the status of its request to enable or disable the receiver. More...
 
void nlme_set_confirm (nwk_enum_t Status, nib_attribute_t NIBAttribute, uint8_t NIBAttributeIndex)
 Notify the application of the status of its request to to change the value of a NIB attribute. More...
 
void nlme_start_confirm (nwk_enum_t Status)
 Notify the application of the status of its request to start a network. More...
 
void nlme_unpair_confirm (uint8_t Status, uint8_t PairingRef)
 Notify the application for the previous unpair request. More...
 
void nlme_unpair_indication (uint8_t PairingRef)
 Notify the application of the removal of link by another device. More...
 
void nlme_update_key_confirm (nwk_enum_t Status, uint8_t PairingRef)
 Notify the application about the key update. More...
 
void nwk_ch_agility_confirm (nwk_enum_t Status, bool ChannelChanged, uint8_t LogicalChannel)
 Confirms the previous channel agility request, i.e. More...
 
void nwk_ch_agility_indication (uint8_t LogicalChannel)
 Prints the new channel after channel agility took place. More...
 
bool pbp_allow_pairing (nwk_enum_t Status, uint64_t SrcIEEEAddr, uint16_t OrgVendorId, uint8_t OrgVendorString[7], uint8_t OrgUserString[15], uint8_t KeyExTransferCount)
 This function decides whether push button pairing request should be allowed. More...
 
void pbp_pair_confirm (nwk_enum_t Status, uint8_t PairingRef)
 Prints the status of push button pairing and if status is success, then send the cmd discovery to controller. More...
 
void vendor_data_confirm (nwk_enum_t Status, uint8_t PairingRef)
 Post processing of the vendor data confirm. More...
 
void vendor_data_ind (uint8_t PairingRef, profile_id_t ProfileId, uint16_t VendorId, uint8_t nsduLength, uint8_t *nsdu, uint8_t RxLinkQuality, uint8_t RxFlags)
 Post processing of the vendor data response. More...
 
void zrc_cmd_disc_confirm (nwk_enum_t Status, uint8_t PairingRef, uint8_t *SupportedCmd)
 The command discovery confirm for the previous command discovery request. More...
 
void zrc_cmd_disc_indication (uint8_t PairingRef)
 The command discovery indication callback indicates that a command discovery request command was receiced. More...
 
void zrc_cmd_indication (uint8_t PairingRef, uint8_t nsduLength, uint8_t *nsdu, uint8_t RxLinkQuality, uint8_t RxFlags)
 Handles the rc command indications at terminal target. More...
 
static void led_handling (void *callback_parameter)
 Application Task related APIs. More...
 

Variables

static bool ch_ag_enabled = true
 
static node_status_t node_status
 
uint8_t rf4ce_new_msg = 0
 
uint8_t tal_pib_CurrentChannel
 
uint64_t tal_pib_IeeeAddress
 
uint16_t tal_pib_PANId
 
static uint8_t target_auto_start = true
 

#define IEEE_ADDRESS_BYTES   8

Referenced by main().

#define LED_DATA   (LED_0)
#define LED_NWK_SETUP   (LED_0)
#define LED_START   (LED_0)

Referenced by main().

#define MAX_PAIRED_DEVICES   NWKC_MAX_PAIRING_TABLE_ENTRIES
#define PAIR_WAIT_PERIOD   500000

Referenced by led_handling(), and nlme_set_confirm().

#define QT_DELTAS   0x26

Referenced by Transmit_Delta().

#define QT_GLOBAL_CONFIG   0x22

Referenced by Transmit_Global_Config().

#define QT_REFERENCES   0x25

Referenced by Transmit_Ref().

#define QT_SENSOR_CONFIG   0x23

Referenced by Transmit_Sensor_Config().

#define QT_SIGN_ON   0x21

List of the command IDs used in QDebug.

Referenced by Transmit_Sign_On().

#define QT_SIGNALS   0x24

Referenced by Transmit_Signals().

#define QT_STATES   0x27

Referenced by Transmit_State().

#define RESET_QT600_DIR   (DDRD)
#define RESET_QT600_OFF ( )    RESET_QT600_PORT |= 1 << RESET_QT600_PIN

Referenced by zrc_cmd_disc_indication().

#define RESET_QT600_ON ( )    RESET_QT600_PORT &= ~(1 << RESET_QT600_PIN) /* low active */

Referenced by main().

#define RESET_QT600_PIN   (PD5)
#define RESET_QT600_PIN_INIT ( )
Value:
do \
{ \
RESET_QT600_PORT |= 1 << RESET_QT600_PIN; /* low active */\
} while (0)
#define RESET_QT600_PORT
List of defines for QT600 control with STB-RCB.
Definition: atmel_rf4ce/examples/atmega128rfa1_avr477_target/main.c:155
#define RESET_QT600_PIN
Definition: atmel_rf4ce/examples/atmega128rfa1_avr477_target/main.c:157
#define RESET_QT600_DIR
Definition: atmel_rf4ce/examples/atmega128rfa1_avr477_target/main.c:156

Referenced by main().

#define RESET_QT600_PORT   (PORTD)

List of defines for QT600 control with STB-RCB.

Enumerator
IDLE 
WARM_START 
COLD_START 
CONFIGURING_ATTRIBUTES 
CONNECTING 
TRANSMITTING 
IDLE 
WARM_START 
COLD_START 
TRANSMITTING 
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 
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 
IDLE 
WARM_START 
COLD_START 
TRANSMITTING 
RESET 
TRX_OFF_START 
TRX_OFF_CONFIRM 
TRX_ON_START 
IDLE 
WARM_START 
COLD_START 
CONFIGURING_ATTRIBUTES 
CONNECTING 
TRANSMITTING 
IDLE 
WARM_START 
COLD_START 
CONFIGURING_ATTRIBUTES 
CONNECTING 
TRANSMITTING 
IDLE 
RESETTING 
POWER_SAVE 
STARTING 
ZID_CONNECTING 
ALL_IN_ONE_START 
WARM_STARTING 
PRINTING_PAIRING_TABLE 
UNPAIRING 

FLASH_DECLARE ( uint16_t  VendorIdentifier)
FLASH_DECLARE ( uint8_t  vendor_string[7])
FLASH_DECLARE ( uint8_t  app_user_string[15])
FLASH_DECLARE ( uint8_t  supported_cec_cmds[32])
void pbp_pair_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef 
)

Prints the status of push button pairing and if status is success, then send the cmd discovery to controller.

Originator push pairing request; controller use.

Parameters
Statusnwk status
PairingRefPairing Ref of the new entry.

References CMD_DISCOVERING, IDLE, LED_NWK_SETUP, LED_OFF, node_status, NWK_SUCCESS, pal_led(), target_auto_start, and zrc_cmd_disc_request().

void vendor_data_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef 
)

Post processing of the vendor data confirm.

Vendor data confirm.

Parameters
statusnwk status (constants defined by nwk layer)
PairingRefPairing reference

References UNUSED.

void vendor_data_ind ( uint8_t  PairingRef,
profile_id_t  ProfileId,
uint16_t  VendorId,
uint8_t  nsduLength,
uint8_t *  nsdu,
uint8_t  RxLinkQuality,
uint8_t  RxFlags 
)

Post processing of the vendor data response.

Vendor data indication.

Parameters
PairingRefPairing reference
ProfileIdProfile id.
VendorIdVendor ID.
nsduLengthLength of the payload.
nsduActual payload
RxLinkQualityLink quality of received packet.
RxFlagsRx Flags.

References UNUSED.

Referenced by main(), stack_indication_callback_init(), and zid_indication_callback_init().

bool ch_ag_enabled = true
static

Referenced by app_task().

uint8_t rf4ce_new_msg = 0

Referenced by main(), and zrc_cmd_indication().

uint8_t tal_pib_CurrentChannel
uint64_t tal_pib_IeeeAddress
uint16_t tal_pib_PANId
uint8_t target_auto_start = true
static

Referenced by app_task(), and pbp_pair_confirm().