![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
A simple project for sending button input up to AT&T Flow
Dependencies: FXOS8700CQ MODSERIAL mbed
For instructions on using this program, see the AT&T Starter Kit tutorial on it.
Diff: wnc_control.cpp
- Revision:
- 36:d4782eabff43
- Parent:
- 34:1a4498e3580e
- Child:
- 38:564b312a719f
diff -r 1a4498e3580e -r d4782eabff43 wnc_control.cpp --- a/wnc_control.cpp Fri Jul 22 18:01:07 2016 +0000 +++ b/wnc_control.cpp Sat Jul 23 02:29:33 2016 +0000 @@ -236,15 +236,41 @@ void at_init_wnc(void) { + static bool pdnSet = false; + string * pRespStr; + pc.puts("Start AT init of WNC:\r\n"); + send_wnc_cmd("AT", &pRespStr, WNC_TIMEOUT_MS); // Heartbeat? + send_wnc_cmd("ATE0", &pRespStr, WNC_TIMEOUT_MS); // Echo ON send_wnc_cmd("AT", &pRespStr, WNC_TIMEOUT_MS); // Heartbeat? - send_wnc_cmd("ATE1", &pRespStr, WNC_TIMEOUT_MS); // Echo ON - string cmd_str("AT%PDNSET=1,"); - cmd_str += MY_APN_STR; - cmd_str += ",IP"; - send_wnc_cmd(cmd_str.c_str(), &pRespStr, 2*WNC_TIMEOUT_MS); // Set APN, cmd seems to take a little longer sometimes - send_wnc_cmd("AT@INTERNET=1", &pRespStr, WNC_TIMEOUT_MS); // Internet services enabled - send_wnc_cmd("AT@SOCKDIAL=1", &pRespStr, WNC_TIMEOUT_MS); + send_wnc_cmd("AT+CMEE=2", &pRespStr, WNC_TIMEOUT_MS); // 2 - verbose error, 1 - numeric error, 0 - just ERROR + do { + if (pdnSet == false) + { + send_wnc_cmd("AT", &pRespStr, WNC_TIMEOUT_MS); // Heartbeat? + send_wnc_cmd("AT@INTERNET=1", &pRespStr, WNC_TIMEOUT_MS); + string cmd_str("AT%PDNSET=1,"); + cmd_str += MY_APN_STR; + cmd_str += ",IP"; + send_wnc_cmd(cmd_str.c_str(), &pRespStr, 4*WNC_TIMEOUT_MS); // Set APN, cmd seems to take a little longer sometimes + send_wnc_cmd("AT", &pRespStr, WNC_TIMEOUT_MS); // Heartbeat? + send_wnc_cmd("AT@SOCKDIAL=1", &pRespStr, WNC_TIMEOUT_MS); + } + } + while (WNC_MDM_ERR != WNC_OK); + // One time during power up to set the APN + pdnSet = true; + +// send_wnc_cmd("AT", &pRespStr, WNC_TIMEOUT_MS); // Heartbeat? +// send_wnc_cmd("AT+CFUN=0", &pRespStr, WNC_TIMEOUT_MS); // Try to force on network pt1 +// send_wnc_cmd("AT", &pRespStr, WNC_TIMEOUT_MS); // Heartbeat? +// send_wnc_cmd("AT+CFUN=1", &pRespStr, WNC_TIMEOUT_MS); // Try to force on network pt2 +// send_wnc_cmd("AT", &pRespStr, WNC_TIMEOUT_MS); // Heartbeat? + pc.puts("WNC Status:\r\n"); + send_wnc_cmd("AT+CPIN?", &pRespStr, WNC_TIMEOUT_MS); // Check if SIM locked + send_wnc_cmd("AT+CREG?", &pRespStr, WNC_TIMEOUT_MS); // Check if registered on network + send_wnc_cmd("AT+CSQ", &pRespStr, WNC_TIMEOUT_MS); // Check RSSI + pc.puts("End AT init of WNC\r\n"); } void at_sockopen_wnc(const string & ipStr, const char * port ) @@ -255,7 +281,9 @@ cmd_str += ipStr; cmd_str += "\","; cmd_str += port; - send_wnc_cmd(cmd_str.c_str(), &pRespStr, WNC_TIMEOUT_MS); + send_wnc_cmd(cmd_str.c_str(), &pRespStr, 5*WNC_TIMEOUT_MS); + send_wnc_cmd("AT@SOCKCREAT?", &pRespStr, WNC_TIMEOUT_MS); + send_wnc_cmd("AT@SOCKCONN?", &pRespStr, WNC_TIMEOUT_MS); } void at_sockclose_wnc(void)