Microchip® Advanced Software Framework

wireless/avr2102_rf4control/apps/zid/adptr/terminal/main.c File Reference
#include <ctype.h>
#include "conf_board.h"
#include <asf.h>
#include "app_config.h"
#include "led.h"
#include "delay.h"
#include "vendor_data.h"
#include "pb_pairing.h"
#include "common_sw_timer.h"
#include "zid.h"

Macros

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

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_alert (void)
 
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])
 
static void handle_input (uint8_t input_char)
 Handle keyboard input. More...
 
static void led_handling (void *callback_parameter)
 Function to handle the LED States based on application state. More...
 
int main (void)
 Main function, initialization and main message loop. More...
 
static 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...
 
static void nlme_reset_confirm (nwk_enum_t Status)
 Notify the application of the status of its request to reset the NWK layer. More...
 
static void nlme_rx_enable_confirm (nwk_enum_t Status)
 Notify the application of the status of its rx enable request. More...
 
static void nlme_start_confirm (nwk_enum_t Status)
 Notify the application of the status of its request to start the NWK. More...
 
static void nlme_unpair_indication (uint8_t PairingRef)
 Notify the application of the removal of link by another device. 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...
 
static void print_app_header (void)
 Print the head lines of the application to the terminal program. More...
 
static void print_main_menu (void)
 Print main menu to terminal program. More...
 
static void print_node_status (void)
 Print the node status to the terminal program. More...
 
static void print_pairing_table (bool start_from_scratch, uint8_t *table_entry, uint8_t index)
 Print the pairing table to the terminal program. More...
 
static void zid_connect_confirm (nwk_enum_t Status, uint8_t PairingRef)
 Notify the application of the status of its connect request. More...
 
static void zid_heartbeat_indication (uint8_t PairingRef)
 Notify the application of the status of its heartbeat request. More...
 
static void zid_indication_callback_init (void)
 This function registers the callback function for indications from the stack. More...
 
static void zid_report_data_indication (uint8_t PairingRef, uint8_t num_report_records, zid_report_data_record_t *zid_report_data_record_ptr, uint8_t RxLinkQuality, uint8_t RxFlags)
 Notify the application when ZID report data is received from the paired device. More...
 

Variables

static uint8_t APP_TIMER
 
static bool duplicate_pair_entry = false
 
static node_status_t node_status
 
static uint8_t number_of_paired_dev = 0
 
static nwk_indication_callback_t nwk_ind
 
static node_status_t previous_node_status
 
static zid_indication_callback_t zid_ind
 

#define LED_DATA   (LED0)
#define LED_DATA   (LED0)
#define LED_NWK_SETUP   (LED0)

Referenced by led_handling(), and main().

#define LED_START   (LED0)

Referenced by main().

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 

static void app_alert ( void  )
static
static void app_task ( void  )
static

Application task.

References handle_input(), nwk_stack_idle(), and sio2host_getchar_nowait().

Referenced by main().

FLASH_DECLARE ( uint16_t  VendorIdentifier)
FLASH_DECLARE ( uint8_t  vendor_string[7])
FLASH_DECLARE ( uint8_t  app_user_string[15])
static void led_handling ( void *  callback_parameter)
static

Function to handle the LED States based on application state.

Parameters
callback_parametercallback parameter if any.

References ALL_IN_ONE_START, APP_TIMER, FUNC_PTR, LED_DATA, LED_NWK_SETUP, LED_Off, LED_Toggle, node_status, NULL, SW_TIMEOUT_RELATIVE, sw_timer_start(), sw_timer_stop(), and ZID_CONNECTING.

static void nlme_get_confirm ( nwk_enum_t  Status,
nib_attribute_t  NIBAttribute,
uint8_t  NIBAttributeIndex,
void *  NIBAttributeValue 
)
static

Notify the application of the status of its request for the value of a NIB attribute.

Parameters
Statusnwk status
NIBAttributeNIBAttribute
NIBAttributeIndexNIBAttributeIndex
NIBAttributeValueValue of the NIB attribute.
static void nlme_reset_confirm ( nwk_enum_t  Status)
static

Notify the application of the status of its request to reset the NWK layer.

Parameters
Statusnwk status
static void nlme_rx_enable_confirm ( nwk_enum_t  Status)
static

Notify the application of the status of its rx enable request.

Parameters
Statusnwk status
static void nlme_start_confirm ( nwk_enum_t  Status)
static

Notify the application of the status of its request to start the NWK.

Parameters
Statusnwk status
static void nlme_unpair_indication ( uint8_t  PairingRef)
static

Notify the application of the removal of link by another device.

The NLME-UNPAIR.indication primitive allows the NLME to notify the application of the removal of a pairing link by another device.

Parameters
PairingRefPairing Ref for which entry is removed from pairing table.
static void print_app_header ( void  )
static

Print the head lines of the application to the terminal program.

Referenced by print_main_menu().

static void print_main_menu ( void  )
static

Print main menu to terminal program.

References print_app_header(), and print_node_status().

Referenced by handle_input().

static void print_node_status ( void  )
static
static void print_pairing_table ( bool  start_from_scratch,
uint8_t *  table_entry,
uint8_t  index 
)
static
void zid_connect_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef 
)
static

Notify the application of the status of its connect request.

Parameters
Statusnwk status.
PairingRefPairing reference.

References duplicate_pair_entry, IDLE, node_status, number_of_paired_dev, and NWK_SUCCESS.

Referenced by handle_input().

void zid_heartbeat_indication ( uint8_t  PairingRef)
static

Notify the application of the status of its heartbeat request.

Parameters
PairingRefPairing reference.
static void zid_indication_callback_init ( void  )
static

This function registers the callback function for indications from the stack.

void zid_report_data_indication ( uint8_t  PairingRef,
uint8_t  num_report_records,
zid_report_data_record_t zid_report_data_record_ptr,
uint8_t  RxLinkQuality,
uint8_t  RxFlags 
)
static

Notify the application when ZID report data is received from the paired device.

Parameters
PairingRefPairing reference.
num_report_recordsnumber of Report records.
*zid_report_data_record_ptrpointer to the report data received.
RxLinkQualityLQI value of the report data frame.
RxFlagsReceive flags.

References mouse_desc_tag::button0, mouse_desc_tag::button1, mouse_desc_tag::button2, pinch_gesture_report_tag::center_x, pinch_gesture_report_tag::center_y, sync_report_tag::contact_count, CONTACT_DATA, contact_data_report_tag::contact_index, contact_data_report_tag::contact_state, contact_data_report_tag::contact_type, scroll_gesture_report_tag::direction, pinch_gesture_report_tag::direction, rotation_gesture_report_tag::direction, scroll_gesture_report_tag::distance, pinch_gesture_report_tag::distance, tap_support_properties_tag::double_tap, tap_gesture_report_tag::finger_count, scroll_gesture_report_tag::finger_count, pinch_gesture_report_tag::finger_present, rotation_gesture_report_tag::finger_present, sync_report_tag::gesture, touch_sensor_properties_tag::gestures, INPUT, keyboard_input_desc_tag::key_code, KEYBOARD, contact_data_report_tag::location_x, tap_gesture_report_tag::location_x, contact_data_report_tag::location_y, tap_gesture_report_tag::location_y, tap_support_properties_tag::long_tap, rotation_gesture_report_tag::magnitude, contact_data_report_tag::major_axis_length, contact_data_report_tag::major_axis_orientation, touch_sensor_properties_tag::max_coordinate_x, touch_sensor_properties_tag::max_coordinate_y, contact_data_report_tag::minor_axis_length, keyboard_input_desc_tag::modifier_keys, MOUSE, touch_sensor_properties_tag::no_of_additional_contacts, touch_sensor_properties_tag::origin, PINCH_GESTURE, contact_data_report_tag::pressure, touch_sensor_properties_tag::reliable_index, zid_report_data_record_tag::report_desc_identifier, zid_report_data_record_tag::report_type, touch_sensor_properties_tag::resolution_x, touch_sensor_properties_tag::resolution_y, ROTATE_GESTURE, SCROLL_GESTURE, touch_sensor_properties_tag::shape, tap_support_properties_tag::single_tap, SYNC, tap_support_properties_tag::tap_and_a_half, TAP_GESTURE, TAP_SUPPORT_PROPERTIES, TOUCH_SENSOR_PROPERTIES, tap_gesture_report_tag::type, scroll_gesture_report_tag::type, mouse_desc_tag::x_coordinate, and mouse_desc_tag::y_coordinate.

uint8_t APP_TIMER
static

Referenced by led_handling(), and main().

bool duplicate_pair_entry = false
static

Referenced by zid_connect_confirm().

uint8_t number_of_paired_dev = 0
static
nwk_indication_callback_t nwk_ind
static
node_status_t previous_node_status
static

Referenced by handle_input().

zid_indication_callback_t zid_ind
static