Microchip® Advanced Software Framework

rf4ce.h File Reference

This header file declares the interface for the RF4Control stack.

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

#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "compiler.h"
#include "return_val.h"
#include "nwk_build_config.h"

Data Structures

struct  NodeDesc_tag
 Elements of the NodeDesc type as defined by 094945r00ZB_RF4CE-Specification.pdf. More...
 
struct  nwk_indication_callback_tag
 struct for network indication callback. More...
 
struct  pairing_table_tag
 Structure implementing the pairing table entry as defined by 094945r00ZB_RF4CE-Specification.pdf. More...
 

Macros

#define ALIGN8BIT
 
#define BAND_2400_BASE_CHANNEL   15
 
#define BAND_2400_CHANNEL_OFFSET   5
 
#define BAND_900_BASE_CHANNEL   1
 
#define BAND_900_CHANNEL_OFFSET   3
 
#define ChannelNormalizationCapableFalse   0x00
 Node capability - constant channel normalization capable false. More...
 
#define ChannelNormalizationCapableTrue   0x08
 Node capability - constant channel normalization capable true. More...
 
#define MAX_SAFE_DATA_FRAME_PAYLOAD   (aMaxMACSafePayloadSize - 12)
 Calculate the maximum data frame payload that is allowed: 12 = FCF + frame counter + profile id + vendor id + MIC. More...
 
#define NodeTypeController   0x00
 Node capability - constant node type controller. More...
 
#define NodeTypeTarget   0x01
 Node capability - constant for node type target. More...
 
#define nwkcMaxDutyCycle   62500 /* symbols = 1 s */
 NWK layer constant - max duty cycle. More...
 
#define nwkcMinActivePeriod   1050 /* symbols = 16.8 ms */
 NWK layer constant - min active period. More...
 
#define PowerSourceMainsFalse   0x00
 Node capability - constant power source main not available. More...
 
#define PowerSourceMainsTrue   0x02
 Node capability - constant power source main available. More...
 
#define RX_DURATION_INFINITY   0xFFFFFF
 Define used as parameters for NLME-RX-ENABLE.request: receiver on. More...
 
#define RX_DURATION_OFF   0
 Define used as parameters for NLME-RX-ENABLE.request: receiver off. More...
 
#define RX_FLAG_BROADCAST   0x01
 Rx flag - broadcast. More...
 
#define RX_FLAG_NO_SEC   0x00
 Rx flag - without security. More...
 
#define RX_FLAG_NOT_VENDOR   0x00
 Rx flag - no vendor-specific data. More...
 
#define RX_FLAG_UNICAST   0x00
 Rx flag - unicast. More...
 
#define RX_FLAG_VENDOR_SPEC   0x04
 Rx flag - vendor-specific data. More...
 
#define RX_FLAG_WITH_SEC   0x02
 Rx flag - with security. More...
 
#define SecurityCapableFalse   0x00
 Node capability - constant security capable false. More...
 
#define SecurityCapableTrue   0x04
 Node capability - constant security capable true. More...
 
#define TXO_ACK_NOT_REQ   0x00
 Tx option - ACK not requested. More...
 
#define TXO_ACK_REQ   0x04
 Tx option - ACK requested. More...
 
#define TXO_BROADCAST   0x01
 Tx option - broadcast. More...
 
#define TXO_CH_NOT_SPEC   0x00
 Tx option - channel not specified. More...
 
#define TXO_CH_SPEC   0x20
 Tx option - channel specified. More...
 
#define TXO_DST_ADDR_IEEE   0x02
 Tx option - destination address: long. More...
 
#define TXO_DST_ADDR_NET   0x00
 Tx option - destination address: short. More...
 
#define TXO_MULTI_CH   0x00
 Tx option - multi-channel transmission. More...
 
#define TXO_SEC_NOT_REQ   0x00
 Tx option - security not requested. More...
 
#define TXO_SEC_REQ   0x08
 Tx option - security requested. More...
 
#define TXO_SINGLE_CH   0x10
 Tx option - single-channel transmission. More...
 
#define TXO_UNICAST   0x00
 Tx option - unicast. More...
 
#define TXO_VEND_NOT_SPEC   0x00
 Tx option - no vendor-specific data. More...
 
#define TXO_VEND_SPEC   0x40
 Tx option - vendor-specific data. More...
 

Typedefs

typedef enum dev_type_tag dev_type_t
 Device types as defined by 094950r00ZB_RF4CE-Device-Type-List.pdf. More...
 
typedef enum nib_attribute_tag nib_attribute_t
 Network Information Base attributes as defined by 094945r00ZB_RF4CE-Specification.pdf. More...
 
typedef void(* nlde_data_confirm_cb_t )(nwk_enum_t Status, uint8_t PairingRef, profile_id_t ProfileId, uint8_t Handle)
 NLDE-DATA.confirm primitive API. More...
 
typedef void(* nlde_data_indication_cb_t )(uint8_t PairingRef, profile_id_t ProfileId, uint16_t VendorId, uint8_t nsduLength, uint8_t *nsdu, uint8_t RxLinkQuality, uint8_t RxFlags)
 NLDE-DATA.indication primitive API. More...
 
typedef void(* nlme_auto_discovery_confirm_cb_t )(nwk_enum_t Status, uint64_t SrcIEEEAddr)
 NLME-AUTO-DISCOVERY.confirm primitive API. More...
 
typedef void(* nlme_comm_status_indication_cb_t )(nwk_enum_t Status, uint8_t PairingRef, uint16_t DstPANId, uint8_t DstAddrMode, uint64_t DstAddr)
 NLME-COMM-STATUS.indication primitive API. More...
 
typedef void(* nlme_discovery_confirm_cb_t )(nwk_enum_t Status, uint8_t NumNodes, node_desc_t *NodeDescList)
 
typedef void(* nlme_discovery_indication_cb_t )(nwk_enum_t Status, uint64_t SrcIEEEAddr, uint8_t OrgNodeCapabilities, uint16_t OrgVendorId, uint8_t OrgVendorString[7], uint8_t OrgAppCapabilities, uint8_t OrgUserString[15], dev_type_t OrgDevTypeList[3], profile_id_t OrgProfileIdList[7], dev_type_t SearchDevType, uint8_t RxLinkQuality)
 NLME-DISCOVERY.indication primitive API. More...
 
typedef void(* nlme_get_confirm_cb_t )(nwk_enum_t Status, nib_attribute_t NIBAttribute, uint8_t NIBAttributeIndex, void *NIBAttributeValue)
 NLME-GET.confirm primitive API. More...
 
typedef void(* nlme_pair_confirm_cb_t )(nwk_enum_t Status, uint8_t PairingRef, uint16_t RecVendorId, uint8_t RecVendorString[7], uint8_t RecAppCapabilities, uint8_t RecUserString[15], dev_type_t RecDevTypeList[3], profile_id_t RecProfileIdList[7])
 NLME-PAIR.confirm primitive API. More...
 
typedef void(* nlme_pair_indication_cb_t )(nwk_enum_t Status, uint16_t SrcPANId, uint64_t SrcIEEEAddr, uint8_t OrgNodeCapabilities, uint16_t OrgVendorId, uint8_t OrgVendorString[7], uint8_t OrgAppCapabilities, uint8_t OrgUserString[15], dev_type_t OrgDevTypeList[3], profile_id_t OrgProfileIdList[7], uint8_t KeyExTransferCount, uint8_t ProvPairingRef)
 NLME-PAIR.indication primitive API. More...
 
typedef void(* nlme_reset_confirm_cb_t )(nwk_enum_t Status)
 NLME-RESET.confirm primitive API. More...
 
typedef void(* nlme_rx_enable_confirm_cb_t )(nwk_enum_t Status)
 Confirmation callback pointer for NLME-RX-ENABLE request. More...
 
typedef void(* nlme_set_confirm_cb_t )(nwk_enum_t Status, nib_attribute_t NIBAttribute, uint8_t NIBAttributeIndex)
 NLME-SET.confirm primitive API. More...
 
typedef void(* nlme_start_confirm_cb_t )(nwk_enum_t Status)
 NLME-START.confirm primitive API. More...
 
typedef void(* nlme_unpair_confirm_cb_t )(uint8_t Status, uint8_t PairingRef)
 NLME-UNPAIR.confirm primitive API. More...
 
typedef void(* nlme_unpair_indication_cb_t )(uint8_t PairingRef)
 NLME-UNPAIR.indication primitive API. More...
 
typedef void(* nlme_update_key_confirm_cb_t )(nwk_enum_t Status, uint8_t PairingRef)
 NLME-UPDATE-KEY.confirm primitive API. More...
 
typedef struct NodeDesc_tag node_desc_t
 Elements of the NodeDesc type as defined by 094945r00ZB_RF4CE-Specification.pdf. More...
 
typedef enum nwk_addr_mode_tag nwk_addr_mode_t
 Enumeration identifiying the address mode as defined by 094945r00ZB_RF4CE-Specification.pdf. More...
 
typedef enum nwk_agility_mode_tag nwk_agility_mode_t
 Enumeration used for implementation-specific channel agility. More...
 
typedef void(* nwk_ch_agility_indication_cb_t )(uint8_t LogicalChannel)
 Indicates a channel agility event. More...
 
typedef __PACK__DATA__ enum
nwk_enum_tag 
nwk_enum_t
 NWK enumerations as defined by 094945r00ZB_RF4CE-Specification.pdf, Table 45 - NWK enumerations description. More...
 
typedef struct
nwk_indication_callback_tag 
nwk_indication_callback_t
 struct for network indication callback. More...
 
typedef struct pairing_table_tag pairing_table_t
 Structure implementing the pairing table entry as defined by 094945r00ZB_RF4CE-Specification.pdf. More...
 
typedef enum profile_id_tag profile_id_t
 Profile IDs as defined by 094951r00ZB_RF4CE-Profile-ID-List.pdf. More...
 
typedef void(* zrc_data_indication_cb_t )(uint8_t PairingRef, uint16_t VendorId, uint8_t nsduLength, uint8_t *nsdu, uint8_t RxLinkQuality, uint8_t RxFlags)
 

Enumerations

enum  dev_type_tag {
  DEV_TYPE_RESERVED = 0x00,
  DEV_TYPE_REMOTE_CONTROL = 0x01,
  DEV_TYPE_TELEVISION = 0x02,
  DEV_TYPE_PROJECTON = 0x03,
  DEV_TYPE_PLAYER = 0x04,
  DEV_TYPE_RECORDER = 0x05,
  DEV_TYPE_VIDEO = 0x06,
  DEV_TYPE_AUDIO = 0x07,
  DEV_TYPE_AV_RECORDER = 0x08,
  DEV_TYPE_SET_TOP_BOX = 0x09,
  DEV_TYPE_HOME_THEATER = 0x0A,
  DEV_TYPE_MEDIA_CENTER = 0x0B,
  DEV_TYPE_GAME_CONSOLE = 0x0C,
  DEV_TYPE_SAT_RADIO = 0x0D,
  DEV_TYPE_IR_EXTENDER = 0x0E,
  DEV_TYPE_MONITOR = 0x0F,
  DEV_TYPE_GENERIC = 0xFE,
  DEV_TYPE_WILDCARD = 0xFF
}
 Device types as defined by 094950r00ZB_RF4CE-Device-Type-List.pdf. More...
 
enum  nib_attribute_tag {
  nwkActivePeriod = 0x60,
  nwkBaseChannel = 0x61,
  nwkDiscoveryLQIThreshold = 0x62,
  nwkDiscoveryRepetitionInterval = 0x63,
  nwkDutyCycle = 0x64,
  nwkFrameCounter = 0x65,
  nwkIndicateDiscoveryRequests = 0x66,
  nwkInPowerSave = 0x67,
  nwkPairingTable = 0x68,
  nwkMaxDiscoveryRepetitions = 0x69,
  nwkMaxFirstAttemptCSMABackoffs = 0x6a,
  nwkMaxFirstAttemptFrameRetries = 0x6b,
  nwkMaxReportedNodeDescriptors = 0x6c,
  nwkResponseWaitTime = 0x6d,
  nwkScanDuration = 0x6e,
  nwkUserString = 0x6f,
  nwkPrivateIeeeAddr = 0x70,
  nwkPrivateVendorIdentifier = 0x71,
  nwkPrivateVendorString = 0x72,
  nwkPrivateNodeCapabilities = 0x73,
  nwkPrivatePanIdentifier = 0x74,
  nwkPrivateShortAddress = 0x75,
  nwkPrivateMaxPairingTableEntries = 0x76,
  nwkPrivateChAgEnabled = 0x77,
  nwkPrivateChAgScanInterval = 0x78,
  nwkPrivateChAgEdThreshold = 0x79,
  aplKeyRepeatInterval = 0x80,
  aplKeyRepeatWaitTime = 0x81,
  aplKeyExchangeTransferCount = 0x82
}
 Network Information Base attributes as defined by 094945r00ZB_RF4CE-Specification.pdf. More...
 
enum  nwk_addr_mode_tag {
  NWK_ADDR_MODE_16 = 0,
  NWK_ADDR_MODE_64 = 1
}
 Enumeration identifiying the address mode as defined by 094945r00ZB_RF4CE-Specification.pdf. More...
 
enum  nwk_agility_mode_tag {
  AG_ONE_SHOT = 0,
  AG_PERIODIC = 1,
  AG_STOP = 2
}
 Enumeration used for implementation-specific channel agility. More...
 
enum  nwk_enum_tag {
  NWK_SUCCESS = 0x00,
  NWK_NO_ORG_CAPACITY = 0xb0,
  NWK_NO_REC_CAPACITY = 0xb1,
  NWK_NO_PAIRING = 0xb2,
  NWK_NO_RESPONSE = 0xb3,
  NWK_NOT_PERMITTED = 0xb4,
  NWK_DUPLICATE_PAIRING = 0xb5,
  NWK_FRAME_COUNTER_EXPIRED = 0xb6,
  NWK_DISCOVERY_ERROR = 0xb7,
  NWK_DISCOVERY_TIMEOUT = 0xb8,
  NWK_SECURITY_TIMEOUT = 0xb9,
  NWK_SECURITY_FAILURE = 0xba,
  NWK_INVALID_PARAMETER = 0xe8,
  NWK_UNSUPPORTED_ATTRIBUTE = 0xf4,
  NWK_INVALID_INDEX = 0xf9,
  NWK_MAC_CHANNEL_ACCESS_FAILURE = 0xE1,
  NWK_MAC_DISABLE_TRX_FAILURE = 0xE3,
  NWK_MAC_FRAME_TOO_LONG = 0xE5,
  NWK_MAC_INVALID_GTS = 0xE6,
  NWK_MAC_INVALID_HANDLE = 0xE7,
  NWK_MAC_NO_ACK = 0xE9,
  NWK_MAC_NO_BEACON = 0xEA,
  NWK_MAC_NO_DATA = 0xEB,
  NWK_MAC_NO_SHORT_ADDRESS = 0xEC,
  NWK_MAC_OUT_OF_CAP = 0xED,
  NWK_MAC_PAN_ID_CONFLICT = 0xEE,
  NWK_MAC_REALIGNMENT = 0xEF,
  NWK_MAC_TRANSACTION_EXPIRED = 0xF0,
  NWK_MAC_TRANSACTION_OVERFLOW = 0xF1,
  NWK_MAC_TX_ACTIVE = 0xF2,
  NWK_MAC_INVALID_ADDRESS = 0xF5
}
 NWK enumerations as defined by 094945r00ZB_RF4CE-Specification.pdf, Table 45 - NWK enumerations description. More...
 
enum  profile_id_tag {
  PROFILE_ID_RESERVED_00 = 0x00,
  PROFILE_ID_ZRC = 0x01,
  PROFILE_ID_ZID = 0x02,
  PROFILE_ID_VENDOR_DATA = 0xFE,
  PROFILE_ID_WILDCARD = 0xFF
}
 Profile IDs as defined by 094951r00ZB_RF4CE-Profile-ID-List.pdf. More...
 

Functions

void clear_pairing_ref (uint8_t first_ref, uint8_t length)
 Clears pairing references within EEPROM. More...
 
bool nlde_data_request (uint8_t PairingRef, profile_id_t ProfileId, uint16_t VendorId, uint8_t nsduLength, uint8_t *nsdu, uint8_t TxOptions, uint8_t Handle, FUNC_PTR confirm_cb)
 NLDE-DATA.request primitive API. More...
 
bool nlme_auto_discovery_request (uint8_t RecAppCapabilities, dev_type_t RecDevTypeList[3], profile_id_t RecProfileIdList[7], uint32_t AutoDiscDuration, FUNC_PTR confirm_cb)
 NLME-AUTO-DISCOVERY.request primitive API. More...
 
bool nlme_discovery_request (uint16_t DstPANId, uint16_t DstNwkAddr, uint8_t OrgAppCapabilities, dev_type_t OrgDevTypeList[3], profile_id_t OrgProfileIdList[7], dev_type_t SearchDevType, uint8_t DiscProfileIdListSize, profile_id_t DiscProfileIdList[7], uint32_t DiscDuration, FUNC_PTR confirm_cb)
 NLME-DISCOVERY.request primitive API. More...
 
bool nlme_discovery_response (nwk_enum_t Status, uint64_t DstIEEEAddr, uint8_t RecAppCapabilities, dev_type_t RecDevTypeList[3], profile_id_t RecProfileIdList[7], uint8_t DiscReqLQI)
 NLME-DISCOVERY.response primitive API. More...
 
bool nlme_get_request (nib_attribute_t NIBAttribute, uint8_t NIBAttributeIndex, FUNC_PTR confirm_cb)
 NLME-GET.request primitive API. More...
 
bool nlme_pair_request (uint8_t LogicalChannel, uint16_t DstPANId, uint64_t DstIEEEAddr, uint8_t OrgAppCapabilities, dev_type_t OrgDevTypeList[3], profile_id_t OrgProfileIdList[7], uint8_t KeyExTransferCount, FUNC_PTR confirm_cb)
 NLME-PAIR.request primitive API. More...
 
bool nlme_pair_response (nwk_enum_t Status, uint16_t DstPANId, uint64_t DstIEEEAddr, uint8_t RecAppCapabilities, dev_type_t RecDevTypeList[3], profile_id_t RecProfileIdList[7], uint8_t ProvPairingRef)
 NLME-PAIR.response primitive API. More...
 
bool nlme_reset_request (bool SetDefaultNIB, FUNC_PTR confirm_cb)
 NLME-RESET.request primitive API. More...
 
bool nlme_rx_enable_request (uint32_t RxOnDuration, FUNC_PTR confirm_cb)
 NLME-RX-ENABLE.request primitive API. More...
 
bool nlme_set_request (nib_attribute_t NIBAttribute, uint8_t NIBAttributeIndex, uint8_t *NIBAttributeValue, FUNC_PTR confirm_cb)
 NLME-SET.request primitive API. More...
 
bool nlme_start_request (FUNC_PTR confirm_cb)
 NLME-START.request primitive API. More...
 
bool nlme_unpair_request (uint8_t PairingRef, FUNC_PTR confirm_cb)
 NLME-UNPAIR.request primitive API. More...
 
bool nlme_unpair_response (uint8_t PairingRef)
 NLME-UNPAIR.response primitive API. More...
 
bool nlme_update_key_request (uint8_t PairingRef, uint8_t NewLinkKey[16], FUNC_PTR confirm_cb)
 NLME-UPDATE-KEY.request primitive API. More...
 
bool nwk_ch_agility_request (nwk_agility_mode_t AgilityMode, FUNC_PTR confirm_cb)
 Sets channel agility mode. More...
 
uint8_t nwk_get_nib_attribute_size (uint8_t nib_attribute_id)
 Gets the NIB attribute value size. More...
 
nwk_enum_t nwk_init (void)
 Initialization of RF4CE network layer. More...
 
bool nwk_ready_to_sleep (void)
 Checks if the entire stack is idle. More...
 
bool nwk_stack_idle (void)
 Checks if the network stack is idle. More...
 
bool nwk_task (void)
 Task handling of RF4CE network layer. More...
 
void read_pairing_ref (uint8_t *pairing_ref, uint8_t length)
 Reads pairing reference from EEPROM. More...
 
void register_nwk_indication_callback (nwk_indication_callback_t *nwk_indication_cb)
 Registering network indication callback. More...
 
void store_pairing_ref (uint8_t *pairing_ref, uint8_t length)
 Stores pairing references to EEPROM. More...
 

Variables

__PACK__RST_DATA__ typedef void(* nwk_ch_agility_confirm_cb_t )(nwk_enum_t Status, bool ChannelChanged, uint8_t LogicalChannel)
 Confirms the previous channel agility request, i.e. More...
 

#define ALIGN8BIT
#define BAND_2400_BASE_CHANNEL   15
#define BAND_2400_CHANNEL_OFFSET   5
#define BAND_900_BASE_CHANNEL   1
#define BAND_900_CHANNEL_OFFSET   3
#define ChannelNormalizationCapableFalse   0x00

Node capability - constant channel normalization capable false.

#define ChannelNormalizationCapableTrue   0x08

Node capability - constant channel normalization capable true.

#define MAX_SAFE_DATA_FRAME_PAYLOAD   (aMaxMACSafePayloadSize - 12)

Calculate the maximum data frame payload that is allowed: 12 = FCF + frame counter + profile id + vendor id + MIC.

#define NodeTypeController   0x00

Node capability - constant node type controller.

#define NodeTypeTarget   0x01

Node capability - constant for node type target.

#define nwkcMaxDutyCycle   62500 /* symbols = 1 s */

NWK layer constant - max duty cycle.

#define nwkcMinActivePeriod   1050 /* symbols = 16.8 ms */

NWK layer constant - min active period.

#define PowerSourceMainsFalse   0x00

Node capability - constant power source main not available.

#define PowerSourceMainsTrue   0x02

Node capability - constant power source main available.

#define RX_DURATION_INFINITY   0xFFFFFF

Define used as parameters for NLME-RX-ENABLE.request: receiver on.

#define RX_DURATION_OFF   0

Define used as parameters for NLME-RX-ENABLE.request: receiver off.

#define RX_FLAG_BROADCAST   0x01

Rx flag - broadcast.

#define RX_FLAG_NO_SEC   0x00

Rx flag - without security.

#define RX_FLAG_NOT_VENDOR   0x00

Rx flag - no vendor-specific data.

#define RX_FLAG_UNICAST   0x00

Rx flag - unicast.

#define RX_FLAG_VENDOR_SPEC   0x04

Rx flag - vendor-specific data.

#define RX_FLAG_WITH_SEC   0x02

Rx flag - with security.

#define SecurityCapableFalse   0x00

Node capability - constant security capable false.

#define SecurityCapableTrue   0x04

Node capability - constant security capable true.

#define TXO_ACK_NOT_REQ   0x00

Tx option - ACK not requested.

#define TXO_ACK_REQ   0x04

Tx option - ACK requested.

#define TXO_BROADCAST   0x01

Tx option - broadcast.

#define TXO_CH_NOT_SPEC   0x00

Tx option - channel not specified.

#define TXO_CH_SPEC   0x20

Tx option - channel specified.

#define TXO_DST_ADDR_IEEE   0x02

Tx option - destination address: long.

#define TXO_DST_ADDR_NET   0x00

Tx option - destination address: short.

#define TXO_MULTI_CH   0x00

Tx option - multi-channel transmission.

#define TXO_SEC_NOT_REQ   0x00

Tx option - security not requested.

#define TXO_SEC_REQ   0x08

Tx option - security requested.

#define TXO_SINGLE_CH   0x10

Tx option - single-channel transmission.

#define TXO_UNICAST   0x00

Tx option - unicast.

#define TXO_VEND_NOT_SPEC   0x00

Tx option - no vendor-specific data.

#define TXO_VEND_SPEC   0x40

Tx option - vendor-specific data.

typedef void(* nlme_discovery_confirm_cb_t)(nwk_enum_t Status, uint8_t NumNodes, node_desc_t *NodeDescList)
typedef void(* zrc_data_indication_cb_t)(uint8_t PairingRef, uint16_t VendorId, uint8_t nsduLength, uint8_t *nsdu, uint8_t RxLinkQuality, uint8_t RxFlags)