An example program demonstrating the use of SMS with the WNC M14A2A Data Module on the Avnet AT&T Started IoT kit.

Dependencies:   WNC14A2AInterface BufferedSerial

WNC 14A2A Data Module Networking Library –SMS Example

This example demonstrates the use of the WNC14A2A Network API that has been updated to support ARMmbed v5 with SMS messages. The example uses the AT&T IoT Kit which is sold by Avnet.

NOTE: Using SMS messages in conjunction with the AT&T IoT Kit are not standard SMS messages. These messages are intended to send messages between IoT devices and services such as FLOW (https://flow.att.com/). The SMS capability does not allow for interaction with a standard cellular phone number, instead, it uses a 15 digit MSIDN. This 15 digit MSIDN is displayed to the user when the program starts.

Compiling

Compiling the example program can be performed either (1) using the online tools at https://developer.mbed.org, or (2) using the Command Line Interface (CLI) tools available from https://github.com/ARMmbed/mbed-cli. The following describes the use of the online tools. Using the CLI requires familiarity with installing compilers and other tools which are beyond the scope of this readme.

1. Launch mbed online compiler in your browser

2. Navigate to https://developer.mbed.org/teams/Avnet/code/SMS_demo/

3. On the right side of the screen, select the “Import into Compiler” button. This bring up a dialog and prompt you to enter a name for the program—suggesting SMS_demo as an example.

Once the components have been imported into your new program, simply execute the Compile button. There will be 225 warning and 1 info message generated which is expected. Copy the resulting 'SMS_demoK64F.bin' program (or whatever you named it ‘*K64F.bin’) from your browser download folder to your connected AT&T IoT Starter kit.

Discussion

The SMS API that is provided in the WNC14A2AInterface class encompases:

  • Start the SMS interface sms_start(). This allows the WNC14A2A to begin processing SMS messages.
  • getSMS is called to retrieve a SMS message that has been sent to the device.
  • sendIOTSms allows the user to send an SMS message to another device on the IoT network.
  • getSMSnbr will return the SMS ID/Number for the device this program is running on.
  • sms_listen() is called so that the device will begin monitoring for incoming SMS messages at a user specified interval. If a call-back function is attached, it will be called when a message is received. If a call-back function is not registered, nothing will be done with the SMS message. The WNC14A2A can store a maximum of 3 messages.
  • sms_attach() specifies the function that is to be called when an SMS message is received

Monitoring for SMS messages is performed by starting a thread that executes at a user defined interval. If no interval is specified, 30 seconds is assumed.

Programming & execution outcome

1. Once the program is compiled, it will be downloaded to your browser ‘Downloads’ folder. To program the IoT Starter Kit, you copy the binary file (‘*K64F.bin’) to the MBED Drive that shows up in the Windows explorer window. While the board is being programmed, the LED on the K64F board will flash rapidly and when complete, it will stop flashing.

2. Once programmed, use a serial terminal program such as Hyperterm or Putty to connect to the IoT Starter Kit. You can find the specific Communication port to use by reviewing ‘Device Manager’ on your computer where it will be displayed as mbed Serial Port (COM21)’ or whatever the correct comport is. The communications parameters for the port are 9600-N81.

3. Press the `reset` button on the K64F and the program will start running! When run, the output will look similar to:

NOTES:

i) terminal programs are inconsistent in how they treat carriage-return-linefeed sequences and their behavior can often times be adjusted using program settings. If you notice output where the text does not follow the example below, adjust the program settings so that Carriage return + line-feeds are output instead of just line-feeds.

ii) Debug output is included by default and can be disabled by modifying the following two lines of code the program:

DEBUG ON

      WNC14A2AInterface wnc(&dbg);
      wnc.doDebug(1);

DEBUG OFF

        WNC14A2AInterface wnc();
        //wnc.doDebug(1);

Sample Output

Sample Ouput

[*] 192043104 TX: AT+CMGL
[*] 192079028 RX: AT+CMGLOK
[*] 202044104 TX: AT+CMGL
[*] 202079194 RX: AT+CMGLOK
Adding DEBUG output

STARTING WNC SMS Test
 [*] 26052 TX: AT+CMGL
[*] 50003 RX:
[*] 66667 readSMSLog: Failed!
[*] 98968 Waiting for WNC to Initialize...
Waiting 12
[*] 28487188
Toggling Wakeup...
[*] 30563648 Toggling complete.
[*] 30596056 TX: AT%PDNSET=1,m2m.com.attz,IP
[*] 30670478 RX: AT%PDNSET=1,m2m.com.attz,IPOK
[*] 30718552 TX: AT+CSQ
[*] 30750365 RX: AT+CSQ+CSQ: 16,0OK
[*] 30786980 TX: AT+CPIN?
[*] 30821393 RX: AT+CPIN?+CPIN: READYOK
[*] 30862090 TX: AT+CREG?
[*] 30897702 RX: AT+CREG?+CREG: 2,1,2717,0BAA1410,7OK
[*] 30953039 Start AT init of WNC:
[*] 30990522 TX: AT
[*] 31016540 RX: ATOK
[*] 31038543 TX: AT
[*] 31064351 RX: ATOK
[*] 31086355 TX: AT+GMR
[*] 31125514 RX: AT+GMRMPSS: M14A2A_v11.50.164451 APSS: M14A2A_v11.53.164451OK
[*] 31206876 TX: ATE0
[*] 31234188 RX: ATE0OK
[*] 31258230 TX: AT+CMEE=2
[*] 31292674 RX: AT+CMEE=2OK
[*] 31321980 TX: AT+CMGF=1
[*] 31377687 RX: AT+CMGF=1OK
[*] 31406981 TX: AT+CPMS="SM","SM","SM"
[*] 31472104 RX: AT+CPMS="SM","SM","SM"+CPMS: 0,3,0,3,0,3OK
[*] 31533647 TX: AT
[*] 31559358 RX: ATOK
[*] 31581356 TX: AT@INTERNET=1
[*] 31625232 RX: AT@INTERNET=1OK
[*] 31658647 TX: AT@SOCKDIAL=1
[*] 31711994 RX: AT@SOCKDIAL=1OK
[*] 31745417 SUCCESS: AT init of WNC!
[*] 31786048 TX: AT+CGCONTRDP=1
[*] 31837126 RX: AT+CGCONTRDP=1+CGCONTRDP: 1,5,"m2m.com.a...252,10.192.205.165,8.8.8.8,8.8.4.4,,,OK
[*] 31940525 ~~~~~~~~~~ WNC IP Stats ~~~~~~~~~~~~
[*] 31993542 ip: 10.192.205.166
[*] 32027917 mask: 255.255.255.252
[*] 32065417 gateway: 10.192.205.165
[*] 32105000 dns pri: 8.8.8.8
[*] 32137292 dns sec: 8.8.4.4
[*] 32169583 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 WNC Initialized
 [*] 32240436 TX: AT+CMGD=1
[*] 32279640 RX: AT+CMGD=1+CMS ERROR: 321
[*] 32322522 TX: AT+CMGD=2
[*] 32361632 RX: AT+CMGD=2+CMS ERROR: 321
[*] 32404501 TX: AT+CMGD=3
[*] 32443645 RX: AT+CMGD=3+CMS ERROR: 321
[*] 32486474 TX: AT%CCID
[*] 32520383 RX: AT%CCID89011702272014195991OK
My number: 882350201419599
-->Pausing 30 seconds then check for SMS received from the console
 [*] 62666364 TX: AT+CMGL
[*] 62701097 RX: AT+CMGLOK
Checked, there are 0 SMS messages

Start Monitoring thread to check every 10 seconds for incomming messages
 [*] 62840905 TX: AT+CMGD=1
[*] 62879902 RX: AT+CMGD=1+CMS ERROR: 321
[*] 62922731 TX: AT+CMGD=2
[*] 62961815 RX: AT+CMGD=2+CMS ERROR: 321
[*] 63004710 TX: AT+CMGD=3
[*] 63043601 RX: AT+CMGD=3+CMS ERROR: 321
sending SMS #1 to 5277..GO;
 [*] 63115647 TX: AT+CSQ
[*] 63147475 RX: AT+CSQ+CSQ: 20,99OK
[*] 63185105 TX: AT+CPIN?
[*] 63220029 RX: AT+CPIN?+CPIN: READYOK
[*] 63260733 TX: AT+CREG?
[*] 63296071 RX: AT+CREG?+CREG: 2,1,2717,0BAA1410,7OK
[*] 63351373 TX: AT+CMGF=1
[*] 63386029 RX: AT+CMGF=1OK
[*] 63415326 TX: AT+CMGS="5277"
[*] 63456175 RX: AT+CMGS="5277"ERROR
[*] 63493762 sendSMSText: Failed!
wait 60 seconds and check for incomming SMS msgs...
 [*] 73087104 TX: AT+CMGL
[*] 73122001 RX: AT+CMGLOK
[*] 83087104 TX: AT+CMGL
[*] 83122046 RX: AT+CMGLOK
[*] 93087104 TX: AT+CMGL
[*] 93122185 RX: AT+CMGLOK
[*] 103087104 TX: AT+CMGL
[*] 103122584 RX: AT+CMGLOK
[*] 113087104 TX: AT+CMGL
[*] 113122528 RX: AT+CMGLOK
[*] 123087104 TX: AT+CMGL
[*] 123122591 RX: AT+CMGLOK
sending SMS #2 to 5277..GO;
 [*] 123611585 TX: AT+CSQ
[*] 123644367 RX: AT+CSQ+CSQ: 21,99OK
[*] 123683022 TX: AT+CPIN?
[*] 123718451 RX: AT+CPIN?+CPIN: READYOK
[*] 123760212 TX: AT+CREG?
[*] 123796733 RX: AT+CREG?+CREG: 2,1,2717,0BAA1410,7OK
[*] 123853144 TX: AT+CMGF=1
[*] 123889282 RX: AT+CMGF=1OK
[*] 123919596 TX: AT+CMGS="5277"
[*] 124255814 RX: AT+CMGS="5277">
[*] 124291360 TX: SMS #2
[*] 125292410 RX: SMS #2+CMGS: 96OK
wait 60 seconds and check for incomming SMS msgs...
 [*] 133088104 TX: AT+CMGL
[*] 133145992 RX: AT+CMGL+CMGL: 1,"REC UNREAD",6,96,"5277"..,08:02:03-28","17/05/01,08:02:03-28",0OK
[*] 133250421 TX: AT+CMGD=1
[*] 133290054 RX: AT+CMGD=1OK
msg_rcvd called, msg from: '5277'
msg_rcvd from: '17/05/01'
msg_rcvd at '08:02:03-28'
msg_rcvd contained '"17/05/01,08:02:03-28",0'

The message received at *17/05/01,08:02:03-28* was sent from the AT&T SIM Control Center to show receipt of an SMS.

WNC FIRMWARE VERSION

The WNC14A2AInterface class currently supports the following version(s):

  • MPSS: M14A2A_v11.50.164451 APSS: M14A2A_v11.53.164451

License

This library is released under the Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License and may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Committer:
JMF
Date:
Sun Apr 23 17:01:12 2017 +0000
Revision:
3:7ed7c680ebf0
Parent:
0:8ef17b8b7104
changed debug settings.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
group-Avnet 0:8ef17b8b7104 1 https://github.com/ARMmbed/mbed-os/#42be5c01a7f91292d5e27124ad9584236025f6ab