Microchip® Advanced Software Framework

miwi_api.h File Reference

Application Program Interface for MiWi Protocols.

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

#include "compiler.h"
#include "miwi_config.h"
#include "miwi_config_p2p.h"
#include "miwi_mesh_app.h"

Data Structures

struct  __CONNECTION_ENTRY
 
union  __CONNECTION_STATUS
 
struct  __defaultParametersRamOnly
 
struct  __defaultParametersRomOrRam
 
struct  __END_DEVICES_Unique_Short_Address
 
struct  __CONNECTION_STATUS::_CONNECTION_STAUTS_bits
 
struct  _CoordHopCount_t
 
struct  _CoordRouteTable_t
 
struct  _RouteEntry_t
 
struct  ACTIVE_SCAN_RESULT
 
union  API_UINT16_UNION
 
union  API_UINT32_UNION
 
union  API_UINT64_UNION
 
struct  beaconDescriptor_t
 
union  CapabilityInfo
 
struct  CommDeviceTable_t
 
struct  coordinatorTable_
 
struct  deviceTable_
 
struct  DuplicateRejectionTable_
 
union  JoinWish
 
struct  RebroadcastTable_
 
struct  RECEIVED_MESH_MESSAGE
 
struct  RECEIVED_MESSAGE
 
struct  searchConf_t
 
struct  SleepDeviceTable_
 

Macros

#define BLOOM_FILTER_SIZE   8
 
#define BROADCAST_TO_ALL   0x01
 
#define CALC_SEC_PAYLOAD_SIZE(x)   (x)
 
#define CONN_MODE_DIRECT   0x00
 
#define CONN_MODE_INDIRECT   0x01
 
#define COORDINATOR_ADDRESS_MASK   0xFF00
 
#define DISABLE_ALL_CONN   0x03
 
#define ENABLE_ACTIVE_SCAN_RSP   0x02
 
#define ENABLE_ALL_CONN   0x00
 
#define ENABLE_PREV_CONN   0x01
 
#define ENDEVICE_ADDRESS_MASK   0x00FF
 
#define HOP_TABLE_COUNT
 
#define INPUT
 
#define IOPUT
 
#define LONG_ADDR_LEN   8
 
#define MESH_BROADCAST_TO_ALL   (0xFFFF)
 
#define MESH_BROADCAST_TO_COORDINATORS   (0xFFFD)
 
#define MESH_BROADCAST_TO_FFDS   (0xFFFE)
 
#define MiApp_CB_AllowConnection(handleInConnectionTable)   true
 
#define MiApp_CB_RFDAcknowledgement(SourceShortAddress, AcknowledgementSeqNum)
 
#define MIWI_MAJOR_VERSION   '6'
 
#define MIWI_MINOR_VERSION   '7'
 
#define MULTICAST_TO_COORDINATORS   0x02
 
#define MULTICAST_TO_FFDS   0x03
 
#define NOISE_DETECT_CS   0x01
 
#define NOISE_DETECT_ENERGY   0x00
 
#define OUTPUT
 
#define POWER_STATE_SLEEP   0x00
 
#define POWER_STATE_WAKEUP   0x01
 
#define POWER_STATE_WAKEUP_DR   0x02
 
#define RXON_ENDEVICE_ADDRESS_MASK   0x0080
 
#define SECURITY_KEY_SIZE   16
 
#define SHORT_ADDR_LEN   2
 
#define START_CONN_CS_SCN   0x02
 
#define START_CONN_DIRECT   0x00
 
#define START_CONN_ENERGY_SCN   0x01
 

Typedefs

typedef union CapabilityInfo CapabilityInfo_t
 
typedef struct __CONNECTION_ENTRY CONNECTION_ENTRY
 
typedef union __CONNECTION_STATUS CONNECTION_STATUS
 
typedef void(* connectionConf_callback_t )(miwi_status_t status)
 
typedef struct _CoordHopCount_t CoordHopCount_t
 
typedef struct coordinatorTable_ CoordinatorTable_t
 
typedef struct _CoordRouteTable_t CoordRouteTable_t
 
typedef void(* DataConf_callback_t )(uint8_t msgConfHandle, miwi_status_t status, uint8_t *msgPointer)
 
typedef struct
__defaultParametersRamOnly 
defaultParametersRamOnly_t
 
typedef struct
__defaultParametersRomOrRam 
defaultParametersRomOrRam_t
 
typedef enum _deviceRole DeviceRole_t
 
typedef struct deviceTable_ DeviceTable_t
 
typedef struct
DuplicateRejectionTable_ 
DuplicateRejectionTable_t
 
typedef struct
__END_DEVICES_Unique_Short_Address 
END_DEVICES_Unique_Short_Address
 
typedef union JoinWish JoinWish_t
 
typedef void(* LinkFailureCallback_t )(void)
 
typedef enum miwi_params miwi_params_t
 
typedef enum miwi_status miwi_status_t
 
typedef void(* PacketIndCallback_t )(RECEIVED_MESSAGE *ind)
 
typedef struct RebroadcastTable_ RebroadcastTable_t
 
typedef void(* ReconnectionCallback_t )(miwi_status_t status)
 
typedef void(* resyncConnection_callback_t )(uint8_t channel, miwi_status_t status)
 
typedef void(* roleUpgrade_callback_t )(uint16_t newShortAddress)
 
typedef struct _RouteEntry_t RouteEntry_t
 
typedef void(* SearchConnectionConf_callback_t )(uint8_t foundScanResults, void *ScanResults)
 
typedef struct SleepDeviceTable_ SleepDeviceTable_t
 

Enumerations

enum  _deviceRole {
  PAN_COORD = 0x01,
  END_DEVICE
}
 
enum  miwi_params {
  CHANNEL = 0x00,
  PANID = 0x01,
  SHORT_ADDRESS = 0x02,
  PARENT_SHORT_ADDRESS = 0x03,
  DEVICE_TIMEOUT = 0x04,
  CHANNELMAP = 0x05,
  CAPABILITYINFO = 0x06,
  BLOOM_AUTO_JOIN = 0x80,
  ROUTE_TEST_MODE = 0x81
}
 
enum  miwi_status {
  SUCCESS = 0,
  FAILURE,
  CHANNEL_ACCESS_FAILURE,
  NO_ACK,
  TIMER_EXPIRED,
  TRANSACTION_EXPIRED = 5,
  ALREADY_EXISTS,
  NO_ROUTE,
  SCAN_NO_BEACON,
  SCAN_MAX_REACHED,
  MEMORY_UNAVAILABLE = 10,
  ERR_TX_FAIL,
  ERR_TRX_FAIL,
  ERR_INVALID_INPUT,
  RECONNECTION_IN_PROGRESS,
  RECONNECTED,
  ADDR_NOT_FOUND_IN_SCANNED_LIST,
  ENTRY_NOT_EXIST = 0xF0,
  NOT_ENOUGH_SPACE = 0xF1,
  NOT_SAME_PAN = 0xF2,
  NOT_PERMITTED = 0xF3,
  ACTIVE_SCAN = 0xF4
}
 

Functions

void DumpConnection (INPUT uint8_t index)
 
void MeshTasks (void)
 
bool MiApp_Commissioning_AddNewDevice (uint64_t joinerAddress, bool triggerBloomUpdate)
 
void MiApp_ConnectionMode (uint8_t Mode)
 
uint8_t MiApp_EstablishConnection (uint8_t Channel, uint8_t addr_len, uint8_t *addr, uint8_t Capability_info, connectionConf_callback_t ConfCallback)
 
bool MiApp_Get (miwi_params_t id, uint8_t *value)
 
bool MiApp_InitChannelHopping (uint32_t ChannelMap)
 
bool MiApp_IsConnected (void)
 
bool MiApp_ManuSpecSendData (uint8_t addr_len, uint8_t *addr, uint8_t msglen, uint8_t *msgpointer, uint8_t msghandle, bool ackReq, DataConf_callback_t ConfCallback)
 
uint16_t MiApp_MeshGetNextHopAddr (uint16_t destAddress)
 
uint8_t MiApp_NoiseDetection (uint32_t ChannelMap, uint8_t ScanDuration, uint8_t DetectionMode, OUTPUT uint8_t *NoiseLevel)
 
miwi_status_t MiApp_ProtocolInit (defaultParametersRomOrRam_t *defaultRomOrRamParams, defaultParametersRamOnly_t *defaultRamOnlyParams)
 
bool MiApp_ReadyToSleep (uint32_t *sleepTime)
 
void MiApp_RemoveConnection (uint8_t ConnectionIndex)
 
bool MiApp_ResetToFactoryNew (void)
 
bool MiApp_ResyncConnection (uint8_t ConnectionIndex, uint32_t ChannelMap, resyncConnection_callback_t callback)
 
bool MiApp_RoleUpgradeNotification_Subscribe (roleUpgrade_callback_t callback)
 
uint8_t MiApp_SearchConnection (uint8_t ScanDuration, uint32_t ChannelMap, SearchConnectionConf_callback_t ConfCallback)
 
bool MiApp_SendData (uint8_t addr_len, uint8_t *addr, uint8_t msglen, uint8_t *msgpointer, uint8_t msghandle, bool ackReq, bool secEnabled, DataConf_callback_t ConfCallback)
 
bool MiApp_Set (miwi_params_t id, uint8_t *value)
 
bool MiApp_StartConnection (uint8_t Mode, uint8_t ScanDuration, uint32_t ChannelMap, connectionConf_callback_t ConfCallback)
 
bool MiApp_SubscribeDataIndicationCallback (PacketIndCallback_t callback)
 
bool MiApp_SubscribeLinkFailureCallback (LinkFailureCallback_t callback)
 
bool MiApp_SubscribeManuSpecDataIndicationCallback (PacketIndCallback_t callback)
 
bool MiApp_SubscribeReConnectionCallback (ReconnectionCallback_t callback)
 
uint8_t MiApp_TransceiverPowerState (uint8_t Mode)
 
void P2PTasks (void)
 
uint8_t Total_Connections (void)
 

Variables

uint8_t conn_size
 
uint8_t currentChannel
 
defaultParametersRamOnly_t defaultParamsRamOnly
 
defaultParametersRomOrRam_t defaultParamsRomOrRam
 
END_DEVICES_Unique_Short_Address END_DEVICES_Short_Address [CONNECTION_SIZE]
 
uint8_t end_nodes
 
bool lost_connection
 
API_UINT32_UNION meshOutgoingFrameCounter
 
uint8_t myConnectionIndex_in_PanCo
 
uint8_t MyindexinPC
 
uint8_t myLongAddress [MY_ADDRESS_LENGTH]
 
DeviceRole_t role
 
RECEIVED_MESSAGE rxMessage
 

#define BLOOM_FILTER_SIZE   8
#define BROADCAST_TO_ALL   0x01
#define CALC_SEC_PAYLOAD_SIZE (   x)    (x)
#define CONN_MODE_DIRECT   0x00
#define CONN_MODE_INDIRECT   0x01
#define COORDINATOR_ADDRESS_MASK   0xFF00
#define DISABLE_ALL_CONN   0x03
#define ENABLE_ACTIVE_SCAN_RSP   0x02

Referenced by frameParse().

#define ENABLE_ALL_CONN   0x00
#define ENABLE_PREV_CONN   0x01

Referenced by frameParse().

#define ENDEVICE_ADDRESS_MASK   0x00FF
#define HOP_TABLE_COUNT
Value:
(((NUM_OF_COORDINATORS % 2) == 0)? \
((NUM_OF_COORDINATORS / 2) + 1))
#define NUM_OF_COORDINATORS
Definition: miwi_config_mesh.h:116
#define INPUT
#define IOPUT
#define MESH_BROADCAST_TO_ALL   (0xFFFF)

Referenced by otauDataSend().

#define MESH_BROADCAST_TO_COORDINATORS   (0xFFFD)
#define MESH_BROADCAST_TO_FFDS   (0xFFFE)
#define MiApp_CB_AllowConnection (   handleInConnectionTable)    true

Referenced by frameParse().

#define MiApp_CB_RFDAcknowledgement (   SourceShortAddress,
  AcknowledgementSeqNum 
)
#define MIWI_MAJOR_VERSION   '6'
#define MIWI_MINOR_VERSION   '7'
#define MULTICAST_TO_COORDINATORS   0x02
#define MULTICAST_TO_FFDS   0x03
#define NOISE_DETECT_CS   0x01
#define NOISE_DETECT_ENERGY   0x00

Referenced by MiApp_StartConnection().

#define OUTPUT
#define POWER_STATE_SLEEP   0x00
#define POWER_STATE_WAKEUP   0x01
#define POWER_STATE_WAKEUP_DR   0x02
#define RXON_ENDEVICE_ADDRESS_MASK   0x0080

Referenced by appSendData().

#define SECURITY_KEY_SIZE   16
#define START_CONN_CS_SCN   0x02

Referenced by MiApp_StartConnection().

#define START_CONN_DIRECT   0x00
#define START_CONN_ENERGY_SCN   0x01

Referenced by MiApp_StartConnection().

typedef void(* connectionConf_callback_t)(miwi_status_t status)
typedef void(* DataConf_callback_t)(uint8_t msgConfHandle, miwi_status_t status, uint8_t *msgPointer)
typedef enum _deviceRole DeviceRole_t
typedef struct deviceTable_ DeviceTable_t
typedef union JoinWish JoinWish_t
typedef void(* LinkFailureCallback_t)(void)
typedef enum miwi_params miwi_params_t
typedef enum miwi_status miwi_status_t
typedef void(* PacketIndCallback_t)(RECEIVED_MESH_MESSAGE *ind)
typedef void(* ReconnectionCallback_t)(miwi_status_t status)
typedef void(* resyncConnection_callback_t)(uint8_t channel, miwi_status_t status)
typedef void(* roleUpgrade_callback_t)(uint16_t newShortAddress)
typedef struct _RouteEntry_t RouteEntry_t
typedef void(* SearchConnectionConf_callback_t)(uint8_t foundScanResults, void *ScanResults)

Enumerator
PAN_COORD 
END_DEVICE 
Enumerator
CHANNEL 
PANID 
SHORT_ADDRESS 
PARENT_SHORT_ADDRESS 
DEVICE_TIMEOUT 
CHANNELMAP 
CAPABILITYINFO 
BLOOM_AUTO_JOIN 
ROUTE_TEST_MODE 
Enumerator
SUCCESS 
FAILURE 
CHANNEL_ACCESS_FAILURE 
NO_ACK 
TIMER_EXPIRED 
TRANSACTION_EXPIRED 
ALREADY_EXISTS 
NO_ROUTE 
SCAN_NO_BEACON 
SCAN_MAX_REACHED 
MEMORY_UNAVAILABLE 
ERR_TX_FAIL 
ERR_TRX_FAIL 
ERR_INVALID_INPUT 
RECONNECTION_IN_PROGRESS 
RECONNECTED 
ADDR_NOT_FOUND_IN_SCANNED_LIST 
ENTRY_NOT_EXIST 
NOT_ENOUGH_SPACE 
NOT_SAME_PAN 
NOT_PERMITTED 
ACTIVE_SCAN 

void DumpConnection ( INPUT uint8_t  index)
void MeshTasks ( void  )

Referenced by wsndemo_task().

bool MiApp_Commissioning_AddNewDevice ( uint64_t  joinerAddress,
bool  triggerBloomUpdate 
)
void MiApp_ConnectionMode ( uint8_t  Mode)

Referenced by Initialize_Demo(), and main().

bool MiApp_Get ( miwi_params_t  id,
uint8_t *  value 
)
bool MiApp_InitChannelHopping ( uint32_t  ChannelMap)
bool MiApp_IsConnected ( void  )

Referenced by otauTask().

bool MiApp_ManuSpecSendData ( uint8_t  addr_len,
uint8_t *  addr,
uint8_t  msglen,
uint8_t *  msgpointer,
uint8_t  msghandle,
bool  ackReq,
DataConf_callback_t  ConfCallback 
)

Referenced by otauDataSend().

uint16_t MiApp_MeshGetNextHopAddr ( uint16_t  destAddress)
uint8_t MiApp_NoiseDetection ( uint32_t  ChannelMap,
uint8_t  ScanDuration,
uint8_t  DetectionMode,
OUTPUT uint8_t *  NoiseLevel 
)

Referenced by MiApp_StartConnection().

bool MiApp_ReadyToSleep ( uint32_t *  sleepTime)
void MiApp_RemoveConnection ( uint8_t  ConnectionIndex)
bool MiApp_ResetToFactoryNew ( void  )

References PDS_DeleteAll().

Referenced by APP_TaskHandler().

bool MiApp_ResyncConnection ( uint8_t  ConnectionIndex,
uint32_t  ChannelMap,
resyncConnection_callback_t  callback 
)
bool MiApp_RoleUpgradeNotification_Subscribe ( roleUpgrade_callback_t  callback)
uint8_t MiApp_SearchConnection ( uint8_t  ScanDuration,
uint32_t  ChannelMap,
SearchConnectionConf_callback_t  ConfCallback 
)

Referenced by APP_TaskHandler().

bool MiApp_SubscribeDataIndicationCallback ( PacketIndCallback_t  callback)

References callback, NULL, and pktRxcallback.

Referenced by appInit(), Initialize_Demo(), and main().

bool MiApp_SubscribeLinkFailureCallback ( LinkFailureCallback_t  callback)

References callback, linkFailureCallback, and NULL.

Referenced by appInit(), and Initialize_Demo().

bool MiApp_SubscribeManuSpecDataIndicationCallback ( PacketIndCallback_t  callback)

Referenced by otauInit().

bool MiApp_SubscribeReConnectionCallback ( ReconnectionCallback_t  callback)

References callback, NULL, and reconnectionCallback.

Referenced by wsndemo_init().

uint8_t MiApp_TransceiverPowerState ( uint8_t  Mode)
uint8_t Total_Connections ( void  )

References CONNECTION_SIZE, and i.

Referenced by run_p2p_demo(), and run_star_demo().

defaultParametersRomOrRam_t defaultParamsRomOrRam

Referenced by run_star_demo().

uint8_t end_nodes
bool lost_connection
API_UINT32_UNION meshOutgoingFrameCounter
uint8_t myConnectionIndex_in_PanCo

Referenced by frameParse(), and run_star_demo().

uint8_t MyindexinPC

Referenced by frameParse().