Files
kunlun/app/smart_grid/inc/iot_sg_cco_drv_api.h
2024-09-28 14:24:04 +08:00

4976 lines
173 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_SG_CCO_DRV_API_H
#define IOT_SG_CCO_DRV_API_H
/* os shim includes */
#include "os_types_api.h"
/* common includes */
#include "iot_pkt_api.h"
#include "iot_uart_api.h"
#include "iot_sg_drv_api.h"
#include "iot_plc_msg_api.h"
#include "iot_sg_cfg.h"
#include "iot_plc_msg_cco_api.h"
/* framework protocol header files */
#include "iot_sg_proto.h"
#ifdef __cplusplus
extern "C" {
#endif
/* define type of app proto, gw */
#define IOT_SG_CCO_APP_PROTO_GW 0
/* define type of app proto, nw */
#define IOT_SG_CCO_APP_PROTO_NW 1
/* invalid white list entry index */
#define IOT_SG_CCO_WL_INVAL_INDEX 0xFFFF
/* max support count of meters*/
#define IOT_SG_MAX_METER_COUNT IOT_SG_APP_WL_MAX_NUM
#define IOT_SG_MAX_STA_COUNT PLC_NETWORK_SCALE
/* start/end index of white list entry */
#define IOT_SG_WL_ENTRY_START_INDEX 1
#define IOT_SG_WL_ENTRY_END_INDEX (IOT_SG_WL_ENTRY_START_INDEX \
+ IOT_SG_APP_WL_MAX_NUM - 1)
/* defines the sg app supported max number of whitelistii */
#define IOT_SG_CCO_APP_WLII_MAX_NUM 1015
/* start/end index of white list ii entry */
#define IOT_SG_CCO_WLII_ENTRY_START_INDEX 1
#define IOT_SG_CCO_WLII_ENTRY_END_INDEX (IOT_SG_CCO_WLII_ENTRY_START_INDEX \
+ IOT_SG_CCO_APP_WLII_MAX_NUM - 1)
/* start index of secondary node */
#define IOT_SG_METER_START_INDEX 1
#define IOT_SG_STA_START_INDEX 1
#define IOT_SG_METER_END_INDEX (IOT_SG_METER_START_INDEX \
+ IOT_SG_MAX_METER_COUNT - 1)
#define IOT_SG_STA_END_INDEX (IOT_SG_STA_START_INDEX \
+ IOT_SG_MAX_STA_COUNT - 1)
/* define maximum number of drivers in the table */
#define IOT_SG_CCO_DRV_TABLE_SIZE 4
/* driver type */
#define IOT_SG_CCTT_DRV_ID_SG 0
#define IOT_SG_CCTT_DRV_ID_SPG 1
#define IOT_SG_CCTT_DRV_ID_CLI 2
/* max 645 packet count in a 3762 packet for sg concurrent meter reading */
#define IOT_SG_CON_MR_MAX_645_CNT 13
#define IOT_SG_CON_MR_MAX_69845_LEN 2000
/* caller app type, cctt driver */
#define IOT_SG_CALLER_TYPE_CCTT (1 << 0)
/* caller app type, cli driver */
#define IOT_SG_CALLER_TYPE_CLI (1 << 1)
/* caller app type, cctt driver */
#define IOT_SG_CALLER_TYPE_CLI2 (1 << 2)
/* caller app type, cctt driver */
#define IOT_SG_CALLER_TYPE_CTRL (1 << 3)
/* caller app type, cctt driver */
#define IOT_SG_CALLER_TYPE_CUS (1 << 4)
#define IOT_SG_CALLER_TYPE_ALL (IOT_SG_CALLER_TYPE_CLI | \
IOT_SG_CALLER_TYPE_CLI2 | \
IOT_SG_CALLER_TYPE_CCTT | \
IOT_SG_CALLER_TYPE_CTRL | \
IOT_SG_CALLER_TYPE_CUS)
#define IOT_SG_INVALID_CCTT_SN (0xFFFF)
/* read meter type - cctt active read meter */
#define IOT_SG_RMT_CCTT 0
/* read meter type - router active read meter */
#define IOT_SG_RMT_ROUTER 1
/* read meter type - cctt active concurrently read meter */
#define IOT_SG_RMT_CCTT_CON 2
/* read meter type - cctt active concurrently read sta module */
#define IOT_SG_RMT_CCTT_CON_STA 3
/* print at most 80 byte for debug log */
#define IOT_SG_CCO_LOG_BYTE 80
#define IOT_SG_CCO_MSG_SHORT_BUF_SIZE 128
#define IOT_SG_CCO_MSG_LONG_BUF_SIZE 512
#define IOT_SG_CCO_DEV_TYPE_COLLECTOR (0)
#define IOT_SG_CCO_DEV_TYPE_METER (1)
#define IOT_SG_CCO_DEV_TYPE_STA (2)
/* router working or stop */
#define IOT_SG_CCO_ROUTER_WORK_FLAG_STOP (0)
#define IOT_SG_CCO_ROUTER_WORK_FLAG_WORKING (1)
/* router work type: meter reading, search meter, upgrade and reserved type */
#define IOT_SG_CCO_ROUTER_WORK_TYPE_MR (0)
#define IOT_SG_CCO_ROUTER_WORK_TYPE_SM (1)
#define IOT_SG_CCO_ROUTER_WORK_TYPE_UPGRADE (2)
#define IOT_SG_CCO_ROUTER_WORK_TYPE_RESVD (3)
/* transformer detect status */
#define IOT_SG_CCO_TSFM_DETECT_DONE (0)
#define IOT_SG_CCO_TSFM_DETECT_DOING (1)
/* node state change */
#define IOT_SG_CCO_CHG_STATE_LEAVE (0)
#define IOT_SG_CCO_CHG_STATE_JOIN (1)
#define IOT_SG_CCO_CHG_STATE_REG (2)
#define IOT_SG_CCO_CHG_STATE_OFFLINE (3)
#define IOT_SG_CCO_CHG_STATE_EVT_RPT (4)
#define IOT_SG_CCO_CHG_STATE_SEARCH_RPT (5)
/* event type */
#define IOT_SG_CCO_EVENT_NORMAL (0)
#define IOT_SG_CCO_EVENT_POWER_DOWN (1)
#define IOT_SG_CCO_EVENT_POWER_UP (2)
#define IOT_SG_CCO_EVENT_POWER_DOWN_C (3)
#define IOT_SG_CCO_EVENT_POWER_UP_C (4)
#define IOT_SG_CCO_EVENT_TSFM (5)
#define IOT_SG_CCO_EVENT_TSFM_CHG (6)
#define IOT_SG_CCO_EVENT_SCORE (7)
#define IOT_SG_CCO_EVENT_LP (8)
#define IOT_SG_CCO_EVENT_CTRL (9)
#define IOT_SG_CCO_EVENT_OPPOSITE_PHASE (10)
#define IOT_SG_CCO_EVENT_NLI_ABNORMAL (11)
/* station state */
#define IOT_SG_CCO_STA_STATE_JOIN (1)
#define IOT_SG_CCO_STA_STATE_LEAVE (2)
#define IOT_SG_CCO_STA_STATE_OFFLINE (3)
#define IOT_SG_CCO_STA_STATE_ONLINE (4)
/* reason of station leave network is unknown */
#define IOT_SG_STA_STATE_CHG_REASON_UNKNOWN (0)
/* reason of station leave network is PM off */
#define IOT_SG_STA_STATE_CHG_REASON_PM_OFF (1)
/* reason of station leave network is channel quality change */
#define IOT_SG_STA_STATE_CHG_REASON_CQC (2)
/* sec node monitor max duration for 13H_F1 unit is 1s */
#define IOT_SG_CCO_MR_MAX_TIMEOUT_AFN_13 (30)
/* sec node monitor max duration for 14H_F1, unit is 1s */
#define IOT_SG_CCO_MR_MAX_TIMEOUT_AFN_14 (30)
/* sec node monitor max duration for F1H_F1, unit is 1s */
#define IOT_SG_CCO_MR_MAX_TIMEOUT_AFN_F1 (90)
#define IOT_SG_CCO_MR_MAX_TIMEOUT_AFN_F1_LESS (45)
/* sec node monitor max duration for F1H_F1, unit is 1s */
#define IOT_SG_CCO_MR_MAX_TIMEOUT_AFN_F1_ZHEJIANG (30)
/* sec node monitor max duration for F1H_F1, unit is 1s */
#define IOT_SG_CCO_MR_MAX_TIMEOUT_AFN_F1_FJ_HENAN (60)
/* sec node monitor max duration for ext task, unit is 1s */
#define IOT_SG_CCO_MR_MAX_TIMEOUT_EXT_TASK_LESS (10)
/* stop sec node reg reason */
#define IOT_SG_CCO_STOP_SEC_NODE_REG_CCTT (1)
#define IOT_SG_CCO_STOP_SEC_NODE_REG_CLI (2)
#define IOT_SG_CCO_STOP_SEC_NODE_REG_TIMEOUT (3)
#define IOT_SG_CCO_STOP_SEC_NODE_REG_POWEROFF (4)
/* CCO's state */
#define IOT_SG_CCO_STATE_IS_NOT_READY (0)
#define IOT_SG_CCO_STATE_IS_READY (1)
/* equipment service provider */
#define IOT_SG_CCO_ESP_AUTO (0)
/* automatic recognition */
#define IOT_SG_CCO_ESP_BEIJING (1)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_HUNAN (2)
/* automatic recognition */
#define IOT_SG_CCO_ESP_SHANXI (3)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_NINGXIA (4)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_SICHUAN (5)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_HUBEI (6)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_PW (7)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_HENAN (8)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_LN (9)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_SH (10)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_JIBEI (11)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_HEBEI (12)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_XIAN (13)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_HX (14)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_XIAN_D (15)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_GUANGZHOU (16)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_GUANGDONG (17)
/* automatic recognition */
#define IOT_SG_CCO_ESP_BEIJING_WL (18)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_ZHEJIANG (19)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_JIANGSU (20)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_YUNNAN (21)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_GUIZHOU (22)
/* non automatic recognition for nw shenhuayingyong */
#define IOT_SG_CCO_ESP_SHYY_SPG (23)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_FUJIAN (24)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_XINJIANG (25)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_HEILONGJIANG (26)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_ZHHW (27)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_SHANDONG (28)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_SXHW (29)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_MENGXI (30)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_GANSU (31)
/* invalid number of equipment service provider */
#define IOT_SG_CCO_ESP_INVALID (IOT_SG_CCO_ESP_GANSU + 1)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_MENGDONG_LC (40)
/* non automatic recognition */
#define IOT_SG_CCO_ESP_CHONGQING (41)
/* meter status in router meter reading progress */
#define IOT_SG_CCO_RT_MR_STATE_UNREAD (0)
#define IOT_SG_CCO_RT_MR_STATE_BUSY (1)
#define IOT_SG_CCO_RT_MR_STATE_SUCCESS (2)
#define IOT_SG_CCO_RT_MR_STATE_FAILED (3)
/* report router status changed event to cctt */
#define IOT_SG_CCO_RT_CHG_STOP_READ_METER (1)
#define IOT_SG_CCO_RT_CHG_STOP_SEARCH_METER (2)
#define IOT_SG_CCO_RT_CHG_STOP_TSFM_DETECT (3)
#define IOT_SG_CCO_RT_CHG_STOP_BD_DETECT (245)
#define IOT_SG_CCO_RT_CHG_STOP_LP_QUERY (246)
/* invalid task id */
#define IOT_SG_INVALID_TASK_ID (0xFFFF)
/* read meter result */
#define IOT_SG_CCO_MR_SUCCESS (0)
#define IOT_SG_CCO_MR_FAIL (1)
/* extension task result */
#define IOT_SG_CCO_EXT_TASK_SUCCESS (0)
#define IOT_SG_CCO_EXT_TASK_FAIL (1)
/* define the status of predict meter reading */
#define IOT_SG_CCO_PREDICT_MR_STATE_IDLE (0)
#define IOT_SG_CCO_PREDICT_MR_STATE_RUN (1)
/* define the status of routing active meter reading */
#define IOT_SG_CCO_RT_AMR_STATE_INIT (0)
#define IOT_SG_CCO_RT_AMR_STATE_RUN (1)
#define IOT_SG_CCO_RT_AMR_STATE_SUSPEND (2)
/* router meter reading message */
#define IOT_SG_CCO_RT_CTRL_RESTART (1)
#define IOT_SG_CCO_RT_CTRL_PAUSE (2)
#define IOT_SG_CCO_RT_CTRL_RESUME (3)
#define IOT_SG_CCO_RT_CTRL_MR_SUCCESS (4)
#define IOT_SG_CCO_RT_CTRL_MR_FAILED (5)
#define IOT_SG_CCO_RT_CTRL_MR_STOP (6)
#define IOT_SG_CCO_RT_CTRL_START_SPECIAL_ARM (7)
/* task priority, 0 means highest priority, 3 means lowest priority */
#define IOT_SG_CCO_TASK_PRIO_0 (0)
#define IOT_SG_CCO_TASK_PRIO_1 (1)
#define IOT_SG_CCO_TASK_PRIO_2 (2)
#define IOT_SG_CCO_TASK_PRIO_3 (3)
/* TSFM status of station define */
/* invalid transformer status */
#define IOT_SG_CCO_PM_TO_TSFM_INVALID (0)
/* same transformer but not in the white list */
#define IOT_SG_CCO_PM_TO_TSFM_1 (1)
/* same transformer and in the white list */
#define IOT_SG_CCO_PM_TO_TSFM_2 (2)
/* different transformer and not in the white list */
#define IOT_SG_CCO_PM_TO_TSFM_3 (3)
/* different transformer but in the white list */
#define IOT_SG_CCO_PM_TO_TSFM_4 (4)
/* transformer status max value */
#define IOT_SG_CCO_PM_TO_TSFM_MAX (4)
/* define controller sub protocol Q/GDW 1376.2 */
#define IOT_SG_CCO_CTRL_PROTO_3762 (0)
/* define controller sub protocol NW */
#define IOT_SG_CCO_CTRL_PROTO_NW (0)
/* define controller sub passthrough protocol */
#define IOT_SG_CCO_CTRL_PROTO_PASSTHROUGH (0)
/* operate flag of the route read meter */
/* stop read meter */
#define IOT_SG_RT_MR_STOP (0)
/* request read meter */
#define IOT_SG_RT_MR_REQUEST (1)
/* read meter commid id base on 3762 value
* these value must be same as defined in 3762 protocol without any modification
*/
#define SG_READ_PM_FAILED (0)
#define SG_READ_PM_SUCCEED (1)
#define SG_MAY_READ_PM (2)
/* phase base on 3762 proto value
* these value must be same as defined in 3762 protocol without any modification
* default phase of meter
*/
#define PROTO_SG_DEFAULT_PHASE (0)
#define PROTO_SG_PHASE_A (1)
#define PROTO_SG_PHASE_B (2)
#define PROTO_SG_PHASE_C (3)
/* function number base on 3762 proto value
* these value must be same as defined in 3762 protocol without any modification
* function number of the cctt active read meter
*/
#define SG_AFN_RMT_CCTT (0x13)
/* function number of the router active read meter */
#define SG_AFN_RMT_ROUTER (0x14)
/* function number of the predict read meter */
#define SG_AFN_PREDICT_MR (0x56)
/* function number of the cctt active concurrently read meter */
#define SG_AFN_RMT_CCTT_CON (0xF1)
/* module id information length */
#define IOT_SG_CCO_MODULE_ID_INFO_LEN (11)
/* type of getting module id */
#define IOT_SG_CCO_GET_MOD_ID_TYPE_VALID (0)
#define IOT_SG_CCO_GET_MOD_ID_TYPE_NOT_SUPPORT (1)
#define IOT_SG_CCO_GET_MOD_ID_TYPE_UNKNOWN (2)
/* transformer detect default timeout, unit is 1s */
#define IOT_SG_CCO_TSFM_DETECT_DEFAULT_TIMEOUT (5 * 60 * 60)
/* transformer detect timeout for beijing, unit is 1s */
#define IOT_SG_CCO_TSFM_DETECT_TIMEOUT_BEIJING (6 * 60 * 60)
/* phase sequence of three phase power meter */
#define IOT_SG_CCO_PHASE_SEQ_ABC (0)
#define IOT_SG_CCO_PHASE_SEQ_ACB (1)
#define IOT_SG_CCO_PHASE_SEQ_BAC (2)
#define IOT_SG_CCO_PHASE_SEQ_BCA (3)
#define IOT_SG_CCO_PHASE_SEQ_CAB (4)
#define IOT_SG_CCO_PHASE_SEQ_CBA (5)
#define IOT_SG_CCO_PHASE_SEQ_LN_REVERSED (6)
#define IOT_SG_CCO_PHASE_SEQ_RSVD (7)
/* max count power meter for collector connected */
#define IOT_SG_CCO_COLLECTOR_METER_MAX_CNT (32)
/* max bcast time for tsfm feature */
#define IOT_SPG_CCO_MAX_BCAST_TIME (1440)
/* branch detect mode */
/* only brm device could launch */
#define IOT_SG_CCO_BD_MOD_BRM_LAUNCH (0)
/* only same net device could launch, include pm and brm device */
#define IOT_SG_CCO_BD_MOD_SAME_NET_DEV_LAUNCH (1)
/* all net device could launch, include same net and neighbor net device */
#define IOT_SG_CCO_BD_MOD_ALL_NET_DEV_LAUNCH (2)
/* branch detect type */
/* normal type */
#define IOT_SG_CCO_BD_TYPE_NOR (0)
/* specific for beijing */
#define IOT_SG_CCO_BD_TYPE_BJ (1)
/* specific for zhejiang */
#define IOT_SG_CCO_BD_TYPE_ZJ (2)
/* branch detect type max value */
#define IOT_SG_CCO_BD_TYPE_MAX (2)
/* branch detect state */
#define IOT_SG_CCO_BRANCH_DETECT_READY_CHECK (0)
#define IOT_SG_CCO_BRANCH_DETECT_QUERY_NEI_NODE (1)
#define IOT_SG_CCO_BRANCH_DETECT_QUERY_NEI_PHASE (2)
#define IOT_SG_CCO_BRANCH_DETECT_QUERY_METER (3)
#define IOT_SG_CCO_BRANCH_DETECT_SEND_DEC_CHECK (4)
#define IOT_SG_CCO_BRANCH_DETECT_CLEAR (5)
#define IOT_SG_CCO_BRANCH_DETECT_SEND (6)
#define IOT_SG_CCO_BRANCH_DETECT_QUERY_RET (7)
#define IOT_SG_CCO_BRANCH_DETECT_TOPO_GEN (8)
#define IOT_SG_CCO_BRANCH_DETECT_SET_NODE (9)
#define IOT_SG_CCO_BRANCH_DETECT_PRE_DONE (10)
#define IOT_SG_CCO_BRANCH_DETECT_DONE (11)
/* pw tsfm state */
#define IOT_SG_CCO_PW_TSFM_CLEAR (0)
#define IOT_SG_CCO_PW_TSFM_SEND (1)
#define IOT_SG_CCO_PW_TSFM_QUERY_RET (2)
#define IOT_SG_CCO_PW_TSFM_WL_GEN (3)
#define IOT_SG_CCO_PW_TSFM_ADDR_CLEAR (4)
#define IOT_SG_CCO_PW_TSFM_DONE (5)
/* STA communication mode */
#define IOT_SG_CCO_COMM_MOD_UNKNOW (0)
#define IOT_SG_CCO_COMM_MOD_CARRIER (1)
#define IOT_SG_CCO_COMM_MOD_WIRELESS (2)
/* station transformer detect result */
#define IOT_SG_CCO_STA_TSFM_DETECT_RET_UNKNOWN (0)
#define IOT_SG_CCO_STA_TSFM_DETECT_RET_SAME (1)
#define IOT_SG_CCO_STA_TSFM_DETECT_RET_DIFFERENT (2)
#define IOT_SG_CCO_STA_TSFM_DETECT_RET_INVALID (3)
/* proto type */
#define IOT_SG_CCO_PROTO_TYPE_UNKNOWN (0)
#define IOT_SG_CCO_PROTO_TYPE_645_1997 (1)
#define IOT_SG_CCO_PROTO_TYPE_645_2007 (2)
/* power meter type */
#define IOT_SG_CCO_PM_TYPE_UNKNOWN (0)
#define IOT_SG_CCO_PM_TYPE_SINGLE (1)
#define IOT_SG_CCO_PM_TYPE_3P (2)
/* collect task add result */
#define IOT_SG_CCO_CLCT_TASK_OK (0)
#define IOT_SG_CCO_CLCT_TASK_ERR_CRC (1)
#define IOT_SG_CCO_CLCT_TASK_ERR_PROTO (2)
#define IOT_SG_CCO_CLCT_TASK_ERR_NOMEM (3)
#define IOT_SG_CCO_CLCT_TASK_ERR_PM (4)
#define IOT_SG_CCO_CLCT_TASK_ERR_SEC_NODE_NO_RSP (5)
#define IOT_SG_CCO_CLCT_TASK_ERR_OTHER (6)
/* define task data invalid error code */
#define IOT_SG_CCO_CLCT_TASK_DATA_ERR_NOTASK (1)
#define IOT_SG_CCO_CLCT_TASK_DATA_ERR_ADDR_INVALID (2)
/* define collect task data flag */
#define IOT_SG_CCO_CLCT_TASK_DATA_VALID (0)
#define IOT_SG_CCO_CLCT_TASK_DATA_INVALID (1)
/* sec node monitor fast duration for ext_task, unit is 1s. dl_buf will be
* retry 1 count, related to IOT_SG_RSVE_AGE and IOT_SG_RETRY_RSVD_AGE.
*/
#define IOT_SG_CCO_EXT_TASK_TIMEOUT_SLOW (25)
/* extension task type */
#define IOT_SG_CCO_EXT_TASK_TYPE_CLCT_ADD (1)
#define IOT_SG_CCO_EXT_TASK_TYPE_CLCT_DEL (2)
#define IOT_SG_CCO_EXT_TASK_TYPE_CLCT_QRY_ID (3)
#define IOT_SG_CCO_EXT_TASK_TYPE_CLCT_QRY_INFO (4)
#define IOT_SG_CCO_EXT_TASK_TYPE_CLCT_READ_DATA (5)
#define IOT_SG_CCO_EXT_TASK_TYPE_CHANNEL (6)
#define IOT_SG_CCO_EXT_TASK_TYPE_RUNTIME (7)
#define IOT_SG_CCO_EXT_TASK_TYPE_SELFCHECK (8)
#define IOT_SG_CCO_EXT_TASK_TYPE_TSFM_ADDR (9)
#define IOT_SG_CCO_EXT_TASK_TYPE_NW_LOCK (10)
#define IOT_SG_CCO_EXT_TASK_TYPE_CLOCK_MANAGE (11)
#define IOT_SG_CCO_EXT_TASK_TYPE_ACCURATE_CORR (12)
#define IOT_SG_CCO_EXT_TASK_TYPE_NODE_INFO (13)
#define IOT_SG_CCO_EXT_TASK_TYPE_NODE_CALL (14)
#define IOT_SG_CCO_EXT_TASK_TYPE_MIN_CLCT_DATA (15)
#define IOT_SG_CCO_EXT_TASK_TYPE_MIN_CLCT2_CFG (16)
#define IOT_SG_CCO_EXT_TASK_TYPE_MIN_CLCT2_CFG_QR (17)
#define IOT_SG_CCO_EXT_TASK_TYPE_MIN_CLCT2_REQ_DATA (18)
/* extension task task_id */
#define IOT_BUF_TASK_ID_MR_MAX (0xFFFF)
#define IOT_BUF_TASK_ID_CLCT_ADD (IOT_BUF_TASK_ID_MR_MAX + \
IOT_SG_CCO_EXT_TASK_TYPE_CLCT_ADD)
#define IOT_BUF_TASK_ID_CLCT_DEL (IOT_BUF_TASK_ID_MR_MAX + \
IOT_SG_CCO_EXT_TASK_TYPE_CLCT_DEL)
#define IOT_BUF_TASK_ID_CLCT_QRY_ID (IOT_BUF_TASK_ID_MR_MAX + \
IOT_SG_CCO_EXT_TASK_TYPE_CLCT_QRY_ID)
#define IOT_BUF_TASK_ID_CLCT_QRY_INFO (IOT_BUF_TASK_ID_MR_MAX + \
IOT_SG_CCO_EXT_TASK_TYPE_CLCT_QRY_INFO)
#define IOT_BUF_TASK_ID_CLCT_READ_DATA (IOT_BUF_TASK_ID_MR_MAX + \
IOT_SG_CCO_EXT_TASK_TYPE_CLCT_READ_DATA)
#define IOT_BUF_TASK_ID_CHENNEL (IOT_BUF_TASK_ID_MR_MAX + \
IOT_SG_CCO_EXT_TASK_TYPE_CHANNEL)
#define IOT_BUF_TASK_ID_RUNTIME (IOT_BUF_TASK_ID_MR_MAX + \
IOT_SG_CCO_EXT_TASK_TYPE_RUNTIME)
#define IOT_BUF_TASK_ID_SELFCHECK (IOT_BUF_TASK_ID_MR_MAX + \
IOT_SG_CCO_EXT_TASK_TYPE_SELFCHECK)
#define IOT_BUF_TASK_ID_TSFM_ADDR (IOT_BUF_TASK_ID_MR_MAX + \
IOT_SG_CCO_EXT_TASK_TYPE_TSFM_ADDR)
#define IOT_BUF_TASK_ID_NW_LOCK (IOT_BUF_TASK_ID_MR_MAX + \
IOT_SG_CCO_EXT_TASK_TYPE_NW_LOCK)
#define IOT_BUF_TASK_ID_CLOCK_MANAGE (IOT_BUF_TASK_ID_MR_MAX + \
IOT_SG_CCO_EXT_TASK_TYPE_CLOCK_MANAGE)
#define IOT_BUF_TASK_ID_ACCURATE_CORR (IOT_BUF_TASK_ID_MR_MAX + \
IOT_SG_CCO_EXT_TASK_TYPE_ACCURATE_CORR)
#define IOT_BUF_TASK_ID_NODE_INFO (IOT_BUF_TASK_ID_MR_MAX + \
IOT_SG_CCO_EXT_TASK_TYPE_NODE_INFO)
#define IOT_BUF_TASK_ID_NODE_CALL (IOT_BUF_TASK_ID_MR_MAX + \
IOT_SG_CCO_EXT_TASK_TYPE_NODE_CALL)
#define IOT_BUF_TASK_ID_MIN_CLCT_DATA (IOT_BUF_TASK_ID_MR_MAX + \
IOT_SG_CCO_EXT_TASK_TYPE_MIN_CLCT_DATA)
#define IOT_BUF_TASK_ID_MIN_CLCT2_CFG (IOT_BUF_TASK_ID_MR_MAX + \
IOT_SG_CCO_EXT_TASK_TYPE_MIN_CLCT2_CFG)
#define IOT_BUF_TASK_ID_MIN_CLCT2_CFG_QR (IOT_BUF_TASK_ID_MR_MAX + \
IOT_SG_CCO_EXT_TASK_TYPE_MIN_CLCT2_CFG_QR)
#define IOT_BUF_TASK_ID_MIN_CLCT2_REQ_DATA (IOT_BUF_TASK_ID_MR_MAX + \
IOT_SG_CCO_EXT_TASK_TYPE_MIN_CLCT2_REQ_DATA)
/* collect task data len */
#define IOT_SG_CCO_CLCT_TASK_CRC_LEN (2)
#define IOT_SG_CCO_CLCT_TASK_DI_DATA_LEN_97 (4)
#define IOT_SG_CCO_CLCT_TASK_DI_DATA_LEN_07 (6)
/* low power meter query default max count */
#define IOT_SG_LP_METER_QUERY_DEFAULT_CNT (10)
/* max sec node count of one frame data */
#define IOT_SG_CCO_MAX_SEC_NODE_SEND_CNT (8)
/* sec node run state info id */
#define IOT_SG_CCO_RUN_STATE_ID_RUNTIME (0)
#define IOT_SG_CCO_RUN_STATE_ID_ZC (1)
#define IOT_SG_CCO_RUN_STATE_ID_UART (2)
#define IOT_SG_CCO_RUN_STATE_ID_LEAVE (3)
#define IOT_SG_CCO_RUN_STATE_ID_RESET (4)
/* state grid 3762, version 2013 */
#define IOT_SG_CCO_CCTT_PROTO_3762_13 (0)
/* state grid 3762, version 2009 */
#define IOT_SG_CCO_CCTT_PROTO_3762_09 (1)
/* south power grid */
#define IOT_SG_CCO_CCTT_PROTO_SPG (2)
/* transformer detect address bcast cmd type */
#define IOT_SG_CCO_BCAST_TSFM_ADDR_CMD_SET (0)
#define IOT_SG_CCO_BCAST_TSFM_ADDR_CMD_DEL (1)
/* transformer detect network lock bcast cmd type */
#define IOT_SG_CCO_BCAST_NW_LOCK_CMD_LOCK (0)
#define IOT_SG_CCO_BCAST_NW_LOCK_CMD_UNLOCK (1)
/* whole network set mode */
#define IOT_SG_CCO_NW_SEND_MODE_SINGLE (0)
#define IOT_SG_CCO_NW_SEND_MODE_ALL (1)
/* cco information report request id */
#define IOT_SG_CCO_REQ_ID_PHASE_INFO_RPT (0)
/* whitle list auto remove timeout, unit is 1s. */
#define IOT_SG_CCO_AUTO_RM_WL_TIMEOUT (30 * 60 * 60)
/* uart baud rate type */
#define IOT_SG_CCO_BAUD_IDX_300 (0)
#define IOT_SG_CCO_BAUD_IDX_600 (1)
#define IOT_SG_CCO_BAUD_IDX_1200 (2)
#define IOT_SG_CCO_BAUD_IDX_2400 (3)
#define IOT_SG_CCO_BAUD_IDX_4800 (4)
#define IOT_SG_CCO_BAUD_IDX_7200 (5)
#define IOT_SG_CCO_BAUD_IDX_9600 (6)
#define IOT_SG_CCO_BAUD_IDX_19200 (7)
#define IOT_SG_CCO_BAUD_IDX_38400 (8)
#define IOT_SG_CCO_BAUD_IDX_57600 (9)
#define IOT_SG_CCO_BAUD_IDX_115200 (10)
/* uart baud rate value */
#define IOT_SG_CCO_UART_BAUD_300 (300)
#define IOT_SG_CCO_UART_BAUD_600 (600)
#define IOT_SG_CCO_UART_BAUD_1200 (1200)
#define IOT_SG_CCO_UART_BAUD_2400 (2400)
#define IOT_SG_CCO_UART_BAUD_4800 (4800)
#define IOT_SG_CCO_UART_BAUD_7200 (7200)
#define IOT_SG_CCO_UART_BAUD_9600 (9600)
#define IOT_SG_CCO_UART_BAUD_19200 (19200)
#define IOT_SG_CCO_UART_BAUD_38400 (38400)
#define IOT_SG_CCO_UART_BAUD_57600 (57600)
#define IOT_SG_CCO_UART_BAUD_115200 (115200)
/* uart config default recover time, unit is 1min */
#define IOT_SG_CCO_BAUD_REC_TIME_DEFULT (120)
/* power down event default valid time, unit is 1s */
#define IOT_SG_CCO_PD_DEFAULT_VALID_TIME (5)
/* power down event max valid time, unit is 1s */
#define IOT_SG_CCO_PD_MAX_VALID_TIME (15)
/* the option of module reset infomation */
#define IOT_SG_CCO_RESET_INFO_OP_PD_CNT (0)
#define IOT_SG_CCO_RESET_INFO_OP_PD_VALID_TIME (1)
/* predict meter reading concurrent max count */
#define IOT_SG_CCO_PREDICT_MR_CON_MAX_CNT (15)
/* cco intern type */
#define IOT_SG_CCO_INTERN_SEND_BRANCH_DETECT (0)
#define IOT_SG_CCO_INTERN_SEND_TSFM_DETECT (1)
#define IOT_SG_CCO_INTERN_SEND_PREDICT_MR (2)
#define IOT_SG_CCO_INTERN_SEND_PW_TSFM (3)
/* bcast type */
#define IOT_SG_CCO_BCAST_TYPE_DEFAULT (0)
#define IOT_SG_CCO_BCAST_TYPE_CLOCK_MANAGE (1)
#define IOT_SG_CCO_BCAST_TYPE_ACCURATE (2)
/* clock manager cmd type */
#define IOT_SG_CCO_CLOCK_MANAGE_SET_AUTO_CORR (1)
#define IOT_SG_CCO_CLOCK_MANAGE_SET_THRESHOLD (2)
#define IOT_SG_CCO_CLOCK_MANAGE_QR_INFO (3)
/* nw transparent transfer data work code */
#define IOT_SG_CCO_TRANS_WORK_CODE_DEFAULT (0x00)
#define IOT_SG_CCO_TRANS_WORK_CODE_CORR_TIME (0x01)
#define IOT_SG_CCO_TRANS_WORK_CODE_COLLECT (0x02)
/* uart data sources */
#define IOT_SG_CCO_LOCAL_PROTO_DATA_SOURCE_CCTT (0)
#define IOT_SG_CCO_LOCAL_PROTO_DATA_SOURCE_CTRL (1)
#define IOT_SG_CCO_LOCAL_PROTO_DATA_SOURCE_CLI (2)
#define IOT_SG_CCO_LOCAL_PROTO_DATA_SOURCE_CUS (3)
/* curve collect parameter type */
#define IOT_SG_CCO_CURVE_COLLET_TYPE_DEF (0)
#define IOT_SG_CCO_CURVE_COLLET_TYPE_v28 (1)
/* sta collect parameter v2.8 task max task id */
#define IOT_SG_CCO_CURVE_DATA_MAX_TASK_ID (7)
/* release date length of sw/hw version */
#define IOT_SG_CCO_VER_DATE_LENGTH (3)
#pragma pack(push) /* save the pack status */
#pragma pack(1) /* 1 byte align */
typedef struct _power_evt_data_field {
uint8_t evt_type;
uint8_t data[0];
}power_evt_data_field_t;
/* node mapping info */
typedef struct _iot_sg_meter_mapping_info {
/* node mac - small endian */
uint8_t node_mac[IOT_MAC_ADDR_LEN];
/* meter address - small endian */
uint8_t meter_addr[IOT_METER_ADDR_LEN];
} iot_sg_meter_mapping_info_t;
/* di and result length */
typedef struct _iot_sg_cco_di_info {
/* di */
uint32_t di;
/* meter reading result length */
uint8_t di_result_len;
} iot_sg_cco_di_info_t;
typedef struct _iot_sg_cco_meter_clct_param {
/* 0 - single phase meter, 1 - three phase meter */
uint8_t pm_type;
/* di count of single phase meter */
uint8_t di_cnt;
/* di result total length of single phase meter */
uint8_t di_result_len;
/* di information of single phase meter */
iot_sg_cco_di_info_t di_info[0];
} iot_sg_cco_meter_clct_param_t;
typedef struct _iot_sg_cco_meter_clct_param_v28 {
/* 0 - single phase meter, 1 - three phase meter */
uint8_t pm_type;
/* di count of single phase meter */
uint8_t di_cnt;
/* di result total length of single phase meter */
uint16_t di_result_len;
/* di information */
iot_sg_cco_di_info_t di_info[0];
} iot_sg_cco_meter_clct_param_v28_t;
typedef struct _iot_sg_cco_meter_clct_rpt_param_v28 {
/* 0 - single phase meter, 1 - three phase meter */
uint8_t pm_type;
/* di count of single phase meter */
uint8_t di_cnt;
/* di information */
uint8_t di_data[0];
} iot_sg_cco_meter_clct_rpt_param_v28_t;
typedef struct _iot_sg_cco_module_clct_param_v28 {
/* sta collect parameter v2.8 task id */
uint8_t task_id;
/* 0 - disabled, 1 - enabled */
uint8_t enabled;
/* 2 - DL/T645-2007, 3 - DL/T698.45, other - reserve, see PROTO_TYPE_XXX */
uint8_t proto_type;
/* unit is 1min */
uint8_t clct_period;
/* collect parameter */
//iot_sg_cco_meter_clct_param_v28_t clct_param[0];
} iot_sg_cco_module_clct_param_v28_t;
typedef struct _iot_sg_cco_curve_node_conf {
/* sta collect parameter v2.8 task id */
uint8_t task_id;
/* node addr count */
uint16_t cnt;
/* node addr, little endian */
uint8_t node_addr[0][IOT_MAC_ADDR_LEN];
} iot_sg_cco_curve_node_conf_t;
/* descriptor of sta collect parameter layout structure in PIB */
typedef struct _iot_sg_cco_module_clct_param {
/* 0 - disabled, 1 - enabled */
uint8_t enabled;
/* unit is 1min */
uint8_t clct_period;
/* 2 - DL/T645-2007, 3 - DL/T698.45, other - reserve, see PROTO_TYPE_XXX */
uint8_t proto_type;
/* collect parameter */
//iot_sg_cco_meter_clct_param_t clct_param[0];
} iot_sg_cco_module_clct_param_t;
/* collection fn structure in collection task */
typedef struct _iot_sg_cco_clct_task_fn {
/* type of pm protocol, see IOT_SG_CCO_PROTO_TYPE_XXX */
uint16_t proto_type : 3,
/* type of pm, see IOT_SG_CCO_PM_TYPE_XXX */
meter_type : 2,
/* reserved for future */
rsvd : 11;
} iot_sg_cco_clct_task_fn_t;
/* collection data time structure */
typedef struct _iot_sg_cco_clct_task_data_time {
/* data time, BIN type */
uint16_t base_min : 6, /* D0 - D5 */
base_hour : 5, /* D6 - D10 */
base_day : 5; /* D11 - D15 */
} iot_sg_cco_clct_task_data_time_t;
typedef struct _iot_sg_collect_task {
/* task id */
uint8_t task_id;
/* task control code */
iot_sg_cco_clct_task_fn_t fn;
/* task timout time, uint is 1s */
uint16_t timeout;
/* collection base time */
iot_sg_cco_clct_task_data_time_t base_time;
/* collection period */
uint8_t period;
/* cnt of di */
uint8_t di_cnt;
/* collect data info and crc */
uint8_t data[0];
} iot_sg_collect_task_t;
/* add collection data read task */
typedef struct _iot_sg_cco_add_clct_data_read_dl {
/* task priority, 0 - hight priority, 3 - low priority */
uint8_t task_pri :4,
/* reserved */
reserved :4;
/* timeout */
uint16_t timeout;
/* collection task id */
uint8_t clct_task_id;
/* collection task sn */
uint8_t clct_task_sn;
/* start time */
iot_sg_cco_clct_task_data_time_t start_time;
/* time count */
uint8_t time_cnt;
} iot_sg_cco_add_clct_data_read_t;
/* collection read task data */
typedef struct _iot_sg_cco_clct_read_data {
/* clct task id */
uint8_t clct_task_id;
/* collection task sn */
uint8_t clct_task_sn;
/* crc code */
uint16_t crc_code;
/* collection data */
uint8_t data[0];
} iot_sg_cco_clct_read_data_t;
/* collection read task data report */
typedef struct _iot_sg_cco_clct_read_data_rpt {
/* sec node mac addr, little endian */
uint8_t mac_addr[IOT_MAC_ADDR_LEN];
/* collection read task data */
iot_sg_cco_clct_read_data_t read_data;
} iot_sg_cco_clct_read_data_rpt_t;
/* collection read task status report */
typedef struct _iot_sg_cco_clct_read_status_rpt {
/* clct task id */
uint8_t clct_task_id;
/* collection task sn */
uint8_t clct_task_sn;
/* sec node mac addr, little endian */
uint8_t mac_addr[IOT_MAC_ADDR_LEN];
/* collection task status, IOT_SG_CCO_CLCT_TASK_XXX */
uint8_t clct_task_status;
} iot_sg_cco_clct_read_status_rpt_t;
/* time struct */
typedef struct _iot_sg_cco_time {
/* time stamp, BCD code to represent */
uint8_t sec;
uint8_t min;
uint8_t hour;
uint8_t day;
uint8_t month;
uint8_t year;
} iot_sg_cco_time_t;
/* location information */
typedef struct _iot_sg_cco_node_location_unit {
/* location unit seconds: BCD code */
uint16_t sec_0 : 4,
sec_1 : 4,
sec_2 : 4,
sec_3 : 4;
/* location unit min: BCD code */
uint8_t min_0 : 4,
min_1 : 4;
/* location unit degree: BCD code */
uint16_t degree_0 : 4,
degree_1 : 4,
degree_2 : 4,
/* 0:north latitude or east longitude,1:south latitude or west longitude */
symbol_3 : 1,
rsvd : 3;
} iot_sg_cco_node_location_unit_t;
typedef struct _iot_sg_cco_sec_node_score_info {
/* assessment score */
uint8_t score;
/* trouble data item, 4 byte to 32 bit.
* each bit corresponding to trouble data item.
* example: D0 is trouble, set bit0 is 1.
*/
uint32_t err_bm;
/* power meter mac address, little endian */
uint8_t pm_mac[IOT_MAC_ADDR_LEN];
} iot_sg_cco_sec_node_score_info_t;
/* low power meter report 188 proto data */
typedef struct _iot_sg_cco_lp_meter_mr_data {
/* low power meter mac addr, little endian */
uint8_t mac_addr[IOT_MAC_ADDR_LEN];
/* CJ-T_188-2004 proto data length */
uint16_t data_len;
/* CJ-T_188-2004 proto data */
uint8_t data[0];
} iot_sg_cco_lp_meter_mr_data_t;
/* report low power meter info from sta to cco */
typedef struct _iot_sg_cco_rpt_lp_meter_data {
/* report low power meter count */
uint8_t rpt_cnt;
/* 188 protocol low power meter data */
uint8_t data[0];
} iot_sg_cco_rpt_lp_meter_data_t;
/* collect task status report */
typedef struct _iot_sg_cco_clct_task_add_rpt {
/* clct task id */
uint8_t clct_task_id;
/* sec node mac addr, little endian */
uint8_t mac_addr[IOT_MAC_ADDR_LEN];
/* collection task status, IOT_SG_CCO_CLCT_TASK_XXX */
uint8_t clct_task_status;
} iot_sg_cco_clct_task_add_rpt_t;
typedef struct _iot_sg_cco_node_base_info_dl {
/* meter addr, little endian */
uint8_t meter_addr[IOT_MAC_ADDR_LEN];
/* element count */
uint8_t element_cnt;
/* element info */
uint8_t element[0];
} iot_sg_cco_node_base_info_dl_t;
typedef struct _iot_sg_cco_node_base_info_ul {
/* meter addr, little endian */
uint8_t meter_addr[IOT_MAC_ADDR_LEN];
/* element info */
uint8_t data[0];
} iot_sg_cco_node_base_info_ul_t;
/* collection task id query report */
typedef struct _iot_sg_cco_clct_task_id_query_rpt {
/* pm address, little-endian */
uint8_t pm_addr[IOT_MAC_ADDR_LEN];
/* max cnt of support task */
uint8_t max_cnt;
/* task cnt */
uint8_t task_cnt;
/* collect task id data */
uint8_t clct_task_id[0];
} iot_sg_cco_clct_task_id_query_rpt_t;
/* collection task info query report */
typedef struct _iot_sg_cco_clct_task_info_query_rpt {
/* pm address, little-endian */
uint8_t pm_addr[IOT_MAC_ADDR_LEN];
/* task info flag, see NW_APP_CLCT_TASK_DATA_VALID */
uint8_t info_valid_flag;
/* collection task info */
iot_sg_collect_task_t task_info;
} iot_sg_cco_clct_task_info_query_rpt_t;
typedef struct _iot_sg_cco_pm_info {
/* device mac address, if the device type is collector,
* the mac is the collector mac address, little-endian.
*/
uint8_t dev_mac[IOT_MAC_ADDR_LEN];
/* mac address of the pm, little-endian */
uint8_t pm_mac[IOT_MAC_ADDR_LEN];
/* power meter proto type, see PROTO_TYPE_XXX */
uint8_t proto_type;
} iot_sg_cco_pm_info_t;
typedef struct _iot_sg_cco_query_channel_info {
/* node addr, little endian */
uint8_t node_addr[IOT_MAC_ADDR_LEN];
/* neighbor node start index */
uint16_t start_index;
/* neighbor node count */
uint8_t node_cnt;
} iot_sg_cco_query_channel_info_t;
typedef struct _iot_sg_cco_node_channel_info {
/* node addr, little endian */
uint8_t node_addr[IOT_MAC_ADDR_LEN];
/* tei */
uint16_t tei;
/* proxy tei */
uint16_t proxy_tei;
/* level */
uint8_t level;
/* uplink traffic success ratio */
uint8_t ul_tf_sr;
/* downlink traffic success ratio */
uint8_t dl_tf_sr;
/* traffic success ratio */
uint8_t tf_sr;
/* snr between neighbor node and local node */
int8_t snr;
/* signal attenuation between neighbor node and local node */
uint8_t signal_attenuation;
} iot_sg_cco_node_channel_info_t;
typedef struct _iot_sg_cco_channel_info {
/* neighbor node total count */
uint16_t total_cnt;
/* report count */
uint8_t rpt_cnt;
/* node channel info */
iot_sg_cco_node_channel_info_t node_channel[0];
} iot_sg_cco_channel_info_t;
typedef struct _iot_sg_cco_query_node_run_state {
/* run info list count */
uint8_t cnt;
/* sec node run info list */
uint8_t id[0];
} iot_sg_cco_query_node_run_state_t;
/* node run state id info header */
typedef struct _iot_sg_cco_run_state_element {
/* info id */
uint8_t id;
/* info data lenght */
uint8_t len;
/* info data */
uint8_t data[0];
} iot_sg_cco_run_state_element_t;
typedef struct _iot_sg_cco_rpt_node_run_state {
/* run info list count */
uint8_t cnt;
/* sec node run info list */
uint8_t data[0];
} iot_sg_cco_rpt_node_run_state_t;
/* runtime info structure, id is IOT_SG_CCO_RUN_STATE_ID_RUNTIME */
typedef struct _iot_sg_cco_node_run_time {
/* runtime, uint is 1s */
uint32_t runtime;
} iot_sg_cco_node_run_time_t;
/* run other info structure,
* id is IOT_SG_CCO_RUN_STATE_ID_ZC.
* id is IOT_SG_CCO_RUN_STATE_ID_UART.
* id is IOT_SG_CCO_RUN_STATE_ID_LEAVE.
* id is IOT_SG_CCO_RUN_STATE_ID_RESET.
*/
typedef struct _iot_sg_cco_node_run_other_info {
uint8_t result;
} iot_sg_cco_node_run_other_info_t;
typedef struct _iot_sg_cco_set_sec_node_tsfm_addr {
/* tsfm_address, little endian */
uint8_t tsfm_addr[IOT_MAC_ADDR_LEN];
/* whole network set mode, see IOT_SG_CCO_NW_SEND_MODE_XXX */
uint8_t set_mode;
/* reserved */
uint8_t rsvd[3];
/* secondary node address, only valid in single set, little endian */
uint8_t sec_node_addr[IOT_MAC_ADDR_LEN];
} iot_sg_cco_set_sec_node_tsfm_addr_t;
typedef struct _iot_sg_cco_set_tsfm_addr {
/* set tsfm addr commad type, see IOT_SG_CCO_BCAST_TSFM_ADDR_CMD_SET_XXX */
uint8_t cmd_type;
/* data length */
uint8_t data_len;
/* reserved */
uint16_t rsvd;
/* cmd data */
uint8_t data[0];
} iot_sg_cco_set_tsfm_addr_t;
typedef struct _iot_sg_cco_nw_lock_set_data {
/* whole network set mode, see IOT_SG_CCO_NW_SEND_MODE_XXX */
uint8_t set_mode;
/* reserved */
uint8_t rsvd;
/* secondary node addres, only valid in single set, little endian */
uint8_t sec_node_mac[IOT_MAC_ADDR_LEN];
} iot_sg_cco_nw_lock_set_data_t;
typedef struct _iot_sg_cco_nw_lock_cmd {
/* command type, see IOT_SG_CCO_BCAST_NW_LOCK_CMD_XXX */
uint8_t cmd_type;
/* data length */
uint8_t data_len;
/* reserved */
uint16_t rsvd;
/* command data */
uint8_t data[0];
} iot_sg_cco_nw_lock_cmd_t;
typedef struct _iot_sg_cco_qry_node_base_info {
/* node mac addr, little endian */
uint8_t mac_addr[IOT_MAC_ADDR_LEN];
/* base info element count */
uint8_t element_cnt;
/* info element */
uint8_t data[0];
} iot_sg_cco_qry_node_base_info_t;
/* power meter info for power event report */
typedef struct _iot_sg_power_evt_pm_info {
/* power meter mac address */
uint8_t mac[IOT_MAC_ADDR_LEN];
/* 0 - power off, 1- power on */
uint8_t power_state;
} iot_sg_power_evt_pm_info_t;
/* addr type for event data field */
typedef struct _iot_sg_evt_data_addr {
/* power meter count */
uint16_t pm_count;
/* power meter info */
iot_sg_power_evt_pm_info_t pm_info[0];
} iot_sg_evt_data_addr_t;
typedef struct _iot_sg_cco_rpt_node_clock_info {
/* meter addr, little endian */
uint8_t pm_addr[IOT_MAC_ADDR_LEN];
/* switch of auto correct time from sta */
uint8_t auto_corr_switch;
/* correct time threshold from sta */
uint8_t corr_threshold;
} iot_sg_cco_rpt_node_clock_info_t;
typedef struct _iot_sg_cco_nli_abnormal_evt_rpt {
/* report total count */
uint16_t total_cnt;
/* start index */
uint16_t start_index;
/* current report count */
uint8_t rpt_cnt;
/* abnormal evt data */
uint8_t data[0];
} iot_sg_cco_nli_abnormal_evt_rpt_t;
typedef struct _iot_sg_cco_accurate_correct_time {
/* ntb for recv correct time message */
uint32_t ntb;
/* data length */
uint16_t len;
/* accurate correct time data */
uint8_t data[0];
} iot_sg_cco_accurate_correct_time_t;
typedef struct _sec_node_info_query {
uint8_t mac[IOT_MAC_ADDR_LEN];
uint16_t node_index;
uint8_t proto_type;
} sec_node_info_query_t;
/* data type for IOT_SG_CCO_SEC_NODE_INFO */
typedef struct _sec_node_query {
/* sta mac addr, big endian */
uint8_t sta_addr[IOT_MAC_ADDR_LEN];
/* dev mac addr, little endian */
uint8_t dev_addr[IOT_MAC_ADDR_LEN];
/* sec node dev type, see IOT_PLC_DEV_TYPE_XXX */
uint8_t dev_type;
/* dev proto type, see PROTO_TYPE_XXX */
uint8_t proto_type;
/* total sec node count of this node */
uint8_t total_sec_node_count;
/* sec node count of this struct contain */
uint8_t contain_sec_node_count;
/* see IOT_SG_CCO_CHG_STATE_XXX */
uint8_t chg_state;
/* see IOT_SG_STA_STATE_CHG_REASON_XXX */
uint8_t leave_reason;
/* start index of first sec node in total sec nodes. */
uint16_t start_idx;
/* duration of station leaving network, unit is 1s */
uint32_t leave_dur;
sec_node_info_query_t node_info[0];
} sec_node_query_t;
/* struct contain info of a secondary node for state change */
typedef struct _sec_node_state_chg_info {
/* node mac addr, little endian */
uint8_t node_addr[IOT_MAC_ADDR_LEN];
/* see IOT_SG_CCO_CHG_STATE_XXX */
uint8_t chg_state;
/* see IOT_SG_STA_STATE_CHG_REASON_XXX */
uint8_t leave_reason;
/* duration of station leaving network, unit is 1s */
uint32_t leave_dur;
} sec_node_state_chg_info_t;
/* struct contain info of report secondary node state change */
typedef struct _sec_node_state_chg {
/* total sec node state change count */
uint8_t total_cnt;
/* start index of first sec node in total sec nodes. */
uint16_t start_idx;
/* sec node state change info */
sec_node_state_chg_info_t node_info[0];
} sec_node_state_chg_t;
typedef struct _iot_sg_wl_op_entry {
/* mac address of secondary node */
uint8_t mac[IOT_MAC_ADDR_LEN];
uint16_t node_index;
/* protocol the node supports */
uint8_t proto_type;
/* communication object type, see PROTO_3762_FJ_OBJ_XXX */
uint8_t obj_type;
} iot_sg_wl_op_entry_t;
typedef struct _iot_sg_wl_op_info {
/* count of meter mac */
uint8_t count;
/* time stamp to remove the entry from white list, unit is 1s */
uint32_t rm_ts;
/* info of node for wl operation */
iot_sg_wl_op_entry_t node_info[0];
} iot_sg_wl_op_info_t;
typedef struct _iot_sg_bl_op_info {
/* count of meter mac */
uint8_t count;
/* info of node for bl operation */
uint8_t node_addr[0][IOT_MAC_ADDR_LEN];
} iot_sg_bl_op_info_t;
/* struct contain info of a secondary node for communication */
typedef struct _iot_sg_sta_meter_info {
/* meter address */
uint8_t meter_mac[IOT_MAC_ADDR_LEN];
/* sta address */
uint8_t sta_mac[IOT_MAC_ADDR_LEN];
/* secondary node index */
uint16_t node_index;
/* protocol the node supports */
uint8_t proto_type;
/* device type, see IOT_PLC_DEV_TYPE_XXX */
uint8_t dev_type;
/* 0:meter read unfinished, 1:meter read finished */
uint8_t meter_read_done : 1;
} iot_sg_sta_meter_info_t;
/* struct contain info of a white list entry*/
typedef struct _iot_sg_wl_entry_info {
/* meter address */
uint8_t mac_addr[IOT_MAC_ADDR_LEN];
/* secondary node index */
uint16_t node_index;
/* protocol the node supports */
uint8_t proto_type;
/* meter status, see IOT_SG_CCO_RT_MR_STATE_XXX */
uint8_t route_mr_state :2,
/* sta module configuration state, 0 fail, 1 success */
sta_mod_cfg_state :1,
/* communication object type, see PROTO_3762_FJ_OBJ_XXX */
obj_type :4,
/* reserved for future */
rsvd :1;
} iot_sg_wl_entry_info_t;
/* struct containing white list entry information */
typedef struct _iot_sg_wl_entry_info_transfer {
uint16_t total_count;
uint16_t count;
iot_sg_wl_entry_info_t info[0];
} iot_sg_wl_entry_info_transfer_t;
/* struct containing secondary node information for communication */
typedef struct _iot_sg_node_info_transfer {
uint16_t total_count;
uint16_t count;
iot_sg_sta_meter_info_t info[0];
} iot_sg_node_info_transfer_t;
/* neighbor network information */
typedef struct _iot_sg_nb_nw_info {
/* nid of the neighbor network */
uint32_t nid;
} iot_sg_nb_nw_info_t;
typedef struct _iot_sg_nb_nw_rpt {
/* total number of neighbor network */
uint16_t count;
/* neighbor network info entries */
iot_sg_nb_nw_info_t nb_info[0];
} iot_sg_nb_nw_rpt_t;
typedef struct _iot_sg_task_info {
/* pending task id */
uint16_t task_id;
/* priority level, 0 - hight priority, 3 - low priority */
uint8_t prio;
/* 0 - need ack, 1 - needless ack */
uint8_t ackflag;
/* count of the task address */
uint16_t addr_cnt;
/* length of the task data */
uint8_t data_len;
/* address field and data field */
uint8_t info[0];
} iot_sg_task_info_t;
/* struct containing upgrade fail entry list information */
typedef struct _iot_sg_upgrade_fail_entry_info {
uint16_t total_count;
uint16_t count;
uint8_t addr[0][IOT_MAC_ADDR_LEN];
} iot_sg_upgrade_fail_entry_info_t;
typedef struct _iot_sg_cco_bd_dev_node_info{
/* node mac addr, little endian */
uint8_t mac_addr[IOT_MAC_ADDR_LEN];
/* device type, see IOT_PLC_DEV_TYPE_XXX */
uint8_t dev_type;
/* father node mac addr, little endian */
uint8_t father_node[IOT_MAC_ADDR_LEN];
/* phase info */
uint8_t phase : 3,
/* reserved */
reserved1 : 1,
/* if phase info is valid */
opposite_phase : 1,
/* phase sequence type */
phase_type : 3;
/* longitude */
iot_sg_cco_node_location_unit_t longitude;
/* latitude */
iot_sg_cco_node_location_unit_t latitude;
/* CT ratio, uint is x1 */
uint16_t i_ratio;
/* PT ratio, uint is x1 */
uint8_t v_ratio;
/* physical phase */
uint8_t phy_phase1 : 2,
phy_phase2 : 2,
phy_phase3 : 2,
/* reserved2 */
reserved2 : 2;
}iot_sg_cco_bd_dev_node_info_t;
typedef struct _iot_sg_cco_bd_dev_info_transfer{
/* total node count */
uint16_t total_cnt;
/* start query index */
uint16_t start_index;
/* report node count */
uint8_t rpt_cnt;
/* physical topo node info */
iot_sg_cco_bd_dev_node_info_t node_info[0];
} iot_sg_cco_bd_dev_info_transfer_t;
typedef struct _iot_sg_ctrl_connect_evt_rpt {
/* connect state, 0 - disconnect, 1 - connect */
uint8_t state;
/* ctrl mac address, little endian */
uint8_t ctrl_mac[IOT_MAC_ADDR_LEN];
} iot_sg_ctrl_connect_evt_rpt_t;
typedef struct _iot_sg_cco_node_evt_ctrl_info {
/* sta mac, big endian */
uint8_t mac_addr[IOT_MAC_ADDR_LEN];
/* event report state, 0 - disable, 1 - enable */
uint8_t enable;
} iot_sg_cco_node_evt_ctrl_info;
typedef struct _iot_sg_cco_node_evt_rpt_ctrl {
/* node event report control info */
iot_sg_cco_node_evt_ctrl_info node_evt_ctrl[0];
} iot_sg_cco_node_evt_rpt_ctrl_t;
/* nw forward module read meter data info */
typedef struct _iot_sg_cco_nw_forward_module_info {
/* work code, see IOT_SG_CCO_TRANS_WORK_CODE_XXX */
uint8_t work_code;
/* work info */
uint8_t data[0];
} iot_sg_cco_nw_forward_module_info_t;
/* base element */
typedef struct _iot_sg_cco_base_sec_node_info {
/* element id */
uint8_t id;
/* element data length */
uint8_t data_len;
/* element data */
uint8_t data[0];
} iot_sg_cco_base_sec_node_info_t;
/* cco build version info */
typedef struct _iot_sg_cco_build_ver_info {
/* Build type: Release/Debug-(0/1) */
uint8_t type_ver;
/* numerically encoded version, like 0x01020304 */
uint32_t firmware_version;
/* external software version. BCD format. range from 0 - 9999 */
uint16_t sw_ver;
/* app software version. bin format. range from 0 - 1023 */
uint16_t app_ver;
/* build year */
uint8_t year;
/* build month */
uint8_t month;
/* build day */
uint8_t day;
/* build hour */
uint8_t hour;
/* build min */
uint8_t min;
/* build sec */
uint8_t sec;
/* vendor id */
uint16_t vendor_id;
/* device id */
uint8_t dev_id[IOT_SG_CCO_MODULE_ID_INFO_LEN];
/* chip management id */
iot_plc_chip_id_t chip_mmid;
/* image crc check result, 0 mean succeed, 1 mean fail */
uint8_t img_check_result : 1,
/* flag mark to if the device has branch signal receiving capability */
br_ident : 1,
/* flag mark to if enable rf */
rf : 1,
/* non 0 means broadcast packet sent in 3phase simultaneously, 0 means
* broadcast packet sent in 3phase in turn.
*/
tx_3phase_flag : 1,
/* reserve for future */
reserve : 4;
/* hardware version */
uint32_t hw_ver;
/* module mac address */
uint8_t mod_addr[IOT_MAC_ADDR_LEN];
/* user type, see USER_TYPE_XXX */
uint8_t user_type;
/* simple pair passcode value. Only same passcode CCO and STA can be
* associated, little endian.
*/
uint16_t passcode;
/* equipment service provider, see IOT_SG_CCO_ESP_XXX */
uint8_t esp;
} iot_sg_cco_build_ver_info_t;
typedef struct _iot_sg_cco_clct_task_addr {
/* sta collect parameter v2.8 task id */
uint8_t task_id;
/* task configuration address total address count */
uint16_t total_cnt;
/* report address count */
uint8_t cnt;
/* power meter address, little endian */
uint8_t pm_mac[0][IOT_MAC_ADDR_LEN];
} iot_sg_cco_clct_task_addr_t;
typedef struct _iot_sg_cco_clct_data_rpt {
/* sta collect parameter v2.8 task id */
uint8_t task_id;
/* power meter address, little endian */
uint8_t pm_mac[IOT_MAC_ADDR_LEN];
/* proto type, see PROTO_TYPE_XXX */
uint8_t proto_type;
/* time stamp, BCD code to represent */
uint8_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t min;
uint8_t sec;
/* sta collect data length */
uint16_t data_len;
/* sta collect data */
uint8_t data[0];
} iot_sg_cco_clct_data_rpt_t;
typedef struct _iot_sg_cco_edge_computing_set {
/* overvoltage monitor switch, 0 - open, others - close */
uint8_t overvoltage_switch;
/* overvoltage monitor threshold, unit is volt */
uint16_t overvoltage_threshold;
/* overvoltage monitor period, unit is 1min */
uint16_t overvoltage_period;
/* overvoltage collect abnormal report round */
uint8_t overvoltage_rpt_round;
/* undervoltage monitor switch, 0 - open, others - close */
uint8_t undervoltage_switch;
/* undervoltage monitor threshold, unit is volt */
uint16_t undervoltage_threshold;
/* undervoltage monitor period, unit is 1min */
uint16_t undervoltage_period;
/* undervoltage collect abnormal report round */
uint8_t undervoltage_rpt_round;
/* clock second pulse monitor switch, 0 - open, others - close */
uint8_t pulse_switch;
/* clock second pulse monitor threshold, unit is 1ms */
uint16_t pulse_threshold;
/* power meter health status monitor switch, 0 - open, others - close */
uint8_t health_status_switch;
/* power meter used time limit threshold, unit is year */
uint8_t used_limit_threshold;
} iot_sg_cco_edge_computing_set_t;
#pragma pack(pop) /* restore the pack status */
/* struct contain info of a secondary node */
typedef struct _iot_sg_pm_node_info {
/* meter address */
uint8_t meter_mac[IOT_MAC_ADDR_LEN];
/* sta address */
uint8_t sta_mac[IOT_MAC_ADDR_LEN];
/* protocol the node supports */
uint8_t proto_type;
/* 0: the node don't active register, 1: the node active register*/
uint8_t active_reg_flag : 1,
/* transformer status, see IOT_SG_CCO_PM_TO_TSFM_XXX */
tsfm_status : 4,
/* phase that device is connected to.
* bit0 set to 1 means device is connected to phase A.
* bit1 set to 1 means device is connected to phase B.
* bit2 set to 1 means device is connected to phase C.
*/
phase : 3;
/* phase type of three phase meter, see IOT_SG_CCO_PHASE_SEQ_XXX */
uint8_t phase_type : 3,
/* flag to mark if L/N reversed in Single-phase power meter or phase
* sequence reversed in Three-phase power meter.
*/
opposite_phase : 1,
/* reserved */
reserved : 4;
/* device type, see IOT_PLC_DEV_TYPE_XXX */
uint8_t dev_type;
} iot_sg_pm_node_info_t;
/* struct containing white list entry count information */
typedef struct _iot_sg_wl_cnt_info {
uint16_t max_node_count; /* max node count */
uint16_t node_count; /* current node count*/
}iot_sg_wl_cnt_info_t;
/* struct containing white list ii entry count information */
typedef struct _iot_sg_wlii_cnt_info {
uint16_t max_node_count; /* max node count */
uint16_t node_count; /* current node count*/
}iot_sg_wlii_cnt_info_t;
/* struct containing secondary node index information */
typedef struct _iot_sg_node_index_info {
uint16_t min_index; /* max node count */
uint16_t max_index; /* current node count*/
}iot_sg_node_index_info_t;
/* struct containing secondary node information */
typedef struct _iot_sg_node_info {
uint16_t total_count;
uint16_t count;
iot_sg_pm_node_info_t info[0];
}iot_sg_node_info_t;
typedef struct _iot_sg_phase_info {
/* For physical phase, if a field is nonzero,
* STA is connected with that phase.
*/
uint8_t phy_phase1 : 2,
phy_phase2 : 2,
phy_phase3 : 2,
/* flag to mark if L/N reversed in Single-phase power meter or phase
* sequence reversed in Three-phase power meter.
*/
opposite_phase : 1,
/* 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,
/* phase that device is connected to.
* bit0 set to 1 means device is connected to phase A.
* bit1 set to 1 means device is connected to phase B.
* bit2 set to 1 means device is connected to phase C.
*/
phase : 3,
/* phase type of three phase meter, see IOT_SG_CCO_PHASE_SEQ_XXX */
phase_type : 3;
/* For logical phase, phase1 is the most possible phase.
* phase3 is the least possible phase.
*/
uint8_t logical_phase1 : 2,
logical_phase2 : 2,
logical_phase3 : 2,
/* flag to mark if app phase info valid */
phase_info_valid : 1,
/* power meter type, 0: single phase, 1: three phase */
pm_type : 1;
}iot_sg_phase_info_t;
typedef struct _iot_sg_upgrade_info {
/* cco upgrade status see - IOT_SG_CCO_UPGRADE_ST_XXX */
uint32_t state;
/* file type - see IOT_FILE_TYPE_XXX */
uint32_t file_type;
/* file identity */
uint8_t id;
/* mac address of the STA being upgraded - (little endian) */
uint8_t sta_mac_addr[IOT_MAC_ADDR_LEN];
/* total block count of the upgrading file */
uint16_t block_cnt;
/* file size */
uint32_t size;
/* crc16 from cctt when receiving data from cctt. */
uint16_t crc;
/* received block count */
uint16_t recv_cnt;
} iot_sg_upgrade_info_t;
typedef struct _iot_sg_upgrade_statistics {
/* total count of sta will being upgrading */
uint16_t total_cnt;
/* count of sta that is started */
uint16_t start_cnt;
/* count of sta is skiped , not upgrade */
uint16_t skip_cnt;
/* count of sta finished upgrade */
uint16_t finish_cnt;
/* count of sta upgrading */
uint16_t upgrading_cnt;
/* count of sta renew sw version done */
uint16_t renew_sw_cnt;
} iot_sg_upgrade_statistics_t;
typedef struct _iot_sg_cco_net_info {
/* communication mode, see IOT_SG_CCO_COMM_MOD_XXX */
uint8_t comm_mode;
/* time of joined network */
uint8_t join_sec;
uint8_t join_min;
uint8_t join_hour;
uint8_t join_day;
uint8_t join_mon;
uint8_t join_year;
/* flag to mark if the sec node in the network */
uint8_t in_net;
/* cost time from power on to join network, unit is 1s */
uint32_t cost_time;
} iot_sg_cco_net_info_t;
typedef struct _iot_sg_cco_net_node_info {
/* node addr, little-endian. */
uint8_t addr[IOT_MAC_ADDR_LEN];
/* phase that device is connected to.
* bit0 set to 1 means device is connected to phase A.
* bit1 set to 1 means device is connected to phase B.
* bit2 set to 1 means device is connected to phase C.
*/
uint8_t phase : 3,
/* phase type of three phase meter, see IOT_SG_CCO_PHASE_SEQ_XXX */
phase_type : 3,
/* power meter type, 0: single phase, 1: three phase */
pm_type : 1,
/* flag to mark if node support minute collection */
minute_clct : 1;
/* physical phase of the station */
uint8_t phy_phase1 : 2,
phy_phase2 : 2,
phy_phase3 : 2,
/* flag to mark if L/N reversed in Single-phase power meter or phase
* sequence reversed in Three-phase power meter.
*/
opposite_phase : 1,
/* flag to mark if L/N reversed in Three-phase power meter */
opposite_3p : 1;
/* flag to mark if have super capacitance */
uint8_t super_cap : 1,
/* flag to mark if could fix position */
fix_position : 1,
/* station detect status, see IOT_SG_CCO_PM_TO_TSFM_XXX */
tsfm_status : 4,
/* mac address type, see IOT_PLC_MAC_ADDR_TYPE_XXX */
addr_type : 2;
/* type of dev the STA module attached, see IOT_PLC_DEV_TYPE_XXX */
uint8_t dev_type;
/* uplink signal quality, valid for sec node */
uint8_t ul_quality : 4,
/* downlink signal quality, valid for sec node */
dl_quality : 4;
/* external, software version */
uint16_t sw_version;
/* internal software version */
uint32_t build_sw_ver;
/* boot version */
uint8_t boot_ver;
/* 2 bytes for vendor id */
uint16_t vendor_id;
/* chip id */
iot_plc_chip_id_t chip_id;
/* network info of the node */
iot_sg_cco_net_info_t net_info;
/* software build time */
uint16_t build_time_y : 7,
build_time_m : 4,
build_time_d : 5;
/* chip code */
uint16_t chip_code;
/* type of getting module id, see IOT_SG_CCO_GET_MOD_ID_TYPE_XXX */
uint8_t recv_result_type : 2,
/* reserved for future */
rsvd : 6;
/* module id information for gw,
* module mac addr, big-endian, for nw.
*/
uint8_t module_id_info[IOT_SG_CCO_MODULE_ID_INFO_LEN];
/* node tei value */
uint16_t tei;
/* software module version */
uint16_t sw_mod_version;
/* release date of sw module version */
uint8_t sw_mod_date[IOT_SG_CCO_VER_DATE_LENGTH];
/* software chip version */
uint16_t sw_chip_version;
/* release date of sw chip version */
uint8_t sw_chip_date[IOT_SG_CCO_VER_DATE_LENGTH];
/* hardware module version */
uint16_t hw_mod_version;
/* release date of hw module version */
uint8_t hw_mod_date[IOT_SG_CCO_VER_DATE_LENGTH];
/* hardware chip version */
uint16_t hw_chip_version;
/* release date of hw chip version */
uint8_t hw_chip_date[IOT_SG_CCO_VER_DATE_LENGTH];
/* app version */
uint16_t app_version;
} iot_sg_cco_net_node_info_t;
typedef struct _iot_sg_cco_reject_bl_node_info {
/* node mac addr, big endian */
uint8_t node_addr[IOT_MAC_ADDR_LEN];
} iot_sg_cco_reject_bl_node_info_t;
typedef struct _iot_sg_cco_lp_meter_info {
/* node addr, little-endian. */
uint8_t addr[IOT_MAC_ADDR_LEN];
/* tei of the station */
uint16_t sta_tei;
/* tei of the proxy */
uint16_t proxy_tei;
/* level of the station */
uint8_t level;
/* role of the station */
uint8_t role;
} iot_sg_cco_lp_meter_info_t;
/* branch identification control parameter structure */
typedef struct _iot_sg_cco_bd_ctrl {
/* branch detect type, see IOT_SG_CCO_BD_TYPE_XXX */
uint8_t bd_type;
/* branch detect mod, see IOT_SG_CCO_BD_MOD_XXX */
uint8_t bd_mod;
} iot_sg_cco_bd_ctrl_t;
typedef struct _iot_sg_cco_info_rpt {
/* flag to mark if sequence reversed. */
uint8_t opposite_phase :1,
/* physical phase of the station, see PROTO_SG_PHASE_XXX */
phy_phase1 :2,
/* reserved */
reserved :5;
} iot_sg_cco_info_rpt_t;
typedef struct _iot_sg_cco_uart_conf {
/* uart baud rate type, see IOT_SG_CCO_BAUD_IDX_XXX */
uint8_t baud_rate :7,
/* flag to mark if set uart baud rate type */
baud_rate_flag :1;
/* uart baud max rate type */
uint8_t max_baud_rate :7,
/* flag to mark if set uart max baud rate type */
max_baud_rate_flag :1;
/* uart baud rate recover time, unit is 1min */
uint16_t rec_time :15,
/* flag to mark if set recover time */
rec_time_flag :1;
/* hardware reset cnt for error baud rate */
uint8_t reset_cnt :7,
/* flag to mark if set reset cnt */
reset_cnt_flag :1;
} iot_sg_cco_uart_conf_t;
typedef struct _iot_sg_cco_node_base_info {
/* node mac addr, little endian */
uint8_t pm_addr[IOT_MAC_ADDR_LEN];
/* base info */
uint8_t data[0];
} iot_sg_cco_node_base_info_t;
typedef struct _iot_sg_cco_base_sec_node_info_ul {
/* current ack count of the secondary node */
uint8_t ack_node_count;
/* element info */
uint8_t element;
/* node base info */
//iot_sg_cco_node_base_info_t base_info[0];
} iot_sg_cco_base_sec_node_info_ul_t;
/**
* @brief function callback to init driver.
* @return: 0 - success.
* @return: otherwise - error code.
*/
typedef uint32_t(*iot_sg_cco_drv_init_func_t)();
/* function callback to deinit driver */
typedef void(*iot_sg_cco_drv_deinit_func_t)();
typedef void(*iot_sg_cco_drv_timer_func_t)();
/**
* @brief function callback for CCo to send report meter data to driver/CLI.
* @param data: report meter data.
* @param len: length of the data.
* @param cmd_info: information of the meter reading command.
* for gw, it's afn. for nw, it's task id.
* @param sn: concentrator cmd sn.
* @param proto_type: proto type of data.
* @param mac_field: address field of meter.
* @param mr_result: read meter result, see IOT_SG_CCO_MR_xxx.
* @param plc_cost: time cost in PLC line for read meter. unit is 1ms.
* @param mr_type: meter read type, see IOT_SG_RMT_XXX
* @param intf_type: interface of calling this API.
* see IOT_SG_CALLER_TYPE_XXX.
*/
typedef uint32_t(*iot_sg_cco_drv_report_meter_data_func_t)(uint8_t *data,
uint16_t len, uint32_t cmd_info, uint16_t sn, uint32_t proto_type,
uint8_t *mac_field, uint8_t mr_result, uint32_t plc_cost, uint8_t mr_type,
uint8_t intf_type);
/**
* @brief function callback for CCo to send event report data from power.
* @param sn: sequence number for a packet.
* @param pm_addr: meter addr of event reporting
* @param dev_type: device type, see IOT_SG_CCO_DEV_TYPE_XXX.
* @param proto_type: proto type of data.
* @param evt_type: event type, see IOT_SG_CCO_EVENT_XXX.
* @param data: event report data.
* @param len: length of the data.
* @param retval: ERR_OK - support event type, others - no support event
* type, delete entry from the ul buf.
*/
typedef uint32_t(*iot_sg_cco_drv_event_report_data_func_t)(uint8_t sn,
uint8_t *pm_addr, uint8_t dev_type, uint32_t proto_type,
uint8_t evt_type, uint8_t *data, uint16_t len);
/**
* @brief function callback for CCo to send report secondary nodes info to
* driver.
* @param sn: sequence number for a 3762 packet.
* @param index: index of meter in table.
* @param data: report secondary nodes info data.
*/
typedef uint32_t(*iot_sg_cco_drv_report_sec_node_data_func_t)(uint8_t sn,
uint16_t index, sec_node_query_t *data);
/**
* @brief function callback for CCo to send topo info to driver.
* @param req_id: request id of data to report.
* @param data: topo info data.
*/
typedef uint32_t(*iot_sg_cco_drv_topo_data_func_t)(uint8_t req_id,
iot_plc_nw_topo_rpt_t *data);
/**
* @brief function callback for CCo to send neighbour network info to driver.
* @param req_id: request id of data to report.
* @param data: neighbour network info data.
*/
typedef uint32_t(*iot_sg_cco_drv_neighbour_net_data_func_t)(uint8_t req_id,
iot_sg_nb_nw_rpt_t *data);
/**
* @brief function callback for CCo to send frequency band info to driver.
* @param req_id: request id of data to report.
* @param req: the pointer of data to report.
*/
typedef uint32_t(*iot_sg_cco_drv_freq_band_data_func_t)(uint8_t req_id,
iot_plc_freq_band_info_query_rpt_t* req);
/**
* @brief function callback for CCo to send frequency band info to driver.
* @param req_id: request id of data to report.
* @param result: the result of frequency band be set.
*/
typedef uint32_t(*iot_sg_cco_drv_freq_band_set_result_func_t)(uint8_t req_id,
uint8_t result);
/**
* @brief function callback for CCo to send rf channel info to driver.
* @param req_id: request id of data to report.
* @param result: the result of rf channel be set.
*/
typedef uint32_t(*iot_sg_cco_drv_rf_channel_set_ret_func_t)(uint8_t req_id,
uint8_t result);
/**
* @brief function callback for CCo set hplc/rf power info to driver.
* @param req_id: request id of data to report.
* @param result: the result of rf channel be set.
*/
typedef uint32_t(*iot_sg_cco_drv_tx_power_set_ret_func_t)(uint8_t req_id,
uint8_t result);
/**
* @brief function to handle data from UART/Concentrator.
* @param channel: data sources, see IOT_SG_CCO_LOCAL_PROTO_DATA_SOURCE_XXX.
* @param pkt: iot_pkt containing data to be process.
* @param ntb: ntb for recv the message.
*/
typedef uint32_t(*iot_sg_cco_drv_cctt_data_func_t)(uint8_t channel,
iot_pkt_t *pkt, uint32_t ntb);
/**
* @brief function callback for CCo to send frequency band info to driver.
* @param sn: sequence number for a 3762 packet.
* @param result: the result of router status change.
* @param intf_type: interface of calling this API.
* see IOT_SG_CALLER_TYPE_XXX.
*/
typedef void(*iot_sg_cco_drv_report_router_status_change)(uint8_t sn,
uint8_t result, uint8_t intf_type);
/**
* @brief function callback for CCo to check if report the sta state change.
* @param state: sta state, see IOT_SG_CCO_STA_STATE_XXX.
* @param sta_mac: station mac address, big-endian.
* @return: 1 - need to report.
* @return: 0 - don't need to report.
*/
typedef uint8_t (*iot_sg_cco_drv_report_sta_state_chg)(uint8_t state,
uint8_t *sta_mac);
/**
* @brief function callback for CCo to network info to driver.
* @param req_id: request id of data to report.
* @param rpt: basic network info report.
*/
typedef void(*iot_sg_cco_drv_report_nw_info_func_t)(
uint8_t req_id, iot_plc_nw_info_query_rpt_t *rpt);
/**
* @brief function callback for reporting transformer detect result
* @param pm_mac: power meter mac address, little-endian.
* @param tsfm_addr: station real transformer mac address, big-endian.
* @param tsfm_status: transformer detect result,
* see IOT_SG_CCO_PM_TO_TSFM_XXX.
* @param dev_type: device type, see IOT_PLC_DEV_TYPE_XXX.
*/
typedef void(*iot_sg_cco_drv_rpt_tsfm_detect_ret)(uint8_t *pm_mac,
uint8_t *tsfm_addr, uint8_t tsfm_status, uint8_t dev_type);
/**
* @brief function callback for notification status change.
* @param curr_state: cco's current state, see IOT_SG_CCO_STATE_XXX.
* @param next_state: cco's next state, see IOT_SG_CCO_STATE_XXX.
* @param cert_flag_chg: pointer to cert flag if the cert flag is changed.
*/
typedef void(*iot_sg_cco_status_chg_func_t)(uint8_t curr_state,
uint8_t next_state, uint8_t *cert_flag_chg);
/**
* @brief function callback for check the meter read availability
* @param mr_type: type of the read data.
* @return: 0 - the data is invalid, otherwise - the data is valid.
*/
typedef uint8_t(*iot_sg_cco_mr_data_valid_func_t)(uint8_t mr_type,
uint8_t *pm_addr);
/**
* @brief function callback for CCO to send muti-nodes' info to driver.
* @param req_id: request id of data to report.
* @param rpt: nodes' info data.
*/
typedef void(*iot_sg_cco_drv_rpt_node_info_func_t)(uint8_t req_id,
iot_plc_node_info_rpt_t *rpt);
/**
* @brief function callback for router request meter reading.
* @param phase: power meter phase
* @param mac: power meter mac address, little-endian
* @param index: power meter index
* @param obj_type: communication object type, see PROTO_3762_FJ_OBJ_XXX
* @param intf_type: interface of calling this API. see IOT_SG_CALLER_TYPE_XXX.
*/
typedef void(*iot_sg_cco_drv_rt_request_mr_func_t)(uint8_t phase, uint8_t *mac,
uint16_t index, uint8_t obj_type, uint8_t intf_type);
/**
* @brief function callback for reporting transformer detect is finished.
* @param tsfm_is_timeout: flag to mark if tsfm done by timeout.
*/
typedef void(*iot_sg_cco_drv_tsfm_detect_done_func_t)(uint8_t tsfm_is_timeout);
/**
* @brief function callback for reporting the node that be rejected join network
* @param node: the node information.
*/
typedef void(*iot_sg_cco_drv_reject_join_node_func_t)(
iot_plc_sta_join_rejected_t *node);
/**
* @brief function callback for passthrough data to cctt
* @param data: data from app, the data will be free in function.
* @return: 0 - success.
* @return: otherwise - error code.
*/
typedef uint32_t (*iot_sg_cco_drv_passthrough_to_cctt_func_t)(iot_pkt_t *data);
/**
* @brief function callback to notify driver that timer fired.
*/
typedef void (*iot_sg_cco_drv_timer_func_t)();
/**
* @brief function callback for network formation is done.
*/
typedef void (*iot_sg_cco_drv_nw_fmt_done_t)();
/**
* @brief function callback for sec node state change report.
* @param sn: sequence number for a data packet.
* @param node_chg: the pointer of node state change data to report.
*/
typedef void (*iot_sg_cco_drv_node_state_chg_rpt_t)(uint8_t sn,
sec_node_state_chg_t *node_chg);
/**
* @brief function callback for CCo to send neighbor dev info to driver.
* @param req_id: request id of data to report.
* @param rpt: neighbor dev info.
*/
typedef void (*iot_sg_cco_drv_neighbor_dev_report_t)(uint8_t req_id,
iot_plc_neighbor_dev_rpt_t *rpt);
/**
* @brief function callback for CCo to send phase info to driver.
* @param req_id: request id of data to report.
* @param rpt: cco phase info.
*/
typedef void (*iot_sg_cco_drv_info_report_t)(uint8_t req_id,
iot_sg_cco_info_rpt_t *rpt);
/**
* @brief function callback to bcast task report.
* @param done: flag to mark if bcast task is done, 0 - bcast task is doing,
* should to send bcast in current, 1 - bcast task is done,
* should to stop bcast task.
*/
typedef void (*iot_sg_cco_drv_bcast_task_rpt_t)(uint8_t done);
/* smart grid cco role driver descriptor */
typedef struct _iot_sg_cco_drv {
/* id of the driver. see IOT_SG_cco_DRV_ID_INVALID */
uint16_t drv_id;
/* supported data type mask. see GW_APP_DATA_TYPE_MASK_XXX */
uint16_t data_type_mask;
/* driver required headroom for each request packet */
uint8_t headroom;
/* driver operation function callbacks */
iot_sg_cco_drv_init_func_t init;
iot_sg_cco_drv_deinit_func_t deinit;
iot_sg_cco_drv_report_meter_data_func_t meter_data_report_cb;
iot_sg_cco_drv_event_report_data_func_t event_data_report_cb;
iot_sg_cco_drv_report_sec_node_data_func_t sec_node_report_cb;
iot_sg_cco_drv_topo_data_func_t topo_report_cb;
iot_sg_cco_drv_neighbour_net_data_func_t neighbour_net_report_cb;
iot_sg_cco_drv_freq_band_data_func_t freq_band_report_cb;
iot_sg_cco_drv_report_nw_info_func_t nw_info_rpt_cb;
iot_sg_cco_drv_freq_band_set_result_func_t freq_band_set_result_report_cb;
iot_sg_cco_drv_rf_channel_set_ret_func_t rf_channel_set_result_report_cb;
iot_sg_cco_drv_tx_power_set_ret_func_t tx_power_set_result_report_cb;
iot_sg_cco_drv_report_router_status_change report_router_status_change;
iot_sg_cco_drv_cctt_data_func_t cctt_data_handler;
iot_sg_cco_drv_timer_func_t timer1_func;
iot_sg_cco_drv_timer_func_t timer2_func;
iot_sg_cco_drv_timer_func_t timer3_func;
iot_sg_cco_drv_timer_func_t timer4_func;
iot_sg_cco_drv_timer_func_t timer5_func;
iot_sg_cco_drv_timer_func_t timer6_func;
iot_sg_cco_drv_timer_func_t log_to_flash_timer_func;
iot_sg_cco_drv_report_sta_state_chg sta_state_chg_cb;
iot_sg_cco_drv_rpt_tsfm_detect_ret rpt_tsfm_detect_ret_cb;
iot_sg_cco_status_chg_func_t cco_status_chg_cb;
iot_sg_cco_mr_data_valid_func_t mr_data_valid_cb;
iot_sg_cco_drv_rpt_node_info_func_t node_info_rpt_cb;
iot_sg_cco_drv_rt_request_mr_func_t rt_request_mr_cb;
iot_sg_cco_drv_tsfm_detect_done_func_t tsfm_detect_done_cb;
iot_sg_cco_drv_reject_join_node_func_t reject_join_cb;
iot_sg_cco_drv_passthrough_to_cctt_func_t passthrough_to_cctt_cb;
iot_sg_cco_drv_nw_fmt_done_t nw_fmt_done_cb;
iot_sg_cco_drv_node_state_chg_rpt_t node_state_chg_cb;
iot_sg_cco_drv_neighbor_dev_report_t neighbor_dev_report_cb;
iot_sg_cco_drv_info_report_t cco_info_report_cb;
iot_sg_cco_drv_bcast_task_rpt_t cco_rpt_bcast_result_cb;
} iot_sg_cco_drv_t;
#if (PLC_SUPPORT_CCO_ROLE && IOT_SMART_GRID_ENABLE)
/**
* @brief iot_sg_cco_send_uart() - send iot_pkt_t data to uart.
* @param pkt: the iot_pkt_t data to be sent to uart.
* @param channel: data sources, see IOT_SG_CCO_LOCAL_PROTO_DATA_SOURCE_XXX
* @return: ERR_OK for success case.
* @return: other value for failed case. See ERR_XXX.
*/
uint32_t iot_sg_cco_send_uart(iot_pkt_t *pkt, uint8_t channel);
/**
* @brief iot_sg_cco_start_driver_timer1() - function callback to allow
* device driver to request smart grid app to start the driver timer.
* once timer fired, smart grid app will
* call iot_sg_cco_drv_timer_func_t to notify driver.
* @param dur: duration of the timer. the unit is 1 ms.
* @return: ERR_OK - for timer started successfully case.
* @return: otherwise - error code.
*/
uint32_t iot_sg_cco_start_driver_timer1(uint32_t dur);
/**
* @brief iot_sg_cco_stop_driver_timer1() - function callback to allow device
* driver to request smart grid app to stop the driver timer.
*/
void iot_sg_cco_stop_driver_timer1();
/**
* @brief iot_sg_cco_start_driver_timer2() - function callback to allow
* device driver to request smart grid app to start the driver timer.
* once timer fired, smart grid app will
* call iot_sg_cco_drv_timer_func_t to notify driver.
* @param dur: duration of the timer. the unit is 1 ms.
* @return: ERR_OK - for timer started successfully case.
* @return: otherwise - error code.
*/
uint32_t iot_sg_cco_start_driver_timer2(uint32_t dur);
/**
* @brief iot_sg_cco_stop_driver_timer2() - function callback to allow device
* driver to request smart grid app to stop the driver timer.
*/
void iot_sg_cco_stop_driver_timer2();
/**
* @brief iot_sg_cco_stop_driver_timer3() - function callback to allow device
* driver to request CCO framework to stop the driver timer 3.
*/
void iot_sg_cco_stop_driver_timer3(void);
/**
* @brief iot_sg_cco_restart_driver_timer3() - function callback to allow
* device driver to request CCO framework
* to restart the driver timer3. once timer fired, CCO framework
* will call timer3_func to notify driver.
* @param dur: duration, unit is 1ms.
*/
void iot_sg_cco_restart_driver_timer3(uint32_t dur);
/**
* @brief iot_sg_cco_start_driver_timer4() - function callback to allow
* device driver to request smart grid app to start the driver timer.
* once timer fired, smart grid app will
* call iot_sg_cco_drv_timer_func_t to notify driver.
* @param dur: duration of the timer. the unit is 1 ms.
* @return: ERR_OK - for timer started successfully case.
* @return: otherwise - error code.
*/
uint32_t iot_sg_cco_start_driver_timer4(uint32_t dur);
/**
* @brief iot_sg_cco_stop_driver_timer4() - function callback to allow device
* driver to request smart grid app to stop the driver timer.
*/
void iot_sg_cco_stop_driver_timer4();
/**
* @brief iot_sg_cco_start_driver_timer5() - function callback to allow
* device driver to request smart grid app to start the driver timer.
* once timer fired, smart grid app will
* call iot_sg_cco_drv_timer_func_t to notify driver.
* @param dur: duration of the timer. the unit is 1 ms.
* @return: ERR_OK - for timer started successfully case.
* @return: otherwise - error code.
*/
uint32_t iot_sg_cco_start_driver_timer5(uint32_t dur);
/**
* @brief iot_sg_cco_stop_driver_timer5() - function callback to allow device
* driver to request smart grid app to stop the driver timer.
*/
void iot_sg_cco_stop_driver_timer5();
/**
* @brief iot_sg_cco_restart_driver_timer5() - function callback to allow
* device driver to request CCO framework
* to restart the driver timer5. once timer fired, CCO framework
* will call timer5_func to notify driver.
* @param dur: duration, unit is 1ms.
*/
void iot_sg_cco_restart_driver_timer5(uint32_t dur);
/**
* @brief iot_sg_cco_start_driver_timer6() - function callback to allow
* device driver to request smart grid app to start the driver timer.
* once timer fired, smart grid app will
* call iot_sg_cco_drv_timer_func_t to notify driver.
* @param dur: duration of the timer. the unit is 1 ms.
* @return: ERR_OK - for timer started successfully case.
* @return: otherwise - error code.
*/
uint32_t iot_sg_cco_start_driver_timer6(uint32_t dur);
/**
* @brief iot_sg_cco_stop_driver_timer6() - function callback to allow device
* driver to request smart grid app to stop the driver timer.
*/
void iot_sg_cco_stop_driver_timer6();
/**
* @brief iot_sg_get_meter_info_by_mac() - get meter info by mac address.
* @param pm_mac: mac address of power meter.
* @param info: node info argument to store meter info.
* @return: 0 - success.
* @return: otherwise - error code.
*/
uint32_t iot_sg_get_meter_info_by_mac(uint8_t *pm_mac,
iot_sg_pm_node_info_t *info);
/**
* @brief - get destination power meter mac address from meter reading package
* @param pm_mac: buffer to receive power meter address
* @param data: meter reading package
* @param len: length of data
* @param proto_type: protocol type of the datagram
* @return: ERR_OK - successful case.
* ERR_XXX for failed case.
*/
uint32_t iot_sg_cco_get_mr_pkt_mac(uint8_t *pm_mac, uint8_t *data, uint16_t len,
uint8_t proto_type);
/**
* @brief iot_sg_set_pm_active_reg_flag_by_mac() - set the flag of power meter
* active register by mac address.
* @param pm_mac: mac address of power meter.
* @param value: flag argument to store meter info.
*/
void iot_sg_set_pm_active_reg_flag_by_mac(uint8_t *pm_mac, uint8_t value);
/**
* @brief iot_sg_set_pm_active_reg_flag_by_index() - set the flag of power
* meter active register by meter index.
* @param node_index: the index of sec node.
* @param value: flag argument to store meter info.
* @return: ERR_OK - success.
* @return: ERR_INVAL - error code.
*/
uint32_t iot_sg_set_pm_active_reg_flag_by_index(uint16_t node_index,
uint8_t value);
/**
* @brief iot_sg_get_sta_index_by_mac() - get the index of station by mac.
* @param pm_mac: mac address of power meter.
* @return: the index of station in map.
*/
uint32_t iot_sg_get_sta_index_by_mac(uint8_t *sta_mac);
/**
* @brief iot_sg_cco_set_rt_mr_result() - set the route meter read result by
* meter index.
* @param node_index: meter read index.
* @param result: meter read result.
* @return: ERR_OK - for success case.
* @return: ERR_INVAL - for failed case.
*/
uint32_t iot_sg_cco_set_rt_mr_result(uint16_t node_index, uint8_t result);
/**
* @brief iot_sg_start_sec_node_reg() - start secondary node registration.
* @param intf_type: interface of calling this API. see IOT_SG_CALLER_TYPE_XXX.
* @param duration: secondary node registration duration, uint is 1s.
* @param count: max sec node count of one frame data for report to cctt.
* @param auto_stop: secondary node registration auto stop flag,
* 0 - not need auto stop, 1 - need auto stop.
* @return: ERR_OK for successful case, ERR_XXX for failed case.
*/
uint32_t iot_sg_start_sec_node_reg(uint8_t intf_type, uint32_t duration,
uint8_t count, uint8_t auto_stop);
/**
* @brief iot_sg_stop_sec_node_reg() - stop secondary node registration.
* @param intf_type: interface of calling this API. see IOT_SG_CALLER_TYPE_XXX.
* @param reason: the reason of the stop cmd.
* @return: ERR_OK for successful case, ERR_XXX for failed case.
*/
uint32_t iot_sg_stop_sec_node_reg(uint8_t intf_type, uint8_t reason);
/**
* @brief iot_sg_cco_recv_ack_to_report() - handle ack from cctt for event
* report & sec node register report.
* it trigger CCo to report next data/sec node immediately.
* @param really_ack: receive ack? 1 - yes, 0 - no.
* @param sn: sequence number of 3762 package.
*/
void iot_sg_cco_recv_ack_to_report(uint8_t really_ack, uint8_t sn);
/**
* @brief iot_sg_comm_test() - communication test.
* @param intf_type: interface of calling this API. see IOT_SG_CALLER_TYPE_XXX.
* @param meter_mac: mac address of the power meter.
* @param data_type: protocol type of the meter for communication test.
* @param data: data for communication test.
* @param len: length of the data.
* @param sn: sequence of the communication test command from
* concentrator.
*/
void iot_sg_comm_test(uint8_t intf_type, uint8_t *meter_mac,
uint8_t data_type, uint8_t *data, uint16_t len, uint16_t sn);
/**
* @brief iot_sg_evt_rpt_ctrl() - control event report.
* @param intf_type: interface of calling this API. see
* IOT_SG_CALLER_TYPE_XXX.
* @param enable_flag: to enable or disable event report function.
*/
void iot_sg_evt_rpt_ctrl(uint8_t intf_type, uint8_t enable_flag);
/**
* @brief if allow to report event.
* @return: 0 - not allow, 1 - allow.
*/
uint8_t iot_sg_cco_get_evt_rpt_state();
/**
* @brief iot_sg_broadcast_data() - broadcast data to all power meters.
* @param intf_type: interface of this API. see IOT_SG_CALLER_TYPE_XXX.
* @param data_type: protocol type of the meter reading data.
* @param data: data to broadcast.
* @param len: length of the data.
* @param sta_mac: sta mac address, big endian.
*/
void iot_sg_broadcast_data(uint8_t intf_type, uint8_t data_type,
uint8_t *data, uint16_t len, uint8_t *sta_mac);
/**
* @brief iot_sg_cco_correct_sta_time() - broadcast correct sta time data to all
* sta modules.
* @param intf_type: interface of this API. see IOT_SG_CALLER_TYPE_XXX.
* @param data_type: protocol type of the broadcast data.
* @param data: data to broadcast.
* @param len: length of the data.
* @param bcast_type: bcast type, see IOT_SG_CCO_BCAST_TYPE_XXX.
* @param ntb: ntb for recv correct time message.
*/
void iot_sg_cco_correct_sta_time(uint8_t intf_type, uint8_t data_type,
uint8_t *data, uint16_t len, uint8_t bcast_type, uint32_t ntb);
/*
* @brief: remove all white list ii entry.
*/
void iot_sg_cco_clear_all_wlii_addr();
/**
* @brief iot_sg_cco_clear_all_wl_addr() - remove all address from white list.
*/
void iot_sg_cco_clear_all_wl_addr();
/**
* @brief iot_sg_cco_add_wl_addr() - add address into whitelist.
* @param intf_type: interface of calling this API. see IOT_SG_CALLER_TYPE_XXX.
* @param iot_pkt: the iot_pkt_t data to add whilte list.
*/
void iot_sg_cco_add_wl_addr(uint8_t intf_type, iot_pkt_t *iot_pkt);
/**
* @brief iot_sg_cco_add_bl_addr() - add address into blacklist.
* @param intf_type: interface of calling this API. see IOT_SG_CALLER_TYPE_XXX.
* @param iot_pkt: the iot_pkt_t data to add black list.
*/
void iot_sg_cco_add_bl_addr(uint8_t intf_type, iot_pkt_t *iot_pkt);
/**
* @brief iot_sg_cco_add_wlii_addr() - add address into whitelist ii.
* @param intf_type: interface of calling this API. see IOT_SG_CALLER_TYPE_XXX.
* @param iot_pkt: the iot_pkt_t data to add whilte list ii.
*/
void iot_sg_cco_add_wlii_addr(uint8_t intf_type, iot_pkt_t *iot_pkt);
/**
* @brief iot_sg_cco_remove_wl_addr() - remove address from whitelist.
* @param intf_type: interface of calling this API.
* see IOT_SG_CALLER_TYPE_XXX.
* @param entry_count: entry count.
* @param mac_addr_array: mac address array to be removed from whitelist.
*/
void iot_sg_cco_remove_wl_addr(uint8_t intf_type, uint8_t entry_count,
uint8_t * mac_addr_array);
/**
* @brief iot_sg_cco_remove_bl_addr() - remove address into blacklist.
* @param intf_type: interface of calling this API. see IOT_SG_CALLER_TYPE_XXX.
* @param iot_pkt: the iot_pkt_t data to add black list.
*/
void iot_sg_cco_remove_bl_addr(uint8_t intf_type, iot_pkt_t *iot_pkt);
/**
* @brief iot_sg_cco_clean_bl_addr() - remove address into blacklist.
* @param intf_type: interface of calling this API. see IOT_SG_CALLER_TYPE_XXX.
*/
void iot_sg_cco_clean_bl_addr(uint8_t intf_type);
/**
* @brief iot_sg_cco_remove_wlii_addr() - remove address from whitelist ii.
* @param intf_type: interface of calling this API.
* see IOT_SG_CALLER_TYPE_XXX.
* @param entry_count: entry count.
* @param mac_addr_array: mac address array to be removed from whitelist.
*/
void iot_sg_cco_remove_wlii_addr(uint8_t intf_type, uint8_t entry_count,
uint8_t * mac_addr_array);
/**
* @brief iot_sg_route_control() - route control / set route state.
* @param intf_type: interface of calling this API. see IOT_SG_CALLER_TYPE_XXX.
* @param op: operation on router - pause / resume / restart.
*/
void iot_sg_route_control(uint8_t intf_type, uint8_t op);
/**
* @brief iot_sg_cco_get_cctt_proto() - get cctt proto proto.
* see IOT_SG_CCO_CCTT_PROTO_XXX.
* @return: proto id.
*/
uint8_t iot_sg_cco_get_cctt_proto();
/**
* @brief: iot_sg_cco_get_rt_read_meter_flag() - get router read meter flag.
* @return: 0 - disable route read meter.
* @return: 1 - enable route read meter.
*/
uint8_t iot_sg_cco_get_rt_read_meter_flag();
/**
* @brief: get whitelist enabled status
* @return: 0 - whitelist is disabled
* @return: otherwise - whitelist is enabled
*/
uint32_t iot_sg_cco_wl_is_enabled();
/**
* @brief: get white list entry count.
* @return: number of white list entry count.
*/
uint32_t iot_sg_cco_get_wl_cnt();
/**
* @brief: get white list ii entry count.
* @return: number of white list ii entry count.
*/
uint32_t iot_sg_cco_get_wlii_cnt();
/**
* @brief: get white list information.
* @param info: node count info argument to store count info.
* @return: ERR_OK - for successfully case.
* @return: other value for failed case.
*/
uint32_t iot_sg_cco_get_wl_cnt_info(iot_sg_wl_cnt_info_t *info);
/**
* @brief: get white list ii information.
* @param info: node count info argument to store count info.
* @return: ERR_OK - for successfully case.
* @return: other value for failed case.
*/
uint32_t iot_sg_cco_get_wlii_cnt_info(iot_sg_wlii_cnt_info_t *info);
/**
* @brief iot_sg_cco_get_meter_index_info() - get meter index info.
* @param info: node index info argument to store count info.
* @return: ERR_OK - for successfully case.
* @return: other value for failed case.
*/
uint32_t iot_sg_cco_get_meter_index_info(iot_sg_node_index_info_t *info);
/**
* @brief iot_sg_cco_reset_parameter_info() - clear parameter info include
* sec_node_info, sec_node_relay_info ...
*/
void iot_sg_cco_reset_parameter_info();
/**
* @brief iot_sg_cco_reset_communication_info() - clear communication info,
* include sec_node_info, phase, relay_level, signal_quality ...
*/
void iot_sg_cco_reset_communication_info();
/**
* @brief iot_sg_cco_reset_wlii() - clear white list ii.
*/
void iot_sg_cco_reset_wlii();
/**
* @brief get white list entry information
* @param start_index: get wl entry info start from this index.
* @param count: max count of white list entry to be returned.
* @return: NULL - for failed case.
* @return: otherwise - an IOT_PKT_T with an array of type
* iot_sg_wl_entry_info_t.
*/
iot_pkt_t* iot_sg_cco_get_wl_entry_info(uint32_t start_index, uint32_t count);
/**
* @brief get white list entry ii information
* @param start_index: get wl ii entry info start from this index.
* @param count: max count of white list ii entry to be returned.
* @return: NULL - for failed case.
* @return: otherwise - an IOT_PKT_T with an array of type
* iot_sg_wlii_entry_info_t.
*/
iot_pkt_t* iot_sg_cco_get_wlii_entry_info(uint32_t start_index,
uint32_t count);
/**
* @brief get branch detect device entry information
* @param start_index: get branch detect entry info start from this index.
* @param count: max count of branch detect entry to be returned.
* @return: NULL - for failed case.
* @return: otherwise - an IOT_PKT_T with an array of type
* iot_sg_cco_bd_dev_info_transfer_t.
*/
iot_pkt_t *iot_sg_cco_get_bd_dev_entry_info(uint16_t start_index,
uint16_t count);
/**
* @brief iot_sg_cco_get_wl_info_by_index() - get node info.
* @param node_index: get meter info start from this index.
* @param node_info: information of the white list entry
* @return: ERR_OK - success.
* @return: ERR_INVAL - failed.
*/
uint32_t iot_sg_cco_get_wl_info_by_index(uint16_t node_index,
iot_sg_wl_entry_info_t* node_info);
/**
* @brief iot_sg_cco_get_meter_by_mac() - get node info.
* @param pm_mac: get meter info of pm mac.
* @param node_info: meter info of type iot_sg_pm_node_info_t.
* @return: ERR_OK - success.
* @return: ERR_INVAL - failed.
*/
uint32_t iot_sg_cco_get_pm_info_by_mac(uint8_t *pm_mac,
iot_sg_pm_node_info_t *info);
/**
* @brief iot_sg_cco_get_meter_by_index() - get node info.
* @param node_index: get meter info start from this index.
* @param node_info: meter info of type iot_sg_pm_node_info_t.
* @return: ERR_OK - success.
* @return: ERR_INVAL - failed.
*/
uint32_t iot_sg_cco_get_pm_info_by_index(uint16_t node_index,
iot_sg_pm_node_info_t* node_info);
/*
* @brief get cco uart bps
* @return: cco uart bps.
*/
uint32_t iot_sg_cco_get_cco_uart_bps();
/**
* @brief iot_sg_cco_config_uart() - config uart in CCo role.
* @param baud: baud rate.
* @param parity: parity bit.
* @param data: data width in bits.
* @param stop: stop bit.
* @param fmt: data frame settings.
* @return: ERR_OK for success case.
* @return: ERR_FAIL for failed case.
*/
uint32_t iot_sg_cco_config_uart(uint32_t baud, uint8_t parity,
uint8_t data, uint8_t stop, iot_frame_fmt *fmt);
/**
* @brief iot_sg_get_cco_mac() - get mac address of CCo.
* @param mac_addr: memory to store the CCo address in big endian.
*/
void iot_sg_get_cco_mac(uint8_t *mac_addr);
/**
* @brief check if meter reading is in progress.
*/
uint32_t iot_sg_cco_is_reading_pm();
/**
* @brief iot_sg_cco_reset_pm_state() - reset power meter property.
*/
void iot_sg_cco_reset_pm_state();
/**
* @brief iot_sg_cco_get_topo_msg() - query node info from mac layer.
* @param req_id: request id.
* @param req_data_ver: request data ver, see IOT_SG_CCO_REQ_DATA_VER_XXX
* @param start_index: start index,
* 0 - invalid, 1 - major node, 2... - sec node
* @param count: query_node count
*/
void iot_sg_cco_get_topo_msg(uint8_t req_id, uint8_t req_data_ver,
uint16_t start_index, uint8_t count);
/**
* @brief iot_sg_cco_get_nw_msg() - query basic nw info from mac layer.
* @param req_id: request id.
*/
void iot_sg_cco_get_nw_msg(uint8_t req_id);
/**
* @brief iot_sg_cco_get_node_info_msg() - query nodes' info from mac layer.
* @param req_id: request id.
* @param ver: request data ver, see IOT_PLC_CCO_TOPO_REQ_DATA_VER_XXX.
* @param sta_mac: pointer to nodes' mac.
* @param sta_cnt: sta count.
*/
void iot_sg_cco_get_node_info_msg(uint8_t req_id, uint8_t ver,
uint8_t *sta_mac, uint8_t sta_cnt);
/**
* @brief iot_sg_cco_get_bl_node_info_msg() - query blacklist nodes' info from
* mac layer.
* @param req_id: request id.
* @param start_index: start node.
* @param count: node count.
*/
void iot_sg_cco_get_bl_node_info_msg(uint8_t req_id, uint16_t start_index,
uint16_t count);
/**
* @brief iot_sg_set_cco_mac_addr() - set mac address of CCo. Mac layer will
* be reset if addr is different with CCo's original address.
* @param addr: the new address of CCo.
* @param reset: if reset lower layer to apply the mac addr.
* @return: ERR_OK - for successful case. mac layer will be reset .
* @return: otherwise - cco already has the same mac addr. mac layer will
* NOT be reset.
*/
uint32_t iot_sg_set_cco_mac_addr(uint8_t *addr, uint8_t reset);
/**
* @brief iot_sg_get_cco_mac_addr() - get mac address of CCo.
* @param addr: return the MAC address of CCO, little endian.
*/
void iot_sg_get_cco_mac_addr(uint8_t *addr);
/**
* @brief get the free white list entry count.
* @return: the free entry count.
*/
uint16_t iot_sg_cco_get_free_wl_entry_count();
/**
* @brief get the free white list ii entry count.
* @return: the free entry count.
*/
uint16_t iot_sg_cco_get_free_wlii_entry_count();
/**
* @brief iot_sg_cco_get_nid() - get nid.
* @return: nid value.
*/
uint32_t iot_sg_cco_get_nid();
/**
* @brief iot_sg_cco_get_nb_nw_info_msg() - query neighbor network info.
* @param req_id: request id.
*/
void iot_sg_cco_get_nb_nw_info_msg(uint8_t req_id);
/**
* @brief iot_sg_cco_start_nw_fmt() - start network formation.
*/
void iot_sg_cco_start_nw_fmt();
/**
* @brief notify framework that the 1st cmd from cctt was received.
*/
void iot_sg_cco_recv_cctt_cmd();
/**
* @brief iot_sg_cco_set_cli_upgrade_enable - set cli upgrade
* @param enable: 1 - take cli upgrade, 0 don't take it;
* @return: ERR_OK - for success case.
* @return: ERR_INVAL - for failed case.
*/
uint32_t iot_sg_cco_set_cli_upgrade_enable(uint8_t enable);
/**
* @brief iot_sg_cco_start_recv_upgrade() - start upgrade device.
* @param file_type: see IOT_SG_FILE_TYPE_XXX.
* @param file_id: file identity.
* @param mac: mac address of the upgrade device.
* @param block_size: size of every block data.
* @param total_block_cnt: total block count of firmware.
* @param file_size: size of the fw data buffer.
* @param crc16: 16 bits crc value of the fw data.
* 0 - no check , other - crc check.
* @param window_time: time window of the upgrade.
* 0 - use system default value.
* unit: millisecond.
* @return: ERR_OK - for success case.
* @return: ERR_INVAL - for failed case.
*/
uint32_t iot_sg_cco_start_recv_upgrade(uint8_t file_type, uint8_t file_id,
uint8_t *mac, uint32_t block_size, uint16_t total_block_cnt,
uint32_t file_size, uint16_t crc16, uint32_t window_time);
/**
* @brief iot_sg_cco_handle_file_segment() - save firmware segment data.
* @param data: buffer containing fw data.
* @param len: length of the fw data buffer.
* @param index: index of the fw data segment.
* @return: ERR_OK - for success case.
* @return: ERR_INVAL - for failed case.
*/
uint32_t iot_sg_cco_handle_file_segment(uint8_t *data, uint32_t len,
uint32_t index);
/**
* @brief: restart upgrading timer to check file recv timeout.
*/
void iot_sg_cco_upgrade_restart_recv_timer();
/**
* @brief - handle IOT_SG_MSG_ID_UPGRADE_STOP message.
* send stop upgrading message to a STA or switch to other state.
* @param clr_file_flag: 1 - clear upgrade file information, 0 don't clear
*/
void iot_sg_cco_handle_stop_upgrade(uint8_t clr_file_flag);
/**
* @brief is upgrading in progress.
* @retval: 1 - upgrading is in progress.
* 0 - no upgrading in progress.
*/
uint32_t iot_sg_cco_is_upgrading();
/**
* @brief iot_sg_cco_get_freq_band_msg() - query carrier comm param.
*/
void iot_sg_cco_get_freq_band_msg(uint8_t req_id);
/**
* @brief iot_sg_cco_set_freq_band_msg() - set carrier comm param.
* @param req_id: request id of data to report.
* @param freq_band: see PLC_LIB_FREQ_BAND_xxx.
*/
void iot_sg_cco_set_freq_band_msg(uint8_t req_id, uint8_t freq_band);
/**
* @brief iot_sg_cco_get_vendor_device_sn() - get vendor device sn.
* @param vendor_device_sn: vendor device sn info.
* @param read_len: need read sn length.
* @return: valid read length.
*/
uint8_t iot_sg_cco_get_vendor_device_sn(uint8_t *vendor_device_sn,
uint8_t read_len);
/**
* @brief iot_sg_cco_set_vendor_device_sn_to_pib() - set vendor device sn.
* @param vendor_device_sn: vendor device sn info.
* @param sn_len: vendor device sn length.
* @return: ERR_OK - success, otherwise - failure.
*/
uint32_t iot_sg_cco_set_vendor_device_sn_to_pib(uint8_t *vendor_device_sn,
uint8_t sn_len);
/**
* @brief iot_sg_cco_set_freq_band_msg() - set carrier comm param.
* @param start: query node start index, start from 0.
* @param cnt: query node count.
*/
void iot_sg_cco_get_neighbor_dev_msg(uint8_t req_id, uint16_t start,
uint8_t cnt);
/**
* @brief iot_sg_cco_cache_router_state_chg_cmd() - cache a router status
* change command entry to buffer.
* @param status: router status, see IOT_SG_CCO_RT_CHG_STOP_XXX.
* @param intf_type: interface of calling this API.
* see IOT_SG_CALLER_TYPE_XXX.
* @return: ERR_OK for success case. Other value for failed case.
*/
uint32_t iot_sg_cco_cache_router_state_chg_cmd(uint32_t status,
uint8_t intf_type);
/**
* @brief iot_sg_cco_cache_sg_mr_cmd() - cache a sg meter reading command
entry to buffer.
* @param mr_type: meter reading type, see IOT_SG_RMT_XXX.
* @param sn: sequence number of the 3762 packet.
* set to IOT_SG_INVALID_CCTT_SN if sn is unknown for
* the command.
* @param afn: fn codes in 3762 packet.
* @param proto_type: proto type of meter reading data.
* @param src_addr: src mac address of the command.
* @param dest_addr: dest mac address of the command.
* @param pkt: iot_pkt_t containing the 3762 pkt.
* @param intf_type: cctt type or cli type
* @param prio: priority of the task.
* @param timeout: timeout value of this task. cctt shall delete the task
* @param need_reply: flag to mark if need reply the task command.
* @param task_id: task id.
* @param sn_inc_flag: if increase sn when retry the meter reading pkt,
* 0 - sn don't inc, 1 - sn inc.
* @param emergency: emergency flag.
* @return: ERR_OK for success case. Other value for failed case.
*/
uint32_t iot_sg_cco_cache_sg_mr_cmd(uint8_t mr_type, uint16_t sn, uint8_t afn,
uint8_t proto_type, uint8_t *src_addr, uint8_t *dest_addr, iot_pkt_t *pkt,
uint8_t intf_type, uint8_t prio, uint16_t timeout, uint8_t need_reply,
uint16_t task_id, uint8_t sn_inc_flag, uint8_t emergency);
/**
* @brief iot_sg_cco_cache_has_sg_mr_cmd() - if read meter cmd with
* specified mac address exist in the cache.
* @param dest_addr: the dest mac address to check for data.
* @return: 1 - if the data with the mac exists.
* @return: 0 - if the data with the mac does not exist.
*/
uint32_t iot_sg_cco_cache_has_sg_mr_cmd(uint8_t *dest_addr);
/**
* @brief iot_sg_cco_cache_has_sg_mr_cmd_ex() - if read meter cmd with
* specified mac address and sn exist in the cache.
* @param dest_addr: the mac address to check for data entry.
* @param sn: the sn to be check for data entry.
* @return: 1 - if the target entry exists.
* @return: 0 - if the target entry does not exist.
*/
uint32_t iot_sg_cco_cache_has_sg_mr_cmd_ex(uint8_t *mac_addr, uint16_t sn);
/**
* @brief iot_sg_cco_cache_has_sg_cmd_exist() - if the cmd with
* specified mac address and sn exist in the cache.
* @param dest_addr: the mac address to check for data entry.
* @param sn: the sn to be check for data entry.
* @param data_type: the cmd data type.
* @return: 1 - if the target entry exists.
* @return: 0 - if the target entry does not exist.
*/
uint32_t iot_sg_cco_cache_has_sg_cmd_exist(uint8_t *mac_addr, uint16_t sn,
uint8_t data_type);
/**
* @brief iot_sg_cco_cache_has_sg_ext_mr_cmd() - if the cmd with
* specified mac address and ext data type exist in the cache.
* @param dest_addr: the mac address to check for data entry.
* @param ext_data_type: the ext cmd data type, IOT_SG_CCO_EXT_TASK_TYPE_XXX.
* @return: 1 - if the target entry exists.
* @return: 0 - if the target entry does not exist.
*/
uint32_t iot_sg_cco_cache_has_sg_ext_mr_cmd(uint8_t *mac_addr,
uint8_t ext_data_type);
/**
* @brief iot_sg_cco_get_645_pkt_cnt() - get count of 645 packet in a buffer.
* @param data: pointer to the buffer.
* @param len: length of the buffer.
* @return: count of 645 packet in the buffer.
*/
uint32_t iot_sg_cco_get_645_pkt_cnt(uint8_t *data, uint32_t len);
/**
* @brief get a flag indicate if router learning is done
* @retval: 1 if router learning is done, 0 if not done.
*/
uint32_t iot_sg_cco_is_route_learn_done();
/**
* @brief check if power meter with specific mac address is online
* @param mac_addr: the power meter mac address to check.
* @retval: 1 if the power meter is online, 0 if offline.
*/
uint32_t iot_sg_cco_is_pm_online(uint8_t *mac_addr);
/**
* @brief: get phase info of the STA/IIC on which the pm was attached
* @param pm_addr: address of the power meter
* @param phase_info: phase info
* @retval: ERR_OK for successful case.
* see ERR_XXX for failed case.
*/
uint32_t iot_sg_cco_get_pm_phase(uint8_t *pm_addr,
iot_sg_phase_info_t *phase_info);
/*
* @brief: get white list entry info by mac address
* @param mac_addr: mac address to search for white list entry in little-endian
* @param info: buffer to receive information
* @retval: ERR_OK for successful case. ERR_FAIL for failed case.
*/
uint32_t iot_sg_get_wl_entry_info_by_mac(uint8_t *mac_addr,
iot_sg_wl_entry_info_t *info);
/*
* @brief: get white list ii entry info by mac address
* @param mac_addr: mac address to search for white list entry ii in
* little-endian
* @param info: buffer to receive information
* @retval: ERR_OK for successful case. ERR_FAIL for failed case.
*/
uint32_t iot_sg_get_wlii_entry_info_by_mac(uint8_t *mac_addr,
iot_sg_wl_entry_info_t *info);
/*
* @brief: get meter mac addr info by index
* @param sta_index: index of mac map
* @param sta_mac: sta mac address, big-endian
* @retval: ERR_OK for successful case. ERR_FAIL for failed case.
*/
uint32_t iot_sg_cco_get_sta_mac_by_index(uint16_t sta_index,
uint8_t* sta_mac);
/**
* @brief: check if the mac addr exist in white list.
* @param mac addr: the mac address to check in little-endian.
* @return: 0 - not exist.
* @return: otherwise - exist.
*/
uint32_t iot_sg_cco_wl_entry_exist(uint8_t *mac_addr);
/**
* @brief: check if the mac addr exist in white list ii.
* @param mac addr: the mac address to check in little-endian.
* @return: 0 - not exist.
* @return: otherwise - exist.
*/
uint32_t iot_sg_cco_wlii_entry_exist(uint8_t *mac_addr);
/**
* @brief get router meter read timeout
* @return: duration, unit is 1s.
*/
uint8_t iot_sg_cco_get_router_mr_timeout();
/**
* @brief get sec node monitor max duration.
* @return: duration, unit is 1s.
*/
uint16_t iot_sg_cco_get_node_monitor_max_dur();
/**
* @brief iot_sg_cco_set_node_monitor_max_dur() - set sec node monitor max
* duration.
* @param dur: the duration, unit is 1s.
*/
void iot_sg_cco_set_node_monitor_max_dur(uint16_t dur);
/**
* @brief iot_sg_cco_get_major_node_mac() - get major node mac address.
* @param major_node_mac: the pointer of parameter that copy major node mac
* address, Little-Endian.
*/
void iot_sg_cco_get_major_node_mac(uint8_t *major_node_mac);
/**
* @brief iot_sg_cco_set_major_node_mac() - set major node mac address.
* @param major_node_mac: the mac address that set to major mac address,
* Little-Endian.
*/
void iot_sg_cco_set_major_node_mac(uint8_t *major_node_mac);
/**
* @brief set repeater addr range
* if the value is valid the repeater in the range are allowed to join
* network.
* if the value is invalid then all repeater are allowed to join
* network.
* 00:00:00:00:00:00 and FF:FF:FF:FF:FF:FF are invalid data.
* @param start_addr: start address, big-endian.
* @param end_addr: end address, big-endian.
* @return: see ERR_XXX.
*/
uint32_t iot_sg_cco_set_repeater_addr_range(uint8_t *start_addr,
uint8_t *end_addr);
/**
* @brief get repeater addr range
* @param start_addr: start address, big-endian.
* @param end_addr: end address, big-endian.
*/
void iot_sg_cco_get_repeater_addr_range(uint8_t *start_addr, uint8_t *end_addr);
/**
* @brief iot_sg_cco_check_exceed_con_cnt() - check if concurrent meter reading
* count exceed max coucurrent count.
* @param dest_addr: meter mac address.
* @return: ERR_OK - success, otherwise - failure.
*/
uint8_t iot_sg_cco_check_exceed_con_cnt(uint8_t *dest_addr);
/**
* @brief iot_sg_cco_get_sn_for_cctt() - get a sn for report data to cctt.
*/
uint8_t iot_sg_cco_get_sn_for_cctt();
/**
* @brief: check if CCo is running in cert mode.
* @return: 1 if in test mode. 0 if not.
*/
uint32_t iot_sg_cco_is_in_cert_mode();
/**
* @brief iot_sg_cco_get_router_work_flag() - get router work flag.
* @return: see IOT_SG_CCO_ROUTER_WORK_FLAG_XXX.
*/
uint8_t iot_sg_cco_get_router_work_flag();
/**
* @brief iot_sg_cco_get_router_work_mode() - get router work mode.
* @return: 1 - learning, 0 - meter reading.
*/
uint8_t iot_sg_cco_get_router_work_mode();
/**
* @brief iot_sg_cco_set_router_work_mode() - set router work mode.
* @param work_mode: 1 - learning, 0 - meter reading.
*/
void iot_sg_cco_set_router_work_mode(uint8_t work_mode);
/**
* @brief iot_sg_cco_get_router_sec_node_reg_allowed() - get sec node register
* allowed status.
* @return: 1 - allow, 0 - forbid.
*/
uint8_t iot_sg_cco_get_router_sec_node_reg_allowed();
/**
* @brief iot_sg_cco_set_router_sec_node_reg_allowed() - set sec node register
* allowed status.
* @param reg_allowed: 1 - allow, 0 - forbid.
*/
void iot_sg_cco_set_router_sec_node_reg_allowed(uint8_t reg_allowed);
/**
* @brief iot_sg_cco_get_router_work_type() - get router work type.
* @return: see IOT_SG_CCO_ROUTER_WORK_TYPE_XXX.
*/
uint8_t iot_sg_cco_get_router_work_type();
/**
* @brief iot_sg_cco_set_router_work_type() - set router work type.
* @param work_type: see IOT_SG_CCO_ROUTER_WORK_TYPE_XXX.
*/
void iot_sg_cco_set_router_work_type(uint8_t work_type);
/**
* @brief iot_sg_cco_get_router_evt_flag() - get router event flag.
* @return: 0 - nothing event need be reported.
* @return: otherwise - some event need be reported.
*/
uint8_t iot_sg_cco_get_router_evt_flag();
/**
* @brief iot_sg_cco_get_tsfm_detect_status() - get transformer detect flag.
* @return: see IOT_SG_CCO_TSFM_DETECT_XXX.
*/
uint8_t iot_sg_cco_get_tsfm_detect_status();
/**
* @brief iot_sg_cco_get_tsfm_detect_enabled() - get transformer detect enabled.
* @return: 0 - disable, 1- enable;
*/
uint8_t iot_sg_cco_get_tsfm_detect_enabled();
/**
* @brief iot_sg_cco_force_stop_tsfm_detect() - force stop tsfm detection.
*/
void iot_sg_cco_force_stop_tsfm_detect();
/**
* @brief iot_sg_cco_set_tsfm_detect_enabled() - set transformer detect enabled.
* @param sta_lock: whether lock the station. 0 - unlock, 1 - lock.
* @param value: 0 - disable, 1- enable;
* @param qr_sta_tsfm_detect_ret: whether query the station transformer detect
* result, 0 - don't query, 1 - query
* @param tsfm_detect_dur: duration of transformer detect, unit is 1s.
* @param bcast_feature: if need to report cco's tsfm feature to sta.
* @param is_keep_bcast: if need to keep bcast until end.
* @return: ERR_OK - success, otherwise - failure.
*/
uint32_t iot_sg_cco_set_tsfm_detect_enabled(uint8_t sta_lock, uint8_t value,
uint8_t qr_sta_tsfm_detect_ret, uint32_t *tsfm_detect_dur,
uint8_t bcast_feature, uint8_t is_kepp_bcast);
/**
* @brief iot_sg_cco_get_pm_proto_type() - get meter protocol type by meter mac
* address, default is PROTO_TYPE_RAW_DATA.
* @param pm_mac: meter mac address.
* @param pm_proto: meter proto space address.
* @return: ERR_OK - success, otherwise - failure.
*/
uint32_t iot_sg_cco_get_pm_proto_type(uint8_t *pm_mac, uint8_t *pm_proto);
/**
* @brief iot_sg_cco_add_null_mr_data() - add an empty meter data entry
* to ul buffer.
* @param intf_type: cctt type or cli type, see IOT_SG_CALLER_TYPE_XXX.
* @param sn: sequence number of the 3762 packet.
* @param afn: fn codes in 3762 packet.
* @param src_mac: src mac address of the command.
* @param dest_mac: dest mac address of the command.
* @param mr_type: meter reading type, see IOT_SG_RMT_XXX.
* @param proto_type: proto type of meter reading data.
* @return: ERR_OK - success, otherwise - failure.
*/
uint32_t iot_sg_cco_add_null_mr_data(uint8_t intf_type, uint8_t sn, uint8_t afn,
uint8_t *src_mac, uint8_t *dest_mac, uint8_t mr_type, uint8_t proto_type);
/**
* @brief iot_sg_cco_get_power_status() - get the cco power status.
* @return: 0 - the cco is power off, otherwise - the cco is power on
*/
uint8_t iot_sg_cco_get_power_status();
/**
* @brief check if CCo to send data.
* @return: 1 - CCo is ready to send data. 0 - CCo is not ready yet.
*/
uint8_t iot_sg_cco_is_ready();
/**
* @brief iot_sg_cco_sec_node_rpt() - cache sec node info for report
* to cctt.
* @param sta_mac: station mac address.
* @param chg_state: change state, see IOT_SG_CCO_CHG_STATE_XXX.
* @param dev_mac: device mac address, if the device type is collector,
* the mac is the collector mac address.
* @param intf_type: interface of calling this API.
* see IOT_SG_CALLER_TYPE_XXX.
* @return: ERR_OK - success, otherwise - failure.
*/
uint32_t iot_sg_cco_sec_node_rpt(uint8_t *sta_mac,
uint8_t chg_state, uint8_t *dev_mac, uint8_t intf_type);
/**
* @brief iot_sg_cco_handle_evt_rpt() - report event info for report to cctt
* @param sta_addr: addr of station, Big-Endian
* @param pm_addr: addr of power meter, Little-Endian
* @param pkt: pointer to iot_pkt structure, this iot_pkt is loaded with
* raw data of event information
* @param seq: seq pointer
* @param evt_type: event type, see IOT_SG_CCO_EVENT_XXX.
* @param dev_type: device type, see IOT_PLC_DEV_TYPE_XXX.
* @param not_check_wl: if check wl exist, 1 - don't check, 0 - check.
* @retval: 0 - for success case
* @retval: otherwise - error code
*/
uint32_t iot_sg_cco_handle_evt_rpt(uint8_t *sta_addr, uint8_t *pm_addr,
iot_pkt_t *pkt, uint16_t *seq, uint8_t evt_type, uint8_t dev_type,
uint8_t not_check_wl);
/**
* @brief iot_sg_cco_get_sec_node_cnt() - get the secondarty node's
* info under the sta
* @param sta_mac: station mac address: big endian.
* @param node_cnt: secondarty node's counter
* @return: pkt pointer, the pkt's detail infor refer to sec_node_info_query_t.
*/
iot_pkt_t *iot_sg_cco_get_sec_node_info(uint8_t *sta_mac, uint8_t *node_cnt);
/**
* @brief iot_sg_cco_get_online_sta_count() - get count that sta online
* @retval: sta count
*/
uint32_t iot_sg_cco_get_online_sta_count();
/**
* @brief iot_sg_cco_set_nw_size() - set network size
* @param nw_size: value of the network size
* @retval: network size
*/
uint16_t iot_sg_cco_set_nw_size(uint16_t nw_size);
/**
* @brief iot_sg_cco_get_nw_size() - get network size
* @retval: network size
*/
uint16_t iot_sg_cco_get_nw_size();
/**
* @brief iot_sg_cco_get_esp() - get equipment service provider
* @retval: see IOT_SG_CCO_ESP_XXX.
*/
uint8_t iot_sg_cco_get_esp();
/**
* @brief: iot_sg_cco_set_esp() - set equipment service provider
* @param esp: see IOT_SG_CCO_ESP_XXX.
*/
void iot_sg_cco_set_esp(uint8_t esp);
/**
* @brief iot_sg_cco_router_mr_find_node_entry() - get a meter for router meter
* reading.
* @param read_pm_index: index of the meter that need to find.
* @param info: output - the meter info that need to read.
* @return 0 - no pm to be read.
* @return otherwise - the pm index to be read.
*/
uint16_t iot_sg_cco_router_mr_find_node_entry(uint16_t read_pm_index,
iot_sg_wl_entry_info_t *info);
/**
* @brief iot_sg_cco_sys_reset_wait_time() - system reset wait time
* @return the time, unit is 1ms.
*/
uint32_t iot_sg_cco_sys_reset_wait_time();
/**
* @brief: clean up both down link, and up link buffer pool
*/
void iot_sg_cco_clean_buf_pool();
/**
* @brief: iot_sg_cco_init_clct_task() - init collection task
*/
void iot_sg_cco_init_clct_task();
/**
* @brief: push task to dl buf
* @param proto_type: proto type of meter reading data.
* @param task_id: task id to be added
* @param prio: priority of the task
* @param sn: sequence number of the spg packet.
* @param timeout: execution time of the task
* @param need_reply: 1 - this packet needs to be responsed
* 0 - this packet no needs to be responsed
* @param src_mac: src mac address of the command.
* @param dst_mac: dest mac address of the command.
* @param pkt: iot_pkt_t containing the spg pkt.
* @param sn_inc_flag:if increase sn when retry the meter reading pkt,
* 0 - sn don't inc, 1 - sn inc.
* @param task_id_filter: 0 - allow task id repetition,
* otherwise - don't allow task id repetition.
* @param emergency: emergency flag
* @param forward: if need to forward data, 0 - don't need, 1 - need.
* @param intf_type: caller, see IOT_SG_CALLER_TYPE_XXX.
* @return: ERR_OK is successful.
* @return: otherwise failure.
*/
uint32_t iot_sg_cco_add_task_cmd(uint8_t proto_type, uint16_t task_id,
uint8_t prio, uint16_t sn, uint16_t timeout, uint8_t need_reply,
uint8_t *src_mac, uint8_t *dst_mac, iot_pkt_t *pkt, uint8_t sn_inc_flag,
uint8_t task_id_filter, uint8_t emergency, uint8_t forward,
uint8_t intf_type);
/**
* @brief: remove dedicated task
* @param task_id: task id to be removed
* @return: ERR_OK is successful.
* @return: otherwise failure.
*/
uint32_t iot_sg_cco_rm_task_cmd(uint16_t task_id);
/**
* @brief: enable read meter.
* @param intf_type: cctt type or cli type see - IOT_SG_CALLER_TYPE_XXX
*/
void iot_sg_cco_enable_mr(uint8_t intf_type);
/**
* @brief: disable read meter.
* @param intf_type: cctt type or cli type see - IOT_SG_CALLER_TYPE_XXX
*/
void iot_sg_cco_disable_mr(uint8_t intf_type);
/**
* @brief: get unfinished task count.
* @retval: unfinished task count.
*/
uint16_t iot_sg_cco_get_unfinished_task_cnt();
/*
* @brief: get task information by task id. Caller shall free the returned
* iot_pkt if necessary.
* @param task_id: id of task whose info to be retrieved.
* @return: a iot_pkt with data of type iot_sg_task_info_t.
* or NULL if failed.
*/
iot_pkt_t* iot_sg_cco_get_task_info_by_id(uint16_t task_id);
/**
* @brief: get count of free task entry.
* @retval: count of free task entry.
*/
uint16_t iot_sg_cco_get_free_task_cnt();
/**
* @brief: get task id start from specific offset.
* @param start_index: start index of task buffer
* @param cnt: count of get task id
* @param taskid: buffer to store task id
* @retval: count of retrieved taskid
*/
uint16_t iot_sg_cco_get_task_listid(uint16_t start_index, uint16_t cnt,
uint16_t *taskid);
/**
* @brief: convert evaluate value to real phase.
* @param dev_type: device type, see IOT_PLC_DEV_TYPE_XXX.
* @param phase1: first possible phase. the highest possibility.
* @param phase2: second possible phase.
* @param phase3: third possible phase. the lowest possibility.
* @retval: real phase. bit0 = 1 measn phase a, bit1 = 1 means phase b,
* @retval: bit2 = 1 means phase c
*/
uint8_t iot_sg_cco_convert_phase(uint8_t dev_type, uint8_t phase1,
uint8_t phase2, uint8_t phase3);
/**
* @brief: get router meter reading state.
* @retval: see IOT_SG_CCO_RT_AMR_STATE_XXX.
*/
uint8_t iot_sg_cco_rt_mr_get_state();
/**
* @brief: if the cco report meter reading result to cctt then
* the cctt should response a ack to cco.
* @param sn: the sn of the cctt ack pkt
*/
void iot_sg_cco_rt_mr_result_ack(uint8_t sn);
/**
* @brief: set a backup sn for router meter reading ack
* as iot_sg_cco_rt_mr_result_ack() supplement.
* @param sn: backup sn
*/
void iot_sg_cco_rt_mr_set_backup_ack_sn(uint8_t sn);
/**
* @brief: get cco connectionless status.
* @retval: 0 - cco is not in connectionless mode.
* @retval: 1 - cco is in connectionless mode.
*/
uint8_t iot_sg_cco_get_conn_less_status();
/**
* @brief is power up again.
* @return: true means as power up again
*/
uint8_t iot_sg_cco_is_power_up_again();
/**
* @brief get secondary node monitor max duration by meter reading type.
* @param intf_type: interface of calling this API.
* see IOT_SG_CALLER_TYPE_XXX.
* @param mr_type: meter reading type, see IOT_SG_RMT_XXX.
* @return: max monitor duration, unit is 1s.
*/
uint16_t iot_sg_cco_get_mr_timeout(uint8_t intf_type, uint8_t mr_type);
/**
* @brief: get transfomer status by mac.
* @param pm_addr: power meter mac addr, little endian.
* @retval: transfomer status, see IOT_SG_CCO_PM_TO_TSFM_XXX.
*/
uint8_t iot_sg_cco_get_tsfm_status_by_mac(uint8_t *pm_addr);
/**
* @brief: get transfomer result by mac.
* @param pm_addr: power meter mac addr, little endian.
* @retval: transfomer result,
* see IOT_SG_CCO_STA_TSFM_DETECT_RET_XXX.
*/
uint8_t iot_sg_cco_get_tsfm_result_by_mac(uint8_t *pm_addr);
/**
* @brief: get station mac address by power meter mac address
* @param meter_mac: power meter mac addr, little endian.
* @param sta_mac: station mac addr, big endian.
* @retval: see ERR_XXX.
*/
uint32_t iot_sg_cco_meter_mac_to_sta_mac(uint8_t *meter_mac, uint8_t *sta_mac);
/**
* @brief: get cco ctrl proto status.
* @retval: 0 - controller is not connected to cco.
* @retval: 1 - controller is connected to cco.
*/
uint8_t iot_sg_cco_get_ctrl_proto_status();
/**
* @brief: send control protocol data.
* @param pkt: iot_pkt_t containing the data that send to controller,
* the ownership of the pkt will be transferred.
*/
void iot_sg_cco_send_ctrl_proto(iot_pkt_t *pkt);
/**
* @brief: send local protocol data.
* @param channel: send channel.
* @param pkt: iot_pkt_t containing the data that send to controller,
* the ownership of the pkt will be transferred.
*/
void iot_sg_cco_local_proto_data_send(uint8_t channel, iot_pkt_t *pkt);
/**
* @brief: get upgrade information from cctt down link.
* @param query_info: upgrade info. please see its definition.
* @return: ERR_OK is successful.
* @return: otherwise failure.
*/
uint32_t iot_sg_cco_query_upgrade_info(iot_sg_upgrade_info_t
*query_info);
/**
* @brief: get the upgrade file segment bitmap info,
* invalid bitmap data set 0.
* @param bitmap: dec bitmap address.
* @param start_index: file segment bitmap offset address, start offset is 0.
* @param size: size of the dec bitmap.
* @return: valid dec bitmap size.
*/
uint16_t iot_sg_cco_query_upgrade_bitmap_info(uint8_t *bitmap,
uint16_t start_index, uint16_t size);
/**
* @brief: get cco upgrade statistics information.
* @param statistics: buf to store upgrade statistics information.
* please see its definition.
* NULL if caller don't want to store the information.
* @param print_flag: flag indicates if statistisc information shall
* be printed to uart.
* 1 - print log. 0 - don't print log.
*/
void iot_sg_cco_upgrade_statistics(iot_sg_upgrade_statistics_t *statistics,
uint8_t print_flag);
/**
* @brief: get sta list that upgrade failed.
* @param start_index: start index that upgrade fail sta list. start from 0.
* @param cnt: size of fail sta addr list.
* @return: pkt address that sta addr list , NULL is fail.
*/
iot_pkt_t *iot_sg_cco_upgrade_get_fail_sta_list(uint16_t start_index,
uint16_t cnt);
/**
* @brief: get device type of the node by mac addr.
* @param sta_mac: station mac address, big-endian.
* @retval: device type of the node, see IOT_PLC_DEV_TYPE_xxx.
*/
uint8_t iot_sg_cco_get_dev_type_by_mac(uint8_t *sta_mac);
/**
* @brief: get power meter type.
* @param sta_mac: station mac address, big-endian.
* @return: 0 - single phase meter.
* @return: otherwise - three phase meter.
*/
uint8_t iot_sg_cco_get_meter_type(uint8_t *sta_mac);
/**
* @brief: get device power status.
* @param sta_mac: station mac address, big-endian.
* @return: 0 - power down.
* @return: otherwise - power on.
*/
uint8_t iot_sg_cco_get_dev_power_state(uint8_t *sta_mac);
/**
* @brief: judge the power meter type.
* @param dev_type: device type, see IOT_PLC_DEV_TYPE_XXX.
* @return: 1 - power meter, include single phase meter and three phase meter.
* @return: otherwise - other device type.
*/
uint8_t iot_sg_cco_is_pm(uint8_t dev_type);
/**
* @brief: judge the collector or power meter type.
* @param dev_type: device type, see IOT_PLC_DEV_TYPE_XXX.
* @return: 1 - power meter or collector.
* @return: otherwise - other device type.
*/
uint8_t iot_sg_cco_is_collector_or_pm(uint8_t dev_type);
/**
* @brief: judge the collector type.
* @param dev_type: device type, see IOT_PLC_DEV_TYPE_XXX.
* @return: 1 - collector.
* @return: otherwise - other device type.
*/
uint8_t iot_sg_cco_is_collector(uint8_t dev_type);
/**
* @brief: get device chip id by mac addr.
* @param sta_addr: station mac address, big-endian.
* @param: chip_id: device chip id.
* @retval: ERR_OK - success.
* @retval: ERR_INVAL - failed.
*/
uint8_t iot_sg_cco_get_dev_chip_id_by_mac(uint8_t *sta_addr,
uint8_t *chip_id);
/**
* @brief: get device module id by mac addr.
* @param sta_addr: station mac address, big-endian.
* @param: mod_id: device module id.
* @retval: ERR_OK - success.
* @retval: ERR_INVAL - failed.
*/
uint8_t iot_sg_cco_get_dev_module_id_by_mac(uint8_t *sta_addr,
uint8_t *mod_id);
/**
* @brief: check if the mac address in the reject blacklist.
* @param mac_addr: mac address, big-endian.
* @retval: 0 - not in the reject blacklist.
* @retval: otherwise - in the reject blacklist
*/
uint32_t iot_sg_cco_reject_bl_exist(uint8_t *mac_addr);
/**
* @brief: add the mac address into reject blacklist.
* @param mac_addr: mac address, big-endian.
*/
void iot_sg_cco_add_reject_bl(uint8_t *mac_addr);
/**
* @brief: clear reject blacklist.
*/
void iot_sg_cco_clear_reject_bl();
/**
* @brief: check if it's the first time STA join the network.
* @param sta_addr: station mac address, big-endian.
* @retval: 0 - first time join network.
* @retval: 1 - not first time join network.
* @retval: 2 - unknown due to not in white list.
*/
uint8_t iot_sg_cco_check_is_first_join(uint8_t *sta_addr);
/**
* @brief: get network node count, include major node.
* @retval: node count.
*/
uint16_t iot_sg_cco_get_net_node_cnt();
/**
* @brief: get network pm count.
* @retval: pm count.
*/
uint16_t iot_sg_cco_get_pm_cnt();
/**
* @brief: get network node information by index.
* @param start_type: 0 - query by tei, 1 - query by index.
* @param value: query value, 1 for major node, 2 ~ end for sec node
* @param info: output - the node information.
* @retval: ERR_OK - the info is valid. otherwise - the info is invalid.
*/
uint32_t iot_sg_cco_get_net_node_info_by_index(uint8_t start_type,
uint16_t value, iot_sg_cco_net_node_info_t *info);
/**
* @brief: get network node information by mac addr.
* @param pm_mac: meter mac address.
* @param info: output - the node information.
* @retval: ERR_OK - the info is valid. otherwise - the info is invalid.
*/
uint32_t iot_sg_cco_get_net_node_info_by_mac(uint8_t *pm_mac,
iot_sg_cco_net_node_info_t *info);
/**
* @brief: get network node information by power meter index.
* @param value: query value, 1 for major node, 2 ~ end for sec node
* @param info: output - the node information.
* @retval: ERR_OK - the info is valid. otherwise - the info is invalid.
*/
uint32_t iot_sg_cco_get_net_node_info_by_pm_index(uint16_t value,
iot_sg_cco_net_node_info_t *info);
/**
* @brief: get sec node score information by index.
* @param index: the specified pm index, start from 1.
* @param info: output - the sec node score information.
* @retval: ERR_OK - the info is valid. otherwise - the info is invalid.
*/
uint32_t iot_sg_cco_get_pm_score_info_by_index(uint16_t index,
iot_sg_cco_sec_node_score_info_t *info);
/**
* @brief: get pm information by real index.
* @param index: the specified pm index, start from 1.
* @param info: output - the pm information.
* @retval: ERR_OK - the info is valid. otherwise - the info is invalid.
*/
uint32_t iot_sg_cco_get_pm_info_by_real_index(uint16_t index,
iot_sg_cco_pm_info_t *info);
/**
* @brief: get power meter addr that collector connected by index.
* @param sta_addr: station mac address, big-endian.
* @param pm_mac : returns power meter addr, if found by index.
* @param index : index for current meter, it started from 1 to max count.
* @retval: 0 - find the power meter.
* @retval: otherwise - not find the power meter.
*/
uint8_t iot_sg_cco_get_collector_meter_addr_by_index(uint8_t *sta_mac,
uint8_t *pm_mac, uint8_t index);
/**
* @brief iot_sg_cco_get_sec_node_reg_cnt() - get the sec node registered count.
* @return: count of registered secondary nodes
*/
uint16_t iot_sg_cco_get_sec_node_reg_cnt();
/**
* @brief: get power meter count, attached to sta.
* @param sta_mac: station mac address, big-endian.
* @retval: power meter count.
*/
uint8_t iot_sg_cco_get_sec_node_cnt(uint8_t *sta_mac);
/**
* @brief: set branch detect enabled
* @param value: 0 - disabled, otherwise - enabled.
* @param ctrl: pointer to iot_sg_cco_bd_crtl_t structure, used to specify
* branch identification parameters, valid only when enabled.
* @retval: ERR_OK: branch detect enable success, others fail.
*/
uint32_t iot_sg_cco_set_branch_detect_enabled(uint8_t value,
iot_sg_cco_bd_ctrl_t *ctrl);
/**
* @brief: add meter mapping information.
* @param meter_addr: meter address.
* @param node_addr: node mac address.
* @retval: successful : ERR_OK, others: fail.
*/
uint32_t iot_sg_cco_add_meter_mapping_info(uint8_t *meter_addr,
uint8_t *node_addr);
/**
* @brief: get meter mapping count.
* @retval: meter mapping count.
*/
uint32_t iot_sg_cco_get_meter_mapping_cnt();
/**
* @brief: set module collect parameter
* @param proto_type: collect proto type, see PROTO_TYPE_XXX
* @param data_len: collect parameter data length
* @param clct_param: collect parameter data pointer
*/
void iot_sg_cco_set_module_clct_param(uint8_t proto_type, uint16_t data_len,
iot_sg_cco_module_clct_param_t *clct_param);
/**
* @brief get module collect parameter
* @param proto_type: collect proto type, see PROTO_TYPE_XXX
* @param type: curve collect parameter type,
* see IOT_SG_CCO_CURVE_COLLET_TYPE_XXX
* @param task_id: task id
* @return: pkt pointer, the pkt's detail infor refer to
* iot_sg_cco_module_clct_param_t.
*/
iot_pkt_t *iot_sg_cco_get_module_clct_param(uint8_t proto_type,
uint8_t type, uint8_t task_id);
/**
* @brief: get meter mapping information from index.
* @param index: meter mapping index, min index is 1.
* @param map_info: meter mapping ptr.
* @retval: ERR_OK - get meter mapping success from index,
* ERR_FAIL -.get meter mapping fail from index.
*/
uint32_t iot_sg_cco_get_meter_mapping_info_from_index(
uint16_t index, iot_sg_meter_mapping_info_t *map_info);
/**
* @brief: get app proto.
* @return: app proto id, see IOT_SG_CCO_APP_PROTO_XXX.
*/
uint8_t iot_sg_cco_get_app_proto(void);
/**
* @brief: send cctt rsp passthrouth data to ckq.
* @param pkt: cctt rsp passthrouth data ptr.
* the pkt will be free in function.
*/
void iot_sg_cco_send_cctt_rsp_passthrouth_data(iot_pkt_t *pkt);
/**
* @brief: get branch detect state.
* @return: branch detect state, see IOT_SG_CCO_BRANCH_DETECT_XXX.
*/
uint8_t iot_sg_cco_get_branch_detect_state(void);
/**
* @brief - update correct time interval to PIB
* @param time: correct time interval
*/
void iot_sg_cco_update_correct_sta_time_interval_to_pib(uint32_t time);
/**
* @brief - get correct time interval from PIB.
* @return: correct time interval.
*/
uint32_t iot_sg_cco_get_correct_sta_time_interval_from_pib(void);
/**
* @brief: save bcast collect task.
* @param hdr: collect task data info pointer.
* @param len: collect task data info length.
* @return: ERR_OK - no problem with the length,
* ERR_FAIL - length oversize.
*/
uint32_t iot_sg_cco_add_collect_task(iot_sg_collect_task_t *hdr,
uint16_t len);
/**
* @brief: delete bcast collect task by task id.
* @param clct_task_id: collect task id.
*/
void iot_sg_cco_delete_clct_task(uint8_t clct_task_id);
/**
* @brief: get collect task info from dl buf or pib by task id.
* @param clct_task_id: collect task id.
* @return: NULL - not find pkt, others - clct task pkt.
*/
iot_pkt_t *iot_sg_cco_get_clct_task_info(uint8_t clct_task_id);
/**
* @brief cache a sg extension task command entry to buffer.
* @param task_type: extension task type,
* see IOT_SG_CCO_EXT_TASK_TYPE_XXX.
* @param dest_addr: dest mac address of the command, little endian.
* @param sn: sequence number of the 3762 packet.
* set to IOT_SG_INVALID_CCTT_SN if sn is unknown for
* the command.
* @param pkt: iot_pkt_t containing the 3762 pkt.
* @param timeout: timeout value of this task. cctt shall delete the task
* @param prio: priority of the task, NULL - default priority.
* @param intf_type: interface of calling this API. see IOT_SG_CALLER_TYPE_XXX.
* @return: ERR_OK for success case. Other value for failed case.
*/
uint32_t iot_sg_cco_cache_ext_task(uint8_t task_type, uint8_t *dest_mac,
uint8_t sn, iot_pkt_t *pkt, uint16_t timeout, uint8_t *prio,
uint8_t intf_type);
/**
* @brief: start low power meter info read.
* @retval: successful : ERR_OK, others: fail.
*/
uint32_t iot_sg_cco_start_lp_meter_read();
/**
* @brief: stop low power meter info read.
* @retval: successful : ERR_OK, others: fail.
*/
uint32_t iot_sg_cco_stop_lp_meter_read();
/**
* @brief: get low power meter enable.
* @return: low power meter enable.
*/
uint8_t iot_sg_cco_get_lp_meter_enable();
/**
* @brief: suspend low power meter search
*/
void iot_sg_cco_lp_meter_suspend_search();
/**
* @brief: get the count of double low power meter in the net.
* @return: count of double low power meter in the net.
*/
uint16_t iot_sg_cco_get_double_lp_meter_cnt();
/**
* @brief: low power meter whether can be meter reading
* @param lp_meter: low power meter mac address.
* @return: 0 - can't be meter reading, otherwise - can be meter reading
*/
uint32_t iot_sg_cco_lp_meter_can_mr(uint8_t *lp_meter);
/**
* @brief: get the double low power meter information
* @param index: start from 1
* @param lp_meter: low power meter information
* @return: see ERR_XXX.
*/
uint32_t iot_sg_cco_get_double_lp_meter_info(uint16_t index,
iot_sg_cco_lp_meter_info_t *lp_meter);
/**
* @brief preprocess read lp meter data.
* @param pkt: read lp meter pkt, will be consumed.
* @param lp_meter_mac: mac address of low power meter, little-endian.
* @param sta_mac: mac address of station, big-endian.
* @retval: processed read lp meter pkt.
*/
iot_pkt_t *iot_sg_cco_pre_proess_read_lp_meter(iot_pkt_t *pkt,
uint8_t *lp_meter_mac, uint8_t *sta_mac);
/**
* @brief iot_sg_cco_get_score_param() - get score param.
* @param flag_enable: pointer, score enable flag.
* @param threshold: pointer, score threshold.
*/
void iot_sg_cco_get_score_param(uint8_t *enable_flag, uint8_t *threshold);
/**
* @brief iot_sg_cco_get_score_start_time() - get score start time.
* @param day: pointer, BIN format.
* @param hour: pointer, BIN format.
* @param minute: pointer, BIN format.
*/
void iot_sg_cco_get_score_start_time(uint8_t *day, uint8_t *hour,
uint8_t *minute);
/**
* @brief iot_sg_cco_set_score_param() - set score parameter.
* @param flag: score report enable. 0 - disable, 1 - enable. default 1.
* @param threshold: score report threshold value. Total of 100, default 60.
*/
void iot_sg_cco_set_score_param(uint8_t flag, uint8_t threshold);
/**
* @brief iot_sg_cco_set_score_start_time() - set score start time.
* @param day: 0 - start every day. others - every month. BIN type.
* @param hour: BIN type.
* @param minute: BIN type.
*/
void iot_sg_cco_set_score_start_time(uint8_t day, uint8_t hour, uint8_t minute);
/**
* @brief: reset pm score state.
*/
void iot_sg_cco_pm_score_state_reset();
/**
* @brief: get node join time stamp.
* @node_mac: node mac address - little endian.
* @retval: station joined time, is based on the time of CCO power-on,
* uint is 1s.
*/
uint32_t iot_sg_cco_get_node_join_ts(uint8_t *node_mac);
/**
* @brief: get reject black list count.
* @retval: reject black list count.
*/
uint32_t iot_sg_cco_get_reject_bl_cnt();
/**
* @brief: get reject black list information by index.
* @index: index: index of reject black list, index start with 1.
* @param info: output - the node information.
* @retval: ERR_OK - the info is valid. otherwise - the info is invalid.
*/
uint32_t iot_sg_cco_get_reject_bl_info(uint16_t index,
iot_sg_cco_reject_bl_node_info_t *info);
/**
* @brief: set equipment service provider.
* @param esp: see IOT_SG_CCO_ESP_XXX.
*/
void iot_sg_cco_update_rw_esp(uint8_t esp);
/**
* @brief: set transformer detect lock time.
* @param net_lock_time: net lock time, uint is 1min.
* @param abn_lock_time: the lock time of abnormal leave net, uint is 1min.
*/
void iot_sg_cco_set_tsfm_detect_lock_time(uint16_t net_lock_time,
uint16_t abn_lock_time);
/**
* @brief: get transformer detect lock time.
* @param net_lock_time: pointer, get net_lock_time from cco.
* @param abn_lock_time: pointer, get abn_lock_time from cco.
*/
void iot_sg_cco_get_tsfm_detect_lock_time(uint16_t *net_lock_time,
uint16_t *abn_lock_time);
/**
* @brief: get cco leave net reason.
*/
uint8_t iot_sg_cco_get_leave_net_reason();
/**
* @brief: get cco phase repeat flag.
* @retval: 0 - no repetition, 1 - repetition phase.
*/
uint8_t iot_sg_cco_get_phase_repeat_flag();
/**
* @brief preprocess bcast collect task data.
* @retval: processed bcast collect task pkt.
*/
iot_pkt_t *iot_sg_cco_query_bcast_clct_task_id();
/*
* @brief: delect task by collect task id.
* @param task_id: collect task id.
* @retval: ERR_OK - delect success. otherwise - delect fail.
*/
uint32_t iot_sg_cco_del_clct_read_task(uint8_t task_id);
/**
* @brief rtc timer synchronization by bcast.
* @param rtc_time: rtc time, bcd format.
*/
void iot_sg_cco_rtc_timer_sync_bcast(iot_sg_cco_time_t *rtc_time);
/*
* @brief: query collect task read info by collect task id.
* @param task_id: collect task id.
* @param cmd_addr: return collect task read commad dest address.
* @return: collect task read date pkt.
*/
iot_pkt_t *iot_sg_cco_query_clct_task_read_info(uint8_t task_id,
uint8_t *cmd_addr);
/**
* @brief set or delete transformer detect address by bcast.
* @param cmd_type: comand type, see IOT_SG_CCO_BCAST_TSFM_ADDR_CMD_XXX.
* @param tsfm_addr: transformer detect address, little endian.
*/
void iot_sg_cco_set_bcast_tsfm_addr_param(uint8_t cmd_type,
uint8_t *tsfm_addr);
/**
* @brief lock or unlock secondary node by bcast.
* @param cmd_type: comand type, see IOT_SG_CCO_BCAST_NW_LOCK_CMD_XXX.
*/
void iot_sg_cco_set_bcast_lock_cmd(uint8_t cmd_type);
/**
* @brief: set trans mode
* @param trans_mode: 0 - check 645/698 pkg for mr dest mac,
* others - doesn't check
*/
void iot_sg_cco_set_trans_mode(uint8_t trans_mode);
/**
* @brief - get read meter trans mode.
* @param proto_type: proto type, see PROTO_TYPE_XXX.
* @return 0 - isn't trans mode, other - is trans mode.
*/
uint8_t iot_sg_cco_get_trans_mode(uint8_t proto_type);
/**
* @brief: set whitelist state.
* @param wl_state: whilte status, 0 - disable, 1- enable.
* @retval: set state, see ERR_XXX.
*/
uint32_t iot_sg_cco_set_wl_state(uint8_t wl_state);
/**
* @brief get whitelist state
* @return whitelist state, 0 - disable, 1 - enable, 2 - delay enable.
*/
uint8_t iot_sg_cco_get_wl_state();
/**
* @brief: clear reject node in the pool.
*/
void iot_sg_cco_clear_reject_node();
/**
* @brief: get dev addr by pm addr
* @param dev_addr: output, little - endian
* @param pm_addr : input, little - endian
* @retval: see ERR_XXX.
*/
uint32_t iot_sg_cco_get_dev_addr(uint8_t *dev_addr, uint8_t *pm_addr);
/**
* @brief: get tsfm addr by pm addr
* @param tsfm_addr: output, big - endian
* @param pm_addr : input, little - endian
* @retval: see ERR_XXX.
*/
uint32_t iot_sg_cco_get_tsfm_addr(uint8_t *tsfm_addr, uint8_t *pm_addr);
/**
* @brief handle sta join certification enable
* @param check_enable: sta join certification flag, 0 - disable, 1 - enable
* @retval: see ERR_XXX.
*/
uint32_t iot_sg_cco_enable_sta_join_check(uint8_t check_enable);
/**
* @brief: set passcode.
* @param passcode: simple pair passcode value. Only same passcode CCO and STA
* can beassociated, little endian.
*/
void iot_sg_cco_set_passcode(uint16_t passcode);
/**
* @brief: get passcodeb.
* @retval: passcode.
*/
uint16_t iot_sg_cco_get_passcode();
/**
* @brief: get sta join check enable state.
* @retval: enable state.
*/
uint8_t iot_sg_cco_get_sta_join_check_enable();
/*
* @brief: set white list auto delete function.
* @param auto_del_wl_flag: 1 - enable, 0 - disable.
*/
void iot_sg_cco_set_wl_auto_del(uint8_t auto_del_wl_flag);
/*
* @brief: set white list entry remove time stamp.
* @param mac_addr: mac address to search for white list entry in little-endian
* @param rm_ts: time stamp to remove the entry from white list, unit is 1s
* @retval: ERR_OK for successful case. ERR_FAIL for failed case.
*/
uint32_t iot_sg_cco_set_wl_entry_rm_ts(uint8_t *mac_addr, uint32_t rm_ts);
/* @brief: whether allow control route meter reading status.
* @retval: ERR_OK for successful case. ERR_FAIL for failed case.
*/
uint32_t iot_sg_cco_allow_ctrl_rt_mr();
/* @brief: update uart config parameter.
* @param uart_conf: uart config parameter;
*/
void iot_sg_cco_set_uart_config(iot_sg_cco_uart_conf_t *uart_conf);
/* @brief: get uart config parameter.
* @param uart_conf: uart config parameter.
*/
void iot_sg_cco_get_uart_config(iot_sg_cco_uart_conf_t *uart_conf);
/* @brief: get tsfm detect time left.
* @retval: time left, unit is 1s.
*/
uint32_t iot_sg_cco_get_tsfm_detect_time_left();
/* @brief: get tsfm detect used time.
* @retval: used time, unit is 1s.
*/
uint32_t iot_sg_cco_get_tsfm_detect_used_time();
/* @brief: get sec node register time left.
* @retval: time left, unit is 1s.
*/
uint32_t iot_sg_cco_get_sec_node_reg_timeout_left();
/* @brief: start bcast task.
* @param bcast_time: bcast time, unit is 1min.
* @param interval: bcast interval time, unit is 1s
*/
void iot_sg_cco_bcast_task_start(uint8_t bcast_time, uint8_t interval);
/* @brief: get bcast task state.
* @retval: bcast task state.
*/
uint8_t iot_sg_cco_get_bcast_task_state();
/*
* @brief: reset bcast task parameter.
*/
void iot_sg_cco_bcast_task_param_reset();
/*
* @brief: get predict meter reading state.
*/
uint8_t iot_sg_cco_predict_mr_get_state();
/*
* @brief: get predict meter reading concurrent count..
*/
uint8_t iot_sg_cco_predict_mr_get_con_cnt();
/* @brief: handle predict meter reading ack.
* @param flw_flag: follow data of flag, 0 - no data, 1 - follow-up data.
* @param sn: sequence number of the 3762 packet.
*/
void iot_sg_cco_handle_predict_mr_ack(uint8_t flw_flag, uint8_t sn);
/* @brief: start predict reading meter. */
void iot_sg_cco_start_predict_mr();
/* @brief: stop predict reading meter. */
void iot_sg_cco_stop_predict_mr();
/* @brief: unicast send node event report control.
* @param pkt: event report control data.
* @param total_cnt: total node count.
*/
void iot_sg_cco_start_node_evt_rpt_ctrl(iot_pkt_t *pkt, uint8_t total_cnt);
/* @brief: get node event report control execute state.
* @retval: execute state, 0 - done, 1 - doing.
*/
uint8_t iot_sg_cco_get_node_evt_ctrl_state();
/* @brief: update reset infomation to pib.
* @param op: module reset infomation option, see IOT_SG_CCO_RESET_INFO_OP_XXX.
* @param param: update reset infomation to this pointer.
*/
void iot_sg_cco_update_reset_info_to_pib(uint8_t op, uint8_t *param);
/* @brief: get reset infomation from pib.
* @param op: module reset infomation option, see IOT_SG_CCO_RESET_INFO_OP_XXX.
* @param param: get reset infomation to this pointer.
*/
void iot_sg_cco_get_reset_info_from_pib(uint8_t op, uint8_t *param);
/* @brief: set auto sec node active register.
* @param auto_reg_active: 0 - disable, others - enable.
*/
void iot_sg_cco_set_auto_reg_active(uint8_t auto_reg_active);
/* @brief: get auto sec node active register.
* @retval: 0 - disable, others - enable.
*/
uint8_t iot_sg_cco_get_auto_reg_active();
/* @brief: judge the node phase is lack of phase.
* @param phase: phase that device is connected to.
* @param pm_type: power meter type, 0 is single phase, 1 is three phase.
* @retval: 0 - the node isn't lack of phase. 1 - the node is lack of phase.
*/
uint8_t iot_sg_cco_is_lack_phase(uint8_t phase, uint8_t pm_type);
/* @brief: get current ntb.
* @retval: ntb.
*/
uint32_t iot_sg_cco_get_ntb();
/* @brief: save pm address that isn't in white list.
* @param addr: address, little - endian.
*/
void iot_sg_cco_save_pm_to_mac_list(uint8_t *addr);
/*
* @brief:add internal command to downlink buffer
* @param intern_type: internal command type, see IOT_SG_CCO_INTERN_SEND_XXX.
* @param pkt:data pointer, the ownership of the pkt will be transferred.
* @param pm_mac: meter mac address, little -endian.
* @retval: result, see ERR_XXX.
*/
uint32_t iot_sg_cco_intern_dl_send(uint8_t intern_type, iot_pkt_t *pkt,
uint8_t *pm_mac);
/* @brief: get power meter address from mac list.
* @param index: index of mac list addr.
* @param addr: return address, little - endian.
* @retval: ERR_OK - for success case
* @retval: others - error code
*/
uint32_t iot_sg_cco_get_mac_list_pm_addr(uint16_t index, uint8_t *addr);
/**
* @brief get total node count from list.
* @retval: total node count.
*/
uint8_t iot_sg_cco_get_mac_list_cnt();
/* @brief: get clock manage parameter.
* @param mac: node address, little endian.
* @param auto_corr: node auto correct flag.
* @param threshold: node clock manager threshold.
* @retval: ERR_OK - for success case, others - error code.
*/
uint32_t iot_sg_cco_get_clock_manage_param(uint8_t *mac, uint8_t *auto_corr,
uint8_t *threshold);
/* @brief: set clock manage parameter.
* @param mac: node address, little endian. the mac is bcast when all mac
* cell is 0x99 or 0xFF.
* @param data: clock manager data.
* @param cmd_type: clock manager cmd, see IOT_SG_CCO_CLOCK_MANAGE_XXX.
* @retval: ERR_OK - for success case, others - error code.
*/
uint32_t iot_sg_cco_set_clock_manage_param(uint8_t *mac, uint8_t data,
uint8_t cmd_type);
/**
* @brief get tsfm state from mac list.
* @param index: index of mac list addr.
* @param addr: return node mac address, little endian.
* @param tsfm_addr: return tsfm dectect major node address, big endian.
* @param result: return tsfm dectect result, 0 - different transformer,
* 1 - same transformer.
* @retval: ERR_OK - for success case
* @retval: others - error code
*/
uint32_t iot_sg_cco_get_mac_list_tsfm_state(uint16_t index, uint8_t *addr,
uint8_t *tsfm_addr, uint8_t *result);
/**
* @brief get tsfm max cnt from mac list.
*/
uint8_t iot_sg_cco_get_mac_list_max_cnt();
/**
* @brief whether pm exists in the MAC address list
* @retval: ERR_OK - exist
* @retval: ERR_XXX - not exist
*/
uint32_t iot_sg_cco_get_mac_list_is_exist(uint8_t *pm_addr);
/**
* @brief: set zc notify enable.
* @param zc_notify: zc notify enable, 0 - disabled, 1 - enable
* @retval: ERR_OK - for success case, others - error code.
*/
uint32_t iot_sg_cco_set_zc_notify_enable(uint8_t zc_notify);
/**
* @brief: get zc notify enable.
* @retval: zc_notify: zc notify enable, 0 - disabled, 1 - enable
*/
uint8_t iot_sg_cco_get_zc_notify_enable();
/**
* @brief: enable rtc tx.
* @param enable: rtc send enable, 0 - disabled, 1 - enable
*/
void iot_sg_cco_set_enable_rtc_tx(uint8_t enable);
/**
* @brief di convert to index of table
* @param di: di data.
* @param proto_type: proto type, see PROTO_TYPE_XXX.
* @return: 0xFF is invalid, otherwise is valid
*/
uint8_t iot_sg_cco_di_convert_to_index(uint32_t di, uint8_t proto_type);
/**
* @brief set abnormal report enable for neutralwire and livewire.
* @param enable: configuration enable flag , 0 - disabled, 1 - enable.
*/
void iot_sg_cco_set_nli_enable(uint8_t enable);
/**
* @brief get abnormal electric current event report enable.
* @return: abnormal event report enable.
*/
uint8_t iot_sg_cco_get_nli_enable();
/**
* @brief get cco base info.
* @param info_id: info id for base info.
* @param info_cnt: info cnt for base info.
* @return: pkt pointer, cco base info data.
*/
iot_pkt_t *iot_sg_cco_get_base_info(uint8_t *info_id, uint8_t info_cnt);
/**
* @brief get local node base info.
* @param pm_mac: meter mac address, little endian.
* @param element_id: need get element id
* @return: 1 - element is set, 0 - element is not set.
*/
uint8_t iot_sg_cco_get_element_bm_is_set(uint8_t *pm_mac,
uint8_t element_id);
/**
* @brief get local node base info.
* @param pm_mac: meter mac address, little endian.
* @param info_id: info id for base info.
* @param info_cnt: info cnt for base info.
* @return: pkt pointer, node local base info data.
*/
iot_pkt_t *iot_sg_cco_get_node_local_base_info(uint8_t *pm_mac, uint8_t *info_id,
uint8_t info_cnt);
/**
* @brief get route read fail count.
* @return: fail count.
*/
uint16_t iot_sg_cco_get_route_read_fail_cnt();
/**
* @brief get route read fail node info for index.
* @param node_index: get route read fail info start from this index.
* @param node_info: information of the white list entry
* @return: ERR_OK - success.
* @return: ERR_INVAL - failed.
*/
uint32_t iot_sg_cco_get_route_read_fail_by_index(uint16_t node_index,
iot_sg_wl_entry_info_t* node_info);
/**
* @brief: get physic link type.
* @return: 1 - HPLC & RF dual mode.
* @return: 0 - HPLC single mode.
*/
uint8_t iot_sg_cco_get_phy_type();
/*
* @brief cco set rf channel.
* @param req_id: request id of data to report.
* @param option: rf option.
* @param channel: rf channel.
* @param rf_cod_enable: 0 - disable, 1 - enable.
*/
void iot_sg_cco_set_rf_channel(uint8_t req_id, uint8_t option, uint8_t channel,
uint8_t rf_cod_enable);
/*
* @brief get uart default baud rate;
* @return default baud rate
*/
uint32_t iot_sg_cco_get_uart_defaut_bps();
/*
* @brief baud rate convert to index
* @param bps:baud rate, see IOT_SG_CCO_UART_BAUD_XXX.
* @return index, see IOT_SG_CCO_BAUD_IDX_XXX.
*/
uint8_t iot_sg_cco_uart_bps_to_idx(uint32_t bps);
/*
* @brief index convert to baud rate
* @param type:baud rate, see IOT_SG_CCO_BAUD_IDX_XXX.
* @return baud rate, see IOT_SG_CCO_UART_BAUD_XXX.
*/
uint32_t iot_sg_cco_uart_idx_to_bps(uint8_t type);
/*
* @brief get user type
* @return user type, see USER_TYPE_XX.
*/
uint8_t iot_sg_cco_get_user_type();
/**
* @brief get cli device type
* @param src_type: plc device type, see IOT_PLC_DEV_TYPE_xxx.
* @return: cli device type, see IOT_CLI_SG_DEVICE_TYPE_xxx.
*/
uint8_t iot_sg_cco_get_node_cli_dev_type(uint8_t src_type);
/*
* @brief convert interface calling by channel
* @param channel: data sources, see IOT_SG_CCO_LOCAL_PROTO_DATA_SOURCE_XXX.
* @return interface calling, see IOT_SG_CALLER_TYPE_XXX.
*/
uint8_t iot_sg_cco_get_intf_type_by_channel(uint8_t channel);
/*
* @brief convert channel by interface calling
* @param interface calling, see IOT_SG_CALLER_TYPE_XXX.
* @return channel: data sources, see IOT_SG_CCO_LOCAL_PROTO_DATA_SOURCE_XXX.
*/
uint8_t iot_sg_cco_get_channel_by_intf_type(uint8_t intf_type);
/*
* @brief send response data to cli.
* @param pkt: iot_pkt_t response proto that send to cli,
* the ownership of the pkt will be transferred.
*/
void iot_sg_cco_send_local_proto_to_cli(iot_pkt_t *pkt);
/*
* @brief set tx power to cvg.
* @param hplc_power: hplc tx power, unit is 1 dbuv.
* @param rf_power: rf tx power, unit is 1 dbm.
* @return 0 - power value valid, other - power value invalid.
*/
uint32_t iot_sg_cco_set_tx_power(uint8_t req_id, uint8_t hplc_power,
int8_t rf_power);
/*
* @brief get cco version build info pkt
* @return cco version build info pkt pointer.
*/
iot_pkt_t *iot_sg_cco_get_ver_build_info_pkt();
/*
* @brief check set band parameter valid
* @param band : freq band
* @return: ERR_OK - valid.
* @return: ERR_INVAL - invalid.
*/
uint32_t iot_sg_cco_check_set_band_valid(uint8_t band);
/*
* @brief get cco force single type flag.
* @return: 0 - non force, others - force single type.
*/
uint8_t iot_sg_cco_get_force_single_type_flag();
/*
* @brief if support sta collect parameter v2.8-2.
* @return 0 - don't support, 1 - support.
*/
uint8_t iot_sg_cco_clct_min_is_v28_v2();
/*
* @brief set force link type
* @param link : force link type, 0 - defaule, 1 - force hplc, 2 - force rf.
*/
void iot_sg_cco_set_force_link_type(uint8_t link);
/*
* @brief get force link type
* @return: force link, 0 - defaule, 1 - force hplc, 2 - force rf.
*/
uint8_t iot_sg_cco_get_force_link_type();
/**
* @brief - update edge computing info.
* @edge_set: edge computing info.
*/
void iot_sg_cco_set_edge_computing(iot_sg_cco_edge_computing_set_t *edge_set);
/**
* @brief - set connless link type.
* @link_type: connless link type, see IOT_PLC_FORCE_LINK_XXX.
*/
void iot_sg_cco_set_connless_link_type(uint8_t link_type);
#else /* PLC_SUPPORT_CCO_ROLE && IOT_SMART_GRID_ENABLE */
uint32_t iot_sg_cco_get_clock_manage_param(uint8_t *mac, uint8_t *auto_corr,
uint8_t *threshold);
uint32_t iot_sg_cco_set_clock_manage_param(uint8_t *mac, uint8_t data,
uint8_t cmd_type);
uint32_t iot_sg_cco_get_pm_score_info_by_index(uint16_t index,
iot_sg_cco_sec_node_score_info_t *info);
void iot_sg_cco_set_score_param(uint8_t flag, uint8_t threshold);
void iot_sg_cco_get_score_param(uint8_t *enable_flag, uint8_t *threshold);
void iot_sg_cco_get_score_start_time(uint8_t *day, uint8_t *hour,
uint8_t *minute);
void iot_sg_cco_set_score_start_time(uint8_t day, uint8_t hour, uint8_t minute);
void iot_sg_cco_pm_score_state_reset();
uint32_t iot_sg_cco_set_branch_detect_enabled(uint8_t value,
iot_sg_cco_bd_ctrl_t *ctrl);
uint8_t iot_sg_cco_get_branch_detect_state(void);
iot_pkt_t *iot_sg_cco_get_bd_dev_entry_info(uint16_t start_index,
uint16_t count);
uint32_t iot_sg_cco_start_lp_meter_read();
uint32_t iot_sg_cco_stop_lp_meter_read();
void iot_sg_cco_lp_meter_suspend_search();
uint8_t iot_sg_cco_get_lp_meter_enable();
uint32_t iot_sg_cco_lp_meter_can_mr(uint8_t *lp_meter);
uint16_t iot_sg_cco_get_double_lp_meter_cnt();
uint32_t iot_sg_cco_get_double_lp_meter_info(uint16_t index,
iot_sg_cco_lp_meter_info_t *lp_meter);
iot_pkt_t *iot_sg_cco_pre_proess_read_lp_meter(iot_pkt_t *pkt,
uint8_t *lp_meter_mac, uint8_t *sta_mac);
void iot_sg_cco_set_edge_computing(iot_sg_cco_edge_computing_set_t *edge_set);
void iot_sg_cco_init_clct_task();
uint32_t iot_sg_cco_add_collect_task(iot_sg_collect_task_t *hdr, uint16_t len);
void iot_sg_cco_delete_clct_task(uint8_t clct_task_id);
iot_pkt_t *iot_sg_cco_get_clct_task_info(uint8_t clct_task_id);
iot_pkt_t *iot_sg_cco_query_bcast_clct_task_id();
uint32_t iot_sg_cco_del_clct_read_task(uint8_t task_id);
iot_pkt_t *iot_sg_cco_query_clct_task_read_info(uint8_t task_id,
uint8_t *cmd_addr);
uint8_t iot_sg_cco_predict_mr_get_state();
uint8_t iot_sg_cco_predict_mr_get_con_cnt();
void iot_sg_cco_handle_predict_mr_ack(uint8_t flw_flag, uint8_t sn);
void iot_sg_cco_start_predict_mr();
void iot_sg_cco_stop_predict_mr();
uint8_t iot_sg_cco_get_wlii_cnt_info(iot_sg_wlii_cnt_info_t *info);
iot_pkt_t* iot_sg_cco_get_wlii_entry_info(uint32_t start_index, uint32_t count);
void iot_sg_cco_add_wlii_addr(uint8_t intf_type, iot_pkt_t *iot_pkt);
void iot_sg_cco_remove_wlii_addr(uint8_t intf_type, uint8_t entry_count,
uint8_t* mac_addr_array);
#define iot_sg_cco_reset_parameter_info()
#define iot_sg_cco_start_driver_timer1(dur) (0)
#define iot_sg_cco_stop_driver_timer1()
#define iot_sg_cco_start_driver_timer2(dur) (0)
#define iot_sg_cco_stop_driver_timer2()
#define iot_sg_cco_restart_driver_timer3(dur)
#define iot_sg_cco_start_driver_timer4(dur) (0)
#define iot_sg_cco_stop_driver_timer4()
#define iot_sg_cco_start_driver_timer5(dur) (0)
#define iot_sg_cco_stop_driver_timer5()
#define iot_sg_cco_restart_driver_timer5(dur)
#define iot_sg_cco_start_driver_timer6(dur) (0)
#define iot_sg_cco_stop_driver_timer6()
#define iot_sg_cco_get_mr_pkt_mac(pm_mac, data, len, proto_type) (ERR_FAIL)
#define iot_sg_cco_set_rt_mr_result(node_index, result) (0)
#define iot_sg_start_sec_node_reg(intf_type, duration, count, auto_stop)
#define iot_sg_stop_sec_node_reg(intf_type, reason)
#define iot_sg_cco_get_evt_rpt_state() (1)
#define iot_sg_broadcast_data(intf_type, data_type, data, len, sta_mac)
#define iot_sg_cco_correct_sta_time(intf_type, data_type, data, len, \
bcast_type, ntb)
#define iot_sg_cco_clear_all_wlii_addr()
#define iot_sg_cco_clear_all_wl_addr()
#define iot_sg_cco_add_wl_addr(intf_type, entry_count)
#define iot_sg_cco_add_bl_addr(intf_type, iot_pkt)
#define iot_sg_cco_remove_wl_addr(intf_type, entry_count, mac_addr_array)
#define iot_sg_cco_remove_bl_addr(intf_type, iot_pkt)
#define iot_sg_cco_clean_bl_addr(intf_type)
#define iot_sg_route_control(intf_type, op)
#define iot_sg_cco_get_meter_count()
#define iot_sg_cco_is_route_learn_done() (0)
#define iot_sg_cco_wl_is_enabled() (0)
#define iot_sg_cco_get_wl_cnt() (0)
#define iot_sg_cco_get_wlii_cnt() (0)
#define iot_sg_cco_reset_wlii()
#define iot_sg_cco_get_wl_info_by_index(node_index, node_info) (0)
#define iot_sg_cco_get_pm_info_by_mac(pm_mac, node_info) (0)
#define iot_sg_cco_get_pm_info_by_index(node_index, node_info) (0)
#define iot_sg_cco_get_meter_by_index(node_index, node_info) (0)
#define iot_sg_cco_reset_pm_state()
#define iot_sg_cco_get_topo_msg(req_id, req_data_ver, start_index, count)
#define iot_sg_cco_get_nw_msg(req_id)
#define iot_sg_coo_get_free_meter_entry_count() (0)
#define iot_sg_cco_get_nb_nw_info_msg(req_id)
#define iot_sg_cco_get_free_wl_entry_count() (0)
#define iot_sg_cco_get_free_wlii_entry_count() (0)
#define iot_sg_cco_get_node_info_msg(req_id, ver, sta_mac, sta_cnt)
#define iot_sg_cco_get_bl_node_info_msg(req_id, start_index, count)
#define iot_sg_set_cco_mac_addr(x1, x2)
#define iot_sg_cco_start_nw_fmt()
#define iot_sg_cco_set_cli_upgrade_enable(enable)
#define iot_sg_cco_start_recv_upgrade(file_type, file_id, mac, block_size, \
total_block_cnt, file_size, crc16, window_time);
#define iot_sg_cco_handle_file_segment(data, len, index)
#define iot_sg_cco_get_freq_band_msg()
#define iot_sg_cco_set_freq_band_msg(req_id, freq_band)
#define iot_sg_cco_get_vendor_device_sn(vendor_device_sn, sn_len) (0)
#define iot_sg_cco_set_vendor_device_sn_to_pib(vendor_device_sn, sn_len) \
(ERR_FAIL)
#define iot_sg_cco_get_neighbor_dev_msg(req_id, start, cnt)
#define iot_sg_cco_cache_sg_mr_cmd(mr_type, sn, afn, proto_type, src_addr, \
dst_addr, pkt, intf_type, prio, timeout, need_reply, task_id, \
sn_inc_flag, emergency) (0)
#define iot_sg_cco_cache_has_sg_mr_cmd(dest_addr)
#define iot_sg_cco_cache_has_sg_ext_mr_cmd(mac_addr, ext_data_type) (0)
#define iot_sg_cco_recv_ack_to_report(really_ack, sn)
#define iot_sg_cco_wl_entry_exist(meter_mac) (0)
#define iot_sg_cco_wlii_entry_exist(meter_mac) (0)
#define iot_sg_get_wl_entry_info_by_mac(mac_addr, info) (0)
#define iot_sg_get_wlii_entry_info_by_mac(mac_addr, info) (0)
#define iot_sg_cco_get_sta_mac_by_index(sta_index, sta_mac) (0)
#define iot_sg_cco_get_router_mr_timeout() (0)
#define iot_sg_cco_get_node_monitor_max_dur() (0)
#define iot_sg_cco_set_node_monitor_max_dur(dur)
#define iot_sg_cco_get_major_node_mac(major_node_mac)
#define iot_sg_cco_set_major_node_mac(major_node_mac)
#define iot_sg_cco_set_repeater_addr_range(start_addr, end_addr) (ERR_FAIL)
#define iot_sg_cco_get_repeater_addr_range(start_addr, end_addr)
#define iot_sg_cco_check_exceed_con_cnt(dest_addr) (0)
#define iot_sg_cco_get_sn_for_cctt() (0)
#define iot_sg_cco_get_router_work_flag() (IOT_SG_CCO_ROUTER_WORK_FLAG_STOP)
#define iot_sg_cco_get_router_work_mode() (0)
#define iot_sg_cco_set_router_work_mode(work_mode)
#define iot_sg_cco_get_router_sec_node_reg_allowed() (0)
#define iot_sg_cco_set_router_sec_node_reg_allowed(reg_allowed)
#define iot_sg_cco_get_router_work_type() \
(IOT_SG_CCO_ROUTER_WORK_TYPE_RESVD)
#define iot_sg_cco_set_router_work_type(work_type)
#define iot_sg_cco_get_router_evt_flag() (0)
#define iot_sg_cco_get_tsfm_detect_status() (IOT_SG_CCO_TSFM_DETECT_DONE)
#define iot_sg_cco_set_tsfm_detect_status(value)
#define iot_sg_cco_get_tsfm_detect_enabled() (0)
#define iot_sg_cco_set_tsfm_detect_enabled(sta_lock, value, \
qr_sta_tsfm_detect_ret, tsfm_detect_dur, bcast_feature, \
is_keep_bcast) (ERR_FAIL)
#define iot_sg_cco_get_pm_proto_type(pm_mac, pm_proto) (0)
#define iot_sg_cco_add_null_mr_data(intf_type, sn, afn, src_mac, dest_mac, \
mr_type, proto_type);
#define iot_sg_cco_get_power_status() (0)
#define iot_sg_cco_sec_node_rpt(sta_mac, chg_state, dev_mac) (0)
#define iot_sg_cco_handle_evt_rpt(sta_addr, pm_addr, pkt, seq, evt_type, \
dev_type, not_check_wl) (ERR_NOSUPP)
#define iot_sg_cco_get_sec_node_info(sta_mac, node_cnt) (NULL)
#define iot_sg_cco_get_esp() (IOT_SG_CCO_ESP_AUTO)
#define iot_sg_cco_set_esp(esp)
#define iot_sg_cco_router_mr_find_node_entry(read_pm_index, info) (0)
#define iot_sg_cco_sys_reset_wait_time (0)
#define iot_sg_cco_clean_buf_pool()
#define iot_sg_cco_add_task_cmd(proto_type, task_id, prio, sn, timeout, \
need_reply, src_mac, dst_mac, pkt, sn_inc_flag, task_id_filter, \
emergency, forward, intf_type) (0)
#define iot_sg_cco_rm_task_cmd(task_id) (0)
#define iot_sg_cco_enable_mr(intf_type)
#define iot_sg_cco_disable_mr(intf_type)
#define iot_sg_cco_get_free_task_cnt() (0)
#define iot_sg_cco_get_task_info_by_id(task_id) (0)
#define iot_sg_cco_get_task_listid(start_index, cnt, taskid) (0)
#define iot_sg_cco_convert_phase(dev_type, phase1, phase2, phase3) (0)
#define iot_sg_cco_rt_mr_get_state() (IOT_SG_CCO_RT_AMR_STATE_INIT)
#define iot_sg_cco_rt_mr_set_backup_ack_sn(sn)
#define iot_sg_cco_rt_mr_result_ack(sn)
#define iot_sg_cco_get_conn_less_status() (0)
#define iot_sg_cco_is_power_up_again() (0)
#define iot_sg_cco_get_mr_timeout(intf_type, mr_type) (0)
#define iot_sg_cco_get_tsfm_status_by_mac(pm_addr) (0)
#define iot_sg_cco_get_tsfm_result_by_mac(pm_addr) (0)
#define iot_sg_cco_meter_mac_to_sta_mac(meter_mac, sta_mac) (ERR_FAIL)
#define iot_sg_cco_get_ctrl_proto_status() (0)
#define iot_sg_cco_send_ctrl_proto(pkt)
#define iot_sg_cco_local_proto_data_send(channel, pkt)
#define iot_sg_cco_query_upgrade_info(query_info) (ERR_FAIL)
#define iot_sg_cco_upgrade_get_fail_sta_list(start_index, cnt) (NULL)
#define iot_sg_cco_upgrade_statistics(statistics, print_flag)
#define iot_sg_cco_get_meter_type(sta_mac) (0)
#define iot_sg_cco_get_dev_power_state(sta_mac) (1)
#define iot_sg_cco_is_pm(dev_type) (0)
#define iot_sg_cco_is_collector_or_pm(dev_type) (0)
#define iot_sg_cco_is_collector(dev_type) (0)
#define iot_sg_cco_get_dev_chip_id_by_mac(sta_addr, chip_id) (ERR_INVAL)
#define iot_sg_cco_get_dev_module_id_by_mac(sta_addr, mod_id) (ERR_INVAL)
#define iot_sg_cco_get_dev_type_by_mac(sta_mac) (0)
#define iot_sg_cco_reject_bl_exist(mac_addr) (0)
#define iot_sg_cco_add_reject_bl(mac_addr)
#define iot_sg_cco_clear_reject_bl()
#define iot_sg_cco_check_is_first_join(sta_addr) (0)
#define iot_sg_cco_get_net_node_cnt() (0)
#define iot_sg_cco_get_pm_cnt() (0)
#define iot_sg_cco_get_net_node_info_by_index(start_type, value, \
info) (ERR_FAIL)
#define iot_sg_cco_get_net_node_info_by_mac(pm_mac, info) (ERR_FAIL)
#define iot_sg_cco_get_net_node_info_by_pm_index(value, info) (ERR_FAIL)
#define iot_sg_cco_get_pm_info_by_real_index(index, info) (ERR_FAIL)
#define iot_sg_cco_get_collector_meter_addr_by_index(sta_mac, pm_mac, index) (0)
#define iot_sg_cco_get_sec_node_reg_cnt() (0)
#define iot_sg_cco_get_sec_node_cnt(sta_mac) (0)
#define iot_sg_cco_add_meter_mapping_info(meter_addr, node_addr) (ERR_FAIL)
#define iot_sg_cco_get_meter_mapping_cnt() (0)
#define iot_sg_cco_set_module_clct_param(proto_type, data_len, clct_param)
#define iot_sg_cco_get_module_clct_param(proto_type, type, task_id) (NULL)
#define iot_sg_cco_get_meter_mapping_info_from_index(index, map_info) (ERR_FAIL)
#define iot_sg_cco_get_app_proto(void) (0)
#define iot_sg_cco_send_cctt_rsp_passthrouth_data(pkt)
#define iot_sg_cco_update_correct_sta_time_interval_to_pib(time) (NULL)
#define iot_sg_cco_get_correct_sta_time_interval_from_pib(void) (0)
#define iot_sg_cco_cache_ext_task(task_type, dest_mac, sn, pkt, \
timeout, prio, intf_type) (0)
#define iot_sg_cco_get_node_join_ts(node_mac) (0)
#define iot_sg_cco_get_reject_bl_cnt() (0)
#define iot_sg_cco_get_reject_bl_info(index, info) (ERR_FAIL)
#define iot_sg_cco_update_rw_esp(esp)
#define iot_sg_cco_set_tsfm_detect_lock_time(net_lock_time, abn_lock_time)
#define iot_sg_cco_get_tsfm_detect_lock_time(net_lock_time, abn_lock_time)
#define iot_sg_cco_get_leave_net_reason() (0)
#define iot_sg_cco_get_phase_repeat_flag() (0)
#define iot_sg_cco_rtc_timer_sync_bcast(rtc_time)
#define iot_sg_cco_set_bcast_tsfm_addr_param(cmd_type, tsfm_addr)
#define iot_sg_cco_set_bcast_lock_cmd(cmd_type)
#define iot_sg_cco_set_trans_mode(trans_mode)
#define iot_sg_cco_get_trans_mode(proto_type) (0)
#define iot_sg_cco_set_wl_state(wl_state) (ERR_FAIL)
#define iot_sg_cco_get_wl_state() (0)
#define iot_sg_cco_clear_reject_node()
#define iot_sg_cco_get_dev_addr(dev_addr, pm_addr) (ERR_FAIL)
#define iot_sg_cco_get_tsfm_addr(tsfm_addr, pm_addr) (ERR_FAIL)
#define iot_sg_cco_enable_sta_join_check(check_enable) (ERR_FAIL)
#define iot_sg_cco_set_passcode(passcode)
#define iot_sg_cco_get_passcode() (0)
#define iot_sg_cco_get_sta_join_check_enable() (0)
#define iot_sg_cco_set_wl_auto_del(del_flag)
#define iot_sg_cco_set_wl_entry_rm_ts(mac_addr, rm_ts) (ERR_FAIL)
#define iot_sg_cco_allow_ctrl_rt_mr() (ERR_FAIL)
#define iot_sg_cco_set_uart_config(uart_conf)
#define iot_sg_cco_get_uart_config(uart_conf)
#define iot_sg_cco_get_tsfm_detect_time_left() (0)
#define iot_sg_cco_get_tsfm_detect_used_time() (0)
#define iot_sg_cco_get_sec_node_reg_timeout_left() (0)
#define iot_sg_cco_bcast_task_start(bcast_time, interval)
#define iot_sg_cco_get_bcast_task_state() (0)
#define iot_sg_cco_bcast_task_param_reset()
#define iot_sg_cco_start_node_evt_rpt_ctrl(pkt, total_cnt)
#define iot_sg_cco_get_node_evt_ctrl_state() (0)
#define iot_sg_cco_update_reset_info_to_pib(op, param)
#define iot_sg_cco_get_reset_info_from_pib(op, param)
#define iot_sg_cco_set_auto_reg_active(auto_reg_active)
#define iot_sg_cco_get_auto_reg_active() (0)
#define iot_sg_cco_is_lack_phase(phase, pm_type) (0)
#define iot_sg_cco_get_ntb() (0)
#define iot_sg_cco_save_pm_to_mac_list(addr)
#define iot_sg_cco_intern_dl_send(intern_type, pkt, pm_mac) (ERR_FAIL)
#define iot_sg_cco_get_mac_list_pm_addr(index, addr) (ERR_FAIL)
#define iot_sg_cco_get_mac_list_cnt() (0)
#define iot_sg_cco_get_mac_list_tsfm_state(index, addr, tsfm_addr, \
result) (ERR_FAIL)
#define iot_sg_cco_get_mac_list_max_cnt() (0)
#define iot_sg_cco_set_zc_notify_enable(zc_notify) (ERR_FAIL)
#define iot_sg_cco_get_zc_notify_enable() (0)
#define iot_sg_cco_set_enable_rtc_tx(enable)
#define iot_sg_cco_di_convert_to_index(di, proto_type) (0xFF)
#define iot_sg_cco_set_nli_enable(enable)
#define iot_sg_cco_get_nli_enable() (0)
#define iot_sg_cco_get_base_info(info_id, info_cnt) (NULL)
#define iot_sg_cco_get_node_local_base_info(pm_mac, info_id, info_cnt) (NULL)
#define iot_sg_cco_get_element_bm_is_set(pm_mac, element_id) (0)
#define iot_sg_cco_get_route_read_fail_cnt()
#define iot_sg_cco_get_route_read_fail_by_index(node_index, node_info) \
(ERR_FAIL)
#define iot_sg_cco_get_phy_type() (0)
#define iot_sg_cco_set_rf_channel(req_id, option, channel, rf_cod_enable)
#define iot_sg_cco_get_uart_defaut_bps() IOT_SG_CCO_BAUD_9600
#define iot_sg_cco_uart_bps_to_idx(bps) IOT_SG_CCO_BAUD_IDX_9600
#define iot_sg_cco_uart_idx_to_bps(type) IOT_SG_CCO_UART_BAUD_9600
#define iot_sg_cco_get_user_type() (0)
#define iot_sg_cco_get_node_cli_dev_type(src_type) (0)
#define iot_sg_cco_send_local_proto_to_cli(pkt)
#define iot_sg_cco_set_tx_power(req_id, hplc_power, rf_power) 0
#define iot_sg_cco_get_intf_type_by_channel(channel) IOT_SG_CALLER_TYPE_CCTT
#define iot_sg_cco_get_cco_uart_bps() (0)
#define iot_sg_cco_get_channel_by_intf_type(intf_type) \
IOT_SG_CCO_LOCAL_PROTO_DATA_SOURCE_CCTT
#define iot_sg_cco_get_ver_build_info_pkt() (NULL)
#define iot_sg_cco_check_set_band_valid(band) (ERR_FAIL)
#define iot_sg_cco_get_force_single_type_flag() (0)
#define iot_sg_cco_clct_min_is_v28_v2() (0)
#define iot_sg_cco_set_force_link_type(link)
#define iot_sg_cco_get_force_link_type() 0
#define iot_sg_cco_set_connless_link_type(link_type)
#endif /* PLC_SUPPORT_CCO_ROLE && IOT_SMART_GRID_ENABLE */
#ifdef __cplusplus
}
#endif
#endif /* IOT_SG_CCO_DRV_H */