1280 lines
47 KiB
C
Executable File
1280 lines
47 KiB
C
Executable File
/****************************************************************************
|
|
|
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
|
|
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
|
be copied by any method or incorporated into another program without
|
|
the express written consent of Aerospace C.Power. This Information or any portion
|
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
|
liability for its use in any way and conveys no license or title under
|
|
any patent or copyright and makes no representation or warranty that this
|
|
Information is free from patent or copyright infringement.
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef IOT_PLC_MSG_API_H
|
|
#define IOT_PLC_MSG_API_H
|
|
|
|
#include "os_types_api.h"
|
|
#include "iot_utils_api.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
|
|
/* pack for the structures in the whole file */
|
|
#pragma pack(push) // save the pack status
|
|
#pragma pack(1) // 1 byte align
|
|
|
|
/* app request succeed */
|
|
#define IOT_PLC_SUCCESS (0x0)
|
|
/* app request succeed, but assigned value is not the same as registered.
|
|
* cvg layer allocated resource according to its status.
|
|
*/
|
|
#define IOT_PLC_SUCCESS_MODIFIED (0x1)
|
|
/* app request failed */
|
|
#define IOT_PLC_FAILED (0x2)
|
|
|
|
/* PLC device role. this definition must be same as PLC_DEV_ROLE_XXX */
|
|
#define IOT_PLC_DEV_ROLE_INVALID (0x0)
|
|
#define IOT_PLC_DEV_ROLE_STA (0x1)
|
|
#define IOT_PLC_DEV_ROLE_PCO (0x2)
|
|
#define IOT_PLC_DEV_ROLE_CCO (0x4)
|
|
|
|
/* PLC device type. this definition must be same as PLC_DEV_TYPE_XXX */
|
|
#define IOT_PLC_DEV_TYPE_METER_CONTROLLER 1
|
|
#define IOT_PLC_DEV_TYPE_CONCENTRATOR 2
|
|
#define IOT_PLC_DEV_TYPE_POWER_METER 3
|
|
#define IOT_PLC_DEV_TYPE_REPEATER 4
|
|
#define IOT_PLC_DEV_TYPE_COLLECTOR_2 5
|
|
#define IOT_PLC_DEV_TYPE_COLLECTOR_1 6
|
|
#define IOT_PLC_DEV_TYPE_POWER_METER_3P 7
|
|
|
|
#define IOT_PLC_DEV_TYPE_BSRM_MONITOR 0x7C
|
|
#define IOT_PLC_DEV_TYPE_BRK_MONITOR 0x7D
|
|
#define IOT_PLC_DEV_TYPE_TSFM_MONITOR 0x7E
|
|
#define IOT_PLC_DEV_TYPE_SWITCH_MONITOR 0x7F
|
|
|
|
/* iot customer device type start at 0x80 */
|
|
#define IOT_PLC_DEV_TYPE_GL_STA 0x80
|
|
#define IOT_PLC_DEV_TYPE_GL_OUTDOOR 0x81
|
|
#define IOT_PLC_DEV_TYPE_GL_INDOOR 0x82
|
|
#define IOT_PLC_DEV_TYPE_GL_LINECTRL 0x83
|
|
#define IOT_PLC_DEV_TYPE_GL_CONCETRATOR 0x84
|
|
#define IOT_PLC_DEV_TYPE_GL_MONITOR 0x85
|
|
#define IOT_PLC_DEV_TYPE_INVAL 0xFF
|
|
|
|
#define IOT_PLC_COMM_TYPE_HPLC 0
|
|
#define IOT_PLC_COMM_TYPE_DUAL_MODE 1
|
|
#define IOT_PLC_COMM_TYPE_RF 2
|
|
|
|
/** STA join rejected reason, same as defined in the spec */
|
|
#define IOT_PLC_REASON_STA_NOT_IN_WHITELIST 0x01
|
|
#define IOT_PLC_REASON_STA_IN_BLACKLIST 0x02
|
|
#define IOT_PLC_REASON_STA_EXCEED_MAX_COUNT 0x03
|
|
#define IOT_PLC_REASON_WHITELIST_NOT_SET 0x04
|
|
#define IOT_PLC_REASON_PROXY_EXCEED_MAX_COUNT 0x05
|
|
#define IOT_PLC_REASON_SUB_STA_EXCEED_MAX_COUNT 0x06
|
|
#define IOT_PLC_REASON_DUPLICATE_MAC 0x08
|
|
#define IOT_PLC_REASON_LEVEL_EXCEED_MAX_COUNT 0x09
|
|
#define IOT_PLC_REASON_SUB_STA_AS_PROXY 0x0B
|
|
#define IOT_PLC_REASON_LOOP_EXIST_IN_TOPO 0x0C
|
|
|
|
/* STA mac address type definition */
|
|
/* the meter addr is used as the MAC addr to join network */
|
|
#define IOT_PLC_MAC_ADDR_TYPE_METER (0)
|
|
/* the module addr is used as the MAC addr to join network */
|
|
#define IOT_PLC_MAC_ADDR_TYPE_MODULE (1)
|
|
/* the collector addr is used as the MAC addr to join network */
|
|
#define IOT_PLC_MAC_ADDR_TYPE_COLLECTOR (2)
|
|
|
|
/* whitelist and blacklist operation */
|
|
#define IOT_PLC_WL_DISABLE (0x0)
|
|
#define IOT_PLC_WL_ADD (0x1)
|
|
#define IOT_PLC_WL_DEL (0x2)
|
|
#define IOT_PLC_WL_ENABLE (0x3)
|
|
#define IOT_PLC_BL_DISABLE (0x4)
|
|
#define IOT_PLC_BL_ADD (0x5)
|
|
#define IOT_PLC_BL_DEL (0x6)
|
|
#define IOT_PLC_BL_ENABLE (0x7)
|
|
#define IOT_PLC_WL_NW_FMT_DONE (0x8)
|
|
#define IOT_PLC_WL_NW_FMT_DOING (0x9)
|
|
#define IOT_PLC_WL_DEL_ALL (0xA)
|
|
#define IOT_PLC_BL_DEL_ALL (0xB)
|
|
#define IOT_PLC_WL_ADD_PA (0xC)
|
|
#define IOT_PLC_WL_ADD_PB (0xD)
|
|
#define IOT_PLC_WL_ADD_PC (0xE)
|
|
|
|
/* common PLC message id definitions shared between CCO and STA device */
|
|
#define IOT_PLC_MSG_MSDU_SEND 0x01
|
|
#define IOT_PLC_MSG_MSDU_RECV 0x02
|
|
#define IOT_PLC_MSG_APP_REG_REQ 0x03
|
|
#define IOT_PLC_MSG_APP_REG_CONF 0x04
|
|
#define IOT_PLC_MSG_CONN_LESS_SEND 0x05
|
|
#define IOT_PLC_MSG_CONN_LESS_RECV 0x06
|
|
#define IOT_PLC_MSG_CTRL_PROTO_SEND 0x07
|
|
#define IOT_PLC_MSG_CTRL_PROTO_RECV 0x08
|
|
#define IOT_PLC_MSG_MSDU_SEND_BY_TEI 0x09
|
|
#define IOT_PLC_MSG_MSDU_CAPTURE_RECV 0x0A
|
|
|
|
#define IOT_PLC_MSG_NW_ID_QUERY 0x10
|
|
#define IOT_PLC_MSG_NW_ID_RPT 0x11
|
|
#define IOT_PLC_MSG_NW_NEIGHBOR_QUERY 0x12
|
|
#define IOT_PLC_MSG_NW_NEIGHBOR_RPT 0x13
|
|
#define IOT_PLC_MSG_NW_WL_QUERY 0x14
|
|
#define IOT_PLC_MSG_NW_WL_RPT 0x15
|
|
#define IOT_PLC_MSG_NW_WL_SET 0x16
|
|
#define IOT_PLC_MSG_NW_WL_SET_RPT 0x17
|
|
#define IOT_PLC_MSG_NW_BL_QUERY 0x18
|
|
#define IOT_PLC_MSG_NW_BL_RPT 0x19
|
|
#define IOT_PLC_MSG_NW_BL_SET 0x1A
|
|
#define IOT_PLC_MSG_NW_BL_SET_RPT 0x1B
|
|
#define IOT_PLC_MSG_FREQ_BAND_SET 0x1C
|
|
#define IOT_PLC_MSG_FREQ_BAND_SET_RPT 0x1D
|
|
#define IOT_PLC_MSG_DEV_INFO_QUERY 0x1E
|
|
#define IOT_PLC_MSG_DEV_INFO_RPT 0x1F
|
|
#define IOT_PLC_MSG_DEV_STATE_CHANGE_RPT 0x20
|
|
#define IOT_PLC_MSG_CFG_SET_REQ 0x21
|
|
#define IOT_PLC_MSG_CFG_SET_CONF 0x22
|
|
#define IOT_PLC_MSG_START_NW_FMT 0X23
|
|
#define IOT_PLC_MSG_STOP_NW_FMT 0X24
|
|
#define IOT_PLC_MSG_BAND_INFO_QUERY 0x25
|
|
#define IOT_PLC_MSG_BAND_INFO_QUERY_RPT 0x26
|
|
#define IOT_PLC_MSG_WDG_SET_REQ 0x27
|
|
#define IOT_PLC_MSG_WDG_SET_CONF 0x28
|
|
#define IOT_PLC_MSG_NEIGHBOR_DEV_QUERY 0x29
|
|
#define IOT_PLC_MSG_NEIGHBOR_DEV_RPT 0x2A
|
|
#define IOT_PLC_MSG_INVALID_MAC_RPT 0x2B
|
|
#define IOT_PLC_MSG_TEI_ADDR_INFO_QUERY 0x2C
|
|
#define IOT_PLC_MSG_TEI_ADDR_INFO_RPT 0x2D
|
|
#define IOT_PLC_MSG_TSFM_CHANGE 0x2E
|
|
#define IOT_PLC_MSG_TX_POWER_CAP_SET 0x2F
|
|
#define IOT_PLC_MSG_TX_POWER_CAP_SET_RPT 0x30
|
|
#define IOT_PLC_MSG_TX_POWER_CAP_QUERY 0x31
|
|
#define IOT_PLC_MSG_TX_POWER_CAP_QUERY_RPT 0x32
|
|
#define IOT_PLC_MSG_CTRL_PROTO_STATUS_RPT 0x33
|
|
#define IOT_PLC_MSG_PHASE_QUERY 0x34
|
|
#define IOT_PLC_MSG_PHASE_RPT 0x35
|
|
#define IOT_PLC_MSG_ZC_CLCT_REQ 0x36
|
|
#define IOT_PLC_MSG_ZC_CLCT_RPT 0x37
|
|
#define IOT_PLC_MSG_QUERYBAND_BITMAP 0x38
|
|
#define IOT_PLC_MSG_QUERYBAND_BITMAP_RPT 0x39
|
|
#define IOT_PLC_MSG_SET_RATE_ADAPT_MODE_REQ 0x40
|
|
#define IOT_PLC_MSG_SET_RATE_ADAPT_MODE_RPT 0x41
|
|
#define IOT_PLC_MSG_AUTH_DAK_SET_REQ 0x42
|
|
#define IOT_PLC_MSG_AUTH_DAK_SET_CONF 0x43
|
|
#define IOT_PLC_MSG_RF_SCAN_TBL_SET 0x44
|
|
#define IOT_PLC_MSG_RF_SCAN_TBL_SET_RPT 0x45
|
|
#define IOT_PLC_MSG_RF_CHANNEL_SET 0x46
|
|
#define IOT_PLC_MSG_RF_CHANNEL_SET_RPT 0x47
|
|
#define IOT_PLC_MSG_ALLOC_LID_RPT 0x48
|
|
#define IOT_PLC_MSG_NEIGHBOR_DEV_QUERY_BY_MAC 0x49
|
|
|
|
/* broadcast message to all app */
|
|
#define IOT_PLC_APP_ID_BCAST 47
|
|
|
|
/* packet send type */
|
|
#define IOT_PLC_MSG_TYPE_INVALID 0x00
|
|
/* unicast packet */
|
|
#define IOT_PLC_MSG_TYPE_UNICAST 0x01
|
|
/* unicast packet to pco */
|
|
#define IOT_PLC_MSG_TYPE_UNICAST_TO_PCO 0x02
|
|
/* proxy broadcast */
|
|
#define IOT_PLC_MSG_TYPE_BCAST 0x03
|
|
/* local broadcast */
|
|
#define IOT_PLC_MSG_TYPE_BCAST_1HOP 0x04
|
|
/* local broadcast even in power collapsed status */
|
|
#define IOT_PLC_MSG_TYPE_BCAST_1HOP_PW_OFF 0x05
|
|
/* whole network broadcast */
|
|
#define IOT_PLC_MSG_TYPE_BCAST_ALL 0x06
|
|
/* connectionless data transmission */
|
|
#define IOT_PLC_MSG_TYPE_CONN_LESS_DATA 0x07
|
|
/* connectionless command transmission */
|
|
#define IOT_PLC_MSG_TYPE_CONN_LESS_CMD 0x08
|
|
/* proxy broadcast to cco */
|
|
#define IOT_PLC_MSG_TYPE_BCAST_TO_CCO 0x09
|
|
/* connectionless data transmission, multihop boardcast */
|
|
#define IOT_PLC_MSG_TYPE_CONN_LESS_DATA_ALL 0x0A
|
|
/* connectionless data transmission, none head mode, local boardcast */
|
|
#define IOT_PLC_MSG_TYPE_NHM_DATA 0x0B
|
|
/* connectionless data transmission, none head mode, multihop boardcast */
|
|
#define IOT_PLC_MSG_TYPE_NHM_DATA_ALL 0x0C
|
|
|
|
/* packet ack type */
|
|
#define IOT_PLC_ACK_TYPE_NONE 0x00
|
|
/* require the worst neighbor to ack */
|
|
#define IOT_PLC_ACK_TYPE_WORST 0x01
|
|
|
|
/* define reason that the MAC address is invalid */
|
|
#define IOT_PLC_INVD_MAC_NOT_IN_WHITELIST 0x01
|
|
#define IOT_PLC_INVD_MAC_IN_BLACKLIST 0x02
|
|
|
|
/* define beacon data maximum length */
|
|
#define IOT_PLC_BEACON_DATA_MAX 14
|
|
|
|
/* phase definition */
|
|
#define IOT_PLC_PHASE_ALL 0
|
|
#define IOT_PLC_PHASE_A 1
|
|
#define IOT_PLC_PHASE_B 2
|
|
#define IOT_PLC_PHASE_C 3
|
|
#define IOT_PLC_PHASE_CNT 3
|
|
|
|
/* frequency band value: 1.953~11.96Mhz */
|
|
#define PLC_LIB_FREQ_BAND_0 0
|
|
/* frequency band value: 2.441~5.615Mhz */
|
|
#define PLC_LIB_FREQ_BAND_1 1
|
|
/* frequency band value: 0.781~2.930Mhz */
|
|
#define PLC_LIB_FREQ_BAND_2 2
|
|
/* frequency band value: 1.758~2.930Mhz */
|
|
#define PLC_LIB_FREQ_BAND_3 3
|
|
/* frequency band value: 5.6~11.96Mhz */
|
|
#define PLC_LIB_FREQ_BAND_4 4
|
|
/* frequency band value: 5.8~9Mhz */
|
|
#define PLC_LIB_FREQ_BAND_8 8
|
|
/* frequency band value: 4.9~24.4Mhz */
|
|
#define PLC_LIB_FREQ_BAND_9 9
|
|
/* frequency band value: 28.3~34.5Mhz */
|
|
#define PLC_LIB_FREQ_BAND_10 10
|
|
/* frequency band value: 4.9~12.2Mhz */
|
|
#define PLC_LIB_FREQ_BAND_11 11
|
|
/* frequency band value: 1.569~4.950Mhz */
|
|
#define PLC_LIB_FREQ_BAND_12 12
|
|
/* frequency band value for ce: 2.441~5.615Mhz */
|
|
#define PLC_LIB_FREQ_BAND_13 13
|
|
/* frequency band value for ce: 1.953~11.96Mhz */
|
|
#define PLC_LIB_FREQ_BAND_14 14
|
|
/* frequency band value for ce: 5.6~11.96Mhz */
|
|
#define PLC_LIB_FREQ_BAND_15 15
|
|
/* multi band: support band1 and band2 */
|
|
#define PLC_LIB_FREQ_BAND_MULTI_1_2 128
|
|
/* MAX BAND NUM */
|
|
#define PLC_LIB_FREQ_BAND_MAX PLC_LIB_FREQ_BAND_MULTI_1_2
|
|
|
|
/* default request id */
|
|
#define IOT_PLC_API_REQ_ID_DEFAULT (0)
|
|
|
|
/* state of transformer detect operation */
|
|
/* invalid state, no need to set state */
|
|
#define IOT_PLC_TSFM_STATE_INVALID (0)
|
|
/* tsfm detect unlock status */
|
|
#define IOT_PLC_TSFM_STATE_UNLOCK (1)
|
|
/* tsfm detect lock status */
|
|
#define IOT_PLC_TSFM_STATE_LOCK (2)
|
|
/* start tsfm detect */
|
|
#define IOT_PLC_TSFM_STATE_ON (3)
|
|
/* stop tsfm detect */
|
|
#define IOT_PLC_TSFM_STATE_OFF (4)
|
|
|
|
/* define the reason of controller proto disconnected */
|
|
/* if the controller tries to connect to other devices, the connection
|
|
* is actively disconnected.
|
|
*/
|
|
#define IOT_PLC_CTRL_PROTO_DISCONN_REASON_CORVED 1
|
|
/* controller protocol connect request timeout */
|
|
#define IOT_PLC_CTRL_PROTO_DISCONN_REASON_TIMEOUT 2
|
|
/* if the connected device is not active for a long time,
|
|
* it is determined to be offline.
|
|
*/
|
|
#define IOT_PLC_CTRL_PROTO_DISCONN_REASON_OFFLINE 3
|
|
|
|
/* define the reason of controller proto connected */
|
|
/* normal connection success */
|
|
#define IOT_PLC_CTRL_PROTO_CONNECT_REASON_NOR 1
|
|
/* connected again while local device is already connected */
|
|
#define IOT_PLC_CTRL_PROTO_CONNECT_REASON_RECON 2
|
|
|
|
/* define the connection state of the controller ptoro */
|
|
#define IOT_PLC_CTRL_PROTO_STATE_DISCONNECTED 1
|
|
#define IOT_PLC_CTRL_PROTO_STATE_CONNECTED 2
|
|
|
|
/* zc collect on default edge */
|
|
#define IOT_PLC_ZC_CT_DEFAULT_EDGE 0
|
|
/* zc collect on falling edge */
|
|
#define IOT_PLC_ZC_CT_FALLING_EDGE 1
|
|
/* zc collect on rising edge */
|
|
#define IOT_PLC_ZC_CT_RISING_EDGE 2
|
|
/* zc collect on falling and rising edge */
|
|
#define IOT_PLC_ZC_CT_ALL_EDGE 3
|
|
|
|
/* unit byte , max support 128 band */
|
|
#define IOT_PLC_BAND_BITMAP_SIZE 16
|
|
|
|
/* rate adaptation mode req parameter start */
|
|
/* set local node's rate adaptation mode */
|
|
#define IOT_PLC_RATE_ADAPT_NODE_LOCAL 1
|
|
/* set network node's rate adaptation mode. applicable to CCO only */
|
|
#define IOT_PLC_RATE_ADAPT_NODE_NETWORK 2
|
|
/* rate adaptation based on packet size */
|
|
#define IOT_PLC_RATE_ADAPT_MODE_FIX 1
|
|
/* rate adaptation based on network communication quality */
|
|
#define IOT_PLC_RATE_ADAPT_MODE_AUTO 2
|
|
|
|
/* rate adaptation fixed low rate */
|
|
#define IOT_PLC_RATE_ADAPT_RATE_LOW 1
|
|
/* rate adaptation fixed medium rate */
|
|
#define IOT_PLC_RATE_ADAPT_RATE_MEDIUM 2
|
|
/* rate adaptation fixed high rate */
|
|
#define IOT_PLC_RATE_ADAPT_RATE_HIGH 3
|
|
/* rate adaptation mode req parameter end */
|
|
|
|
/* sta device leave network due to unknown reasons */
|
|
#define IOT_PLC_LEAVE_REASON_UNKNOWN 0
|
|
/* sta device leave network due to current preferred network SN changed */
|
|
#define IOT_PLC_LEAVE_REASON_SN_CHG 1
|
|
/* sta device leave network due to no beacon received */
|
|
#define IOT_PLC_LEAVE_REASON_NO_BC_RX 2
|
|
/* sta device leave network due to tf_sr is 0 */
|
|
#define IOT_PLC_LEAVE_REASON_TF_0 3
|
|
/* sta device leave network due to level exceeded */
|
|
#define IOT_PLC_LEAVE_REASON_LEVEL 4
|
|
/* sta device leave network due to receive leave indication mme from CCO */
|
|
#define IOT_PLC_LEAVE_REASON_LEAVE_IND 5
|
|
|
|
/* define the reason STA was kicked out by CCO */
|
|
#define IOT_PLC_KICK_REASON_CCO_IND (0x00)
|
|
#define IOT_PLC_KICK_REASON_EXCEED_MAX_LEVEL (0x01)
|
|
#define IOT_PLC_KICK_REASON_STA_NOT_IN_WLIST (0x02)
|
|
#define IOT_PLC_KICK_REASON_STA_IN_BLIST (0x03)
|
|
#define IOT_PLC_KICK_REASON_STA_NOT_IN_NETWORK (0x04)
|
|
|
|
/* joining state, sta is applying to join the network */
|
|
#define IOT_PLC_STA_STATE_JOINING (0x00)
|
|
/* online state, sta has successfully joined the network */
|
|
#define IOT_PLC_STA_STATE_ONLINE (0x01)
|
|
/* offline state, sta has left the network */
|
|
#define IOT_PLC_STA_STATE_OFFLINE (0x02)
|
|
|
|
/* authorized DAK operation */
|
|
#define IOT_PLC_AUTH_DAK_DISABLE (0x0)
|
|
#define IOT_PLC_AUTH_DAK_ENABLE (0x1)
|
|
#define IOT_PLC_AUTH_DAK_ADD (0x2)
|
|
#define IOT_PLC_AUTH_DAK_DEL (0x3)
|
|
#define IOT_PLC_AUTH_DAK_DEL_ALL (0x4)
|
|
|
|
/* define rf options */
|
|
#define IOT_PLC_RF_OPTION_INVALID (0)
|
|
#define IOT_PLC_RF_OPTION_1 (1)
|
|
#define IOT_PLC_RF_OPTION_2 (2)
|
|
#define IOT_PLC_RF_OPTION_3 (3)
|
|
#define IOT_PLC_RF_OPTION_MAX IOT_PLC_RF_OPTION_3
|
|
|
|
/* invalid channel id */
|
|
#define IOT_PLC_CHANNEL_ID_INVALID (0)
|
|
/* option1 channel id max */
|
|
#define IOT_PLC_OPTION1_CHANNEL_ID_MAX (40)
|
|
/* option2 channel id max */
|
|
#define IOT_PLC_OPTION2_CHANNEL_ID_MAX (80)
|
|
/* option3 channel id max */
|
|
#define IOT_PLC_OPTION3_CHANNEL_ID_MAX (201)
|
|
|
|
/* define scan option channel table max */
|
|
#define IOT_PLC_RF_SCAN_TBL_MAX (104)
|
|
|
|
/* define tx power range */
|
|
#define IOT_PLC_HPLC_TX_POWER_MAX_DBUV (137)
|
|
#define IOT_PLC_HPLC_TX_POWER_MIN_DBUV (95)
|
|
#define IOT_PLC_RF_TX_POWER_MAX_DBM (20)
|
|
#define IOT_PLC_RF_TX_POWER_MIN_DBM (-35)
|
|
#define IOT_PLC_RF_TX_POWER_INVALID (-128)
|
|
|
|
/* define tx link type */
|
|
#define IOT_PLC_TX_LINK_TYPE_HPLC (0)
|
|
#define IOT_PLC_TX_LINK_TYPE_RF (1)
|
|
#define IOT_PLC_TX_LINK_TYPE_DUAL (2)
|
|
#define IOT_PLC_TX_LINK_TYPE_MAX IOT_PLC_TX_LINK_TYPE_DUAL
|
|
|
|
/* define force link type */
|
|
#define IOT_PLC_FORCE_LINK_MIX (0)
|
|
#define IOT_PLC_FORCE_LINK_HPLC (1)
|
|
#define IOT_PLC_FORCE_LINK_RF (2)
|
|
|
|
|
|
//TODO: make sure strct is 4 bytes aligned
|
|
/** plc message header */
|
|
typedef struct _iot_plc_msg_header {
|
|
/** application id */
|
|
uint8_t app_id;
|
|
/** msg id */
|
|
uint8_t msg_id;
|
|
/** request id */
|
|
uint8_t req_id;
|
|
/** reserved for future */
|
|
uint8_t reserved;
|
|
} iot_plc_msg_header_t;
|
|
|
|
/**
|
|
* IOT_PLC_MSG_MSDU_SEND format
|
|
* IOT_PLC_MSG_CONN_LESS_SEND format
|
|
* IOT_PLC_MSG_CTRL_PROTO_SEND format
|
|
* IOT_PLC_MSG_MSDU_SEND_BY_TEI format
|
|
*/
|
|
typedef struct _iot_plc_msdu_send {
|
|
/** type of the message. see IOT_PLC_MSG_TYPE_XXX */
|
|
uint8_t msg_type :4,
|
|
/** type of the ack required for this packet from the listener. see
|
|
* IOT_PLC_ACK_TYPE_XXX this flag is only available for broadcast packet.
|
|
*/
|
|
ack_type :1,
|
|
/* flag to mark if rx need to be switched to this ppm.
|
|
* set 0 if not required.
|
|
*/
|
|
is_only_tx :1,
|
|
/** tx link type, see IOT_PLC_TX_LINK_TYPE_XX.
|
|
* this parameter is only available for IOT_PLC_MSG_TYPE_CONN_LESS_XXX
|
|
*/
|
|
link_type :2;
|
|
/* the ppm value fixed */
|
|
int8_t fix_ppm;
|
|
/** flag to mark if the message cannot be encrypted */
|
|
uint16_t no_encrypt :1,
|
|
/** retry count */
|
|
retry_cnt :3,
|
|
/** payload length */
|
|
len :12;
|
|
/** final destion mac address. for IOT_PLC_MSG_MSDU_SEND_BY_TEI case,
|
|
* dst[0] is the lowest 8 bits and dst[1] is the highest 8 bits of the tei.
|
|
*/
|
|
uint8_t dst[IOT_MAC_ADDR_LEN];
|
|
/** original mac address. */
|
|
uint8_t src[IOT_MAC_ADDR_LEN];
|
|
/** msdu type */
|
|
uint8_t type;
|
|
/** link id */
|
|
uint8_t lid;
|
|
/** msdu data payload */
|
|
uint8_t data[0];
|
|
} iot_plc_msdu_send_t;
|
|
|
|
/** IOT_PLC_MSG_MSDU_RECV format */
|
|
typedef struct _iot_plc_msdu_recv {
|
|
/** payload length */
|
|
uint16_t len :12,
|
|
/* flag to mark if link type is rf or not.
|
|
* 1 means rf. 0 means plc.
|
|
*/
|
|
is_rf :1,
|
|
/** reserved for future */
|
|
reserved :3;
|
|
/** final destion mac address */
|
|
uint8_t dst[IOT_MAC_ADDR_LEN];
|
|
/** original source mac address */
|
|
uint8_t src[IOT_MAC_ADDR_LEN];
|
|
/** SNR of this mpdu */
|
|
int8_t snr;
|
|
/** RSSI of this mpdu, unit is 1dbm, invald rssi value is -128 */
|
|
int8_t rssi;
|
|
/** tx successful ratio to pco, valid for cco role */
|
|
uint8_t ul_tf_sr;
|
|
/** rx successful ratio from pco, valid for cco role */
|
|
uint8_t dl_tf_sr;
|
|
/** msdu data payload */
|
|
uint8_t data[0];
|
|
} iot_plc_msdu_recv_t;
|
|
|
|
/** IOT_PLC_MSG_APP_REG_REQ format */
|
|
typedef struct _iot_plc_app_reg_req {
|
|
/** requested msdu type */
|
|
uint8_t type;
|
|
/** requested default priority for the msdu */
|
|
uint8_t prio;
|
|
} iot_plc_app_reg_req_t;
|
|
|
|
/** IOT_PLC_MSG_APP_REG_CONF format */
|
|
typedef struct _iot_plc_app_reg_conf {
|
|
/** result of the request */
|
|
uint8_t result;
|
|
/** approved msdu type */
|
|
uint8_t type;
|
|
/** approved default priority for the msdu */
|
|
uint8_t prio;
|
|
/** device mac address */
|
|
uint8_t dev_mac[IOT_MAC_ADDR_LEN];
|
|
} iot_plc_app_reg_conf_t;
|
|
|
|
/** IOT_PLC_MSG_DEV_INFO_RPT format */
|
|
typedef struct _iot_plc_dev_info_rpt {
|
|
/** role of local device. see IOT_PLC_DEV_ROLE_XXX */
|
|
uint8_t dev_role;
|
|
/** type of local device. see IOT_PLC_DEV_TYPE_XXX */
|
|
uint8_t dev_type;
|
|
/** if lower layer is ready to serve app.
|
|
* if is_ready is 0, app shall not call api
|
|
* except iot_plc_query_dev_info.
|
|
*/
|
|
uint8_t is_ready : 1,
|
|
/* non 0 means broadcast packet sent in 3phase simultaneously, 0 means
|
|
* broadcast packet sent in 3phase in turn.
|
|
*/
|
|
tx_3phase_flag : 1,
|
|
/** force link type, see IOT_PLC_FORCE_LINK_XXX */
|
|
force_link : 2,
|
|
/* reserve for future */
|
|
rsvd : 4;
|
|
/** software reset count */
|
|
uint16_t hw_reset_cnt;
|
|
/** hardware reset connt */
|
|
uint16_t sw_reset_cnt;
|
|
/** mac address of local device */
|
|
uint8_t local_mac[IOT_MAC_ADDR_LEN];
|
|
/** mac address of CCo */
|
|
uint8_t cco_mac[IOT_MAC_ADDR_LEN];
|
|
/** zero cross ntb collect type */
|
|
uint8_t collect_type;
|
|
/**
|
|
* reason for leaving the network last time. see IOT_PLC_LEAVE_REASON_XXX.
|
|
*/
|
|
uint8_t leave_net_reason;
|
|
/** hplc rx snr from the network to local device */
|
|
int8_t snr;
|
|
/** connless ppm, unit: 1 ppm, it is always 0 for cco */
|
|
int16_t connless_ppm;
|
|
/** network ppm, unit: 1 ppm. if is_ready = 0, this value is invalid,
|
|
* and it is always 0 for cco.
|
|
*/
|
|
int16_t nw_ppm;
|
|
} iot_plc_dev_info_rpt_t;
|
|
|
|
/** IOT_PLC_MSG_DEV_STATE_CHANGE_RPT format */
|
|
typedef struct _iot_plc_dev_state_change_rpt {
|
|
/** network sn */
|
|
uint8_t nework_sn;
|
|
/** if lower layer is ready to serve app.
|
|
* if is_ready is 0, app shall not call api
|
|
* except iot_plc_query_dev_info.
|
|
*/
|
|
uint8_t is_ready :1,
|
|
/** flag to mark if cert test command ever detected */
|
|
cert_test_detected :1,
|
|
/**
|
|
* for CCO role case, flag to mark if whole network formation done.
|
|
* for STA role case, flag to mark if local device network formation done.
|
|
*/
|
|
nw_fmt_done :1,
|
|
/**
|
|
* for CCO role case, flag to mark if whole network route learning done.
|
|
* for STA role case, flag to mark if local device route learning done.
|
|
*/
|
|
route_learn_done :1,
|
|
/* only for CCO role case, flag to mark if cco device test is detected */
|
|
cco_test_detected :1,
|
|
/** role of local device */
|
|
dev_role :3;
|
|
/** tei of the device */
|
|
uint16_t dev_tei :12,
|
|
/** flag to mark if the joined cco is from the same vendor as us for sta */
|
|
same_vendor :1,
|
|
/**
|
|
* only for STA role case, it stands for the sta network state, see
|
|
* IOT_PLC_STA_STATE_XXX
|
|
*/
|
|
sta_net_state :2,
|
|
/** reserved */
|
|
rsvd :1;
|
|
/** pco tei of the device */
|
|
uint16_t pco_tei :12,
|
|
/** force link type, see IOT_PLC_FORCE_LINK_XXX */
|
|
force_link :2,
|
|
/** flag to mark if production test is detected */
|
|
pt_detected :1,
|
|
/** reserved for future */
|
|
rsvd2 :1;
|
|
/** network route period */
|
|
uint16_t rt_period;
|
|
/** mac address of local device */
|
|
uint8_t local_mac[IOT_MAC_ADDR_LEN];
|
|
/** mac address of CCo */
|
|
uint8_t cco_mac[IOT_MAC_ADDR_LEN];
|
|
/** local nid */
|
|
uint32_t nid;
|
|
/**
|
|
* reason for leaving the network last time. see IOT_PLC_LEAVE_REASON_XXX.
|
|
*/
|
|
uint8_t leave_net_reason :4,
|
|
/** level of the peer */
|
|
level :4;
|
|
} iot_plc_dev_state_change_rpt_t;
|
|
|
|
/** IOT_PLC_MSG_NW_ID_RPT format */
|
|
typedef struct _iot_plc_nid_rpt {
|
|
/** nid of current network.
|
|
* nid takes 3 byte according to SG spec
|
|
*/
|
|
uint32_t nid;
|
|
} iot_plc_nid_rpt_t;
|
|
|
|
/** neighbour network information */
|
|
typedef struct _iot_plc_nb_nw_info {
|
|
/** nid of the neighbour network */
|
|
uint32_t nid :24,
|
|
/** flag indicate if neighbour network is single-pass to local network
|
|
* 1 means single-pass. 0 means double-pass.
|
|
*/
|
|
sp_flag :1,
|
|
/** flag to mark if beacon data is available */
|
|
bc_data_flag :1,
|
|
/** flag to mark if cco address is available */
|
|
addr_flag :1,
|
|
/** reserved for future */
|
|
rvsd :5;
|
|
/** bandwidth taken by neighbour network in millisecond */
|
|
uint32_t bandwidth;
|
|
/** cco mac address */
|
|
uint8_t addr[IOT_MAC_ADDR_LEN];
|
|
/** each phase snr of the network */
|
|
int8_t snr[IOT_PLC_PHASE_CNT];
|
|
/** beacon data info */
|
|
uint8_t bc_data[IOT_PLC_BEACON_DATA_MAX];
|
|
} iot_plc_nb_nw_info_t;
|
|
|
|
/** IOT_PLC_MSG_NW_NEIGHBOR_RPT format */
|
|
typedef struct _iot_plc_nb_nw_rpt {
|
|
/** total number of neighbour network */
|
|
uint16_t count;
|
|
/** neighbour network info entries */
|
|
iot_plc_nb_nw_info_t nb_info[0];
|
|
} iot_plc_nb_nw_rpt_t;
|
|
|
|
/** IOT_PLC_MSG_NW_WL_QUERY format */
|
|
typedef struct _iot_plc_wl_query {
|
|
/** start entry index in whitelist */
|
|
uint16_t start;
|
|
/** maximum number of whitelist entry to return for this request */
|
|
uint16_t count;
|
|
} iot_plc_wl_query_t;
|
|
|
|
/** IOT_PLC_MSG_NW_BL_QUERY format */
|
|
typedef struct _iot_plc_bl_query {
|
|
/** start entry index in blacklist */
|
|
uint16_t start;
|
|
/** maximum number of blacklist entry to return for this request */
|
|
uint16_t count;
|
|
} iot_plc_bl_query_t;
|
|
|
|
/** IOT_PLC_MSG_NW_WL_RPT format */
|
|
typedef struct _iot_plc_wl_rpt {
|
|
/** total count of whitelist entries */
|
|
uint16_t total_count;
|
|
/** count of entries contained in this reply packet */
|
|
uint16_t count;
|
|
/** report done */
|
|
uint16_t done : 1,
|
|
/** reserved for future */
|
|
reserved : 15;
|
|
/** whitelist entries */
|
|
uint8_t mac_addr[0][IOT_MAC_ADDR_LEN];
|
|
} iot_plc_wl_rpt_t;
|
|
|
|
/** IOT_PLC_MSG_NW_BL_RPT format */
|
|
typedef struct _iot_plc_bl_rpt {
|
|
/** total count of blacklist entries */
|
|
uint16_t total_count;
|
|
/** count of entries contained in this reply packet */
|
|
uint16_t count;
|
|
/** report done */
|
|
uint16_t done : 1,
|
|
/** reserved for future */
|
|
reserved : 15;
|
|
/** blacklist entries */
|
|
uint8_t mac_addr[0][IOT_MAC_ADDR_LEN];
|
|
} iot_plc_bl_rpt_t;
|
|
|
|
/** IOT_PLC_MSG_NW_WL_SET format */
|
|
typedef struct _iot_plc_wl_set_req {
|
|
/** action to perform: DISABLE / ADD / DELETE whitelist entries */
|
|
uint8_t action;
|
|
/** count of whitelist entries to operate on */
|
|
uint16_t count;
|
|
/** whitelist entries */
|
|
uint8_t mac_addr[0][IOT_MAC_ADDR_LEN];
|
|
} iot_plc_wl_set_req_t;
|
|
|
|
/** IOT_PLC_MSG_NW_BL_SET format */
|
|
typedef struct _iot_plc_bl_set_req {
|
|
/** action to perform: DISABLE / ADD / DELETE blacklist entries */
|
|
uint8_t action;
|
|
/** count of blacklist entries to operate on */
|
|
uint16_t count;
|
|
/** blacklist entries */
|
|
uint8_t mac_addr[0][IOT_MAC_ADDR_LEN];
|
|
} iot_plc_bl_set_req_t;
|
|
|
|
/** IOT_PLC_MSG_NW_ID_SET format */
|
|
typedef struct _iot_plc_wl_set_rpt {
|
|
/** result of the whitelist set request */
|
|
uint8_t result;
|
|
/** error number */
|
|
uint8_t err_no;
|
|
} iot_plc_wl_set_rpt_t;
|
|
|
|
/** IOT_PLC_MSG_NW_BL_SET_RPT format */
|
|
typedef struct _iot_plc_bl_set_rpt {
|
|
/** result of the blacklist set request */
|
|
uint8_t result;
|
|
/** error number */
|
|
uint8_t err_no;
|
|
} iot_plc_bl_set_rpt_t;
|
|
|
|
/** IOT_PLC_MSG_CFG_SET_REQ format */
|
|
typedef struct _iot_plc_cfg_set_req {
|
|
/** flag to mark if pco_snr_rpt config available */
|
|
uint32_t pco_snr_rpt_valid :1,
|
|
/** flag to mark if addr config available */
|
|
addr_valid :1,
|
|
/** flag to mark if device type config available */
|
|
dev_type_valid :1,
|
|
/** flag to mark if simple pair passcode is available */
|
|
passcode_valid :1,
|
|
/** mac addr type. see IOT_PLC_MAC_ADDR_TYPE_METER_XX */
|
|
addr_type :2,
|
|
/** flag to mark if power config available */
|
|
pw_collapsed_valid :1,
|
|
/** flag to mark if the join check is available */
|
|
join_check_valid :1,
|
|
/** flag to mark if rtc_tx config available */
|
|
rtc_tx_valid :1,
|
|
/** flag to mark if force link communication is available */
|
|
force_link_valid :1,
|
|
/** force link type, see IOT_PLC_FORCE_LINK_XXX */
|
|
force_link :2,
|
|
/** reserved for future */
|
|
rsvd1 :20;
|
|
/** local mac address to be used */
|
|
uint8_t addr[IOT_MAC_ADDR_LEN];
|
|
/** local device type. see IOT_PLC_DEV_TYPE_XXX */
|
|
uint8_t dev_type;
|
|
/** set to 1 if reset lower layer to apply the cfg immediately */
|
|
uint8_t reset :1,
|
|
/** set to 1 to enable pco snr report */
|
|
pco_snr_rpt :1,
|
|
/** set to 1 if allow all APP data TX in power collapsed status */
|
|
ignore_pw_collapsed :1,
|
|
/** flag to mark if enable join check, 1 - enable, 0 - disable */
|
|
join_check :1,
|
|
/** set to 1 if allow to send rtc beacon entry */
|
|
rtc_tx :1,
|
|
/** reserved for future */
|
|
rsvd2 :3;
|
|
/** simple pair passcode value. Only same passcode CCO and STA can be
|
|
* associated.
|
|
*/
|
|
uint16_t passcode;
|
|
} iot_plc_cfg_set_req_t;
|
|
|
|
/** IOT_PLC_MSG_CFG_SET_CONF format */
|
|
typedef struct _iot_plc_cfg_set_conf {
|
|
/** result of the request */
|
|
uint8_t result;
|
|
/** error number */
|
|
uint8_t err_no;
|
|
} iot_plc_cfg_set_conf_t;
|
|
|
|
/** IOT_PLC_MSG_START_NW_FMT format */
|
|
typedef struct _iot_plc_start_nw_fmt {
|
|
/** flag to mark if force start required. if plc network formation already
|
|
* started, set this flag will restart the whole process from the very
|
|
* beginning.
|
|
*/
|
|
uint8_t force;
|
|
} iot_plc_start_nw_fmt_t;
|
|
|
|
/** IOT_PLC_MSG_BAND_INFO_QUERY_RPT format */
|
|
typedef struct _iot_plc_band_info_query_rpt {
|
|
/** frequency band. see PLC_LIB_FREQ_BAND_XXX */
|
|
uint8_t freq_band;
|
|
/** noise floor of current band. unit is 1dbm */
|
|
uint8_t noise_floor;
|
|
/** hplc tx power cap. 0 means no tx power cap. unit is 1 dbuv */
|
|
uint8_t power_cap;
|
|
/** rf option, see IOT_PLC_RF_OPTION_XXX */
|
|
uint8_t option :2,
|
|
/** rf channel coordination enable, 0 - disable, 1 - enable */
|
|
cod_enable :1,
|
|
/** reserved for future */
|
|
rsvd :5;
|
|
/** rf channel, see IOT_PLC_CHANNEL_ID_XXX */
|
|
uint8_t channel;
|
|
/** rf tx power cap. unit is 1 dbm, see RF_TX_POWER_XXX */
|
|
int8_t rf_power_cap;
|
|
} iot_plc_freq_band_info_query_rpt_t;
|
|
|
|
/** IOT_PLC_MSG_WDG_SET_REQ format */
|
|
typedef struct _iot_plc_wdg_set_req {
|
|
/** 0 - disable plc watch dog
|
|
* otherwise - eanble plc watch dog
|
|
*/
|
|
uint8_t enable;
|
|
/* watch dog bite interval, unit is 1 min, less than 30 minutes is
|
|
* disallowed.
|
|
*/
|
|
uint16_t interval;
|
|
} iot_plc_wdg_set_req_t;
|
|
|
|
/** IOT_PLC_MSG_WDG_SET_CONF format */
|
|
typedef struct _iot_plc_wdg_set_conf {
|
|
/** current status of the plc watch dog feature.
|
|
* 0 - plc watch dog disabled
|
|
* otherwise - plc watch dog enabled
|
|
*/
|
|
uint8_t status;
|
|
} iot_plc_wdg_set_conf_t;
|
|
|
|
/** IOT_PLC_MSG_FREQ_BAND_SET format */
|
|
typedef struct _iot_plc_freq_band_set {
|
|
/** frequency band */
|
|
uint8_t freq_band;
|
|
} iot_plc_freq_band_set_t;
|
|
|
|
/** IOT_PLC_MSG_FREQ_BAND_SET_RPT format */
|
|
typedef struct _iot_plc_freq_band_set_rpt {
|
|
/** result of the freq band set request */
|
|
uint8_t result;
|
|
/** error number */
|
|
uint8_t err_no;
|
|
} iot_plc_freq_band_set_rpt_t;
|
|
|
|
/** IOT_PLC_MSG_RF_CHANNEL_SET format */
|
|
typedef struct _iot_plc_set_rf_channel {
|
|
/** rf option, see IOT_PLC_RF_OPTION_XXX */
|
|
uint8_t option :2,
|
|
/** rf channel coordination enable, 0 - disable, 1 - enable */
|
|
cod_enable :1,
|
|
/** reserved for future */
|
|
rsvd :5;
|
|
/** rf channel, see IOT_PLC_CHANNEL_ID_XXX */
|
|
uint8_t channel;
|
|
} iot_plc_set_rf_channel_t;
|
|
|
|
/** IOT_PLC_MSG_RF_CHANNEL_SET_RPT format */
|
|
typedef struct _iot_plc_set_rf_channel_rpt {
|
|
/** result of rf channel set request */
|
|
uint8_t result;
|
|
/** error number */
|
|
uint8_t err_no;
|
|
} iot_plc_set_rf_channel_rpt_t;
|
|
|
|
/** scan option channel */
|
|
typedef struct _iot_plc_rf_scan {
|
|
/** scan option id */
|
|
uint8_t option_id;
|
|
/** scan channel id */
|
|
uint8_t channel_id;
|
|
/* option and channel min time, uint 500ms */
|
|
uint8_t min_time;
|
|
/** option and channel dwell time, uint 500ms */
|
|
uint8_t dwell_time;
|
|
} iot_plc_rf_scan_t;
|
|
|
|
/** IOT_PLC_MSG_RF_SCAN_TBL_SET format */
|
|
typedef struct _iot_plc_set_rf_scan_tbl {
|
|
/** number of valid rf in rf scan table */
|
|
uint8_t rf_cnt;
|
|
/** rf scan table */
|
|
iot_plc_rf_scan_t rf_scan_tbl[IOT_PLC_RF_SCAN_TBL_MAX];
|
|
} iot_plc_set_rf_scan_tbl_t;
|
|
|
|
/** IOT_PLC_MSG_RF_SCAN_TBL_SET_RPT format */
|
|
typedef struct _iot_plc_set_rf_scan_tbl_rpt {
|
|
/** result of rf scan table set request */
|
|
uint8_t result;
|
|
/** error number */
|
|
uint8_t err_no;
|
|
} iot_plc_set_rf_scan_tbl_rpt_t;
|
|
|
|
/** IOT_PLC_MSG_NEIGHBOR_DEV_QUERY_BY_MAC format */
|
|
typedef struct _iot_plc_neighbor_dev_query_mac {
|
|
/** count of nodes to be queried */
|
|
uint8_t node_cnt;
|
|
/** the node mac array to be queried, big endian */
|
|
uint8_t mac[0][IOT_MAC_ADDR_LEN];
|
|
} iot_plc_neighbor_dev_query_mac_t;
|
|
|
|
/** IOT_PLC_MSG_NEIGHBOR_DEV_QUERY format */
|
|
typedef struct _iot_plc_neighbor_dev_query {
|
|
/** start tei of the query */
|
|
uint16_t start;
|
|
/** requested number of valid entries */
|
|
uint16_t count;
|
|
/** start type, see IOT_PLC_QUERY_TOPO_START_AS_XXX */
|
|
uint8_t start_type;
|
|
} iot_plc_neighbor_dev_query_t;
|
|
|
|
/** plc neighbor device info format */
|
|
typedef struct _iot_plc_neighbor_dev_info {
|
|
/** tei of the neighbor device */
|
|
uint32_t tei :12,
|
|
/** tei of the neighbor device proxy */
|
|
proxy_tei :12,
|
|
/** level of the station */
|
|
level :4,
|
|
/** role of the station */
|
|
role :4;
|
|
/** hplc uplink traffic success ratio */
|
|
uint8_t ul_tf_sr;
|
|
/** hplc downlink traffic success ratio */
|
|
uint8_t dl_tf_sr;
|
|
/** rf uplink traffic success ratio */
|
|
uint8_t rf_ul_tf_sr;
|
|
/** rf downlink traffic success ratio */
|
|
uint8_t rf_dl_tf_sr;
|
|
/** physical phase of the station */
|
|
uint16_t phase1 :2,
|
|
phase2 :2,
|
|
phase3 :2,
|
|
/** flag to mark if device is direct sub sta of local device */
|
|
d_sub_sta :1,
|
|
/** flag to mark if device proxy of local device */
|
|
proxy :1,
|
|
/** flag to mark if devie address is valid */
|
|
addr_valid :1,
|
|
/** reserved for future */
|
|
reserved :5;
|
|
/** hplc rx snr from the node to local device */
|
|
int8_t snr;
|
|
/** rf rx snr from the node to local device */
|
|
int8_t rf_snr;
|
|
/** attenuation from the node to local device */
|
|
int8_t attenuation;
|
|
/** mac address of the station */
|
|
uint8_t addr[IOT_MAC_ADDR_LEN];
|
|
} iot_plc_neighbor_dev_info_t;
|
|
|
|
/** IOT_PLC_MSG_NEIGHBOR_DEV_RPT format */
|
|
typedef struct _iot_plc_neighbor_dev_rpt {
|
|
/** total number of valid tei */
|
|
uint16_t total_cnt;
|
|
/** total direct sub sta of local device */
|
|
uint16_t total_d_sub_sta_cnt;
|
|
/** number of valid tei in current message */
|
|
uint16_t cnt;
|
|
/** report done */
|
|
uint16_t done: 1,
|
|
/** reserved for future */
|
|
reserved: 15;
|
|
/** node info of each valid tei */
|
|
iot_plc_neighbor_dev_info_t node[0];
|
|
} iot_plc_neighbor_dev_rpt_t;
|
|
|
|
/** IOT_PLC_MSG_INVALID_MAC_RPT format */
|
|
typedef struct _iot_plc_invalid_mac_rpt {
|
|
/** the reason that the MAC address is invalid, see IOT_PLC_INVD_MAC_XXX */
|
|
uint8_t reason;
|
|
/* network id */
|
|
uint32_t nid;
|
|
/** pointer to invalid mac addr */
|
|
uint8_t mac[IOT_MAC_ADDR_LEN];
|
|
/** pointer to cco mac addr */
|
|
uint8_t cco_mac[IOT_MAC_ADDR_LEN];
|
|
} iot_plc_invalid_mac_rpt_t;
|
|
|
|
/** IOT_PLC_MSG_TEI_ADDR_INFO_QUERY format
|
|
* query tei address information
|
|
*/
|
|
typedef struct _iot_plc_query_tei_addr_info {
|
|
/** start tei */
|
|
uint16_t start_tei;
|
|
/** start query position. bit0, bit1, bit2, ... */
|
|
uint16_t offset;
|
|
/** bm len */
|
|
uint8_t bm_len;
|
|
/** tei bitmap, bit0 represent start tei,
|
|
* bit1 represent start tei + 1 and so on.
|
|
*/
|
|
uint8_t bm[0];
|
|
} iot_plc_query_tei_addr_info_t;
|
|
|
|
/** tei address information */
|
|
typedef struct _iot_plc_tei_addr_info {
|
|
/** tei */
|
|
uint16_t tei;
|
|
/** mac address */
|
|
uint8_t addr[IOT_MAC_ADDR_LEN];
|
|
} iot_plc_tei_addr_info_t;
|
|
|
|
/** IOT_PLC_MSG_TEI_ADDR_INFO_RPT format
|
|
* report tei address information
|
|
*/
|
|
typedef struct _iot_plc_rpt_tei_addr_info {
|
|
/** flag to mark if all tei in the bitmap have been handled */
|
|
uint8_t done;
|
|
/** tei and addr count */
|
|
uint8_t count;
|
|
/** tei and addr information */
|
|
iot_plc_tei_addr_info_t info[0];
|
|
} iot_plc_rpt_tei_addr_info_t;
|
|
|
|
/** IOT_PLC_MSG_TX_POWER_CAP_SET format */
|
|
typedef struct _iot_plc_tx_power_cap_set {
|
|
/** hplc tx power. unit is 1 dbuv */
|
|
uint8_t hplc_power;
|
|
/** rf tx power. unit is 1 dbm */
|
|
int8_t rf_power;
|
|
/** flag to mark if hplc power config is valid */
|
|
uint8_t hplc_valid :1,
|
|
/** flag to mark if rf power config is valid */
|
|
rf_valid :1,
|
|
/** reserved for future */
|
|
rsvd :6;
|
|
} iot_plc_tx_power_cap_set_t;
|
|
|
|
/** IOT_PLC_MSG_TX_POWER_CAP_SET_RPT format */
|
|
typedef struct _iot_plc_tx_power_cap_set_rpt {
|
|
/** result of the tx power cap set request */
|
|
uint8_t result;
|
|
/** error number */
|
|
uint8_t err_no;
|
|
} iot_plc_tx_power_cap_set_rpt_t;
|
|
|
|
/** IOT_PLC_MSG_TX_POWER_CAP_QUERY_RPT format */
|
|
typedef struct _iot_plc_tx_power_cap_query_rpt {
|
|
/** tx power cap. unit is 1 dbm */
|
|
uint8_t power;
|
|
} iot_plc_tx_power_cap_query_rpt_t;
|
|
|
|
/** IOT_PLC_MSG_TSFM_CHANGE format */
|
|
typedef struct _iot_plc_tsfm_change_req {
|
|
/** flag to mark if transformer mac address valid */
|
|
uint8_t tfsm_addr_valid :1,
|
|
/** flag to mark if white list notification enable,
|
|
* invalid for sta role case. 0 - disable, 1 - enable.
|
|
*/
|
|
wl_notify_enable :1,
|
|
/** flag to mark if zc ntb notification enable, invalid for sta role case.
|
|
* 0 - disable, 1 - enable.
|
|
*/
|
|
zc_notify_enable :1,
|
|
/** flag to mark if lock time valid */
|
|
lock_time_valid :1,
|
|
/** reserved for future */
|
|
reserved :4;
|
|
/** the state of transformer detect, see IOT_PLC_TSFM_STATE_XXX */
|
|
uint8_t state;
|
|
/** transformer mac address info. */
|
|
uint8_t tfsm_addr[IOT_MAC_ADDR_LEN];
|
|
/** net lock time, uint is 1min.
|
|
* 0 means no lock.
|
|
*/
|
|
uint16_t net_lock_time;
|
|
/** the lock time of abnormal leave net, uint is 1min.
|
|
* 0 means no lock.
|
|
*/
|
|
uint16_t abn_lock_time;
|
|
/* network unlock delay time, unit is 1min. */
|
|
uint16_t unlock_delay;
|
|
} iot_plc_tsfm_change_req_t;
|
|
|
|
/** IOT_PLC_MSG_PHASE_RPT format */
|
|
typedef struct _iot_plc_phase_rpt {
|
|
/** flag to mark if physical phase identification done */
|
|
uint8_t done :1,
|
|
/** flag to mark if L/N reversed in Single-phase power meter or phase
|
|
* sequence reversed in Three-phase power meter.
|
|
*/
|
|
opposite_phase :1,
|
|
/** physical phase of the device, bit0-2 means phaseA/B/C, set "1" to
|
|
* indicate which phase the device belongs to.
|
|
*/
|
|
phy_phase :3,
|
|
/** logical phase of the device, see IOT_PLC_PHASE_XXX */
|
|
logic_phase :2,
|
|
/** flag to mark if L/N reversed in Three-phase power meter */
|
|
opposite_3p :1;
|
|
/* connection position of N-wire if L/N of three-phase meter is reversed.
|
|
* see IOT_PLC_PHASE_XXX.
|
|
* Note: the position refers to the physical phase terminal.
|
|
*/
|
|
uint8_t opposite_3p_pos :2,
|
|
/* flag to mark if the 3phase device have the zc repeat phase */
|
|
zc_repeat_3p :1,
|
|
/* reserved for future */
|
|
reserved1 :5;
|
|
} iot_plc_phase_rpt_t;
|
|
|
|
/** IOT_PLC_MSG_CTRL_PROTO_STATUS_RPT format */
|
|
typedef struct _iot_plc_ctrl_proto_state_rpt {
|
|
/** connection state, see IOT_PLC_CTRL_PROTO_STATE_XXX */
|
|
uint8_t state;
|
|
/** reasons of state change, see IOT_PLC_CTRL_PROTO_DISCONN_REASON_XXX and
|
|
* IOT_PLC_CTRL_PROTO_CONNECT_REASON_XXX.
|
|
*/
|
|
uint8_t reason;
|
|
/** remote dev addr connected to it, the byte order is Big-Endian */
|
|
uint8_t addr[IOT_MAC_ADDR_LEN];
|
|
/** remote dev role connected to it */
|
|
uint8_t role;
|
|
/** remote dev sn */
|
|
uint8_t sn;
|
|
} iot_plc_ctrl_proto_state_rpt_t;
|
|
|
|
/** IOT_PLC_MSG_ZC_CLCT_REQ format */
|
|
typedef struct _iot_plc_zc_collect_req {
|
|
/** time to start collecting, unit is 1 ntb */
|
|
uint32_t start_ntb;
|
|
/** collection count, if the local device has 3 phase zc data,
|
|
* and collecton count is not a multiple of 3, the count of
|
|
* actual collection returned is a multiple of 3.
|
|
*/
|
|
uint8_t clct_cnt;
|
|
} iot_plc_zc_collect_req_t;
|
|
|
|
typedef struct _iot_plc_zc_data {
|
|
/** time to start collecting, unit is 1 ntb */
|
|
uint32_t start_ntb;
|
|
/** reserved */
|
|
uint8_t rsvd;
|
|
/** number of data per phase, its index corresponds to the outgoing phase
|
|
* seq.
|
|
*/
|
|
uint8_t phase_cnt[3];
|
|
/** continuous zc period data collected, each element value represents
|
|
* the difference of (zc_period - 20ms), unit is 1/(25Mhz/8)s.
|
|
* 3 phase data sequence: [A1,A2,A3][B1,B2,B3][C1,C2,C3].
|
|
*/
|
|
int16_t diff[0];
|
|
} iot_plc_zc_data_t;
|
|
|
|
/** IOT_PLC_MSG_ZC_CLCT_RPT format */
|
|
typedef struct _iot_plc_zc_collect_rpt {
|
|
/** collection results, see ERR_XXX */
|
|
uint8_t result;
|
|
/** edge type, see IOT_PLC_ZC_CT_XXX_EDGE */
|
|
uint8_t clct_type;
|
|
/** total number of ZC data */
|
|
uint16_t clct_cnt;
|
|
/** length of zc data payload */
|
|
uint16_t len;
|
|
/** zc data payload, layout see iot_plc_zc_data_t structure
|
|
* if collection type is 2 edges, the falling edge data is in front
|
|
* and the rising edge data is in the back.
|
|
*/
|
|
uint8_t data[0];
|
|
} iot_plc_zc_collect_rpt_t;
|
|
|
|
/** IOT_PLC_MSG_QUERYBAND_BITMAP format */
|
|
typedef struct _iot_plc_query_band_bitmap {
|
|
/** query support band or scan band.
|
|
* 0: SUPPORT BAND.
|
|
* 1: SCAN BAND.
|
|
*/
|
|
uint8_t is_scan_band;
|
|
} iot_plc_query_band_bitmap_t;
|
|
|
|
/** IOT_PLC_MSG_QUERYBAND_BITMAP_RPT format */
|
|
typedef struct _iot_plc_query_band_bitmap_rpt {
|
|
/** get support band or scan band.
|
|
* 0: SUPPORT BAND.
|
|
* 1: SCAN BAND.
|
|
*/
|
|
uint8_t is_scan_band;
|
|
|
|
/** query support band bitmap, bandid see PLC_LIB_FREQ_BAND_xxx */
|
|
uint8_t band_bitmap[IOT_PLC_BAND_BITMAP_SIZE];
|
|
} iot_plc_query_band_bitmap_rpt_t;
|
|
|
|
/** IOT_PLC_MSG_SET_RATE_ADAPT_MODE_REQ formate */
|
|
typedef struct _iot_plc_rate_adapt_mode_req {
|
|
/** see IOT_PLC_RATE_ADAPT_NODE_XXX */
|
|
uint8_t target_node;
|
|
/** see IOT_PLC_RATE_ADAPT_MODE_XXX */
|
|
uint8_t rate_adapt_mode;
|
|
/** see IOT_PLC_RATE_ADAPT_RATE_XXX, this value is valid only when
|
|
* target_node == IOT_PLC_RATE_ADAPT_NODE_LOCAL
|
|
* and rate_adapt_mode == IOT_PLC_RATE_ADAPT_MODE_FIX */
|
|
uint8_t fixed_rate_level;
|
|
} iot_plc_set_rate_adapt_mode_req_t;
|
|
|
|
/** IOT_PLC_MSG_SET_RATE_ADAPT_MODE_RPT format */
|
|
typedef struct _iot_plc_set_rate_adapt_mode_rpt {
|
|
/** result of the set rate adapt mode request */
|
|
uint8_t result;
|
|
/** error number */
|
|
uint8_t err_no;
|
|
} iot_plc_set_rate_adapt_mode_rpt_t;
|
|
|
|
/** IOT_PLC_MSG_MSDU_CAPTURE_RECV format */
|
|
typedef struct _iot_plc_msdu_capture_recv {
|
|
/** payload length */
|
|
uint16_t len;
|
|
/** final destion tei */
|
|
uint16_t dst_tei;
|
|
/** original source tei */
|
|
uint16_t src_tei;
|
|
/** msdu data payload */
|
|
uint8_t data[0];
|
|
} iot_plc_msdu_capture_recv_t;
|
|
|
|
/** plc link statistics */
|
|
typedef struct _iot_plc_link_statistics {
|
|
/** tx sof cnt, contain the number of packets successfully sent to link,
|
|
* and the number of packets that failed to be sent for some reason.
|
|
*/
|
|
uint32_t tx_sof_cnt;
|
|
/** tx sof failed cnt, the number of packets that failed to be sent to link.
|
|
*/
|
|
uint32_t tx_sof_fail_cnt;
|
|
/** rx sof cnt, contain the number of all packets received from the link
|
|
*/
|
|
uint32_t rx_sof_cnt;
|
|
/** rx sof failed cnt, contain all failed packets received from the link
|
|
* , such as CRC errors, duplicated, unknown, and so on.
|
|
*/
|
|
uint32_t rx_sof_fail_cnt;
|
|
} iot_plc_link_statistics_t;
|
|
|
|
/**
|
|
* crypto KEY struct
|
|
*/
|
|
typedef struct _iot_plc_crypto_key {
|
|
/** key buffer */
|
|
uint8_t key[32];
|
|
/** key length, unit is 1 bit */
|
|
uint16_t keybits;
|
|
} iot_plc_crypto_key_t;
|
|
|
|
/**
|
|
* DAK/MAC pair struct, be used for IEEE1901 authentication
|
|
*/
|
|
typedef struct _iot_plc_dak_mac_pair {
|
|
/** DAK is pre-shared unique to an STA and is assigned to STAs during
|
|
* manufacturing as a DAK/MAC pair.
|
|
*/
|
|
iot_plc_crypto_key_t dak;
|
|
/** authenticated mac addr, Big-Endian */
|
|
uint8_t auth_mac[IOT_MAC_ADDR_LEN];
|
|
} iot_plc_dak_mac_pair_t;
|
|
|
|
/** IOT_PLC_MSG_AUTH_DAK_SET_REQ format */
|
|
typedef struct _iot_plc_authrz_dak_set_req {
|
|
/** action to perform: ENABLE / DISABLE / ADD / DEL DAK pair entries */
|
|
uint8_t action;
|
|
/* count of DAK/MAC pair */
|
|
uint16_t count;
|
|
/* DAK/MAC pair entries */
|
|
iot_plc_dak_mac_pair_t dak_pair[0];
|
|
} iot_plc_authrz_dak_set_req_t;
|
|
|
|
/** IOT_PLC_MSG_AUTH_DAK_SET_CONF format */
|
|
typedef struct _iot_plc_authrz_dak_set_conf {
|
|
/** result of the request */
|
|
uint8_t result;
|
|
/** error number */
|
|
uint8_t err_no;
|
|
} iot_plc_authrz_dak_set_conf_t;
|
|
|
|
/** IOT_PLC_MSG_ALLOC_LID_RPT format */
|
|
typedef struct _iot_plc_alloc_lid_rpt {
|
|
/** allocated dcsma lid, valid range 4 - 255 */
|
|
uint8_t dcsma_lid;
|
|
/** allocated tdma lid, valid range 4 - 255 */
|
|
uint8_t tdma_lid;
|
|
} iot_plc_alloc_lid_rpt_t;
|
|
|
|
#pragma pack(pop) /* restore the pack status */
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* IOT_PLC_MSG_API_H */
|