Example programs for MultiTech Dragonfly devices demonstrating how to use the MultiTech MTSCellularInterface library for cellular radio communication and control.
Library Not Included!
The MTSCellularInterface library is not included and must be cloned from GitHub.
mbed-os version
The MTSCellularInterface library does not currently support mbed-os-5.5.x releases. We recommend using mbed-os version 5.4.7.
Example Programs Description
This application contains multiple example programs. Each example demonstrates a different way to configure and use a Dragonfly. A short summary of each example is provided below.
All examples print logging on the USB debug port at 115200 baud.
Most cellular radios require an APN to be set before the radio can be used. Please set the APN in the example you're using before trying to run it. The SMS example also requires a phone number to be set. The number should be in 10 digit format (1xxxyyyxxxx).
TCP Example
This example demonstrates how to use MTSCellularInterface to make TCP socket connections. It brings up the cellular link, does a HTTP GET request on http://developer.mbed.org, and displays the response.
The APN must be set in the TCP example source code before this example is run.
SMS Example
This example demonstrates how to use MTSCellularInterface to send and receive SMS messages. It brings up the cellular link, sends a SMS message to the configured phone number, then loops forever displaying any received SMS messages.
The APN and phone number must be set in the SMS example source code before this example is run.
Choosing An Example Program
Only the active example is compiled. The active example can be updated by changing the ACTIVE_EXAMPLE definition in the examples/example_config.h file.
By default the TCP example will be compiled.
example_config.h
// This is where you choose which example program will be compiled // to run on the target device. #ifndef __EXAMPLE__CONFIG_H__ #define __EXAMPLE__CONFIG_H__ // List of available example programs. #define SMS_EXAMPLE 1 // see sms_example.cpp #define TCP_EXAMPLE 2 // see tcp_example.cpp // Example program that will be compiled to run on target. #if !defined(ACTIVE_EXAMPLE) #define ACTIVE_EXAMPLE TCP_EXAMPLE #endif #endif
Compile the SMS example instead.
example_config.h
// This is where you choose which example program will be compiled // to run on the target device. #ifndef __EXAMPLE__CONFIG_H__ #define __EXAMPLE__CONFIG_H__ // List of available example programs. #define SMS_EXAMPLE 1 // see sms_example.cpp #define TCP_EXAMPLE 2 // see tcp_example.cpp // Example program that will be compiled to run on target. #if !defined(ACTIVE_EXAMPLE) #define ACTIVE_EXAMPLE SMS_EXAMPLE #endif #endif
Library
The MTSCellularInterface library can be cloned from MultiTech's GitHub page.
Diff: examples/src/tcp_example.cpp
- Revision:
- 1:be566f16398d
- Parent:
- 0:2c9b8730c55d
- Child:
- 2:31cc1a3ebcf3
--- a/examples/src/tcp_example.cpp Tue Jun 13 22:24:22 2017 +0000 +++ b/examples/src/tcp_example.cpp Wed Jun 21 13:27:26 2017 -0500 @@ -8,7 +8,7 @@ #include "mbed.h" #include "MTSCellularInterface.h" #include "MTSLog.h" -#include "Example_config.h" +#include "example_config.h" #if ACTIVE_EXAMPLE == TCP_EXAMPLE @@ -32,6 +32,9 @@ // RADIO_TX = pin PC_7, RADIO_RX = pin PC_6 MTSCellularInterface *radio = new MTSCellularInterface(RADIO_TX, RADIO_RX); + // Print the MTSCellularInterface version + logInfo("MTSCellularInterface Version %s", radio->get_library_version().c_str()); + //Modify to match your apn if you are using the MTQ-H5 or MTQ-LAT3. const char apn[] = "";