一 知识点
1 AI指令后面一定要加 \n\r
2 注意AT指令里面待双引号的这种,要使用斜杠隔开。
二 源码:
void Set_Pdu_Mode(void) { u8 a = 1; if(atKey == 1)//允许发送AT指令 { atKey = 0; UartSendStr("test start\r\n");//串口1输出开始提示 while(a != 9) { switch (a) { case 1: a = Second_AT_Command("AT","OK");//如果a =9则表明最后一条语句发送完毕,跳出循环,否则一直进行指定指令的发送 delay2s(); if(a == 0) //如果正常发送,则进行下一步 a = 2; break; case 2: a =Second_AT_Command("AT+CSTT=\"CMNET\"","OK"); delay2s(); if(a == 0) //如果正常发送,则进行下一步 a = 3; break; case 3: a = Second_AT_Command("AT+CIICR","OK"); delay2s(); if(a == 0) //如果正常发送,则进行下一步 a = 4; break; case 4: a = Second_AT_Command("AT+MCONFIG=\"test\",\"\",\"\"","OK"); delay2s(); if(a == 0) //如果正常发送,则进行下一步 a = 5; break; case 5: a = Second_AT_Command("AT+MIPSTART=\"47.111.138.129\",\"1883\"","OK"); delay2s(); if(a == 0) //如果正常发送,则进行下一步 a = 6; break; case 6: a = Second_AT_Command("AT+MCONNECT=1,60","OK"); delay2s(); if(a == 0) //如果正常发送,则进行下一步 a = 7; break; case 7: a =Second_AT_Command("AT+MSUB=\"mqtt/topic\",0","OK"); delay2s(); if(a == 0) //如果正常发送,则进行下一步 a = 8; break; case 8: a = Second_AT_Command("AT+MPUB=\"mqtt/topic\",0,0,\"strat\"","OK"); delay2s(); if(a == 0) //如果正常发送,则进行下一步 a = 9; break; defalut: a = 1; } } }
作者:虚生 出处:https://www.cnblogs.com/dylancao/ 以音频和传感器算法为核心的智能可穿戴产品解决方案提供商 ,提供可穿戴智能软硬件解决方案的设计,开发和咨询服务。 勾搭热线:邮箱:1173496664@qq.com weixin:18019245820 市场技术对接群:347609188 |