97 lines
2.9 KiB
C
Executable File
97 lines
2.9 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_BT_EXT_PROTOCOL_H_
|
|
#define _IOT_BT_EXT_PROTOCOL_H_
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "os_types_api.h"
|
|
#include "os_utils_api.h"
|
|
|
|
/* plc bluetooth protocol information */
|
|
/* protocol format
|
|
* start_code(2) + version(1) + port(1) + crc(2) + payload len(2)
|
|
* + payload(n) + end_code(2)
|
|
*/
|
|
/* packet start code */
|
|
#define IOT_BT_EXT_PROTO_START_CODE 0x24
|
|
/* packet end code */
|
|
#define IOT_BT_EXT_PROTO_END_CODE 0x42
|
|
|
|
/* start code fields length */
|
|
#define IOT_BT_EXT_PROTO_START_LEN 2
|
|
/* end code fields length */
|
|
#define IOT_BT_EXT_PROTO_END_LEN 2
|
|
/* payload_len field length */
|
|
#define IOT_BT_EXT_PROTO_PL_LEN_FIELD_LEN 2
|
|
/* min packet length(none payload) */
|
|
#define IOT_BT_EXT_PROTO_PACKET_MIN_LEN (sizeof(iot_bt_ext_proto_hdr_t) \
|
|
+ sizeof(iot_bt_ext_proto_start_t) + sizeof(iot_bt_ext_proto_end_t))
|
|
|
|
/* plc bt protocol version */
|
|
#define IOT_BT_EXT_PROTO_VERSION 0
|
|
|
|
typedef enum {
|
|
/* at command port, not support */
|
|
IOT_BT_EXT_PORT_AT_CMD = 0,
|
|
/* current protocol/device port, not support */
|
|
IOT_BT_EXT_PORT_PROTO = 1,
|
|
/* upgrade port */
|
|
IOT_BT_EXT_PORT_UPGRADE = 2,
|
|
/* device management port */
|
|
IOT_BT_EXT_PORT_DEV_MGMT = 3,
|
|
/* port id max id */
|
|
IOT_BT_EXT_PORT_SUB_NUM,
|
|
} IOT_BT_EXT_PORT_SUB_ID;
|
|
|
|
#pragma pack(push)
|
|
#pragma pack(1)
|
|
|
|
/* plc bt protocol typedef */
|
|
/* plc bt protocol start filed */
|
|
typedef struct _iot_bt_ext_proto_start {
|
|
/* start sync code */
|
|
uint8_t start[IOT_BT_EXT_PROTO_START_LEN];
|
|
} iot_bt_ext_proto_start_t;
|
|
|
|
/* plc bt protocol header filed */
|
|
typedef struct _iot_bt_ext_proto_hdr {
|
|
/* protocol version number */
|
|
uint8_t version;
|
|
/* communication port, see IOT_BT_EXT_PROTO_PORT_XXX */
|
|
uint8_t port;
|
|
/* payload crc */
|
|
uint16_t crc;
|
|
/* payload length */
|
|
uint16_t length;
|
|
} iot_bt_ext_proto_hdr_t;
|
|
|
|
/* plc bt protocol end filed */
|
|
typedef struct _iot_bt_ext_proto_end {
|
|
/* end sync code */
|
|
uint8_t end[IOT_BT_EXT_PROTO_END_LEN];
|
|
} iot_bt_ext_proto_end_t;
|
|
|
|
#pragma pack(pop)
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|