Microchip® Advanced Software Framework

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

Macros

#define APP_USER_STRING_SIZE   (15)
 
#define BUTTON_0   0
 
#define BUTTON_1   1
 
#define BUTTON_2   2
 
#define BUTTON_DELETE   (76)
 
#define BUTTON_DOWN   (81)
 
#define BUTTON_ESC   (41)
 
#define BUTTON_FUNCTION_F5   (62)
 
#define BUTTON_LEFT   (80)
 
#define BUTTON_MEDIA_MODE   (0x02)
 
#define BUTTON_MODE   (0x00FE)
 
#define BUTTON_MPLAYER   (0x0008)
 
#define BUTTON_MUTE   (0x0001)
 
#define BUTTON_NEXT   (0x0040)
 
#define BUTTON_PAGE_DOWN   (78)
 
#define BUTTON_PAGE_UP   (75)
 
#define BUTTON_PAUSE   (0x0100)
 
#define BUTTON_PLAY   (0x0080)
 
#define BUTTON_PPT_MODE   (0x01)
 
#define BUTTON_PREVIOUS   (0x0020)
 
#define BUTTON_REPEAT   (0x0200)
 
#define BUTTON_RIGHT   (79)
 
#define BUTTON_STOP   (0x0010)
 
#define BUTTON_TAB   (43)
 
#define BUTTON_UP   (82)
 
#define BUTTON_VOLUME_N   (0x0004)
 
#define BUTTON_VOLUME_P   (0x0002)
 
#define INTER_FRAME_DURATION_US   200000 /* 200 ms */
 
#define LAST_BUTTON_INDEX   (0xFF)
 
#define TX_OPTIONS
 
#define VENDOR_STRING_LEN_SIZE   (7)
 
#define ZID_ATTRIBUTE_REQ_SIZE   (10)
 

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)
 application failure indication More...
 
static void app_nlme_rx_enable_confirm (nwk_enum_t Status)
 The NLME-RX-ENABLE.confirm primitive reports the results of the attempt to enable or disable the receiver. More...
 
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)
 nlde_data_confirm The NLDE-DATA.confirm primitive is generated by the NWK layer entity in response to an NLDE-DATA.request primitive. More...
 
 FLASH_DECLARE (uint16_t VendorIdentifier)
 
 FLASH_DECLARE (uint8_t app_user_string[APP_USER_STRING_SIZE])
 
static void indicate_fault_behavior (void)
 Indicating malfunction. More...
 
int main (void)
 Main function, initialization and main message loop. More...
 
void nlde_data_confirm (nwk_enum_t Status, uint8_t PairingRef, profile_id_t ProfileId)
 nlde_data_confirm The NLDE-DATA.confirm primitive is generated by the NWK layer entity in response to an NLDE-DATA.request primitive. More...
 
static void nlme_reset_confirm (nwk_enum_t Status)
 nlme_reset_confirm The NLME-RESET.confirm primitive allows the NLME to notify the application of the status of its request to reset the NWK layer. More...
 
static void nlme_start_confirm (nwk_enum_t Status)
 nlme_start_confirm The NLME-START.confirm primitive allows the NLME to notify the application of the status of its request to start a network. More...
 
void vendor_app_alive_req (void)
 Vendor-specific 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)
 zid_data_confirm is call back of zid_data_request which gives the status of the 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)
 zid_data_confirm is call back to the application layer. More...
 
void zid_heartbeat_confirm (nwk_enum_t Status, uint8_t PairingRef)
 heart beat confirm; target and controller use More...
 
static void zid_report_data_confirm (nwk_enum_t Status, uint8_t PairingRef)
 zid_report_data_confirm is call back of zid_report_data_request which gives the status of the 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)
 ZID Report Data indication used to know if the adaptor sends any output report to the ZID Device. More...
 
static void zid_set_attribute_confirm (nwk_enum_t status, uint8_t PairingRef, zid_attribute_t ZIDAttribute, uint8_t ZIDAttributeIndex)
 zid_set_attribute_confirm ZID Set attribute confirm callback allows to check whether attributes are sent to the ZID Adaptor. More...
 

Variables

uint8_t b_event = 0xFF
 
uint8_t b_state = 0xFF
 
uint8_t button_mode = BUTTON_MEDIA_MODE
 
uint16_t key_mapping_media []
 
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 APP_USER_STRING_SIZE   (15)
#define BUTTON_0   0
#define BUTTON_1   1

Referenced by app_task().

#define BUTTON_2   2

Referenced by app_task().

#define BUTTON_DELETE   (76)
#define BUTTON_DOWN   (81)
#define BUTTON_ESC   (41)
#define BUTTON_FUNCTION_F5   (62)
#define BUTTON_LEFT   (80)
#define BUTTON_MEDIA_MODE   (0x02)
#define BUTTON_MODE   (0x00FE)
#define BUTTON_MPLAYER   (0x0008)
#define BUTTON_MUTE   (0x0001)
#define BUTTON_NEXT   (0x0040)
#define BUTTON_PAGE_DOWN   (78)
#define BUTTON_PAGE_UP   (75)
#define BUTTON_PAUSE   (0x0100)
#define BUTTON_PLAY   (0x0080)
#define BUTTON_PPT_MODE   (0x01)
#define BUTTON_PREVIOUS   (0x0020)
#define BUTTON_REPEAT   (0x0200)
#define BUTTON_RIGHT   (79)
#define BUTTON_STOP   (0x0010)
#define BUTTON_TAB   (43)
#define BUTTON_UP   (82)
#define BUTTON_VOLUME_N   (0x0004)
#define BUTTON_VOLUME_P   (0x0002)
#define INTER_FRAME_DURATION_US   200000 /* 200 ms */

Referenced by app_task().

#define LAST_BUTTON_INDEX   (0xFF)

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(), Send_Message(), and zid_get_report_indication().

#define VENDOR_STRING_LEN_SIZE   (7)
#define ZID_ATTRIBUTE_REQ_SIZE   (10)

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

application failure indication

static void app_nlme_rx_enable_confirm ( nwk_enum_t  Status)
static

The NLME-RX-ENABLE.confirm primitive reports the results of the attempt to enable or disable the receiver.

Parameters
StatusStatus of the nlme_rx_enable_req

References COLD_START, delay_ms, FUNC_PTR, IDLE, indicate_fault_behavior(), LED_Off, LED_On, nlme_reset_confirm(), nlme_reset_request(), node_status, NWK_SUCCESS, WARM_START, and ZID_APP_LED.

Referenced by nlme_reset_confirm().

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

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

Parameters
PairingRefPairingRef for the current transaction
payload_lengthpayload length
payloadpayload to check the adaptor compatibility
Returns
bool true or false
FLASH_DECLARE ( uint16_t  VendorIdentifier)
FLASH_DECLARE ( uint8_t  app_user_string[APP_USER_STRING_SIZE])
static void nlme_reset_confirm ( nwk_enum_t  Status)
static

nlme_reset_confirm The NLME-RESET.confirm primitive allows the NLME to notify the application of the status of its request to reset the NWK layer.

Parameters
Statusstatus from the network layer corresponds to the nlme_reset_req

References app_nlme_rx_enable_confirm(), COLD_START, FUNC_PTR, indicate_fault_behavior(), nlme_reset_request(), nlme_rx_enable_request(), nlme_start_confirm(), nlme_start_request(), node_status, NWK_SUCCESS, pairing_ref, and WARM_START.

Referenced by app_nlme_rx_enable_confirm(), handle_incoming_msg(), handle_input(), main(), nlme_start_confirm(), zid_connect_confirm(), and zid_set_attribute_confirm().

static void nlme_start_confirm ( nwk_enum_t  Status)
static

nlme_start_confirm The NLME-START.confirm primitive allows the NLME to notify the application of the status of its request to start a network.

Parameters
Statusstatus from the network layer corresponds to the nlme_start_req

References aplHIDNumStdDescComps, app_alert(), COLD_START, CONFIGURING_ATTRIBUTES, FUNC_PTR, indicate_fault_behavior(), nlme_reset_confirm(), nlme_reset_request(), node_status, NWK_SUCCESS, WARM_START, ZID_ATTRIBUTE_REQ_SIZE, zid_set_attribute_confirm(), and zid_set_attribute_request().

Referenced by handle_incoming_msg(), handle_input(), and nlme_reset_confirm().

void vendor_app_alive_req ( void  )

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

Vendor data alive request.

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(), COLD_START, CONNECTING, delay_ms, FUNC_PTR, IDLE, indicate_fault_behavior(), LED_Off, LED_On, nlme_reset_confirm(), nlme_reset_request(), node_status, NWK_SUCCESS, pairing_ref, WARM_START, ZID_APP_LED, zid_state, and ZID_STATE_IDLE.

Referenced by zid_set_attribute_confirm().

static void zid_data_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef 
)
static

zid_data_confirm is call back of zid_data_request which gives the status of the data request

Parameters
StatusStatus of the zid_data_request
PairingRefpairing reference for current transaction

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

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

zid_data_confirm is call back to the application layer.

   HID adaptor shall create a get report command frame and transmit
   it to the appropriate HID class device. On receipt of the
   corresponding report data  command frame, the HID adaptor shall pass

the report to the HID class driver.

Parameters
zid_report_typeReport type
PairingRefpairing reference for current transaction
zid_report_desczid report descriptor type
RxLinkQualityReceived frame link quality
RxFlagsReceived frame RxFlags

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_heartbeat_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef 
)

heart beat confirm; target and controller use

The heart beat confirm is a callback that provides the status of the ZID Adaptor. HID class device can periodically check in with the HID adaptor to give it the opportunity to send a message back

Parameters
StatusStatus of the heartbeat command
PairingRefPairingRef contains assigned pairing reference.

Referenced by handle_incoming_msg().

static void zid_report_data_confirm ( nwk_enum_t  Status,
uint8_t  PairingRef 
)
static

zid_report_data_confirm is call back of zid_report_data_request which gives the status of the report data request

Parameters
StatusStatus of the zid_report_data_request
PairingRefpairing reference for current transaction

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

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

ZID Report Data indication used to know if the adaptor sends any output report to the ZID Device.

Parameters
PairingRefPairingRef contains assigned pairing reference.
num_report_recordstotal no of reports in the report data
zid_report_data_record_ptrpointer to the report data
RxLinkQualityLink Quality of the received report
RxFlagsFlags for the Received frame

Referenced by main().

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

zid_set_attribute_confirm ZID Set attribute confirm callback allows to check whether attributes are sent to the ZID Adaptor.

Parameters
Statusstatus from the network layer corresponds to the zid_set_attribute_request
PairingRefcurrent pairing ref
ZIDAttributeattribute name
ZIDAttributeIndexattribute index

References aplHIDStdDescCompsList, app_alert(), APP_CAPABILITIES, COLD_START, CONNECTING, DEV_TYPE_REMOTE_CONTROL, DEV_TYPE_WILDCARD, FUNC_PTR, indicate_fault_behavior(), LED_Off, nlme_reset_confirm(), nlme_reset_request(), node_status, NUM_SUPPORTED_PROFILES, NWK_SUCCESS, PROFILE_ID_ZID, set_attribute_index, WARM_START, ZID_APP_LED, ZID_ATTRIBUTE_REQ_SIZE, zid_connect_confirm(), and zid_org_connect_request().

Referenced by app_task(), and nlme_start_confirm().

uint8_t b_event = 0xFF

Referenced by app_task(), and main().

uint8_t b_state = 0xFF

Referenced by app_task(), and main().

uint8_t button_mode = BUTTON_MEDIA_MODE

Referenced by app_task().

uint16_t key_mapping_media[]
Initial value:
LAST_BUTTON_INDEX, LAST_BUTTON_INDEX}
#define BUTTON_VOLUME_P
Definition: wireless/avr2102_rf4control/apps/zid/dev/qt_remote/main.c:124
#define BUTTON_NEXT
Definition: wireless/avr2102_rf4control/apps/zid/dev/qt_remote/main.c:122
#define BUTTON_MUTE
Definition: wireless/avr2102_rf4control/apps/zid/dev/qt_remote/main.c:126
#define BUTTON_PAUSE
Definition: wireless/avr2102_rf4control/apps/zid/dev/qt_remote/main.c:119
#define BUTTON_PREVIOUS
Definition: wireless/avr2102_rf4control/apps/zid/dev/qt_remote/main.c:123
#define LAST_BUTTON_INDEX
Definition: wireless/avr2102_rf4control/apps/zid/dev/qt_remote/main.c:147
#define BUTTON_VOLUME_N
Definition: wireless/avr2102_rf4control/apps/zid/dev/qt_remote/main.c:125
#define BUTTON_MPLAYER
Definition: wireless/avr2102_rf4control/apps/zid/dev/qt_remote/main.c:120
#define BUTTON_PLAY
Definition: wireless/avr2102_rf4control/apps/zid/dev/qt_remote/main.c:118
#define BUTTON_STOP
Definition: wireless/avr2102_rf4control/apps/zid/dev/qt_remote/main.c:121

Referenced by app_task().

uint8_t pairing_ref = 0xFF
static
uint8_t report_id = 0
static

Referenced by zid_report_data_confirm().

uint8_t set_attribute_index = 0
static
zid_indication_callback_t zid_ind
static