You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
2.8 KiB
121 lines
2.8 KiB
1 year ago
|
//////////////////////////////////////////////////////////////////////////
|
||
|
/// COPYRIGHT NOTICE
|
||
|
/// Copyright (c) 2023, 传控科技
|
||
|
/// All rights reserved.
|
||
|
///
|
||
|
/// @file asp_gsensor.c
|
||
|
/// @brief asp_gsensor
|
||
|
///
|
||
|
///(本文件实现的功能的详述)
|
||
|
/// 放置算法 初始化之类的 是bs_xxx型号的gsensor的上层,与型号无关
|
||
|
|
||
|
|
||
|
#include "asp_mqtt.h"
|
||
|
#include "msp_UART1.h"
|
||
|
|
||
|
#include "msp_iicMx.h"
|
||
|
#include "bsp_msa300.h"
|
||
|
|
||
|
|
||
|
|
||
|
TS_task_mqtt_ ts_task_mqtt;
|
||
|
|
||
|
|
||
|
|
||
|
void L2_mqtt_init(u8 d)
|
||
|
{
|
||
|
if (d)
|
||
|
{
|
||
|
|
||
|
}else
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
void L2_Task_step_register(void)
|
||
|
{
|
||
|
L1_task_reg_clear(&ts_task_mqtt.task);
|
||
|
///L3_task_s_go(ts_Task_step,D_task_init);
|
||
|
}
|
||
|
|
||
|
void PrintString2(u8 *puts)
|
||
|
{
|
||
|
for (; *puts != 0; puts++)
|
||
|
{
|
||
|
///TX2_write2buff(*puts); //遇到停止符0结束
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
xdata char comand_uart1[] = "AT+LMQTTPUB=0,0,0,0,\"$dp\",64,\"{\"ccsens_data\":00}\"\r\n";
|
||
|
|
||
|
|
||
|
void L2_Task_step_handle(TS_task_mqtt_ *s)
|
||
|
{///fixme:需要添加超时保护
|
||
|
unsigned char d = 0;
|
||
|
|
||
|
TTSS_Task_init():
|
||
|
printfs("\r\nL2_Task_step_handle TTSS_Task_init");
|
||
|
L2_task_go(D_Task_mqtt_init);
|
||
|
|
||
|
TTSS_Task_step(D_Task_mqtt_init):
|
||
|
|
||
|
TTSS_Task_step(D_Task_mqtt_init):
|
||
|
|
||
|
P05 = 0;////////////NB_RST
|
||
|
P53 = 1; //////////NB_POWER
|
||
|
delay_ms(100);
|
||
|
|
||
|
P53 = 0; //////////NB_POWER LOW ACTIVE
|
||
|
P05 = 1;////////////NB_RST
|
||
|
|
||
|
S_delay(1);
|
||
|
P53 = 1;///////////////NB_POWER
|
||
|
|
||
|
|
||
|
|
||
|
TTSS_Task_step(D_Task_mqtt_init):
|
||
|
PrintString2("AT+CMEE=1\r\n"); //mqtt config
|
||
|
|
||
|
PrintString2("AT+CSQ\r\n"); //mqtt config
|
||
|
|
||
|
PrintString2("AT+LMQTTCFG=\"cloud\",0,1,3\r\n"); //mqtt config
|
||
|
S_delay(1);
|
||
|
PrintString2("AT+LMQTTOPEN=0,\"183.230.40.39\",6002\r\n"); //BUILDING TCP OK
|
||
|
|
||
|
PrintString2("AT+LMQTTCONN=0,\"1062916368\",\"587005\",\"mm1234\"\r\n"); //BUILDING ON LINE // 设备ID,产品ID,鉴权信息 MQTT CONECT OK
|
||
|
S_delay(1);
|
||
|
|
||
|
PrintString2("AT+LMQTTSUBUNSUB=0,0,1,\"test\",2\r\n"); ////////sub topic
|
||
|
// PrintString2("AT+MQTTOPEN=1,1,0\r\n"); //BUILDING
|
||
|
S_delay(1);
|
||
|
|
||
|
PrintString2("AT+LMQTTPUB=0,0,0,0,\"$dp\",64,\"{\"ccsens_data\":00}\"\r\n"); ////////senddata
|
||
|
S_delay(1);
|
||
|
|
||
|
four_bt = temp_dat_TP/1000+48;
|
||
|
three_bt = (temp_dat_TP%1000)/100+48;
|
||
|
two_bt = ((temp_dat_TP%1000)%100)/10+48;
|
||
|
one_bt = (((temp_dat_TP%1000)%100)%10)+48;
|
||
|
//
|
||
|
// comand_uart1[87] = four_bt;
|
||
|
// comand_uart1[88] = three_bt;
|
||
|
comand_uart1[45] = two_bt;
|
||
|
comand_uart1[46] = one_bt;
|
||
|
|
||
|
PrintString2(comand_uart1);
|
||
|
|
||
|
L2_task_go(D_Task_mqtt_ok);
|
||
|
///printf("\r\nF =%d<-%d ", (int)s->loc_want,s->loc_now);
|
||
|
TTSS_Task_step(D_Task_mqtt_ok):
|
||
|
s->ok_want = 1;
|
||
|
/// L2_task_go(0);
|
||
|
// printf("\r\nstep_ok =%d<-%d ", (int)s->loc_want,s->loc_now);
|
||
|
L2_task_Tdelay_go(D_Tdelay_30s,D_Task_mqtt_init);///测试使用:
|
||
|
TTSS_Task_end();
|
||
|
}
|
||
|
|
||
|
|