241 lines
		
	
	
		
			7.9 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			241 lines
		
	
	
		
			7.9 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/****************************************************************************
 | 
						|
 | 
						|
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_SWC_MSG_API_H
 | 
						|
#define IOT_SWC_MSG_API_H
 | 
						|
 | 
						|
#include "os_types_api.h"
 | 
						|
#include "iot_utils_api.h"
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
extern "C" {
 | 
						|
#endif
 | 
						|
 | 
						|
/* pack for the structures in the whole file */
 | 
						|
#pragma pack(push)  // save the pack status
 | 
						|
#pragma pack(1)     // 1 byte align
 | 
						|
 | 
						|
/** app request succeed */
 | 
						|
#define IOT_SWC_SUCCESS                     (0x0)
 | 
						|
/** app request failed */
 | 
						|
#define IOT_SWC_FAILED                      (0x1)
 | 
						|
 | 
						|
/** whitelist and blacklist operation */
 | 
						|
#define IOT_SWC_WL_DISABLE                  (0x0)
 | 
						|
#define IOT_SWC_WL_ADD                      (0x1)
 | 
						|
#define IOT_SWC_WL_DEL                      (0x2)
 | 
						|
#define IOT_SWC_WL_ENABLE                   (0x3)
 | 
						|
#define IOT_SWC_BL_DISABLE                  (0x4)
 | 
						|
#define IOT_SWC_BL_ADD                      (0x5)
 | 
						|
#define IOT_SWC_BL_DEL                      (0x6)
 | 
						|
#define IOT_SWC_BL_ENABLE                   (0x7)
 | 
						|
 | 
						|
/** common SWC message id definitions shared between CCO and STA device */
 | 
						|
#define IOT_SWC_MSG_CFG_SET_REQ             0x80
 | 
						|
#define IOT_SWC_MSG_CFG_SET_CONF            0x81
 | 
						|
#define IOT_SWC_MSG_MSDU_SEND               0x82
 | 
						|
#define IOT_SWC_MSG_MSDU_RECV               0x83
 | 
						|
#define IOT_SWC_MSG_NW_WL_QUERY             0x84
 | 
						|
#define IOT_SWC_MSG_NW_WL_RPT               0x85
 | 
						|
#define IOT_SWC_MSG_NW_WL_SET               0x86
 | 
						|
#define IOT_SWC_MSG_NW_WL_SET_RPT           0x87
 | 
						|
#define IOT_SWC_MSG_NW_BL_QUERY             0x88
 | 
						|
#define IOT_SWC_MSG_NW_BL_RPT               0x89
 | 
						|
#define IOT_SWC_MSG_NW_BL_SET               0x8A
 | 
						|
#define IOT_SWC_MSG_NW_BL_SET_RPT           0x8B
 | 
						|
#define IOT_SWC_MSG_KEEP_ALIVE              0x8C
 | 
						|
 | 
						|
/** packet send type */
 | 
						|
#define IOT_SWC_MSG_TYPE_INVALID            0x00
 | 
						|
/** unicast packet */
 | 
						|
#define IOT_SWC_MSG_TYPE_UNICAST            0x01
 | 
						|
/** broadcast packet */
 | 
						|
#define IOT_SWC_MSG_TYPE_BCAST              0x02
 | 
						|
 | 
						|
/** SWC device type */
 | 
						|
#define IOT_SWC_DEV_TYPE_METER_CONTROLLER   1
 | 
						|
#define IOT_SWC_DEV_TYPE_CONCENTRATOR       2
 | 
						|
#define IOT_SWC_DEV_TYPE_POWER_METER        3
 | 
						|
#define IOT_SWC_DEV_TYPE_REPEATER           4
 | 
						|
#define IOT_SWC_DEV_TYPE_COLLECTOR_2        5
 | 
						|
#define IOT_SWC_DEV_TYPE_COLLECTOR_1        6
 | 
						|
#define IOT_SWC_DEV_TYPE_INVAL              0xFF
 | 
						|
 | 
						|
/* default request id */
 | 
						|
#define IOT_SWC_API_REQ_ID_DEFAULT          0
 | 
						|
 | 
						|
/** swc message header */
 | 
						|
typedef struct _iot_swc_msg_header {
 | 
						|
    /** msg id */
 | 
						|
    uint8_t     msg_id;
 | 
						|
    /** request id */
 | 
						|
    uint8_t     req_id;
 | 
						|
    /** reserved for future */
 | 
						|
    uint16_t    rsvd;
 | 
						|
} iot_swc_msg_header_t;
 | 
						|
 | 
						|
/** IOT_SWC_MSG_CFG_SET_REQ format */
 | 
						|
typedef struct _iot_swc_cfg_set_req {
 | 
						|
    /** type of local device. see IOT_SWC_DEV_TYPE_XXX */
 | 
						|
    uint8_t             dev_type;
 | 
						|
    /** if reset lower layer to apply the configuration */
 | 
						|
    uint8_t             reset;
 | 
						|
    /** software version */
 | 
						|
    uint16_t            sw_ver;
 | 
						|
    /** mac address of local device */
 | 
						|
    uint8_t             addr[IOT_MAC_ADDR_LEN];
 | 
						|
} iot_swc_cfg_set_req_t;
 | 
						|
 | 
						|
/** IOT_SWC_MSG_CFG_SET_CONF format */
 | 
						|
typedef struct _iot_swc_cfg_set_conf {
 | 
						|
    /** result of the request */
 | 
						|
    uint8_t             result;
 | 
						|
    /** error number */
 | 
						|
    uint8_t             err_no;
 | 
						|
} iot_swc_cfg_set_conf_t;
 | 
						|
 | 
						|
/** IOT_SWC_MSG_MSDU_SEND format */
 | 
						|
typedef struct _iot_swc_msdu_send {
 | 
						|
    /** type of the message. see IOT_SWC_MSG_TYPE_XXX */
 | 
						|
    uint8_t     msg_type;
 | 
						|
    /** link id */
 | 
						|
    uint8_t     lid;
 | 
						|
    /** payload length */
 | 
						|
    uint16_t    len;
 | 
						|
    /** final destion mac address */
 | 
						|
    uint8_t     dst[IOT_MAC_ADDR_LEN];
 | 
						|
    /** original source mac address */
 | 
						|
    uint8_t     src[IOT_MAC_ADDR_LEN];
 | 
						|
    /** msdu data payload */
 | 
						|
    uint8_t     data[0];
 | 
						|
} iot_swc_msdu_send_t;
 | 
						|
 | 
						|
/** IOT_SWC_MSG_MSDU_RECV format */
 | 
						|
typedef struct _iot_swc_msdu_recv {
 | 
						|
    /** payload length */
 | 
						|
    uint16_t    len;
 | 
						|
    /** final destion mac address */
 | 
						|
    uint8_t     dst[IOT_MAC_ADDR_LEN];
 | 
						|
    /** original source mac address */
 | 
						|
    uint8_t     src[IOT_MAC_ADDR_LEN];
 | 
						|
    /** msdu data payload */
 | 
						|
    uint8_t     data[0];
 | 
						|
} iot_swc_msdu_recv_t;
 | 
						|
 | 
						|
/** IOT_SWC_MSG_NW_WL_QUERY format */
 | 
						|
typedef struct _iot_swc_wl_query {
 | 
						|
    /** start entry index in whitelist */
 | 
						|
    uint16_t             start;
 | 
						|
    /** maximum number of whitelist entry to return for this request */
 | 
						|
    uint16_t             count;
 | 
						|
} iot_swc_wl_query_t;
 | 
						|
 | 
						|
/** IOT_SWC_MSG_NW_BL_QUERY format */
 | 
						|
typedef struct _iot_swc_bl_query {
 | 
						|
    /** start entry index in blacklist */
 | 
						|
    uint16_t             start;
 | 
						|
    /** maximum number of blacklist entry to return for this request */
 | 
						|
    uint16_t             count;
 | 
						|
} iot_swc_bl_query_t;
 | 
						|
 | 
						|
/** IOT_SWC_MSG_NW_WL_RPT format */
 | 
						|
typedef struct _iot_swc_wl_rpt {
 | 
						|
    /** total count of whitelist entries */
 | 
						|
    uint16_t            total_count;
 | 
						|
    /** count of entries contained in this reply packet */
 | 
						|
    uint16_t            count;
 | 
						|
    /** report done */
 | 
						|
    uint16_t            done    :1,
 | 
						|
    /** reserved for future */
 | 
						|
                        rsvd    :15;
 | 
						|
    /** whitelist entries */
 | 
						|
    uint8_t             mac_addr[0][IOT_MAC_ADDR_LEN];
 | 
						|
} iot_swc_wl_rpt_t;
 | 
						|
 | 
						|
/** IOT_SWC_MSG_NW_BL_RPT format */
 | 
						|
typedef struct _iot_swc_bl_rpt {
 | 
						|
    /** total count of blacklist entries */
 | 
						|
    uint16_t            total_count;
 | 
						|
    /** count of entries contained in this reply packet */
 | 
						|
    uint16_t            count;
 | 
						|
    /** report done */
 | 
						|
    uint16_t            done    :1,
 | 
						|
    /** reserved for future */
 | 
						|
                        rsvd    :15;
 | 
						|
    /** blacklist entries */
 | 
						|
    uint8_t             mac_addr[0][IOT_MAC_ADDR_LEN];
 | 
						|
} iot_swc_bl_rpt_t;
 | 
						|
 | 
						|
/** IOT_SWC_MSG_NW_WL_SET format */
 | 
						|
typedef struct _iot_swc_wl_set_req {
 | 
						|
    /** action to perform: DISABLE / ADD / DELETE whitelist entries. see
 | 
						|
     * IOT_SWC_WL_XXX.
 | 
						|
     */
 | 
						|
    uint8_t             action;
 | 
						|
    /** count of whitelist entries to operate on */
 | 
						|
    uint16_t            count;
 | 
						|
    /** whitelist entries */
 | 
						|
    uint8_t             mac_addr[0][IOT_MAC_ADDR_LEN];
 | 
						|
} iot_swc_wl_set_req_t;
 | 
						|
 | 
						|
/** IOT_SWC_MSG_NW_BL_SET format */
 | 
						|
typedef struct _iot_swc_bl_set_req {
 | 
						|
    /** action to perform: DISABLE / ADD / DELETE blacklist entries. see
 | 
						|
     * IOT_SWC_BL.
 | 
						|
     */
 | 
						|
    uint8_t             action;
 | 
						|
    /** count of blacklist entries to operate on */
 | 
						|
    uint16_t            count;
 | 
						|
    /** blacklist entries */
 | 
						|
    uint8_t             mac_addr[0][IOT_MAC_ADDR_LEN];
 | 
						|
} iot_swc_bl_set_req_t;
 | 
						|
 | 
						|
/** IOT_SWC_MSG_NW_WL_SET_RPT format */
 | 
						|
typedef struct _iot_swc_wl_set_rpt {
 | 
						|
    /** result of the whitelist set request */
 | 
						|
    uint8_t             result;
 | 
						|
    /** error number */
 | 
						|
    uint8_t             err_no;
 | 
						|
} iot_swc_wl_set_rpt_t;
 | 
						|
 | 
						|
/** IOT_SWC_MSG_NW_BL_SET_RPT format */
 | 
						|
typedef struct _iot_swc_bl_set_rpt {
 | 
						|
    /** result of the blacklist set request */
 | 
						|
    uint8_t             result;
 | 
						|
    /** error number */
 | 
						|
    uint8_t             err_no;
 | 
						|
} iot_swc_bl_set_rpt_t;
 | 
						|
 | 
						|
/** IOT_SWC_MSG_KEEP_ALIVE format */
 | 
						|
typedef struct _iot_swc_keep_alive {
 | 
						|
    /** flag to mark if SWC MAC is waiting for configuration from APP to
 | 
						|
     * start network formation.
 | 
						|
     */
 | 
						|
    uint8_t             wait_for_cfg    :1,
 | 
						|
    /** reserved for future */
 | 
						|
                        rsvd            :7;
 | 
						|
} iot_swc_keep_alive_t;
 | 
						|
 | 
						|
/* callback type definition. */
 | 
						|
typedef void(*iot_swc_lib_cb_t)(iot_pkt_t *pkt);
 | 
						|
 | 
						|
#pragma pack(pop)    /* restore the pack status */
 | 
						|
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
}
 | 
						|
#endif
 | 
						|
 | 
						|
#endif /* IOT_SWC_MSG_API_H */ |