#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 "sio2host.h"
Macros | |
#define | LED_DATA (LED0) |
#define | LED_NWK_SETUP (LED0) |
#define | LED_START (LED0) |
#define | MAX_PAIRED_DEVICES NWKC_MAX_PAIRING_TABLE_ENTRIES |
Typedefs | |
typedef enum node_status_tag | node_status_t |
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]) | |
FLASH_DECLARE (uint8_t supported_cec_cmds[32]) | |
static char * | get_status_text (nwk_enum_t status) |
This function is used to print the status in text on the hyperterminal. More... | |
static void | handle_input (uint8_t input_char) |
Handle keyboard input. More... | |
static void | led_handling (void *callback_parameter) |
LED handling including timer control . More... | |
int | main (void) |
Main function of the Terminal Target application. 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 request to enable or disable the receiver. More... | |
static 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... | |
static void | nlme_start_confirm (nwk_enum_t Status) |
Notify the application of the status of its request to start a network. More... | |
static void | nlme_unpair_confirm (uint8_t Status, uint8_t PairingRef) |
Notify the application for the previous unpair request. More... | |
static void | nlme_unpair_indication (uint8_t PairingRef) |
Notify the application of the removal of link by another device. More... | |
static void | nwk_ch_agility_confirm (nwk_enum_t Status, bool ChannelChanged, uint8_t LogicalChannel) |
Confirms the previous channel agility request, i.e. More... | |
static 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... | |
static void | pbp_rec_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... | |
static void | print_app_header (void) |
Print the head lines of the application to the terminal program. More... | |
static void | print_ch_change_submenu (void) |
Prints the sub menu for the base channel change. 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 | print_sub_mode_ch_ag_setup (void) |
Prints the sub menu for the channel agility. More... | |
static void | print_unpair_submenu (void) |
Print the unpairing submenu to the terminal program. More... | |
static void | print_vendor_data_submenu (vendor_cmd_id_t Vcmd) |
This function is used to print the vendor data submenu on the hyperterminal. More... | |
void | vendor_data_confirm (nwk_enum_t Status, uint8_t PairingRef, profile_id_t ProfileId, uint8_t Handle) |
Post processing of the vendor data confirm. More... | |
static void | vendor_data_ind (uint8_t PairingRef, uint16_t VendorId, uint8_t nsduLength, uint8_t *nsdu, uint8_t RxLinkQuality, uint8_t RxFlags) |
Post processing of the vendor data response. More... | |
static 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... | |
static void | zrc_cmd_disc_indication (uint8_t PairingRef) |
The command discovery indication callback indicates that a command discovery request command was receiced. More... | |
static 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... | |
Variables | |
static bool | ch_ag_enabled = false |
static bool | duplicate_pair_entry = false |
static uint8_t | led_timer |
static node_status_t | node_status |
static uint8_t | number_of_paired_dev = 0 |
static nwk_indication_callback_t | nwk_ind |
static uint8_t | nwk_Private_ChAgEdThreshold |
static uint32_t | nwk_Private_ChAgScanInterval |
static uint8_t | nwk_ScanDuration |
static node_status_t | previous_node_status |
static zrc_indication_callback_t | zrc_ind |
#define LED_DATA (LED0) |
Referenced by led_handling(), main(), and zrc_cmd_indication().
#define LED_NWK_SETUP (LED0) |
Referenced by handle_input(), led_handling(), main(), and nlme_start_confirm().
#define LED_START (LED0) |
Referenced by main().
#define MAX_PAIRED_DEVICES NWKC_MAX_PAIRING_TABLE_ENTRIES |
Referenced by nlme_get_confirm().
typedef enum node_status_tag node_status_t |
enum node_status_tag |
|
static |
|
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] | ) |
FLASH_DECLARE | ( | uint8_t | supported_cec_cmds[32] | ) |
|
static |
This function is used to print the status in text on the hyperterminal.
status | nwk status (constants defined by nwk layer) |
References NWK_DISCOVERY_ERROR, NWK_DISCOVERY_TIMEOUT, NWK_DUPLICATE_PAIRING, NWK_FRAME_COUNTER_EXPIRED, NWK_INVALID_INDEX, NWK_INVALID_PARAMETER, NWK_MAC_CHANNEL_ACCESS_FAILURE, NWK_MAC_DISABLE_TRX_FAILURE, NWK_MAC_INVALID_ADDRESS, NWK_MAC_INVALID_GTS, NWK_MAC_INVALID_HANDLE, NWK_MAC_NO_ACK, NWK_MAC_NO_BEACON, NWK_MAC_NO_DATA, NWK_MAC_NO_SHORT_ADDRESS, NWK_MAC_OUT_OF_CAP, NWK_MAC_PAN_ID_CONFLICT, NWK_MAC_REALIGNMENT, NWK_MAC_TRANSACTION_EXPIRED, NWK_MAC_TRANSACTION_OVERFLOW, NWK_MAC_TX_ACTIVE, NWK_NO_ORG_CAPACITY, NWK_NO_PAIRING, NWK_NO_REC_CAPACITY, NWK_NO_RESPONSE, NWK_NOT_PERMITTED, NWK_SECURITY_FAILURE, NWK_SECURITY_TIMEOUT, NWK_SUCCESS, and NWK_UNSUPPORTED_ATTRIBUTE.
Referenced by nlme_reset_confirm(), nlme_set_confirm(), nlme_start_confirm(), nlme_unpair_confirm(), nwk_ch_agility_confirm(), pbp_rec_pair_confirm(), and zrc_cmd_disc_confirm().
|
static |
Handle keyboard input.
input_char | character typed from input device. |
References AG_PERIODIC, AG_STOP, ALIVE_REQ, ALL_IN_ONE_START, APP_CAPABILITIES, BATTERY_STATUS_REQ, ch_ag_enabled, CH_AGILITY_EXECUTION, DEVICE_TYPE_LIST_SIZE, FUNC_PTR, FW_VERSION_REQ, GETTING_CH_AG_NIBS, IDLE, led_handling(), LED_NWK_SETUP, led_timer, nlme_get_confirm(), nlme_get_request(), nlme_reset_confirm(), nlme_reset_request(), nlme_rx_enable_confirm(), nlme_rx_enable_request(), nlme_start_confirm(), nlme_start_request(), node_status, NULL, nwk_ch_agility_confirm(), nwk_ch_agility_request(), nwkcMinActivePeriod, nwkPrivateChAgEdThreshold, pbp_rec_pair_confirm(), pbp_rec_pair_request(), POWER_SAVE, previous_node_status, print_ch_change_submenu(), print_main_menu(), print_pairing_table(), print_unpair_submenu(), print_vendor_data_submenu(), PRINTING_PAIRING_TABLE, PROFILE_ID_LIST_SIZE, PUSH_BUTTON_PAIRING, RESETTING, RX_DURATION_INFINITY, STARTING, SUPPORTED_DEV_TYPE_0, SUPPORTED_PROFILE_ID_0, SW_TIMEOUT_RELATIVE, sw_timer_start(), UNPAIRING, and WARM_STARTING.
Referenced by app_task().
|
static |
LED handling including timer control .
References ALL_IN_ONE_START, FUNC_PTR, LED_DATA, LED_NWK_SETUP, led_timer, node_status, NULL, PUSH_BUTTON_PAIRING, SW_TIMEOUT_RELATIVE, sw_timer_start(), and sw_timer_stop().
Referenced by handle_input(), nlme_start_confirm(), and zrc_cmd_indication().
int main | ( | void | ) |
Main function of the Terminal Target application.
References app_alert(), app_task(), board_init(), cpu_irq_enable, delay_init, irq_initialize_vectors, LED_DATA, LED_NWK_SETUP, LED_START, led_timer, nlme_unpair_indication(), nwk_indication_callback_tag::nlme_unpair_indication_cb, nwk_ch_agility_indication(), nwk_indication_callback_tag::nwk_ch_agility_indication_cb, nwk_init(), NWK_SUCCESS, nwk_task(), register_nwk_indication_callback(), register_zrc_indication_callback(), sio2host_init(), sw_timer_get_id(), sw_timer_init(), sysclk_init(), vendor_data_ind(), zrc_indication_callback::vendor_data_ind_cb, zrc_cmd_disc_indication(), zrc_indication_callback::zrc_cmd_disc_indication_cb, zrc_cmd_indication(), and zrc_indication_callback::zrc_cmd_indication_cb.
|
static |
Notify the application of the status of its request for the value of a NIB attribute.
Status | nwk status |
NIBAttribute | NIBAttribute |
NIBAttributeIndex | NIBAttributeIndex |
NIBAttributeValue | Value of the NIB attribute. |
References pairing_table_tag::DestinationLogicalChannel, FUNC_PTR, IDLE, MAX_PAIRED_DEVICES, nlme_get_request(), node_status, number_of_paired_dev, nwk_Private_ChAgEdThreshold, nwk_Private_ChAgScanInterval, nwk_ScanDuration, NWK_SUCCESS, nwkBaseChannel, nwkPairingTable, nwkPrivateChAgEdThreshold, nwkPrivateChAgScanInterval, nwkScanDuration, previous_node_status, print_pairing_table(), print_sub_mode_ch_ag_setup(), and WARM_STARTING.
Referenced by handle_input(), nlme_rx_enable_confirm(), print_node_status(), and print_pairing_table().
|
static |
Notify the application of the status of its request to reset the NWK layer.
Status | nwk status |
References ALL_IN_ONE_START, FUNC_PTR, get_status_text(), IDLE, nlme_rx_enable_confirm(), nlme_rx_enable_request(), nlme_start_confirm(), nlme_start_request(), node_status, number_of_paired_dev, NWK_SUCCESS, RESETTING, RX_DURATION_INFINITY, and WARM_STARTING.
Referenced by handle_input().
|
static |
Notify the application of the status of its request to enable or disable the receiver.
Status | nwk status |
References FUNC_PTR, nlme_get_confirm(), nlme_get_request(), node_status, nwkPairingTable, and WARM_STARTING.
|
static |
Notify the application of the status of its request to to change the value of a NIB attribute.
Status | nwk status |
NIBAttribute | NIBAttribute |
NIBAttributeIndex | NIBAttributeIndex |
References get_status_text(), IDLE, node_status, NWK_SUCCESS, and nwkBaseChannel.
Referenced by print_ch_change_submenu(), and print_sub_mode_ch_ag_setup().
|
static |
Notify the application of the status of its request to start a network.
The NLME-START.confirm primitive allows the NLME to notify the application of the status of its request to start a network.
Status | nwk status |
References ALL_IN_ONE_START, APP_CAPABILITIES, DEVICE_TYPE_LIST_SIZE, FUNC_PTR, get_status_text(), IDLE, led_handling(), LED_NWK_SETUP, led_timer, node_status, NULL, pbp_rec_pair_confirm(), pbp_rec_pair_request(), PROFILE_ID_LIST_SIZE, STARTING, SUPPORTED_DEV_TYPE_0, SUPPORTED_PROFILE_ID_0, SW_TIMEOUT_RELATIVE, and sw_timer_start().
Referenced by handle_input(), and nlme_reset_confirm().
|
static |
Notify the application for the previous unpair request.
The NLME-UNPAIR.confirm primitive allows the NLME to notify the application of the status of its request to remove a pair with another device.
Status | nwk status |
PairingRef | Pairing Ref for which entry is removed from pairing table. |
References get_status_text(), IDLE, node_status, number_of_paired_dev, NWK_NO_PAIRING, and UNPAIRING.
Referenced by print_unpair_submenu().
|
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.
PairingRef | Pairing Ref for which entry is removed from pairing table. |
References number_of_paired_dev.
Referenced by main().
|
static |
Confirms the previous channel agility request, i.e.
nwk_ch_agility_req()
Status | nwk status |
ChannelChanged | whether channel is changed. |
LogicalChannel | changed logical channel. |
References ch_ag_enabled, get_status_text(), IDLE, and node_status.
Referenced by handle_input().
|
static |
Prints the new channel after channel agility took place.
LogicalChannel | changed logical channel. |
Referenced by main().
|
static |
Prints the status of push button pairing and if status is success, then send the cmd discovery to controller.
Status | nwk status |
PairingRef | Pairing Ref of the new entry. |
References CMD_DISCOVERING, duplicate_pair_entry, FUNC_PTR, get_status_text(), IDLE, node_status, number_of_paired_dev, NWK_SUCCESS, zrc_cmd_disc_confirm(), and zrc_cmd_disc_request().
Referenced by handle_input(), and nlme_start_confirm().
|
static |
Print the head lines of the application to the terminal program.
References BOARD_NAME.
Referenced by print_main_menu().
|
static |
Prints the sub menu for the base channel change.
References BASE_CHANNEL_CHANGE, FUNC_PTR, isdigit, nlme_set_confirm(), nlme_set_request(), node_status, nwkBaseChannel, and sio2host_getchar().
Referenced by handle_input().
|
static |
Print main menu to terminal program.
References print_app_header(), and print_node_status().
Referenced by handle_input().
|
static |
Print the node status to the terminal program.
References ALL_IN_ONE_START, ch_ag_enabled, CH_AGILITY_EXECUTION, FUNC_PTR, IDLE, nlme_get_confirm(), nlme_get_request(), node_status, number_of_paired_dev, nwkBaseChannel, POWER_SAVE, PRINTING_PAIRING_TABLE, PUSH_BUTTON_PAIRING, RESETTING, STARTING, and UNPAIRING.
Referenced by print_main_menu().
|
static |
Print the pairing table to the terminal program.
start_from_scratch | Whether pairing table has to printed from scratch. |
table_entry | Table entry |
index | Index of the table entry to be printed. |
References addr, pairing_table_tag::DestinationIEEEaddress, pairing_table_tag::DestinationLogicalChannel, pairing_table_tag::DestinationNetworkAddress, pairing_table_tag::DestinationPANidentifier, FUNC_PTR, nlme_get_confirm(), nlme_get_request(), nwkPairingTable, pairing_table_tag::RecipientCapabilities, pairing_table_tag::RecipientFrameCounter, pairing_table_tag::SecurityLinkKey, and pairing_table_tag::SourceNetworkAddress.
Referenced by handle_input(), and nlme_get_confirm().
|
static |
Prints the sub menu for the channel agility.
References FUNC_PTR, isdigit, nlme_set_confirm(), nlme_set_request(), nwk_Private_ChAgEdThreshold, nwk_Private_ChAgScanInterval, nwk_ScanDuration, nwkPrivateChAgEdThreshold, nwkPrivateChAgScanInterval, nwkScanDuration, sio2host_getchar(), and sio2host_getchar_nowait().
Referenced by nlme_get_confirm().
|
static |
Print the unpairing submenu to the terminal program.
References FUNC_PTR, IDLE, nlme_unpair_confirm(), nlme_unpair_request(), node_status, and sio2host_getchar().
Referenced by handle_input().
|
static |
This function is used to print the vendor data submenu on the hyperterminal.
Vcmd | Vendor command id to be requested. |
References IDLE, node_status, NWKC_VENDOR_IDENTIFIER, PROFILE_ID_ZRC, sio2host_getchar(), TXO_ACK_REQ, TXO_CH_NOT_SPEC, TXO_DST_ADDR_IEEE, TXO_MULTI_CH, TXO_SEC_REQ, TXO_UNICAST, TXO_VEND_SPEC, and vendor_data_request().
Referenced by handle_input().
void vendor_data_confirm | ( | nwk_enum_t | Status, |
uint8_t | PairingRef, | ||
profile_id_t | ProfileId, | ||
uint8_t | Handle | ||
) |
Post processing of the vendor data confirm.
status | nwk status (constants defined by nwk layer) |
PairingRef | Pairing reference |
Handle | Network Layer retries |
References EOT, get_next_tx_buffer(), RF4CONTROL_PID, RF4CONTROL_PID_LEN, and VENDOR_DATA_CONFIRM.
|
static |
Post processing of the vendor data response.
PairingRef | Pairing reference |
VendorId | Vendor ID. |
nsduLength | Length of the payload. |
nsdu | Actual payload |
RxLinkQuality | Link quality of received packet. |
RxFlags | Rx Flags. |
References ALIVE_RESP, BATTERY_STATUS_RESP, FUNC_PTR, FW_VERSION_RESP, IDLE, nlme_rx_enable_confirm(), nlme_rx_enable_request(), node_status, PGM_READ_WORD, POWER_SAVE, RX_DURATION_INFINITY, and RX_ON_RESP.
|
static |
The command discovery confirm for the previous command discovery request.
request command was receiced.
Status | nwk status |
PairingRef | Pairing Ref for destination. |
SupportedCmd | Supported commands by destination node. |
References get_status_text(), IDLE, and node_status.
Referenced by pbp_rec_pair_confirm().
|
static |
The command discovery indication callback indicates that a command discovery request command was receiced.
PairingRef | Pairing Ref for the source. |
References PGM_READ_BLOCK, and zrc_cmd_disc_response().
Referenced by main().
|
static |
Handles the rc command indications at terminal target.
PairingRef | Pairing reference |
nsduLength | Length of the payload. |
nsdu | Actual payload |
RxLinkQuality | Link quality of received packet. |
RxFlags | Rx Flags. |
References zrc_cmd_frm_tag::fcf, FUNC_PTR, IDLE, LED_DATA, led_handling(), led_timer, nlme_rx_enable_confirm(), nlme_rx_enable_request(), node_status, NULL, POWER_SAVE, zrc_cmd_frm_tag::rc_cmd, RX_DURATION_INFINITY, SW_TIMEOUT_RELATIVE, sw_timer_start(), USER_CONTROL_PRESSED, USER_CONTROL_RELEASED, USER_CONTROL_REPEATED, and zrc_print_rc_cmd_text().
Referenced by main().
Referenced by handle_input(), nwk_ch_agility_confirm(), and print_node_status().
Referenced by pbp_allow_pairing(), and pbp_rec_pair_confirm().
|
static |
Referenced by handle_input(), led_handling(), main(), nlme_start_confirm(), and zrc_cmd_indication().
|
static |
Referenced by handle_input(), led_handling(), nlme_get_confirm(), nlme_reset_confirm(), nlme_rx_enable_confirm(), nlme_set_confirm(), nlme_start_confirm(), nlme_unpair_confirm(), nwk_ch_agility_confirm(), pbp_rec_pair_confirm(), print_ch_change_submenu(), print_node_status(), print_unpair_submenu(), print_vendor_data_submenu(), vendor_data_ind(), zrc_cmd_disc_confirm(), and zrc_cmd_indication().
|
static |
|
static |
|
static |
Referenced by nlme_get_confirm(), and print_sub_mode_ch_ag_setup().
|
static |
Referenced by nlme_get_confirm(), and print_sub_mode_ch_ag_setup().
|
static |
Referenced by nlme_get_confirm(), and print_sub_mode_ch_ag_setup().
|
static |
Referenced by handle_input(), and nlme_get_confirm().
|
static |