经过一个月左右的努力,BC95终于调试通过了。
>>Enter main loop>>
uart1 recv[20]=
+CSQ:20,99
OK
rssi=20
appJson[]={"M":"update","ID":"863703030454644","SN":"2","V":{"2001":"100","2002":"20","2003":"300","2004":"1","2005":"0"}}
AT
+NSOST=0,61.157.88.83,5678,112,7B224D223A22757064617465222C224944223A22383633373033303330343534363434222C22534E223A2232222C2256
223A7B2232303031223A22313030222C2232303032223A223230222C2232303033223A22333030222C2232303034223A2231222C2232303035223A2230227D7
D
uart1 recv[15]=
0,112
OK
Failed 1 times.
uart1 recv[16]=
+NSONMI:0,65
resp received success!
AT+NSORF=0,200
uart1 recv[165]=
0,61.157.88.83,5678,65,7B224D223A22726573706F6E7365222C224944223A22383633373033303330343534363434222C22534E223A2232222C2256223A
7B2232303035223A2231227D7D,0
OK
BC95 recv app:{"M":"response","ID":"863703030454644","SN":"2","V":{"2005":"1"}}
uart1 recv[20]=
+CSQ:19,99
OK
rssi=19
appJson[]={"M":"update","ID":"863703030454644","SN":"2","V":{"2001":"100","2002":"19","2003":"300","2004":"1","2005":"0"}}
AT
+NSOST=0,61.157.88.83,5678,112,7B224D223A22757064617465222C224944223A22383633373033303330343534363434222C22534E223A2232222C2256
223A7B2232303031223A22313030222C2232303032223A223139222C2232303033223A22333030222C2232303034223A2231222C2232303035223A2230227D7
D
FreeRTOS 7.6.0 for STM32F030
Build date: Aug 13 2017 16:51:02
The current time is : 08:00:00
start to init BC95 at:28800
uart1 recv[74]=
REBOOTING
樹 ?
REBOOT_CAUSE_APPLICATION_AT
Neul
OK
ERROR
OK
uart1 recv[6]=
OK
测试BC95初始化时间,包括:复位BC95,设置频段,连接NB网络,激活PDN,获得udp socket。
第一次测试时间:53s。
第二次,sockfd=0
init BC95 end at:28837,cost=37s
第三次复位测试,
sockfd=0
init BC95 end at:28837,cost=37s
BC95_Init. sockfd=0
第四次,也是cost=37s
总结:
1、BC95初始化中,首先应该是一条reboot命令。 char gBc95RebootCmd[]="AT+NRB\r\n";
2、BC95关联PS域很容易失败。char gBc95AttachCmd[]="AT+CGATT=1\r\n";
建议不断拉大时延尝试3次。
3、BC95读/写的内容是16进制编码(ASCII码),比如你要发A3这个数据,就得发4133这两个编码后的数据。
我写了两个小功能的func来转换。
unsigned int Utls_StringToHex(char Str[],char HexStr[])
unsigned int Utls_HexToString(char HexStr[],char outStr[])
中国电信的NB-IoT网络在重点城市都开通了。这个应用场景我比较认同:
公共节能。人来灯亮,人走灯灭。或是天黑灯亮,天亮灯熄。