Microchip® Advanced Software Framework

wireless/avr2102_rf4control/apps/zid/dev/terminal/main.c File Reference
#include <asf.h>
#include "conf_board.h"
#include "led.h"
#include "common_sw_timer.h"
#include "keyboard.h"
#include "app_config.h"
#include "rf4ce.h"
#include "vendor_data.h"
#include "pb_pairing.h"
#include "zid.h"
#include "zid_device.h"

Macros

#define INTER_FRAME_DURATION_US   200000 /* 200 ms */
 
#define TX_OPTIONS
 

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_nlme_rx_enable_confirm (nwk_enum_t Status)
 
static void app_task (void)
 Application task and state machine. More...
 
bool check_zid_adaptor_compatibility (uint8_t PairingRef, uint8_t payload_length, uint8_t *payload)
 This function checks the Adaptor compatibility while pairing decides whether push button pairing request should be allowed. More...
 
static void extended_delay_ms (uint16_t delay_ms)
 Extended blocking delay. More...
 
 FLASH_DECLARE (uint16_t VendorIdentifier)
 
 FLASH_DECLARE (uint8_t vendor_string[7])
 
 FLASH_DECLARE (uint8_t app_user_string[15])
 
static void indicate_fault_behavior (void)
 Indicating malfunction. More...
 
static key_state_t key_state_read (key_id_t key_no)
 Read key_state. More...
 
int main (void)
 Main function of the ZID Device application. More...
 
void nlde_data_confirm (nwk_enum_t Status, uint8_t PairingRef, profile_id_t ProfileId)
 NLDE-DATA.confirm primitive API. More...
 
static void nlme_reset_confirm (nwk_enum_t Status)
 
static void nlme_start_confirm (nwk_enum_t Status)
 
void vendor_app_alive_req (void)
 Vendor-spefic callback; handles reaction to incoming alive request. More...
 
static void zid_connect_confirm (nwk_enum_t Status, uint8_t PairingRef)
 Push button pairing confirm; target and controller use. More...
 
static void zid_data_confirm (nwk_enum_t Status, uint8_t PairingRef)
 Confirmation status to the application for its ZID data request. More...
 
static void zid_get_report_indication (uint8_t PairingRef, zid_report_types_t zid_report_type, zid_report_desc_t zid_report_desc, uint8_t RxLinkQuality, uint8_t RxFlags)
 Notify the application when ZID report data is received from the paired device. More...
 
static void zid_report_data_confirm (nwk_enum_t Status, uint8_t PairingRef)
 Confirmation status to the application for its report data request. 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)
 
static void zid_set_attribute_confirm (nwk_enum_t status, uint8_t PairingRef, zid_attribute_t ZIDAttribute, uint8_t ZIDAttributeIndex)
 

Variables

key_state_t key_state = KEY_RELEASED
 
static bool loop_end = false
 
static node_status_t node_status
 
static uint8_t pairing_ref = 0xFF
 
static uint8_t report_id = 0
 
static uint8_t set_attribute_index = 0
 
static zid_indication_callback_t zid_ind
 

#define INTER_FRAME_DURATION_US   200000 /* 200 ms */

Referenced by app_task().

#define TX_OPTIONS
Value:
#define TXO_ACK_REQ
Tx option - ACK requested.
Definition: atmel_rf4ce/lib/rf4ce.h:71
#define TXO_DST_ADDR_NET
Tx option - destination address: short.
Definition: atmel_rf4ce/lib/rf4ce.h:65
#define TXO_MULTI_CH
Tx option - multi-channel transmission.
Definition: atmel_rf4ce/lib/rf4ce.h:77
#define TXO_VEND_NOT_SPEC
Tx option - no vendor-specific data.
Definition: atmel_rf4ce/lib/rf4ce.h:85
#define TXO_CH_NOT_SPEC
Tx option - channel not specified.
Definition: atmel_rf4ce/lib/rf4ce.h:81
#define TXO_SEC_REQ
Tx option - security requested.
Definition: atmel_rf4ce/lib/rf4ce.h:75
#define TXO_UNICAST
Tx option - unicast.
Definition: atmel_rf4ce/lib/rf4ce.h:61

Referenced by app_task(), and zid_get_report_indication().

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_nlme_rx_enable_confirm ( nwk_enum_t  Status)
static
static void app_task ( void  )
static

Application task and state machine.

References aplHIDStdDescCompsList, pinch_gesture_report_tag::center_x, pinch_gesture_report_tag::center_y, CONFIGURING_ATTRIBUTES, sync_report_tag::contact_count, CONTACT_DATA, 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, scroll_gesture_report_tag::finger_count, pinch_gesture_report_tag::finger_present, rotation_gesture_report_tag::finger_present, FUNC_PTR, sync_report_tag::gesture, touch_sensor_properties_tag::gestures, IDLE, INPUT, INTER_FRAME_DURATION_US, keyboard_input_desc_tag::key_code, KEY_PRESSED, key_state_read(), KEYBOARD, tap_support_properties_tag::long_tap, loop_end, rotation_gesture_report_tag::magnitude, touch_sensor_properties_tag::max_coordinate_x, touch_sensor_properties_tag::max_coordinate_y, keyboard_input_desc_tag::modifier_keys, MOUSE, node_status, nwk_stack_idle(), touch_sensor_properties_tag::origin, pairing_ref, PINCH_GESTURE, touch_sensor_properties_tag::reliable_index, zid_report_data_record_tag::report_data, zid_report_data_record_tag::report_desc_identifier, report_id, zid_report_data_record_tag::report_type, touch_sensor_properties_tag::resolution_x, touch_sensor_properties_tag::resolution_y, ROTATE_GESTURE, SCROLL_GESTURE, SELECT_KEY, set_attribute_index, touch_sensor_properties_tag::shape, tap_support_properties_tag::single_tap, sw_timer_get_time(), SYNC, tap_support_properties_tag::tap_and_a_half, TAP_GESTURE, TAP_SUPPORT_PROPERTIES, TOUCH_SENSOR_PROPERTIES, TRANSMITTING, TX_OPTIONS, scroll_gesture_report_tag::type, zid_report_data_confirm(), zid_report_data_request(), zid_set_attribute_confirm(), and zid_set_attribute_request().

Referenced by main().

bool check_zid_adaptor_compatibility ( uint8_t  PairingRef,
uint8_t  payload_length,
uint8_t *  payload 
)

This function checks the Adaptor compatibility while pairing decides whether push button pairing request should be allowed.

nlde_data_confirm The NLDE-DATA.confirm primitive is generated by the NWK layer entity in response to an NLDE-DATA.request primitive.

Decision could be based on one of the parameter.

Parameters
PairingRefPairing reference.
payload_lengthLength of the Payload
*payloadPointer to the Payload Adaptor attributes can be extracted from the payload.
Returns
true if pairing is granted; else false
static void extended_delay_ms ( uint16_t  delay_ms)
static

Extended blocking delay.

Parameters
delay_msDelay value in ms

References delay_ms.

Referenced by app_nlme_rx_enable_confirm(), indicate_fault_behavior(), and zid_connect_confirm().

FLASH_DECLARE ( uint16_t  VendorIdentifier)
FLASH_DECLARE ( uint8_t  vendor_string[7])
FLASH_DECLARE ( uint8_t  app_user_string[15])
static void indicate_fault_behavior ( void  )
static
static key_state_t key_state_read ( key_id_t  key_no)
static

Read key_state.

Parameters
key_noKeyid to be read.

References ioport_get_pin_level(), KEY_PRESSED, KEY_RELEASED, and SELECT_KEY.

Referenced by app_task(), and main().

static void nlme_reset_confirm ( nwk_enum_t  Status)
static
static void nlme_start_confirm ( nwk_enum_t  Status)
static
void vendor_app_alive_req ( void  )

Vendor-spefic callback; handles reaction to incoming alive request.

Vendor data alive request.

References delay_ms, LED0, LED_Off, and LED_On.

static void zid_connect_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef 
)
static

Push button pairing confirm; target and controller use.

The push button pairing confirm is a callback that provides the status of the push pairing request.

Parameters
StatusStatus of the last pairing transaction
PairingRefIf pairing was successful, PairingRef contains assigned pairing reference.

References app_alert(), CONNECTING, extended_delay_ms(), IDLE, indicate_fault_behavior(), LED0, LED_Off, LED_On, node_status, NWK_SUCCESS, and pairing_ref.

Referenced by zid_set_attribute_confirm().

static void zid_data_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef 
)
static

Confirmation status to the application for its ZID data request.

Parameters
Statusnwk status
PairingRefPairing reference.

References IDLE, indicate_fault_behavior(), LED0, LED_Off, node_status, and NWK_SUCCESS.

Referenced by zid_get_report_indication().

static void zid_get_report_indication ( uint8_t  PairingRef,
zid_report_types_t  zid_report_type,
zid_report_desc_t  zid_report_desc,
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, FUNC_PTR, IDLE, INPUT, MOUSE, node_status, pairing_ref, zid_report_data_record_tag::report_data, zid_report_data_record_tag::report_desc_identifier, zid_report_data_record_tag::report_type, TRANSMITTING, TX_OPTIONS, mouse_desc_tag::x_coordinate, mouse_desc_tag::y_coordinate, zid_data_confirm(), and zid_report_data_request().

Referenced by main().

static void zid_report_data_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef 
)
static

Confirmation status to the application for its report data request.

Parameters
Statusnwk status
PairingRefPairing reference.

References IDLE, indicate_fault_behavior(), LED0, LED_Off, node_status, NWK_SUCCESS, and report_id.

Referenced by app_task().

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 
)
static

Referenced by main().

static void zid_set_attribute_confirm ( nwk_enum_t  status,
uint8_t  PairingRef,
zid_attribute_t  ZIDAttribute,
uint8_t  ZIDAttributeIndex 
)
static

Referenced by app_task(), and main().

bool loop_end = false
static

Referenced by app_task().

uint8_t pairing_ref = 0xFF
static
uint8_t report_id = 0
static
uint8_t set_attribute_index = 0
static
zid_indication_callback_t zid_ind
static