This commit is contained in:
小马_666 2025-05-09 16:48:19 +08:00
parent dcce7887ca
commit 40c054d491
8 changed files with 44 additions and 23 deletions

View File

@ -28,9 +28,12 @@
#define SYS_RELAY_SWITCH (0X04U)
#define SYS_ALARM_VALVE_MAX (0X30U)
// 正式平台链接
#define SYS_IOT_URL ("8.130.122.162")
#define SYS_IOT_PORT ("7153")
//测试平台链接
// #define SYS_IOT_URL ("8.130.105.38")
// #define SYS_IOT_PORT ("7133")

View File

@ -34,7 +34,7 @@
#define CMD_TYPE_INSTRUCTION_REPLY 0x14 // 命令类型 - 指令下发回复 (设备->平台)
#define CMD_TYPE_TIME_CALIBRATION 0x15 // 命令类型 - 时间校准 (设备->平台)
#define PROTOCOL_VERSION 0x41 /*协议版本*/
#define PROTOCOL_VERSION 0x11 /*协议版本*/
/*数据序列号*/
#define DATA_SERIAL_NUM 0x0001 // 1
@ -80,6 +80,8 @@
#define INSTRUCTION_DOWN_VALVE_ADD 0x61 // 新增阀门设备
#define INSTRUCTION_DOWN_VALVE_REPLACE 0x62 // 更换阀门设备
#define INSTRUCTION_DOWN_VALVE_REMOVE 0x63 // 移除阀门设备
/************************************************************************************************************/
#define RESPONSE_CODE_SUCCESS 0x00 // 响应码 - 操作成功
#define RESPONSE_CODE_CRC_FAIL 0x01 // 响应码 - CRC 校验失败

20
bsp/src/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,20 @@
{
"MicroPython.executeButton": [
{
"text": "▶",
"tooltip": "运行",
"alignment": "left",
"command": "extension.executeFile",
"priority": 3.5
}
],
"MicroPython.syncButton": [
{
"text": "$(sync)",
"tooltip": "同步",
"alignment": "left",
"command": "extension.execute",
"priority": 4
}
]
}

View File

@ -18,7 +18,7 @@
* 2019-12-13 qiyongzhong first version
*/
#include <stdio.h>
// #include <stdio.h>
#include <string.h>
#include "bsp_flash.h"
#include <at_device_ml307.h>
@ -186,7 +186,7 @@ static void urc_tcp_connect_state(struct at_client *client, const char *data, rt
if (sscanf(data, "+MIPOPEN:%d,%d", &id, &err_code) == 2)
{
if (id == socket_id)
socket_id = id;
{
switch (err_code)
{
@ -217,6 +217,7 @@ static void urc_tcp_disconnect(struct at_client *client, const char *data, rt_si
if (sscanf(data, "+MIPURC: \"disconn\",%d,%d", &id, &state) == 2)
{
socket_id = id;
if (id == socket_id)
{
ml307_conncet_tcp_flag = 0;
@ -890,11 +891,11 @@ static void ml307_init_thread_entry(void *parameter)
while (1)
{
/* power on the ml307 device */
rt_thread_mdelay(1000);
// rt_thread_mdelay(1000);
ml307_power_on(device);
LOG_D("power on %s device.", device->name);
rt_thread_mdelay(2000);
// rt_thread_mdelay(2000);
/* wait ml307 startup finish, send AT every 500ms, if receive OK, SYNC success*/
if (at_client_obj_wait_connect(client, ML307_WAIT_CONNECT_TIME))
{

View File

@ -380,11 +380,19 @@ int BSP_Bt_Process(uint8_t *data, uint16_t len)
if(valve[data_buf[3] - 1].valve_connct_status == 1)
{
LOG_D("阀门连接");
while (!power_on_send_flag)//等待4G模块联网完成
{
rt_thread_mdelay(100);
}
Ml307_Send_Event(kMl307ValveConnectEvent);
}
else
{
LOG_D("阀门断开");
while (!power_on_send_flag)
{
rt_thread_mdelay(100);
}
Ml307_Send_Event(KMl307ValveDisconnectEvent);
}
break;

View File

@ -1,4 +1,4 @@
#include "bsp_flash.h"
#include "lwutil.h"
#include "bsp_rtc.h"
#include "bsp_hr.h"
@ -6,6 +6,7 @@
#include <rtthread.h>
#include <rthw.h>
#include "rtdef.h"
#include "bsp_flash.h"
#define LOG_TAG "bsp_flash"
#define LOG_LVL LOG_LVL_DBG

View File

@ -991,22 +991,8 @@ int Compare_HeaderToTail(struct Ml307_Ops *ops)
void Handle_Server_Reply(struct Ml307_Ops *ops)
{
if ((ops->recv->recv_data.event_type == INSTRUCTION_HEART_BEAT) ||
(ops->recv->recv_data.event_type == EVENT_TYPE_SELF_CHECK) ||
(ops->recv->recv_data.event_type == EVENT_TYPE_SILENCE) ||
(ops->recv->recv_data.event_type == EVENT_TYPE_EXCEPTION) ||
(ops->recv->recv_data.event_type == EVENT_TYPE_VALVE_STATUS) ||
(ops->recv->recv_data.event_type == EVENT_TYPE_FAN_STATUS) ||
(ops->recv->recv_data.event_type == EVENT_TYPE_TEMP_ANOMALY) ||
(ops->recv->recv_data.event_type == EVENT_TYPE_POWER_ON) ||
(ops->recv->recv_data.event_type == EVENT_TYPE_POWER_OFF) ||
(ops->recv->recv_data.event_type == EVENT_TYPE_ALARM) ||
(ops->recv->recv_data.event_type == EVENT_TYPE_ALARM_RECOVER) ||
(ops->recv->recv_data.event_type == EVENT_TYPE_FAULT) ||
(ops->recv->recv_data.event_type == EVENT_TYPE_FAULT_RECOVER) ||
(ops->recv->recv_data.event_type == EVENT_TYPE_DEVICE_FAILURE) ||
(ops->recv->recv_data.event_type == EVENT_TYPE_VALVE_CONNECT) ||
(ops->recv->recv_data.event_type == EVENT_TYPE_VALVE_DISCONNECT))
if ((ops->recv->recv_data.event_type >= EVENT_TYPE_HEARTBEAT) &&
(ops->recv->recv_data.event_type <= INSTRUCTION_DOWN_VALVE_REMOVE))
{
LOG_D("服务器响应成功,响应码:[%02X]\n", ops->recv->recv_data.event_type);
rt_sem_release(ml307_recv_msg_sem);