104 lines
2.3 KiB
C
104 lines
2.3 KiB
C
/*
|
|
* ne_general.h -- provide iot-system device layer operation interface.
|
|
*
|
|
*
|
|
* ORIGINAL AUTHOR:
|
|
*
|
|
* Copyright (c) 2018 Netease Corporation
|
|
*/
|
|
|
|
#ifndef NE_GENERAL_H
|
|
#define NE_GENERAL_H
|
|
|
|
#include "c_types.h"
|
|
|
|
#define NE_DEVICE_GENERAL_HEAD 0x3c
|
|
#define NE_GENERAL_MAX_SBUF_LEN 18
|
|
|
|
#define GENERAL_DEBUG_ENABLE 1
|
|
#if GENERAL_DEBUG_ENABLE
|
|
#define GENERAL_LOG_EX LOG_EX
|
|
#else
|
|
#define GENERAL_LOG_EX
|
|
#endif
|
|
|
|
|
|
enum{
|
|
NE_GENERAL_SUCCESS,
|
|
NE_GENERAL_FAIL
|
|
};
|
|
|
|
enum{
|
|
NE_GENERAL_OTA_INFO,
|
|
NE_GENERAL_OTA_START,
|
|
NE_GENERAL_OTA_DOWNLOAD,
|
|
NE_GENERAL_OTA_READ,
|
|
NE_GENERAL_OTA_STOP
|
|
};
|
|
|
|
enum{
|
|
NE_GENERAL_NETWORK_CONNECTED,
|
|
NE_GENERAL_NETWORK_DISCONNECT,
|
|
NE_GENERAL_NETWORK_MISSSID,
|
|
NE_GENERAL_NETWORK_CONNECTTING,
|
|
NE_GENERAL_NETWORK_MQTT_CONNECT,
|
|
NE_GENERAL_NETWORK_MQTT_DISCONNECT,
|
|
};
|
|
|
|
enum{
|
|
NE_DEVICE_GENERAL_PASS_THROUGH,
|
|
NE_DEVICE_GENERAL_ALL_UPLOAD,
|
|
NE_DEVICE_GENERAL_MCU_OTA,
|
|
NE_DEVICE_GENERAL_WIFI_PROCESS,
|
|
NE_DEVICE_GENERAL_ABNORMAL
|
|
};
|
|
|
|
enum{
|
|
NE_DEVICE_GENERAL_CMD_START_CONNET,
|
|
NE_DEVICE_GENERAL_CMD_CANNEL_CONNET,
|
|
NE_DEVICE_GENERAL_CMD_STATUS_NOTIC,
|
|
NE_DEVICE_GENERAL_CMD_GET_STATUS,
|
|
NE_DEVICE_GENERAL_CMD_CLEAR_SSID,
|
|
NE_DEVICE_GENERAL_CMD_RESET_WIFI,
|
|
NE_DEVICE_GENERAL_CMD_GET_VERSION,
|
|
NE_DEVICE_GENERAL_CMD_GET_CHIPID,
|
|
NE_DEVICE_GENERAL_CMD_GET_DEVICENAME,
|
|
};
|
|
|
|
#pragma pack (1)
|
|
|
|
typedef struct{
|
|
uint8 header;
|
|
uint8 checksum[2];
|
|
uint8 len[2];
|
|
uint8 type;
|
|
uint8 version[2];
|
|
}ne_general_protocol_header_t;
|
|
|
|
typedef struct{
|
|
uint8 msgtype;
|
|
uint8 result;
|
|
}ne_general_rsp_data_t;
|
|
|
|
|
|
|
|
#pragma pack (0)
|
|
|
|
|
|
int32 ne_general_init(void *arg);
|
|
int32 ne_general_deinit(void * arg);
|
|
int32 ne_general_write(void *arg, uint8 *input, uint32 len);
|
|
int32 ne_general_read(void *arg, uint8 **output, uint32 *len);
|
|
int32 ne_general_split(void *arg, uint32 *offset, uint8 *input, uint32 len, uint8 *output, uint32 *out_len);
|
|
int32 ne_general_process(void *arg, uint8 type, uint8 *input, uint32 ilen, uint8 * output, uint32 maxlen);
|
|
|
|
int ne_general_create_frame(uint8_t frame_type, uint8_t *payload, int in_len, uint8 *output, int max_len);
|
|
void ne_general_set_network_status(uint8 net_status);
|
|
uint8 ne_general_get_network_status(void);
|
|
void ne_general_notic_net_status(uint8 net_status);
|
|
|
|
|
|
|
|
#endif
|
|
|