You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
TermApp/app/src/main/cpp/mqtt_south.h

155 lines
6.7 KiB
C

#ifndef _SOUTH_MQTT_H
#define _SOUTH_MQTT_H
#include "rtthread.h"
#include "cJSON.h"
#define PLATFORM_UPGRADE_DEVICES 0 /*设备升级(命令只是下发通知,设备回应是否收到通知。设备升级的结果由设备作为属性自行上报)*/
#define PLATFORM_ISSUES_CONFIGFILE 1 /*平台下发参数配置文件*/
#define GET_DEVICE_LOGLIST 2 /*查询终端设备日志列表*/
#define GET_DEVICE_LOGFILE 3 /*查询终端设备日志文件*/
#define GET_DEVICE_TIME 4 /*平台端查询终端设备的系统时间*/
#define GET_TRANS_ONLINE_MONITCONFIG 5 /*获取输电在线监测终端的运行状态参数*/
#define GET_FUNCTION_CONFIGURATION 6 /*获取装置功能配置*/
#define GET_ICING_ONLINE_ALARM_MONITCONFIG 7 /*获取设置覆冰在线监测终端的告警阈*/
#define GET_DEVICE_DATA 8 /*请求设备数据*/
#define GET_PHOTO_PARAMS 9 /*平台端查询终端设备图片配置信息*/
#define GET_CAPTURE_TIMES_TASK_INFORMATION 10 /*平台端查询终端设备定时抓拍任务信息*/
#define GET_DEVICE_SOLAR_POWER_PROPERTIES 11 /*查询设备太阳能电池板状态数据*/
#define GET_WEATHER_MONITORING 12 /*查询终端微气象数据*/
#define GET_PULL_AND_ANGLE_MONITORING 13 /*查询终端拉力倾角监测*/
#define SET_DEVICE_TIME 14 /*平台端设置终端设备的系统时间*/
#define SET_TRANS_ONLINE_MONITCONFIG 15 /*设置输电在线监测终端的运行状态参数*/
#define SET_FUNCTION_CONFIGURATION 16 /*装置功能配置*/
#define SET_ICING_ONLINE_ALARM_MONIT_CONFIG 17 /*设置覆冰在线监测终端的告警阈值*/
#define SET_PHOTO_PARAMS 18 /*平台端设置终端设备图片配置信息*/
#define SET_ACCEPT_CAMERA_PHOTO 19 /*平台端允许终端上送照片*/
#define SET_CAPTURE_TIMES_TASK_PARAMETER 20 /*平台端设置终端设备定时抓拍任务信息*/
#define ACTION_RESTART 21 /*控制终端重启*/
#define CAMERA_REMOTE_CONTROL 22 /*平台下发命令设置控制设备云台*/
#define MANUAL_CAPTURE_PICTURE 23 /*设置终设备手动抓拍指令*/
#define GET_COLLECT_INFORMATION 24 /*查询终端设备的采集信息(气象装置使用)*/
#define GET_MICRO_METEOROLOGICAL_ALARM 25 /*查询终端设备的微气象告警阈值(气象装置使用)*/
#define SET_MICRO_METEOROLOGICAL_ALARM 26 /*设置终端设备的微气象告警阈值(气象装置使用)*/
#define MAX_BUFUNIT_NUM 100 // 缓冲区单元最大数量
#define MIN_MALLOC_SIZE 200 // malloc分配内存的最小尺寸
// MQTT URC数据接收函数接口指针
typedef const struct
{
//char *account; // 命令说明
char *cmd_name; // 命令名称
int (*recv_process)(cJSON*, int ); /* urc数据处理*/
}MQTT_URC_FUNC;
struct WR_DATA
{
uint16_t MsgLen;
uint8_t topid;
struct WR_DATA *Next;
uint8_t MsgData[2];
};
typedef struct
{
struct WR_DATA *WriteData; /* 下行数据缓冲区*/
int iWriteDataNo; /*下行数据缓冲区序号*/
}MQTT_SEND_BUF;
typedef struct
{
uint8_t picdata[64]; /* 84H报文*/
int datalen; /*报文长度*/
}MQTT_UP_PIC;
typedef struct
{
char file[64];
char data[512];
uint8_t type;
uint8_t mode;
uint32_t size;
uint32_t total_pkt;
uint32_t curr_idx;
uint32_t data_len;
}MQTT_FILE_INFO_TYPE;
extern uint32_t south_encode_timestamp(uint8_t *buf,uint32_t t);
int mqtt_base_properties(void);
int mqtt_communicationtechnical_properties(void);
int mqtt_gatewaytechnical_properties(void);
int mqtt_devicetechnical_properties(void);
int powerOnContactMessage_Json(void);
int mqtt_ext_70h(uint8_t *data, uint32_t num);
extern int getsystime(char * timebuf);
int mqtt_keep_alive(uint8_t *data, uint32_t num);
uint8_t isauto_photo(char *file_name);
int mqtt_req_up_pic(uint8_t *data, uint32_t num);
//int mqtt_upload_image_data(cJSON* outdata, uint8_t *data, uint32_t num);
//int mqtt_upload_image_finished(cJSON* outdata, uint8_t *data, uint32_t num);
int mqtt_send_pull_data(uint8_t *data, uint32_t num);
int mqtt_first_pull_data(uint8_t index);
int mqtt_send_weather_data(uint8_t *data, uint32_t num);
int mqtt_first_weather_data(void);
int mqtt_first_unusual_event(void);
int mqtt_device_unusual_event(uint8_t *data, uint32_t num);
int mqtt_status_Monitoring(void);
int mqtt_longitude_latitude_info(void);
int mqtt_solarpower_properties(void);
int mqtt_send_south_data(uint8_t *data,uint32_t num);
int mqtt_dev_upload_file_info(void);
//int mqtt_dev_upload_file_data(MQTT_FILE_INFO_TYPE* mqtt_file_info);
//int mqtt_dev_upload_file_finish(MQTT_FILE_INFO_TYPE* mqtt_file_info);
//int mqtt_dev_upload_file_process(MQTT_FILE_INFO_TYPE* mqtt_file_info);
int deviceUpgradeInfoUpload(void);
int mqtt_cjson_analysis(char *in_command, int payload_len);
int mqtt_south_recv_process(cJSON *json_buf,uint32_t len);
int get_device_time(cJSON *json_buf, int mid);
int platform_upgrade_devices(cJSON *json_buf, int mid);
int get_device_logfile(cJSON *json_buf, int mid);
int platform_lsuue_configure_file(cJSON *json_buf, int mid);
int get_transOnlineMonit_Config(cJSON *json_buf, int mid);
int get_Fun_config(cJSON *json_buf, int mid);
int get_alarmMonit_config(cJSON *json_buf, int mid);
int get_device_data(cJSON *json_buf,int mid);
int get_photo_params(cJSON *json_buf, int mid);
int get_CaptureTimesTask_info(cJSON *json_buf, int mid);
int get_solarpower_properties(cJSON *json_buf, int mid);
int mqtt_time_set(char *hostsettime);
int set_device_time(cJSON *json_buf, int mid);
int set_online_monit_config(cJSON *json_buf, int mid);
int set_Fun_config(cJSON *json_buf, int mid);
int set_Icing_alarm_config(cJSON *json_buf, int mid);
int set_photo_params(cJSON *json_buf, int mid);
int set_accept_camera_photo(cJSON *json_buf, int mid);
int set_capture_times(cJSON *json_buf, int mid);
int action_restart(cJSON *json_buf, int mid);
int camera_remote_control(cJSON *json_buf, int mid);
int manual_capture_picture(cJSON *json_buf, int mid);
int get_pull_angle_monitoring(cJSON *json_buf, int mid);
int get_weather_monitoring(cJSON *json_buf, int mid);
int get_device_loglist(cJSON *json_buf, int mid);
//插到最后一个结点之后
int AddNode(int cmdid, char *buf, int len);
//从头结点往后删
void DelNode(void);
/* mqtt 初始化*/
void mqtt_send_init(void);
void mqtt_south_send_data(void);
uint8_t readversion(void);
void saveversion(void);
uint8_t readupconfigstate(void);
void saveconfigstate(void);
void mqtt_south_poll_process(void);
int open_upgrade_file(void);
int close_upgrade_file(int fd);
int32_t save_upgrade_file(int fd, uint8_t *filedata, uint32_t size);
uint32_t hostip_char_to_int(char *hostip);
#endif