Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
ca821x_api.c File Reference

API Access Function Declarations for MCPS, MLME, HWME and TDME. More...

#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "ca821x_api.h"
#include "ca821x_blacklist.h"
#include "ca821x_log.h"
#include "mac_messages.h"
Include dependency graph for ca821x_api.c:

Macros

#define API_LQI_LIMIT   (75)
 LQI limit, below which received frames should be rejected. More...
 
#define DATAREQ   (Command.PData.DataReq)
 Shorthand for MCPS-DATA Request parameter set. More...
 
#define ASSOCREQ   (Command.PData.AssocReq)
 Shorthand for MLME-ASSOCIATE Request parameter set. More...
 
#define ASSOCRSP   (Command.PData.AssocRsp)
 Shorthand for MLME-ASSOCIATE Response parameter set. More...
 
#define GETREQ   (Command.GetReq)
 Shorthand for MLME-GET Request parameter set. More...
 
#define GETCNF   (Response.PData.GetCnf)
 Shorthand for MLME-GET Confirm parameter set. More...
 
#define ORPHANRSP   (Command.PData.OrphanRsp)
 Shorthand for MLME-ORPHAN Response parameter set. More...
 
#define SIMPLECNF   (Response.PData)
 Shorthand for the raw parameter data of a confirm. More...
 
#define SCANREQ   (Command.PData.ScanReq)
 Shorthand for MLME-SCAN Request parameter set. More...
 
#define SETREQ   (Command.SetReq)
 Shorthand for MLME-SET Request parameter set. More...
 
#define SIMPLECNF   (Response.PData)
 Shorthand for the raw parameter data of a confirm. More...
 
#define STARTREQ   (Command.StartReq)
 Shorthand for MLME-START Request parameter set. More...
 
#define POLLREQ   (Command.PollReq)
 Shorthand for MLME-POLL Request parameter set. More...
 

Functions

uint8_t ca821x_get_sync_response_id (uint8_t cmdid)
 Function to get the command ID for the synchronous response to a sync command. More...
 
ca_error ca821x_api_init (struct ca821x_dev *pDeviceRef)
 Initialisation function for initialising a ca821x_dev data structure for use with the API. More...
 
ca_mac_status MCPS_DATA_request (uint8_t SrcAddrMode, struct FullAddr DstAddr, uint8_t MsduLength, uint8_t *pMsdu, uint8_t MsduHandle, uint8_t TxOptions, struct SecSpec *pSecurity, struct ca821x_dev *pDeviceRef)
 MCPS_DATA_request (Send Data) according to CA8211 API Spec. More...
 
ca_mac_status MCPS_PURGE_request_sync (uint8_t *MsduHandle, struct ca821x_dev *pDeviceRef)
 MCPS_PURGE_request/confirm according to API Spec. More...
 
ca_mac_status MLME_ASSOCIATE_request (uint8_t LogicalChannel, struct FullAddr DstAddr, uint8_t CapabilityInfo, struct SecSpec *pSecurity, struct ca821x_dev *pDeviceRef)
 MLME_ASSOCIATE_request according to API Spec. More...
 
ca_mac_status MLME_ASSOCIATE_response (uint8_t *pDeviceAddress, uint16_t AssocShortAddress, uint8_t Status, struct SecSpec *pSecurity, struct ca821x_dev *pDeviceRef)
 MLME_ASSOCIATE_response according to API Spec. More...
 
ca_mac_status MLME_DISASSOCIATE_request (struct FullAddr DevAddr, uint8_t DisassociateReason, uint8_t TxIndirect, struct SecSpec *pSecurity, struct ca821x_dev *pDeviceRef)
 MLME_DISASSOCIATE_request according to API Spec. More...
 
ca_mac_status MLME_GET_request_sync (uint8_t PIBAttribute, uint8_t PIBAttributeIndex, uint8_t *pPIBAttributeLength, void *pPIBAttributeValue, struct ca821x_dev *pDeviceRef)
 MLME_GET_request/confirm according to API Spec. More...
 
ca_mac_status MLME_ORPHAN_response (uint8_t *pOrphanAddress, uint16_t ShortAddress, uint8_t AssociatedMember, struct SecSpec *pSecurity, struct ca821x_dev *pDeviceRef)
 MLME_ORPHAN_response according to API Spec. More...
 
ca_mac_status MLME_RESET_request_sync (uint8_t SetDefaultPIB, struct ca821x_dev *pDeviceRef)
 MLME_RESET_request/confirm according to API Spec. More...
 
ca_mac_status MLME_RX_ENABLE_request_sync (uint8_t DeferPermit, uint32_t RxOnTime, uint32_t RxOnDuration, struct ca821x_dev *pDeviceRef)
 MLME_RX_ENABLE_request/confirm according to API Spec. More...
 
ca_mac_status MLME_SCAN_request (uint8_t ScanType, uint32_t ScanChannels, uint8_t ScanDuration, struct SecSpec *pSecurity, struct ca821x_dev *pDeviceRef)
 MLME_SCAN_request according to API Spec. More...
 
ca_mac_status MLME_SET_request_sync (uint8_t PIBAttribute, uint8_t PIBAttributeIndex, uint8_t PIBAttributeLength, const void *pPIBAttributeValue, struct ca821x_dev *pDeviceRef)
 MLME_SET_request/confirm according to API Spec. More...
 
ca_mac_status MLME_START_request_sync (uint16_t PANId, uint8_t LogicalChannel, uint8_t BeaconOrder, uint8_t SuperframeOrder, uint8_t PANCoordinator, uint8_t BatteryLifeExtension, uint8_t CoordRealignment, struct SecSpec *pCoordRealignSecurity, struct SecSpec *pBeaconSecurity, struct ca821x_dev *pDeviceRef)
 MLME_START_request/confirm according to API Spec. More...
 
ca_mac_status MLME_POLL_request_sync (struct FullAddr CoordAddress, struct SecSpec *pSecurity, struct ca821x_dev *pDeviceRef)
 
ca_mac_status HWME_SET_request_sync (uint8_t HWAttribute, uint8_t HWAttributeLength, uint8_t *pHWAttributeValue, struct ca821x_dev *pDeviceRef)
 HWME_SET_request/confirm according to API Spec. More...
 
ca_mac_status HWME_GET_request_sync (uint8_t HWAttribute, uint8_t *HWAttributeLength, uint8_t *pHWAttributeValue, struct ca821x_dev *pDeviceRef)
 HWME_GET_request/confirm according to API Spec. More...
 
ca_mac_status HWME_HAES_request_sync (uint8_t HAESMode, uint8_t *pHAESData, struct ca821x_dev *pDeviceRef)
 HWME_HAES_request/confirm according to API Spec. More...
 
ca_mac_status TDME_SETSFR_request_sync (uint8_t SFRPage, uint8_t SFRAddress, uint8_t SFRValue, struct ca821x_dev *pDeviceRef)
 TDME_SETSFR_request/confirm according to API Spec. More...
 
ca_mac_status TDME_GETSFR_request_sync (uint8_t SFRPage, uint8_t SFRAddress, uint8_t *SFRValue, struct ca821x_dev *pDeviceRef)
 TDME_GETSFR_request/confirm according to API Spec. More...
 
ca_mac_status TDME_TESTMODE_request_sync (uint8_t TestMode, struct ca821x_dev *pDeviceRef)
 TDME_TESTMODE_request/confirm according to API Spec. More...
 
ca_mac_status TDME_SET_request_sync (uint8_t TestAttribute, uint8_t TestAttributeLength, void *pTestAttributeValue, struct ca821x_dev *pDeviceRef)
 TDME_SET_request/confirm according to API Spec. More...
 
ca_mac_status TDME_TXPKT_request_sync (uint8_t TestPacketDataType, uint8_t *TestPacketSequenceNumber, uint8_t *TestPacketLength, void *pTestPacketData, struct ca821x_dev *pDeviceRef)
 TDME_TXPKT_request/confirm according to API Spec. More...
 
ca_mac_status TDME_LOTLK_request_sync (uint8_t *TestChannel, uint8_t *TestRxTxb, uint8_t *TestLOFDACValue, uint8_t *TestLOAMPValue, uint8_t *TestLOTXCALValue, struct ca821x_dev *pDeviceRef)
 TDME_LOTLK_request/confirm according to API Spec. More...
 
ca_mac_status TDME_ChipInit (struct ca821x_dev *pDeviceRef)
 TDME Chip Register Default Initialisation Macro. More...
 
ca_mac_status TDME_ChannelInit (uint8_t channel, struct ca821x_dev *pDeviceRef)
 TDME Channel Register Default Initialisation Macro (Tx) More...
 
ca_mac_status TDME_CheckPIBAttribute (uint8_t PIBAttribute, uint8_t PIBAttributeLength, const void *pPIBAttributeValue)
 Checks Attribute Values that are not checked in MAC. More...
 
uint8_t TDME_tx_dbm_to_paib (int8_t txpdbm)
 Function to convert transmit power in dBm to PA current setting. More...
 
int8_t TDME_tx_paib_to_dbm (uint8_t paib)
 Function to convert PA current setting to transmit power in dBm. More...
 
ca_mac_status TDME_SetTxPower (uint8_t txp, struct ca821x_dev *pDeviceRef)
 Sets the tx power for MLME_SET phyTransmitPower. More...
 
ca_mac_status TDME_GetTxPower (uint8_t *txp, struct ca821x_dev *pDeviceRef)
 Returns the tx power for MLME_GET phyTransmitPower. More...
 
union ca821x_api_callbackca821x_get_callback (uint8_t cmdid, struct ca821x_dev *pDeviceRef)
 Function to get a reference to the callback for a certain command ID. More...
 
ca_error ca821x_upstream_dispatch (struct MAC_Message *msg, struct ca821x_dev *pDeviceRef)
 Call the relevant callback routine if populated or the generic_dispatch for a received command. More...
 
ca_error BLACKLIST_Add (struct MacAddr *pAddress, struct ca821x_dev *pDeviceRef)
 Add an address to the blacklist. More...
 
void BLACKLIST_Clear (struct ca821x_dev *pDeviceRef)
 Clear the entire blacklist. More...
 

Detailed Description

API Access Function Declarations for MCPS, MLME, HWME and TDME.

Macro Definition Documentation

◆ API_LQI_LIMIT

#define API_LQI_LIMIT   (75)

LQI limit, below which received frames should be rejected.

◆ ASSOCREQ

#define ASSOCREQ   (Command.PData.AssocReq)

Shorthand for MLME-ASSOCIATE Request parameter set.

◆ ASSOCRSP

#define ASSOCRSP   (Command.PData.AssocRsp)

Shorthand for MLME-ASSOCIATE Response parameter set.

◆ DATAREQ

#define DATAREQ   (Command.PData.DataReq)

Shorthand for MCPS-DATA Request parameter set.

◆ GETCNF

#define GETCNF   (Response.PData.GetCnf)

Shorthand for MLME-GET Confirm parameter set.

◆ GETREQ

#define GETREQ   (Command.GetReq)

Shorthand for MLME-GET Request parameter set.

◆ ORPHANRSP

#define ORPHANRSP   (Command.PData.OrphanRsp)

Shorthand for MLME-ORPHAN Response parameter set.

Usually used for requests with a single-byte payload etc.

◆ POLLREQ

#define POLLREQ   (Command.PollReq)

Shorthand for MLME-POLL Request parameter set.

◆ SCANREQ

#define SCANREQ   (Command.PData.ScanReq)

Shorthand for MLME-SCAN Request parameter set.

◆ SETREQ

#define SETREQ   (Command.SetReq)

Shorthand for MLME-SET Request parameter set.

◆ SIMPLECNF [1/2]

#define SIMPLECNF   (Response.PData)

Shorthand for the raw parameter data of a confirm.

Usually used for confirms with just a status etc.

◆ SIMPLECNF [2/2]

#define SIMPLECNF   (Response.PData)

Shorthand for the raw parameter data of a confirm.

Usually used for confirms with just a status etc.

◆ STARTREQ

#define STARTREQ   (Command.StartReq)

Shorthand for MLME-START Request parameter set.

Function Documentation

◆ MLME_POLL_request_sync()

ca_mac_status MLME_POLL_request_sync ( struct FullAddr  CoordAddress,
struct SecSpec pSecurity,
struct ca821x_dev pDeviceRef 
)