Skip to content

Latest commit

 

History

History

LE910Cx_L

AppZone m2mb Sample Apps

Package Version: 1.1.22-CxL

Minimum Firmware Version: 25.21.000.3

Features

This package goal is to provide sample source code for common activities kickstart.

Quick start

Deployment Instructions

To manually deploy the Sample application on the devices perform the following steps:

  1. Have 25.21.000.3 FW version flashed (AT#SWPKGV will give you the FW version)

  2. Copy m2mapz.bin to /data/azc/mod/

    AT#M2MWRITE="/data/azc/mod/m2mapz.bin",<size>,1
    

where <size> is in bytes

  1. Configure the module to run the downloaded binary as default app: AT#M2MRUN=2,m2mapz.bin
  2. Restart the module and if no AT commands are sent within 10 seconds, start the app: AT+M2M=4,10

References

More info on

Known Issues

None

Contact Information, Support

For general contact, technical support services, technical questions and report documentation errors contact Telit Technical Support at: [email protected].

For detailed information about where you can buy the Telit modules or for recommendations on accessories and components visit:

http://www.telit.com

Our aim is to make this guide as helpful as possible. Keep us informed of your comments and suggestions for improvements.

Telit appreciates feedback from the users of our information.

Troubleshooting

  • Application does not work/start:

    • Delete application binary and retry
    AT#M2MDEL="/data/azc/mod/m2mapz.bin"
    
    • Delete everything, reflash and retry
    AT#M2MDEL="/data/azc/mod/m2mapz.bin"
    AT#M2MDEL="/data/azc/mod/appcfg.ini"
    
  • Application project does not compile

    • Right click on project name
    • Select Properties
    • Select AppZone tab
    • Select the right plugin (firmware) version
    • Press "Restore Defaults", then "Apply", then "OK"
    • Build project again
  • Application project shows missing symbols on IDE

    • Right click on project name
    • Select Index
    • Select Rebuild. This will regenerate the symbols index.

Making source code changes

Folder structure

The applications code follow the structure below:

  • hdr: header files used by the application
    • app_cfg.h: the main configuration file for the application
  • src: source code specific to the application
  • azx: helpful utilities used by the application (for GPIOs, LOGGING etc)
    • hdr: generic utilities' header files
    • src: generic utilities' source files
  • Makefile.in: customization of the Make process

Import a Sample App into an IDE project

Consider that the app HelloWorld that prints on Main UART is a good starting point. To import it in a project, please follow the steps below:

On IDE, create a new project: "File"-> "New" -> "Telit Project"

Select the preferred firmware version (e.g. 30.00.xx7) and create an empty project.

in the samples package, go in the HelloWorld folder (e.g. AppZoneSampleApps-MAIN_UART\HelloWorld ), copy all the files and folders in it (as src, hdr, azx ) and paste them in the root of the newly created IDE project. You are now ready tyo build and try the sample app on your device.

Heap and starting address

By default, every application defines a memory HEAP size and its start address in memory.

They are usually provided by the linking phase of the build process:

"[...]arm-none-eabi-ld" --defsym __ROM=0x40000000 --defsym __HEAP_PUB_SIZE=0x40000 --defsym 

__ROM is the default starting address, __HEAP_PUB_SIZE is the default HEAP size in bytes. Both are expressed in hexadecimal format.

These values can be customized through makefile variables:

HEAP=<new size in bytes>
ROM_START=<new address>

IMPORTANT allowed address range is 0x40000000 - 0x4FFFF000.

Main contents

AUX UART

MAIN UART

USB0

BASIC

MISC

Installing beta version libraries Plug-in

Applications

MISC

Applications that provide usage examples for various functionalities, without prints

GPIO toggle example

Sample application showcasing GPIO usage with M2MB API

Features

  • How to open a gpio in output mode and change its status

BASIC

Basic applications showing simple operations with minimum code overhead

Basic Hello World (Main UART)

The application prints "Hello World!" on Main UART every 2 seconds using

Features

  • How to open Main UART as an output channel
  • How to print messages out of the channel

Application workflow

M2MB_main.c

  • Open Main UART with m2mb_uart_open function
  • write a welcome message using m2mb_uart_write
  • write "Hello World!" every 2 seconds in a while loop, using m2mb_uart_write


Basic Hello World (USB0)

The application prints "Hello World!" on USB 0 every 2 seconds using

Features

  • How to open USB 0 as an output channel
  • How to print messages out of the channel

Application workflow

M2MB_main.c

  • Open USB 0 with m2mb_usb_open function
  • write a welcome message using m2mb_usb_write
  • write "Hello World!" every 2 seconds in a while loop, using m2mb_usb_write


Basic Task

The application shows how to create and manage tasks with m2mb APIs. Debug prints on MAIN UART (can be changed in M2MB_Main function)

Features

  • How to create a new task using m2mb APIs
  • How to start the task and send messages to it
  • how to destroy the task

Application workflow

M2MB_main.c

  • Open UART
  • Print welcome message
  • Configure and create message queue for task
  • Configure and create task
  • Send 2 messages to the task queue

task_entry_function

  • Receive messages from the task queue in a loop
  • Print the message data when one arrives


UART USB tunnel example

Sample application that opens a tunnel between main UART and USB0 port.

Features

  • Opens Main UART port with a callback function
  • Opens USB0 port with a callback function
  • Creates a simple task to manage data exchange between ports

Application workflow

M2MB_main function

  • Create Main UART handle and configure its parameters
  • Create USB0 handle and configure its parameters
  • Create the data management task
  • Write READY on both ports when the tunneling is ready

USB_Cb

  • When data are received on the USB0 port, retrieve the available amount and send the value to the data management task with the proper command

UART_Cb

  • When data are received on the Main UART port, retrieve the available amount and send the value to the data management task with the proper command

dataTask_Cb

  • if command is TASK_UART_READ_AND_USB_WRITE, read the requested amount from the Main UART port and write it on USB0
  • if command is TASK_USB_READ_AND_UART_WRITE, read the requested amount from the USB0 port and write it on Main UART

UART output received from USB0 (in RED, the user input data from UART )

USB0 output received from UART (in RED, the user input data from USB0 )


AUX UART

Applications that provide usage examples for various functionalities, log output on Auxiliary UART

Alarm example

Sample application that shows how to set an alarm to wake-up module. Debug prints on AUX UART

Features

  • How to set an alarm
  • How to use it to turn on module

Application workflow

M2MB_main.c

  • Init RTC
  • Wait for registration
  • Get current date and time
  • Call function set_alarm
  • Init Power and turn off module


FOTA_FTP_client example

Sample application that shows how to download a delta file from an FTP server, stores it in the FOTA partition and deploys it. Debug prints on AUX UART

Features

  • How to download a delta file from FTP server using FTP client
  • How to store directly delta file in the FOTA partition
  • How to deploy delta file to upgrade mdoule fw.

Application workflow

M2MB_main.c

  • Print welcome message
  • Create a main task to manage connectivity, delta download and deployment

ftp_test.c

msgFTPTask()

  • Initialize Network structure and check registration
  • Initialize PDP structure and start PDP context. Event will be received on
  • Initialize FOTA system then reset parameters.
  • After PDP context activation notified by PdPCallback() configure fota client parameters as FTP server url, username and password and SSL
  • Get delta filefrom server and store it directly in the FOTA partition
  • If delta download went fine, check it (m2mb_fota_update_package_check_setup) and if it's correct apply it (m2mb_fota_start).
  • Once completed restart module.

PdpCallback()

  • When PDP context is enabled, send a message to fotaTask to start the download

buf_data_cb_OTA()

  • Handles data reception and writing in the FOTA partition (one block size at a time)


USB0

Applications that provide usage examples for various functionalities, log output on USB0

Alarm example

Sample application that shows how to set an alarm to wake-up module. Debug prints on USB0

Features

  • How to set an alarm
  • How to use it to turn on module

Application workflow

M2MB_main.c

  • Init RTC
  • Wait for registration
  • Get current date and time
  • Call function set_alarm
  • Init Power and turn off module


ATI (AT Instance)

Sample application showing how to use AT Instance functionality (sending AT commands from code). The example supports both sync and async (using a callback) modes. Debug prints on USB0

Features

  • How to open an AT interface from the application
  • How to send AT commands and receive responses on the AT interface

Application workflow, sync mode

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Init AT0 (first AT instance)
  • Send AT+CGMR command
  • Print response.
  • Release AT0

at_sync.c

  • Init ati functionality and take AT0
  • Send AT+CGMR command, then read response after 2 seconds, then return it
  • Deinit ati, releasing AT0

Application workflow, async mode

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Init AT0 (first AT instance)
  • Send AT+CGMR command
  • Print response.
  • Release AT0

at_async.c

  • Init ati functionality and take AT0, register AT events callback
  • Send AT+CGMR command, wait for response semaphore (released in callback), then read it and return it
  • Deinit ati, releasing AT0


AWS demo

Sample application showcasing AWS Iot Core MQTT communication. Debug prints on USB0

Features

  • How to check module registration and enable PDP context
  • How to load certificates into device SSL session storage
  • How to configure MQTT client parameters
  • How to connect to AWS server with SSL and exchange data over a topic

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a task to manage MQTT client and start it

aws_demo.c

  • Initialize Network structure and check registration

  • Initialize PDP structure and start PDP context

  • Init MQTT client

  • Configure it with all parameters (Client ID, PDP context ID, keepalive timeout...)

  • Initialize the TLS parameters (TLS1.2) andh auth mode (server+client auth in the example)

  • Create SSL context

  • Read certificates files and store them

  • Connect MQTT client to broker

  • Subscribe to topic

  • Publish 10 messages with increasing counter

  • Print received message in mqtt_topc_cb function

  • Disconnect MQTT client and deinit it

  • Disable PDP context

How to get started with AWS IoT

  • Go to AWS console and create an account if one is not available yet.
  • Go to IoT Core section
  • Go to Secure > Policies section
  • Create a new policy, which describes what the device will be allowed to do (e.g. subscribe, publish)
  • Give it a name, then configure it using the configuration below (it is possible to copy/paste by clicking on Add statements section, then Advanced mode ) :
{
  "Version": "2012-10-17",
  "Statement": [
  {
    "Action": [
      "iot:Publish",
      "iot:Subscribe",
      "iot:Connect",
      "iot:Receive"
    ],
    "Effect": "Allow",
    "Resource": [
      "*"
    ]
  }
  ]
}
  • Click on create to complete the policy creation.
  • Go to Manage section
  • Press Create, then Create a single thing
  • Give the new thing a name, then click on Next
  • Select One-click certificate creation (recommended) by clicking on Create certificate
  • Once presented with the Certificate created page, download all certificates and keys
  • Click on the Activate button to enable the certificate authentication of the newly created device
  • Click on Attach a policy and select the policy created in a previous step

For further information, please refer to the full AWS IoT documentation

Application setup

  • Set CLIENTCERTFILE and CLIENTKEYFILE defines in aws_demo.c file in order to match the certificate and key created in the previous section.
  • Set AWS_BROKER_ADDRESS to the correct AWS URL. It can be retrieved from AWS IoT Manage > Things > Interact in the HTTPS Rest API Endpoint URL.
  • Set CLIENT_ID to the desired Client ID for your AWS device
  • (Optional) if required, change CACERTFILE to match the one to be used.

Device setup

The application requires the certificates (provided in sample app certs subfolder ) to be stored in /data/azc/mod/ssl_certs/ folder. It can be created with

AT#M2MMKDIR=/data/azc/mod/ssl_certs

Certificates can then be loaded with

AT#M2MWRITE="/data/azc/mod/ssl_certs/preload_CACert_01.crt",1468 AT#M2MWRITE="/data/azc/mod/ssl_certs/Amazon-IoT.crt",1646

providing the file content in RAW mode (for example using the "Transfer Data" button in Telit AT Controller)

For client certificates, the commands will be

AT#M2MWRITE="/data/azc/mod/ssl_certs/xxxxx.crt",yyyy
AT#M2MWRITE="/data/azc/mod/ssl_certs/xxxxx.key",zzzz

PLEASE NOTE: always verify the file sizes to be used in the commands above as they might change

Data received from a subscriber:


App Manager

Sample application showing how to manage AppZone apps from m2mb code. Debug prints on USB0

Features

  • How to get how many configured apps are available
  • How to get the handle to manage the running app (change start delay, enable/disable)
  • How to create the handle for a new binary app, enable it and set its parameters
  • How to start the new app without rebooting the device, then stop it after a while.

Prerequisites

This app will try to manage another app called "second.bin", which already exists in the module filesystem and can be anything (e.g. another sample app as GPIO toggle). the app must be built using the flag ROM_START=

in the Makefile to set a different starting address than the main app (by default, 0x40000000). For example, 0x41000000.

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • get a non existing app handle and verify it is NULL
  • get the current app handle, then get the start delay set in the INI file (so persistent)
  • change the current app delay value in the INI file
  • verify that the change has been stored
  • get current app state
  • create an handle for a second application binary.
  • add it to the INI file
  • set its execution flag to 0
  • get the delay time and the state from INI file for the new app
  • get the current set address for the new app
  • set the app delay in RAM, INI will not be affected.
  • start the new app without reboot, using the right set delay
  • wait some time, then get the app state and the used RAM amount
  • wait 10 seconds, then stop the second app.
  • set its execution flag to 1 so it will run at next boot.


App update OTA via FTP

Sample application showcasing Application OTA over FTP with AZX FTP. Debug prints on USB0

Features

  • How to check module registration and activate PDP context
  • How to connect to a FTP server
  • How to download an application binary and update the local version

The app uses a predefined set of parameters. To load custom parameters, upload the ota_config.txt file (provided in project's /src folder) in module's /data/azc/mod folder, for example with

AT#M2MWRITE="/data/azc/mod/ota_config.txt",<filesize>

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a task to manage app OTA and start it

ftp_utils.c

  • Set parameters to default

  • Try to load parameters from ota_config.txt file

  • Initialize Network structure and check registration

  • Initialize PDP structure and start PDP context

  • Initialize FTP client

  • Connect to FTP server and log in

  • Get new App binary file size on remote server

  • Download the file in /data/azc/mod folder, with the provided name

  • Close FTP connection

  • Disable PDP context

  • Update applications configuration in app_utils.c

app_utils.c

  • Set new application as default
  • Delete old app binary
  • Restart module


CJSON example:

Sample application showcasing how to manage JSON objects. Debug prints on USB0

Features

  • How to read a JSON using cJSON library
  • How to write a JSON
  • How to manipulate JSON objects

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Parse an example string into a JSON object and print the result in a formatted string
  • Print some test outcomes (e.g. non existing item correctly not found)
  • Retrieve single elements from the parsed JSON object and use them to format a descriptive string
  • Delete the JSON object
  • Create a new JSON object appending elements to it
  • Print the result JSON string from the object


Easy AT example

Sample application showcasing Easy AT functionalities. Debug prints on USB0

Features

  • Shows how to register custom commands

The application adds two custom commands to the list of available ones:

  • AT#MYCMD
  • AT#MYINPUT

AT#MYCMD

This is a simple parameter-waiting command. It expects one string parameter, and will print it on the logging interface once received. The command simply returns OK

AT#MYINPUT

This command expects a numeric parameter, which indicates how many bytes will be received over the interface at most (the command will provide a prompt indicating it is waiting data). Then the data management callback will print when data is received, and if CTRL+Z (0x1A in hex) is received, it will complete the process, printing in the log interface what was received. sending ESC will terminate the process discarding any pending data.

Events

Sample application showcasing events setup and usage. Debug prints on USB0

Features

  • How to setup OS events with a custom bitmask
  • How to wait for events and generate them in callback functions to synchronize blocks of code

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Create an event handler
  • Create a timer to generate an event, with a 2 seconds expiration time
  • Wait for a specific event bit on the event handler
  • At timer expiration, set the same event bit and verify that the code flow went through after the event.


Events - Barrier (multi events)

Sample application showcasing how to setup and use multiple events to create a barrier. Debug prints on USB0

Features

  • How to setup OS events to be used as a barrier
  • How to wait for multiple events in the same point, and generate them in callback functions to synchronize blocks of code

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Create an event handler
  • Create a timer to generate an event, with a 3 seconds expiration time
  • Create another timer to generate an event, with a 6 seconds expiration time
  • Start both timers
  • Wait for both event bits on the event handler (each one will be set by one of the timers)
  • At first timer expiration, set the first event bit and verify that the code flow does not procede.
  • At second timer expiration, set the second event bit and verify that the code flow went through after the event (implementing a barrier).


FOTA example

Sample application showcasing FOTA usage with M2MB API. Debug prints on USB0

Features

  • How download a delta file from a remote server
  • How to apply the delta and update the module firmware

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a main task to manage connectivity.

  • create a fota task to manage FOTA and start it with INIT option

fota.c

fotaTask()

  • Initialize FOTA system then reset parameters.
  • Check current FOTA state, if not in IDLE, return error.
  • Send a message to mainTask so networking is initialized.
  • after PdPCallback() notifies the correct context activation, configure the fota client parameters such as FTP server URL, username and password
  • get delta file from server. when it is completed, FOTADownloadCallback is called.
  • If delta download went fine, check it.
  • If delta file is correct, apply it. Once complete, restart the module.

mainTask()

  • Initialize Network structure and check registration
  • Initialize PDP structure and start PDP context. Event will be received on PdPCallback function
  • Disable PDP context when required to stop the app

PdpCallback()

  • When PDP context is enabled, send a message to fotaTask to start the download


FOTA_FTP_client example

Sample application that shows how to download a delta file from an FTP server, stores it in the FOTA partition and deploys it. Debug prints on USB0

Features

  • How to download a delta file from FTP server using FTP client
  • How to store directly delta file in the FOTA partition
  • How to deploy delta file to upgrade mdoule fw.

Application workflow

M2MB_main.c

  • Print welcome message
  • Create a main task to manage connectivity, delta download and deployment

ftp_test.c

msgFTPTask()

  • Initialize Network structure and check registration
  • Initialize PDP structure and start PDP context. Event will be received on
  • Initialize FOTA system then reset parameters.
  • After PDP context activation notified by PdPCallback() configure fota client parameters as FTP server url, username and password and SSL
  • Get delta filefrom server and store it directly in the FOTA partition
  • If delta download went fine, check it (m2mb_fota_update_package_check_setup) and if it's correct apply it (m2mb_fota_start).
  • Once completed restart module.

PdpCallback()

  • When PDP context is enabled, send a message to fotaTask to start the download

buf_data_cb_OTA()

  • Handles data reception and writing in the FOTA partition (one block size at a time)


FOTA from Local File example

Sample application that shows how perform FOTA upgrade using a delta file stored into file system. Debug prints on USB0

Features

  • How to store and get FOTA upgrade information to/from a file
  • How to get delta file from module file system
  • How to apply the delta and update module firmware

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Check if module has been already upgraded or needs to be upgraded reading FOTA upgrade status from a file

  • Create a fota task to manage FOTA and start it with INIT option

smartFotaTask()

  • Initialize FOTA system then reset parameters.
  • Get FOTA partiton size and block size
  • Copy delta file from file system to FOTA paartition. when it is completed, FOTADownloadCallback is called.
  • If delta file is correct, apply it. Once complete, write FOTA status flag and current fw version to a file, restart the module.


FTP

Sample application showcasing FTP client demo with AZX FTP. Debug prints on USB0

Features

  • How to check module registration and activate PDP context
  • How to connect to a FTP server
  • How to exchange data with the server

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a task to manage FTP client and start it

ftp_test.c

  • Initialize Network structure and check registration

  • Initialize PDP structure and start PDP context

  • Init FTP client and set the debug function for it

  • Connect to the server

  • Perform log in

  • Check remote file size and last modification time

  • Download file from server to local filesystem. A data callback is set to report periodic info about the download status

  • Upload the same file to the server with a different name. A data callback is set to report periodic info about the upload status

  • Download another file content in a buffer instead of a file. A data callback is set to report periodic info about the download status

  • Close the connection with FTP server

  • Disable PDP context


File System example

Sample application showcasing M2MB File system API usage. Debug prints on USB0

Features

  • How to open a file in write mode and write data in it
  • How to reopen the file in read mode and read data from it

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Open file in write mode

  • Write data in file

  • Close file

  • Reopen file in read mode

  • Read data from file and print it

  • Close file and delete it


GNSS example

Sample application showing how to use GNSS functionality. Debug prints on USB0

Features

  • How to enable GNSS receiver on module
  • How to collect location information from receiver

Note: on MEx10G1 product family both M2MB_GNSS_SERVICE_NMEA_REPORT and M2MB_GNSS_SERVICE_POSITION_REPORT services are available, while on ME910C1 product family only M2MB_GNSS_SERVICE_POSITION_REPORT is available

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Print a welcome message
  • Create GNSS task and send a message to it

gps_task.c

  • Init Info feature and get module type
  • Init gnss, enable position/NMEA report and start it.
  • When a fix or a NMEA sentence is available, a message will be printed by the GNSS callback function


GPIO interrupt example

Sample application showing how to use GPIOs and interrupts. Debug prints on USB0

Features

  • How to open a GPIO in input mode with interrupt
  • How to open a second GPIO in output mode to trigger the first one

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Open GPIO 4 as output

  • Open GPIO 3 as input and set interrupt for any edge (rising and falling). A jumper must be used to short GPIO 3 and 4 pins.

  • Toggle GPIO 4 status high and low every second

  • An interrupt is generated on GPIO 3


General_INFO example

Sample application prints some Module/SIM information as IMEI, fw version, IMSI and so on; it prints also some information about registration. Debug prints on USB0

Features

  • How to print some Module information as IMEI, FW version etc
  • How to print some SIM information as IMSI, ICCID
  • How to get and print some informatio about Module registration as Netowrk Operator, AcT, RSSI, etc

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Print welcome message
  • Init NET functionality
  • Init INFO functionality
  • Get and print Module and SIM info
  • Wait form module to register to network
  • Get and print registration INFO


HTTP Client

Sample application showing how to use HTTPs client functionalities. Debug prints on USB0

Features

  • How to check module registration and activate PDP context
  • How to initialize the http client, set the debug hook function and the data callback to manage incoming data
  • How to perform GET, HEAD or POST operations (GET also with single range support)

NOTE: the sample app has an optional dependency on azx_base64.h if basic authentication is required (refer to HTTP_BASIC_AUTH_GET define in M2MB_main.c for further details)

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a task to manage HTTP client and start it

httpTaskCB

  • Initialize Network structure and check registration
  • Initialize PDP structure and start PDP context
  • Create HTTP client options and initialize its functionality
  • Create HTTP SSL config and initialize the SSL options
  • Configure data management options for HTTP client
  • Appy all configurations to HTTP client
  • Perform a GET request to a server
  • Disable PDP context

DATA_CB

  • Print incoming data
  • Set the abort flag to 0 to keep going.


HW Timer (Hardware Timer)

The sample application shows how to use HW Timers M2MB API. Debug prints on USB0

Features

  • How to open configure a HW timer
  • How to use the timer to manage recurring events

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create hw timer structure

  • Configure it with 100 ms timeout, periodic timer (auto fires when expires) and autostart

  • Init the timer with the parameters

  • Wait 10 seconds

  • Stop the timer

TimerCb

  • Print a message with an increasing counter


Hello World

The application prints "Hello World!" over selected output every two seconds. Debug prints on USB0, using AZX log example functions

Features

  • How to open an output channel using AZX LOG sample functions
  • How to print logging information on the channel using AZX LOG sample functions

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Print "Hello World!" every 2 seconds in a while loop


I2C example

Sample application showing how to communicate with an I2C slave device. Debug prints on USB0

Features

  • How to open a communication channel with an I2C slave device
  • How to send and receive data to/from the slave device

Setup

  • Connect sensor VDD to 1v8 supply (e.g. Vaux/PwrMon pin of the module)
  • Connect sensor GND to a GND pin of the module
  • Connect sensor SDA to module GPIO2
  • Connect sensor SCL to module GPIO3

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Open I2C bus, setting SDA an SCL pins as 2 and 3 respectively
  • Set registers to configure accelerometer -Read in a loop the 6 registers carrying the 3 axes values and show the g value for each of them


Little FileSystem 2

Sample application showing how use lfs2 porting with RAM disk and SPI data flash. Debug prints on USB0

Features

  • How to create and manage Ram Disk
  • How to manage file-system in Ram disk partition
  • How to create and manage SPI Flash memory partition
  • How to manage file-system in SPI Flash memory partition

Application workflow

M2MB_main.c

  • Init logging system
  • Call Ram Disk tests
  • Call Flash memory tests

ram_utils_usage.c

  • Initialize Ram Disk
  • Format and Mount partition
  • List files
  • Files creation and write content
  • List files
  • Read files
  • Unmount and Release resources

spi_utils_usage.c

  • Initialize SPI Flash chip
  • Initialize SPI Flash Disk
  • Format and Mount partition
  • List files
  • Files creation and write content
  • List files
  • Read files
  • Delete files
  • Directories creation and deletion
  • Unmount and Release resources

Notes:

For SPI Flash a JSC memory is used with chip select pin connected to module GPIO2 pin. For better performances, a 33kOhm pull-down resistor on SPI clock is suggested. Please refer to SPI_echo sample app for SPI connection details.

For LE910Cx (both Linux and ThreadX based devices), AT#SPIEN=1 command must be sent once before running the app


Logging Demo

Sample application showing how to print on one of the available output interfaces. Debug prints on USB0

Features

  • How to open a logging channel
  • How to set a logging level
  • How to use different logging macros

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Print a message with every log level


MD5 example

Sample application showing how to compute MD5 hashes using m2mb crypto. Debug prints on USB0

Features

  • Compute MD5 hash of a file
  • Compute MD5 hash of a string

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Create a temporary file with the expected content
  • Compute MD5 hash of the provided text file
  • Compare the hash with the expected one
  • Compute MD5 hash of a string
  • Compare the hash with the expected one
  • Delete test file


MQTT Client

Sample application showcasing MQTT client functionalities (with SSL). Debug prints on USB0

Features

  • How to check module registration and enable PDP context
  • How to configure MQTT client parameters
  • How to connect to a broker with SSL and exchange data over a subscribed topic

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a task to manage MQTT client and start it

mqtt_demo.c

  • Initialize Network structure and check registration

  • Initialize PDP structure and start PDP context

  • Init MQTT client

  • Configure it with all parameters (Client ID, username, password, PDP context ID, keepalive timeout...)

  • Connect MQTT client to broker

  • Subscribe to two topics

  • Publish 10 messages with increasing counter. Even messages are sent to topic 1, odd messages on topic 2.

  • Print received message in mqtt_topc_cb function

  • Disconnect MQTT client and deinit it

  • Disable PDP context


MultiTask

Sample application showcasing multi tasking functionalities with M2MB API. Debug prints on USB0

Features

  • How to create tasks using azx utilities
  • How to use send messages to tasks
  • How to use a semaphore to synchronize two tasks

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create three tasks with the provided utility (this calls public m2mb APIs)

  • Send a message to the task1, its callback function azx_msgTask1 will be called

azx_msgTask1

  • Print received parameters from main
  • Send modified parameters to task2 (its callback function azx_msgTask2 will be called)
  • wait for an InterProcess Communication semaphore to be available (released by task3)
  • Once the semaphore is available, print a message and return

azx_msgTask2

  • Print received parameters from caller
  • If first parameter is bigger than a certain value, Send modified parameters to task3
  • Else, use the second parameter as a task handle and print the corresponding name plus the value of the first parameter

azx_msgTask3

  • Print received parameters from task 2
  • release IPC semaphore
  • send message to task 2 with first parameter below the threshold and second parameter with task3 handle


NTP example

The application connects to an NTP server, gets current date and time and updates module's internal clock. Debug prints on USB0

Features

  • How to get current date and time from an NTP server
  • How to set current date and time on module

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Print welcome message
  • Send message to ntpTask

ntp_task.c

NTP_task()

  • Waits module registration
  • When module is registered, initializes ntp setting CID, server url and timeout
  • When PDP context is correctly opened, a query to NTP server is done to get current date and time
  • On SET_MODULE_RTC message type reception, module RTC is set with date time value got from NTP server.

m2mb_ntp_ind_callback()

  • As soon as M2MB_NTP_VALID_TIME event is received, current date and time is printend and a message (with SET_MODULE_RTC type) is sent to NTP_task


RTC example

Sample application that shows RTC apis functionalities: how to get/set moudle system time and timestamp. Debug prints on USB0

Features

  • How to read module timestamp
  • How to read module system time
  • How to set new system time

Application workflow

M2MB_main.c

  • Init log azx and print a welcome message
  • Init net functionality and wait for module registration
  • Init RTC functionality and get module time in timestamp format (seconds from the epoch)
  • Get moudle system time in date/time format
  • Add 1 hour to timestamp, convert it to system time and set it to module


SIM event handler example

Sim Event Demo application. Debug prints on USB0, using AZX log example functions

Features

  • How to use ATI function for asynchronous management
  • How to cath URC from an AppZone application
  • How to catch SIM related events and handle them

Application workflow

M2MB_main.c

  • Print welcome message
  • Initialize AT interface
  • Initialize AT URC manager task
  • Initialize SIM event manager task
  • Send 'AT#SIMPR=1' to activate SIM URCs
  • Insert SIM in SIM slot 1 and receive SIM inserted message
  • Remove SIM from SIM slot 1 and receive SIM removed message


SMS PDU

Sample application showcasing how to create and decode PDUs to be used with m2mb_sms_* API set. A SIM card and antenna must be present. Debug prints on USB0

Features

  • How to enable SMS functionality
  • How to use encode an SMS PDU to be sent with m2mb_api
  • How to decode a received SMS response from PDU to ASCII mode.

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Init sms functionality
  • Create PDU from text message
  • Send message to destination number
  • Wait for response
  • When SMS PDU response is received, decode it and print information about it, plus the message content


SMS_atCmd example

Sample application showcasing how to receive an SMS containing an AT command, process the AT command and send its answer to sender (configurable in sms_config.txt). A SIM card and antenna must be present. Debug prints on USB0

Features

  • How to receive an SMS with an AT command as text inside
  • How to send AT command to parser and read the answer
  • How to send the AT command answer back to sender via SMS

Optional configuration file to be put in /data/azc/mod folder, copy sms_config.txt file into your module running the following AT command:

AT#M2MWRITE="/data/azc/mod/sms_config.txt",138
>>> here receive the prompt; then type or send the file, sized 138 bytes

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Print welcome message
  • Init SMS functionality
  • Read configuration file sms_config.txt (send SMS with AT command answer back, delte SMS received)
  • Init AT command parser
  • Create a task to handle SMS parsing and AT command sending
  • Wait for an incoming SMS

callbacks.c

msgSMSparse()

  • When SMS has been received, content is decoded and printed. If there is an AT command inside, command is executed and answer printed and sent back to sender as an SMS (depending on sms_config.txt setting)


SMTP Client

Sample application showing SMTP echo demo with M2MB API. Debug prints on USB0

Features

  • How to check module registration and activate PDP context
  • How to open a SMTP client
  • How to send a mail

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a task to manage SMTP client and start it

M2MB_main.c

  • Initialize Network structure and check registration

  • Initialize PDP structure and start PDP context

  • Initialize SMTP client and connect to SMTP server

  • Prepare email and send it

  • Close SMTP client

  • Disable PDP context


SPI Echo

Sample application showing how to communicate over SPI with m2mb API. Debug prints on USB0

Features

  • How to open an SPI bus. MOSI and MISO will be shorted, to have an echo.
  • How to communicate over SPI bus

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Open SPI bus, set parameters

  • Send data on MOSI and read the same in MISO

Notes:

For LE910Cx (both Linux and ThreadX based devices), AT#SPIEN=1 command must be sent once before running the app


SPI sensors

Sample application showing SPI usage, configuring two ST devices: a magnetometer (ST LIS3MDL) and a gyroscope (ST L3G4200D). The application will read values from both devices using GPIO4 and 3 (respectively) as magnetometer CS and gyro CS. Debug prints on USB0

Features

  • How to open an SPI bus with a slave device
  • How to communicate with the device over the SPI bus

Setup

  • Connect sensor VDD to 3v8 supply (e.g. Vbatt on the module)
  • Connect sensor GND to a GND pin of the module
  • Connect sensors MOSI to module SPI_MOSI
  • Connect sensors MISO to module SPI_MISO
  • Connect sensors CLK to module SPI_CLK
  • Connect magnetometer CS to module GPIO 2
  • Connect gyroscope CS to module GPIO 3

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Open SPI bus, set parameters
  • Configure GPIO 2 and GPIO 3 as output, set them high (idle)
  • Set registers to configure magnetometer
  • Read in a loop (10 iterations) the registers carrying the 3 axes values and show the gauss value for each of them. A metal object is put close to the sensor to change the read values.
  • Set registers to configure gyroscope
  • Read in a loop (10 iterations) the registers carrying the 3 axes values and show the degrees per second value for each of them. The board is rotated to change the read values.

Notes:

For LE910Cx (both Linux and ThreadX based devices), AT#SPIEN=1 command must be sent once before running the app


SW Timer (Software Timer)

The sample application shows how to use SW Timers M2MB API. Debug prints on USB0

Features

  • How to open configure a SW timer
  • How to use the timer to manage recurring events

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create sw timer structure

  • Configure it with 4 seconds timeout, periodic timer (auto fires when expires)

  • Init the timer with the parameters

  • Start the timer

  • Wait 10 seconds

  • Stop the timer

timerCb

  • Print a message with inside the callback


TCP IP

Sample application showcasing TCP echo demo with M2MB API. Debug prints on USB0

Features

  • How to check module registration and activate PDP context
  • How to open a TCP client socket
  • How to communicate over the socket

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a task to manage socket and start it

m2m_tcp_test.c

  • Initialize Network structure and check registration

  • Initialize PDP structure and start PDP context

  • Create socket and link it to the PDP context id

  • Connect to the server

  • Send data and receive response

  • Close socket

  • Disable PDP context


TCP non blocking example

Sample application that shows how to configure and connect a TCP-IP non blocking socket. Debug prints on USB0

Features

  • How to check module registration and activate PDP context
  • How to open a TCP client non Blocking socket
  • How to communicate over the socket

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a task to manage socket and start it

m2m_tcp_test.c

  • Initialize Network structure and check registration

  • Initialize PDP structure and start PDP context

  • Create socket and link it to the PDP context id

  • Set the socket as non Blocking and connect to server. Uses m2mb_socket_bsd_select, m2mb_socket_bsd_fd_isset_func to check when socket is connected.

  • Send data and receive response

  • Close socket

  • Disable PDP context


TCP Socket status

Sample application showcasing how to check a TPC connected socket current status. Debug prints on USB0

Features

  • How to check module registration and activate PDP context
  • How to open a TCP client socket
  • How to check if the TCP socket is still valid

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a task to manage socket and start it

m2m_tcp_test.c

  • Initialize Network structure and check registration

  • Initialize PDP structure and start PDP context

  • Create socket and link it to the PDP context id

  • Connect to the server

  • Check in a loop the current socket status using the adv_select function with a 2 seconds timeout

  • Close socket when the remote host closes it

  • Disable PDP context


TCP Server

Sample application showcasing TCP listening socket demo with M2MB API. Debug prints on USB0

Features

  • How to check module registration and activate PDP context
  • How to open a TCP listening socket
  • How to manage external hosts connection and exchange data

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a task to manage socket and start it

m2m_tcp_test.c

  • Initialize Network structure and check registration

  • Initialize PDP structure and start PDP context

  • Create socket and set it in non-blocking mode

  • Bind the socket to the listening port

  • Start listening for incoming connection

  • Check if a connection is incoming using m2mb_socket_bsd_select function

  • If a client connects, perform accept on the child socket

  • Send a "START" message to the client

  • Send some data

  • Wait for data from client and print it

  • Close the child socket

  • Start listening again, up to 3 times

  • Close listening socket

  • Disable PDP context

Debug Log

Data on a PuTTY terminal


TLS SSL Client

Sample application showcasing TLS/SSL with client certificates usage with M2MB API. Debug prints on USB0

Features

  • How to check module registration and enable PDP context
  • How to open a SSL client socket
  • How to communicate over SSL socket

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Create a task to manage the connection and start it

ssl_test.c

  • Initialize Network structure and check registration

  • Initialize PDP structure and start PDP context

  • Create socket and link it to the PDP context id

  • Connect to the server over TCP socket

  • Initialize the TLS parameters (TLS1.2) andh auth mode (server+client auth in the example)

  • Create SSL context

  • Read certificates files and store them

  • Create secure socket and connect to the server using SSL

  • Send data and receive response

  • Close secure socket

  • Close socket

  • Delete SSL context

  • Disable PDP context

The application requires the certificates to be stored in /data/azc/mod/ssl_certs/ folder. It can be created with

AT#M2MMKDIR=/data/azc/mod/ssl_certs

Certificates can then be loaded with

AT#M2MWRITE="/data/azc/mod/ssl_certs/data/azc/modulesCA.crt",1740

and providing the file content in RAW mode (for example using the "Transfer Data" button in Telit AT Controller)

For client certificates (if required), the commands will be

AT#M2MWRITE="/data/azc/mod/ssl_certs/data/azc/modulesClient.crt",1651
AT#M2MWRITE="/data/azc/mod/ssl_certs/data/azc/modulesClient_pkcs1.key",1679

PLEASE NOTE: always verify the file sizes to be used in the commands above as they might change


UDP client

Sample application showcasing UDP echo demo with M2MB API. Debug prints on USB0

Features

  • How to check module registration and activate PDP context
  • How to open a UDP client socket
  • How to communicate over the socket

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Print welcome message
  • Create a task and start it

m2m_udp_test.c

  • Initialize Network structure and check registration
  • Initialize PDP structure and start PDP context
  • Create socket and link it to the PDP context id
  • Send data and receive response
  • Close socket
  • Disable PDP context


UDP_Server example

Sample application that shows UDP listening socket demo with m2mb apis. Debug prints on USB0

Features

  • How to configure an UDP socket into listen mode
  • How to receive data using m2mb_socket_bsd_select
  • How to read data received and send data to client

Application workflow

M2MB_main.c

  • Print welcome message
  • Init task apis and create M2M_msgUDPTask to handle UDP socket

m2mb_udp_test.c

M2M_msgUDPTask

  • Wait for module registration
  • Activate PDP context
  • Create UDP listen socket
  • Wait for incoming data from client using m2mb_socket_bsd_select
  • When there are data on socket, read them and send some data back to client


ZLIB example

Sample application showing how to compress/uncompress with ZLIB. Debug prints on USB0

Features

  • How to compress a file
  • How to uncompress a file

In order to execute the entire test, copy test.gz file into your module running the following AT command:

AT#M2MWRITE="/data/azc/mod/test.gz",138
>>> here receive the prompt; then type or send the file, sized 138 bytes

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Test the compression and decompression of a data string
  • Test the decompression of a .gz file (test.gz), expected to be in /data/azc/mod folder, into its content test.txt. The file must be uploaded by the user (see steps above).


MAIN UART

Applications that provide usage examples for various functionalities, log output on MAIN UART

Alarm example

Sample application that shows how to set an alarm to wake-up module. Debug prints on MAIN UART

Features

  • How to set an alarm
  • How to use it to turn on module

Application workflow

M2MB_main.c

  • Init RTC
  • Wait for registration
  • Get current date and time
  • Call function set_alarm
  • Init Power and turn off module


ATI (AT Instance)

Sample application showing how to use AT Instance functionality (sending AT commands from code). The example supports both sync and async (using a callback) modes. Debug prints on MAIN UART

Features

  • How to open an AT interface from the application
  • How to send AT commands and receive responses on the AT interface

Application workflow, sync mode

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Init AT0 (first AT instance)
  • Send AT+CGMR command
  • Print response.
  • Release AT0

at_sync.c

  • Init ati functionality and take AT0
  • Send AT+CGMR command, then read response after 2 seconds, then return it
  • Deinit ati, releasing AT0

Application workflow, async mode

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Init AT0 (first AT instance)
  • Send AT+CGMR command
  • Print response.
  • Release AT0

at_async.c

  • Init ati functionality and take AT0, register AT events callback
  • Send AT+CGMR command, wait for response semaphore (released in callback), then read it and return it
  • Deinit ati, releasing AT0


AT Tunnel

Sample application showcasing how to perform an AT tunnel from Main UART to an AT instance. Debug prints on USB1.

Features

  • How to open an AT interface from the application
  • How to receive data from main UART and tunnel it to the AT interface, then report back to UART the AT response

Application workflow

M2MB_main.c

  • Open USB1 for debug
  • Initialize UART with callback function to manage input data
  • Initialize AT system to manage AT commands from UART
  • wait 5 minutes then deinit AT system

Main UART:

USB1 debug log:


AWS demo

Sample application showcasing AWS Iot Core MQTT communication. Debug prints on MAIN UART

Features

  • How to check module registration and enable PDP context
  • How to load certificates into device SSL session storage
  • How to configure MQTT client parameters
  • How to connect to AWS server with SSL and exchange data over a topic

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a task to manage MQTT client and start it

aws_demo.c

  • Initialize Network structure and check registration

  • Initialize PDP structure and start PDP context

  • Init MQTT client

  • Configure it with all parameters (Client ID, PDP context ID, keepalive timeout...)

  • Initialize the TLS parameters (TLS1.2) andh auth mode (server+client auth in the example)

  • Create SSL context

  • Read certificates files and store them

  • Connect MQTT client to broker

  • Subscribe to topic

  • Publish 10 messages with increasing counter

  • Print received message in mqtt_topc_cb function

  • Disconnect MQTT client and deinit it

  • Disable PDP context

How to get started with AWS IoT

  • Go to AWS console and create an account if one is not available yet.
  • Go to IoT Core section
  • Go to Secure > Policies section
  • Create a new policy, which describes what the device will be allowed to do (e.g. subscribe, publish)
  • Give it a name, then configure it using the configuration below (it is possible to copy/paste by clicking on Add statements section, then Advanced mode ) :
{
  "Version": "2012-10-17",
  "Statement": [
  {
    "Action": [
      "iot:Publish",
      "iot:Subscribe",
      "iot:Connect",
      "iot:Receive"
    ],
    "Effect": "Allow",
    "Resource": [
      "*"
    ]
  }
  ]
}
  • Click on create to complete the policy creation.
  • Go to Manage section
  • Press Create, then Create a single thing
  • Give the new thing a name, then click on Next
  • Select One-click certificate creation (recommended) by clicking on Create certificate
  • Once presented with the Certificate created page, download all certificates and keys
  • Click on the Activate button to enable the certificate authentication of the newly created device
  • Click on Attach a policy and select the policy created in a previous step

For further information, please refer to the full AWS IoT documentation

Application setup

  • Set CLIENTCERTFILE and CLIENTKEYFILE defines in aws_demo.c file in order to match the certificate and key created in the previous section.
  • Set AWS_BROKER_ADDRESS to the correct AWS URL. It can be retrieved from AWS IoT Manage > Things > Interact in the HTTPS Rest API Endpoint URL.
  • Set CLIENT_ID to the desired Client ID for your AWS device
  • (Optional) if required, change CACERTFILE to match the one to be used.

Device setup

The application requires the certificates (provided in sample app certs subfolder ) to be stored in /data/azc/mod/ssl_certs/ folder. It can be created with

AT#M2MMKDIR=/data/azc/mod/ssl_certs

Certificates can then be loaded with

AT#M2MWRITE="/data/azc/mod/ssl_certs/preload_CACert_01.crt",1468 AT#M2MWRITE="/data/azc/mod/ssl_certs/Amazon-IoT.crt",1646

providing the file content in RAW mode (for example using the "Transfer Data" button in Telit AT Controller)

For client certificates, the commands will be

AT#M2MWRITE="/data/azc/mod/ssl_certs/xxxxx.crt",yyyy
AT#M2MWRITE="/data/azc/mod/ssl_certs/xxxxx.key",zzzz

PLEASE NOTE: always verify the file sizes to be used in the commands above as they might change

Data received from a subscriber:


App Manager

Sample application showing how to manage AppZone apps from m2mb code. Debug prints on MAIN UART

Features

  • How to get how many configured apps are available
  • How to get the handle to manage the running app (change start delay, enable/disable)
  • How to create the handle for a new binary app, enable it and set its parameters
  • How to start the new app without rebooting the device, then stop it after a while.

Prerequisites

This app will try to manage another app called "second.bin", which already exists in the module filesystem and can be anything (e.g. another sample app as GPIO toggle). the app must be built using the flag ROM_START=

in the Makefile to set a different starting address than the main app (by default, 0x40000000). For example, 0x41000000.

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • get a non existing app handle and verify it is NULL
  • get the current app handle, then get the start delay set in the INI file (so persistent)
  • change the current app delay value in the INI file
  • verify that the change has been stored
  • get current app state
  • create an handle for a second application binary.
  • add it to the INI file
  • set its execution flag to 0
  • get the delay time and the state from INI file for the new app
  • get the current set address for the new app
  • set the app delay in RAM, INI will not be affected.
  • start the new app without reboot, using the right set delay
  • wait some time, then get the app state and the used RAM amount
  • wait 10 seconds, then stop the second app.
  • set its execution flag to 1 so it will run at next boot.


App update OTA via FTP

Sample application showcasing Application OTA over FTP with AZX FTP. Debug prints on MAIN UART

Features

  • How to check module registration and activate PDP context
  • How to connect to a FTP server
  • How to download an application binary and update the local version

The app uses a predefined set of parameters. To load custom parameters, upload the ota_config.txt file (provided in project's /src folder) in module's /data/azc/mod folder, for example with

AT#M2MWRITE="/data/azc/mod/ota_config.txt",<filesize>

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a task to manage app OTA and start it

ftp_utils.c

  • Set parameters to default

  • Try to load parameters from ota_config.txt file

  • Initialize Network structure and check registration

  • Initialize PDP structure and start PDP context

  • Initialize FTP client

  • Connect to FTP server and log in

  • Get new App binary file size on remote server

  • Download the file in /data/azc/mod folder, with the provided name

  • Close FTP connection

  • Disable PDP context

  • Update applications configuration in app_utils.c

app_utils.c

  • Set new application as default
  • Delete old app binary
  • Restart module


CJSON example:

Sample application showcasing how to manage JSON objects. Debug prints on MAIN UART

Features

  • How to read a JSON using cJSON library
  • How to write a JSON
  • How to manipulate JSON objects

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Parse an example string into a JSON object and print the result in a formatted string
  • Print some test outcomes (e.g. non existing item correctly not found)
  • Retrieve single elements from the parsed JSON object and use them to format a descriptive string
  • Delete the JSON object
  • Create a new JSON object appending elements to it
  • Print the result JSON string from the object


Easy AT example

Sample application showcasing Easy AT functionalities. Debug prints on MAIN UART

Features

  • Shows how to register custom commands

The application adds two custom commands to the list of available ones:

  • AT#MYCMD
  • AT#MYINPUT

AT#MYCMD

This is a simple parameter-waiting command. It expects one string parameter, and will print it on the logging interface once received. The command simply returns OK

AT#MYINPUT

This command expects a numeric parameter, which indicates how many bytes will be received over the interface at most (the command will provide a prompt indicating it is waiting data). Then the data management callback will print when data is received, and if CTRL+Z (0x1A in hex) is received, it will complete the process, printing in the log interface what was received. sending ESC will terminate the process discarding any pending data.

Events

Sample application showcasing events setup and usage. Debug prints on MAIN UART

Features

  • How to setup OS events with a custom bitmask
  • How to wait for events and generate them in callback functions to synchronize blocks of code

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Create an event handler
  • Create a timer to generate an event, with a 2 seconds expiration time
  • Wait for a specific event bit on the event handler
  • At timer expiration, set the same event bit and verify that the code flow went through after the event.


Events - Barrier (multi events)

Sample application showcasing how to setup and use multiple events to create a barrier. Debug prints on MAIN UART

Features

  • How to setup OS events to be used as a barrier
  • How to wait for multiple events in the same point, and generate them in callback functions to synchronize blocks of code

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Create an event handler
  • Create a timer to generate an event, with a 3 seconds expiration time
  • Create another timer to generate an event, with a 6 seconds expiration time
  • Start both timers
  • Wait for both event bits on the event handler (each one will be set by one of the timers)
  • At first timer expiration, set the first event bit and verify that the code flow does not procede.
  • At second timer expiration, set the second event bit and verify that the code flow went through after the event (implementing a barrier).


FOTA example

Sample application showcasing FOTA usage with M2MB API. Debug prints on MAIN UART

Features

  • How download a delta file from a remote server
  • How to apply the delta and update the module firmware

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a main task to manage connectivity.

  • create a fota task to manage FOTA and start it with INIT option

fota.c

fotaTask()

  • Initialize FOTA system then reset parameters.
  • Check current FOTA state, if not in IDLE, return error.
  • Send a message to mainTask so networking is initialized.
  • after PdPCallback() notifies the correct context activation, configure the fota client parameters such as FTP server URL, username and password
  • get delta file from server. when it is completed, FOTADownloadCallback is called.
  • If delta download went fine, check it.
  • If delta file is correct, apply it. Once complete, restart the module.

mainTask()

  • Initialize Network structure and check registration
  • Initialize PDP structure and start PDP context. Event will be received on PdPCallback function
  • Disable PDP context when required to stop the app

PdpCallback()

  • When PDP context is enabled, send a message to fotaTask to start the download


FOTA_FTP_client example

Sample application that shows how to download a delta file from an FTP server, stores it in the FOTA partition and deploys it. Debug prints on MAIN UART

Features

  • How to download a delta file from FTP server using FTP client
  • How to store directly delta file in the FOTA partition
  • How to deploy delta file to upgrade mdoule fw.

Application workflow

M2MB_main.c

  • Print welcome message
  • Create a main task to manage connectivity, delta download and deployment

ftp_test.c

msgFTPTask()

  • Initialize Network structure and check registration
  • Initialize PDP structure and start PDP context. Event will be received on
  • Initialize FOTA system then reset parameters.
  • After PDP context activation notified by PdPCallback() configure fota client parameters as FTP server url, username and password and SSL
  • Get delta filefrom server and store it directly in the FOTA partition
  • If delta download went fine, check it (m2mb_fota_update_package_check_setup) and if it's correct apply it (m2mb_fota_start).
  • Once completed restart module.

PdpCallback()

  • When PDP context is enabled, send a message to fotaTask to start the download

buf_data_cb_OTA()

  • Handles data reception and writing in the FOTA partition (one block size at a time)


FOTA from Local File example

Sample application that shows how perform FOTA upgrade using a delta file stored into file system. Debug prints on MAIN UART

Features

  • How to store and get FOTA upgrade information to/from a file
  • How to get delta file from module file system
  • How to apply the delta and update module firmware

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Check if module has been already upgraded or needs to be upgraded reading FOTA upgrade status from a file

  • Create a fota task to manage FOTA and start it with INIT option

smartFotaTask()

  • Initialize FOTA system then reset parameters.
  • Get FOTA partiton size and block size
  • Copy delta file from file system to FOTA paartition. when it is completed, FOTADownloadCallback is called.
  • If delta file is correct, apply it. Once complete, write FOTA status flag and current fw version to a file, restart the module.


FTP

Sample application showcasing FTP client demo with AZX FTP. Debug prints on MAIN UART

Features

  • How to check module registration and activate PDP context
  • How to connect to a FTP server
  • How to exchange data with the server

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a task to manage FTP client and start it

ftp_test.c

  • Initialize Network structure and check registration

  • Initialize PDP structure and start PDP context

  • Init FTP client and set the debug function for it

  • Connect to the server

  • Perform log in

  • Check remote file size and last modification time

  • Download file from server to local filesystem. A data callback is set to report periodic info about the download status

  • Upload the same file to the server with a different name. A data callback is set to report periodic info about the upload status

  • Download another file content in a buffer instead of a file. A data callback is set to report periodic info about the download status

  • Close the connection with FTP server

  • Disable PDP context


File System example

Sample application showcasing M2MB File system API usage. Debug prints on MAIN UART

Features

  • How to open a file in write mode and write data in it
  • How to reopen the file in read mode and read data from it

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Open file in write mode

  • Write data in file

  • Close file

  • Reopen file in read mode

  • Read data from file and print it

  • Close file and delete it


GNSS example

Sample application showing how to use GNSS functionality. Debug prints on MAIN UART

Features

  • How to enable GNSS receiver on module
  • How to collect location information from receiver

Note: on MEx10G1 product family both M2MB_GNSS_SERVICE_NMEA_REPORT and M2MB_GNSS_SERVICE_POSITION_REPORT services are available, while on ME910C1 product family only M2MB_GNSS_SERVICE_POSITION_REPORT is available

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Print a welcome message
  • Create GNSS task and send a message to it

gps_task.c

  • Init Info feature and get module type
  • Init gnss, enable position/NMEA report and start it.
  • When a fix or a NMEA sentence is available, a message will be printed by the GNSS callback function


GPIO interrupt example

Sample application showing how to use GPIOs and interrupts. Debug prints on MAIN UART

Features

  • How to open a GPIO in input mode with interrupt
  • How to open a second GPIO in output mode to trigger the first one

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Open GPIO 4 as output

  • Open GPIO 3 as input and set interrupt for any edge (rising and falling). A jumper must be used to short GPIO 3 and 4 pins.

  • Toggle GPIO 4 status high and low every second

  • An interrupt is generated on GPIO 3


General_INFO example

Sample application prints some Module/SIM information as IMEI, fw version, IMSI and so on; it prints also some information about registration. Debug prints on MAIN UART

Features

  • How to print some Module information as IMEI, FW version etc
  • How to print some SIM information as IMSI, ICCID
  • How to get and print some informatio about Module registration as Netowrk Operator, AcT, RSSI, etc

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Print welcome message
  • Init NET functionality
  • Init INFO functionality
  • Get and print Module and SIM info
  • Wait form module to register to network
  • Get and print registration INFO


HTTP Client

Sample application showing how to use HTTPs client functionalities. Debug prints on MAIN UART

Features

  • How to check module registration and activate PDP context
  • How to initialize the http client, set the debug hook function and the data callback to manage incoming data
  • How to perform GET, HEAD or POST operations (GET also with single range support)

NOTE: the sample app has an optional dependency on azx_base64.h if basic authentication is required (refer to HTTP_BASIC_AUTH_GET define in M2MB_main.c for further details)

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a task to manage HTTP client and start it

httpTaskCB

  • Initialize Network structure and check registration
  • Initialize PDP structure and start PDP context
  • Create HTTP client options and initialize its functionality
  • Create HTTP SSL config and initialize the SSL options
  • Configure data management options for HTTP client
  • Appy all configurations to HTTP client
  • Perform a GET request to a server
  • Disable PDP context

DATA_CB

  • Print incoming data
  • Set the abort flag to 0 to keep going.


HW Timer (Hardware Timer)

The sample application shows how to use HW Timers M2MB API. Debug prints on MAIN UART

Features

  • How to open configure a HW timer
  • How to use the timer to manage recurring events

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create hw timer structure

  • Configure it with 100 ms timeout, periodic timer (auto fires when expires) and autostart

  • Init the timer with the parameters

  • Wait 10 seconds

  • Stop the timer

TimerCb

  • Print a message with an increasing counter


Hello World

The application prints "Hello World!" over selected output every two seconds. Debug prints on MAIN UART, using AZX log example functions

Features

  • How to open an output channel using AZX LOG sample functions
  • How to print logging information on the channel using AZX LOG sample functions

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Print "Hello World!" every 2 seconds in a while loop


I2C example

Sample application showing how to communicate with an I2C slave device. Debug prints on MAIN UART

Features

  • How to open a communication channel with an I2C slave device
  • How to send and receive data to/from the slave device

Setup

  • Connect sensor VDD to 1v8 supply (e.g. Vaux/PwrMon pin of the module)
  • Connect sensor GND to a GND pin of the module
  • Connect sensor SDA to module GPIO2
  • Connect sensor SCL to module GPIO3

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Open I2C bus, setting SDA an SCL pins as 2 and 3 respectively
  • Set registers to configure accelerometer -Read in a loop the 6 registers carrying the 3 axes values and show the g value for each of them


Little FileSystem 2

Sample application showing how use lfs2 porting with RAM disk and SPI data flash. Debug prints on MAIN UART

Features

  • How to create and manage Ram Disk
  • How to manage file-system in Ram disk partition
  • How to create and manage SPI Flash memory partition
  • How to manage file-system in SPI Flash memory partition

Application workflow

M2MB_main.c

  • Init logging system
  • Call Ram Disk tests
  • Call Flash memory tests

ram_utils_usage.c

  • Initialize Ram Disk
  • Format and Mount partition
  • List files
  • Files creation and write content
  • List files
  • Read files
  • Unmount and Release resources

spi_utils_usage.c

  • Initialize SPI Flash chip
  • Initialize SPI Flash Disk
  • Format and Mount partition
  • List files
  • Files creation and write content
  • List files
  • Read files
  • Delete files
  • Directories creation and deletion
  • Unmount and Release resources

Notes:

For SPI Flash a JSC memory is used with chip select pin connected to module GPIO2 pin. For better performances, a 33kOhm pull-down resistor on SPI clock is suggested. Please refer to SPI_echo sample app for SPI connection details.

For LE910Cx (both Linux and ThreadX based devices), AT#SPIEN=1 command must be sent once before running the app


Logging Demo

Sample application showing how to print on one of the available output interfaces. Debug prints on MAIN UART

Features

  • How to open a logging channel
  • How to set a logging level
  • How to use different logging macros

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Print a message with every log level


MD5 example

Sample application showing how to compute MD5 hashes using m2mb crypto. Debug prints on MAIN UART

Features

  • Compute MD5 hash of a file
  • Compute MD5 hash of a string

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Create a temporary file with the expected content
  • Compute MD5 hash of the provided text file
  • Compare the hash with the expected one
  • Compute MD5 hash of a string
  • Compare the hash with the expected one
  • Delete test file


MQTT Client

Sample application showcasing MQTT client functionalities (with SSL). Debug prints on MAIN UART

Features

  • How to check module registration and enable PDP context
  • How to configure MQTT client parameters
  • How to connect to a broker with SSL and exchange data over a subscribed topic

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a task to manage MQTT client and start it

mqtt_demo.c

  • Initialize Network structure and check registration

  • Initialize PDP structure and start PDP context

  • Init MQTT client

  • Configure it with all parameters (Client ID, username, password, PDP context ID, keepalive timeout...)

  • Connect MQTT client to broker

  • Subscribe to two topics

  • Publish 10 messages with increasing counter. Even messages are sent to topic 1, odd messages on topic 2.

  • Print received message in mqtt_topc_cb function

  • Disconnect MQTT client and deinit it

  • Disable PDP context


MultiTask

Sample application showcasing multi tasking functionalities with M2MB API. Debug prints on MAIN UART

Features

  • How to create tasks using azx utilities
  • How to use send messages to tasks
  • How to use a semaphore to synchronize two tasks

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create three tasks with the provided utility (this calls public m2mb APIs)

  • Send a message to the task1, its callback function azx_msgTask1 will be called

azx_msgTask1

  • Print received parameters from main
  • Send modified parameters to task2 (its callback function azx_msgTask2 will be called)
  • wait for an InterProcess Communication semaphore to be available (released by task3)
  • Once the semaphore is available, print a message and return

azx_msgTask2

  • Print received parameters from caller
  • If first parameter is bigger than a certain value, Send modified parameters to task3
  • Else, use the second parameter as a task handle and print the corresponding name plus the value of the first parameter

azx_msgTask3

  • Print received parameters from task 2
  • release IPC semaphore
  • send message to task 2 with first parameter below the threshold and second parameter with task3 handle


NTP example

The application connects to an NTP server, gets current date and time and updates module's internal clock. Debug prints on MAIN UART

Features

  • How to get current date and time from an NTP server
  • How to set current date and time on module

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Print welcome message
  • Send message to ntpTask

ntp_task.c

NTP_task()

  • Waits module registration
  • When module is registered, initializes ntp setting CID, server url and timeout
  • When PDP context is correctly opened, a query to NTP server is done to get current date and time
  • On SET_MODULE_RTC message type reception, module RTC is set with date time value got from NTP server.

m2mb_ntp_ind_callback()

  • As soon as M2MB_NTP_VALID_TIME event is received, current date and time is printend and a message (with SET_MODULE_RTC type) is sent to NTP_task


RTC example

Sample application that shows RTC apis functionalities: how to get/set moudle system time and timestamp. Debug prints on MAIN UART

Features

  • How to read module timestamp
  • How to read module system time
  • How to set new system time

Application workflow

M2MB_main.c

  • Init log azx and print a welcome message
  • Init net functionality and wait for module registration
  • Init RTC functionality and get module time in timestamp format (seconds from the epoch)
  • Get moudle system time in date/time format
  • Add 1 hour to timestamp, convert it to system time and set it to module


SIM event handler example

Sim Event Demo application. Debug prints on MAIN UART, using AZX log example functions

Features

  • How to use ATI function for asynchronous management
  • How to cath URC from an AppZone application
  • How to catch SIM related events and handle them

Application workflow

M2MB_main.c

  • Print welcome message
  • Initialize AT interface
  • Initialize AT URC manager task
  • Initialize SIM event manager task
  • Send 'AT#SIMPR=1' to activate SIM URCs
  • Insert SIM in SIM slot 1 and receive SIM inserted message
  • Remove SIM from SIM slot 1 and receive SIM removed message


SMS PDU

Sample application showcasing how to create and decode PDUs to be used with m2mb_sms_* API set. A SIM card and antenna must be present. Debug prints on MAIN UART

Features

  • How to enable SMS functionality
  • How to use encode an SMS PDU to be sent with m2mb_api
  • How to decode a received SMS response from PDU to ASCII mode.

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Init sms functionality
  • Create PDU from text message
  • Send message to destination number
  • Wait for response
  • When SMS PDU response is received, decode it and print information about it, plus the message content


SMS_atCmd example

Sample application showcasing how to receive an SMS containing an AT command, process the AT command and send its answer to sender (configurable in sms_config.txt). A SIM card and antenna must be present. Debug prints on MAIN UART

Features

  • How to receive an SMS with an AT command as text inside
  • How to send AT command to parser and read the answer
  • How to send the AT command answer back to sender via SMS

Optional configuration file to be put in /data/azc/mod folder, copy sms_config.txt file into your module running the following AT command:

AT#M2MWRITE="/data/azc/mod/sms_config.txt",138
>>> here receive the prompt; then type or send the file, sized 138 bytes

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Print welcome message
  • Init SMS functionality
  • Read configuration file sms_config.txt (send SMS with AT command answer back, delte SMS received)
  • Init AT command parser
  • Create a task to handle SMS parsing and AT command sending
  • Wait for an incoming SMS

callbacks.c

msgSMSparse()

  • When SMS has been received, content is decoded and printed. If there is an AT command inside, command is executed and answer printed and sent back to sender as an SMS (depending on sms_config.txt setting)


SMTP Client

Sample application showing SMTP echo demo with M2MB API. Debug prints on MAIN UART

Features

  • How to check module registration and activate PDP context
  • How to open a SMTP client
  • How to send a mail

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a task to manage SMTP client and start it

M2MB_main.c

  • Initialize Network structure and check registration

  • Initialize PDP structure and start PDP context

  • Initialize SMTP client and connect to SMTP server

  • Prepare email and send it

  • Close SMTP client

  • Disable PDP context


SPI Echo

Sample application showing how to communicate over SPI with m2mb API. Debug prints on MAIN UART

Features

  • How to open an SPI bus. MOSI and MISO will be shorted, to have an echo.
  • How to communicate over SPI bus

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Open SPI bus, set parameters

  • Send data on MOSI and read the same in MISO

Notes:

For LE910Cx (both Linux and ThreadX based devices), AT#SPIEN=1 command must be sent once before running the app


SPI sensors

Sample application showing SPI usage, configuring two ST devices: a magnetometer (ST LIS3MDL) and a gyroscope (ST L3G4200D). The application will read values from both devices using GPIO4 and 3 (respectively) as magnetometer CS and gyro CS. Debug prints on MAIN UART

Features

  • How to open an SPI bus with a slave device
  • How to communicate with the device over the SPI bus

Setup

  • Connect sensor VDD to 3v8 supply (e.g. Vbatt on the module)
  • Connect sensor GND to a GND pin of the module
  • Connect sensors MOSI to module SPI_MOSI
  • Connect sensors MISO to module SPI_MISO
  • Connect sensors CLK to module SPI_CLK
  • Connect magnetometer CS to module GPIO 2
  • Connect gyroscope CS to module GPIO 3

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Open SPI bus, set parameters
  • Configure GPIO 2 and GPIO 3 as output, set them high (idle)
  • Set registers to configure magnetometer
  • Read in a loop (10 iterations) the registers carrying the 3 axes values and show the gauss value for each of them. A metal object is put close to the sensor to change the read values.
  • Set registers to configure gyroscope
  • Read in a loop (10 iterations) the registers carrying the 3 axes values and show the degrees per second value for each of them. The board is rotated to change the read values.

Notes:

For LE910Cx (both Linux and ThreadX based devices), AT#SPIEN=1 command must be sent once before running the app


SW Timer (Software Timer)

The sample application shows how to use SW Timers M2MB API. Debug prints on MAIN UART

Features

  • How to open configure a SW timer
  • How to use the timer to manage recurring events

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create sw timer structure

  • Configure it with 4 seconds timeout, periodic timer (auto fires when expires)

  • Init the timer with the parameters

  • Start the timer

  • Wait 10 seconds

  • Stop the timer

timerCb

  • Print a message with inside the callback


TCP IP

Sample application showcasing TCP echo demo with M2MB API. Debug prints on MAIN UART

Features

  • How to check module registration and activate PDP context
  • How to open a TCP client socket
  • How to communicate over the socket

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a task to manage socket and start it

m2m_tcp_test.c

  • Initialize Network structure and check registration

  • Initialize PDP structure and start PDP context

  • Create socket and link it to the PDP context id

  • Connect to the server

  • Send data and receive response

  • Close socket

  • Disable PDP context


TCP non blocking example

Sample application that shows how to configure and connect a TCP-IP non blocking socket. Debug prints on MAIN UART

Features

  • How to check module registration and activate PDP context
  • How to open a TCP client non Blocking socket
  • How to communicate over the socket

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a task to manage socket and start it

m2m_tcp_test.c

  • Initialize Network structure and check registration

  • Initialize PDP structure and start PDP context

  • Create socket and link it to the PDP context id

  • Set the socket as non Blocking and connect to server. Uses m2mb_socket_bsd_select, m2mb_socket_bsd_fd_isset_func to check when socket is connected.

  • Send data and receive response

  • Close socket

  • Disable PDP context


TCP Socket status

Sample application showcasing how to check a TPC connected socket current status. Debug prints on MAIN UART

Features

  • How to check module registration and activate PDP context
  • How to open a TCP client socket
  • How to check if the TCP socket is still valid

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a task to manage socket and start it

m2m_tcp_test.c

  • Initialize Network structure and check registration

  • Initialize PDP structure and start PDP context

  • Create socket and link it to the PDP context id

  • Connect to the server

  • Check in a loop the current socket status using the adv_select function with a 2 seconds timeout

  • Close socket when the remote host closes it

  • Disable PDP context


TCP Server

Sample application showcasing TCP listening socket demo with M2MB API. Debug prints on MAIN UART

Features

  • How to check module registration and activate PDP context
  • How to open a TCP listening socket
  • How to manage external hosts connection and exchange data

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Print welcome message

  • Create a task to manage socket and start it

m2m_tcp_test.c

  • Initialize Network structure and check registration

  • Initialize PDP structure and start PDP context

  • Create socket and set it in non-blocking mode

  • Bind the socket to the listening port

  • Start listening for incoming connection

  • Check if a connection is incoming using m2mb_socket_bsd_select function

  • If a client connects, perform accept on the child socket

  • Send a "START" message to the client

  • Send some data

  • Wait for data from client and print it

  • Close the child socket

  • Start listening again, up to 3 times

  • Close listening socket

  • Disable PDP context

Debug Log

Data on a PuTTY terminal


TLS SSL Client

Sample application showcasing TLS/SSL with client certificates usage with M2MB API. Debug prints on MAIN UART

Features

  • How to check module registration and enable PDP context
  • How to open a SSL client socket
  • How to communicate over SSL socket

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX

  • Create a task to manage the connection and start it

ssl_test.c

  • Initialize Network structure and check registration

  • Initialize PDP structure and start PDP context

  • Create socket and link it to the PDP context id

  • Connect to the server over TCP socket

  • Initialize the TLS parameters (TLS1.2) andh auth mode (server+client auth in the example)

  • Create SSL context

  • Read certificates files and store them

  • Create secure socket and connect to the server using SSL

  • Send data and receive response

  • Close secure socket

  • Close socket

  • Delete SSL context

  • Disable PDP context

The application requires the certificates to be stored in /data/azc/mod/ssl_certs/ folder. It can be created with

AT#M2MMKDIR=/data/azc/mod/ssl_certs

Certificates can then be loaded with

AT#M2MWRITE="/data/azc/mod/ssl_certs/data/azc/modulesCA.crt",1740

and providing the file content in RAW mode (for example using the "Transfer Data" button in Telit AT Controller)

For client certificates (if required), the commands will be

AT#M2MWRITE="/data/azc/mod/ssl_certs/data/azc/modulesClient.crt",1651
AT#M2MWRITE="/data/azc/mod/ssl_certs/data/azc/modulesClient_pkcs1.key",1679

PLEASE NOTE: always verify the file sizes to be used in the commands above as they might change


Uart To Server

Sample application showcasing how to send data from main UART to a connected TCP server. Debug messages are printed on AUX UART port.

Features

  • How to open main UART to receive data
  • How to connect to a server
  • How to transmit received data from the UART to the server and viceversa

Application workflow

M2MB_main.c

  • Open UART for data and USB1 for debug
  • Init socket, activate PDP context and connect to server
  • Init UART, set its callback function, create tasks to handle input from UART and response from server (optional)
  • Send a confirmation on UART
  • Wait for data, when it is received, send it to the server
  • When a response is received, print it on UART.

Main UART:

Debug log on USB1:


UDP client

Sample application showcasing UDP echo demo with M2MB API. Debug prints on MAIN UART

Features

  • How to check module registration and activate PDP context
  • How to open a UDP client socket
  • How to communicate over the socket

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Print welcome message
  • Create a task and start it

m2m_udp_test.c

  • Initialize Network structure and check registration
  • Initialize PDP structure and start PDP context
  • Create socket and link it to the PDP context id
  • Send data and receive response
  • Close socket
  • Disable PDP context


UDP_Server example

Sample application that shows UDP listening socket demo with m2mb apis. Debug prints on MAIN UART

Features

  • How to configure an UDP socket into listen mode
  • How to receive data using m2mb_socket_bsd_select
  • How to read data received and send data to client

Application workflow

M2MB_main.c

  • Print welcome message
  • Init task apis and create M2M_msgUDPTask to handle UDP socket

m2mb_udp_test.c

M2M_msgUDPTask

  • Wait for module registration
  • Activate PDP context
  • Create UDP listen socket
  • Wait for incoming data from client using m2mb_socket_bsd_select
  • When there are data on socket, read them and send some data back to client


USB Cable Check

Sample application showing how to check if USB cable is plugged in or not. Debug prints on MAIN UART

Features

  • How to open an USB channel and configure it with a callback function
  • How to manage USB cable events in the callback function

Application workflow

M2MB_main.c

  • Open UART/UART_AUX for debug
  • open usb channel and set the callback
  • Print greeting message
  • Print current usb status

USB_Cb

  • if the event is a connection/disconnection, show the current status


Basic USB read/write example

Sample application that shows how to use the basic read/write USB apis. Synchronous or asynchronous mode is available setting SYNC to 1 or 0. Debug prints on MAIN UART

Features

  • Read and write on USB (synchoronous mode)
  • Read and write on USB (asynchronous mode)

Application workflow

M2MB_main.c

  • Open USB port (USB0)

  • Set rx and tx timeouts

  • SYNC

    • read until some data are availableon USB
    • as soon as some data are available on USB read them and write on USB data received
  • ASYNC

    • set the USB callback
    • write some data on USB and wait for data to be read
    • as soon as some data are available on USB M2MB_USB_RX_EVENT is generated and handled by callback. Data are read and printed on serial com port.


ZLIB example

Sample application showing how to compress/uncompress with ZLIB. Debug prints on MAIN UART

Features

  • How to compress a file
  • How to uncompress a file

In order to execute the entire test, copy test.gz file into your module running the following AT command:

AT#M2MWRITE="/data/azc/mod/test.gz",138
>>> here receive the prompt; then type or send the file, sized 138 bytes

Application workflow

M2MB_main.c

  • Open USB/UART/UART_AUX
  • Test the compression and decompression of a data string
  • Test the decompression of a .gz file (test.gz), expected to be in /data/azc/mod folder, into its content test.txt. The file must be uploaded by the user (see steps above).


Installing beta version libraries Plug-in

New beta plug-in installation

To install a new plug-in for a beta firmware into the IDE, first receive plug-in ".zip" packet, then unzip the file in a local folder and open the SDK IDE.

PLEASE DO NOT USE BETA PLUGINS FOR PRODUCTION DEPLOYMENTS, SOFTWARE IS PROVIDED AS IS AND CUSTOMER ACKNOWLEDGES THAT IT IS POSSIBLE THE DEVICE MAY MISFUNCTION. PLEASE REFER TO Contact Information, Support section

Click on "Help" tag and choose "Install New Software...". This window will appear:

Click on "Add..." button and then in the following window click on "Local..." to select the unzipped folder with the plug-in content.

Once selected the plug-in folder, the "Location:" form will present the selected path. Now in "Name:" write a name for the new libraries (for example 37.00.xx0_B037) and click on "OK" button.

The new packet is now ready to be installed: select it and click on "Next >" button until "Review Licenses" window will appear.

Accept the licenses when required and click on "Finish" button to complete the installation.

Change existing project libraries

To align an old project to the new libraries, right click on the project and choose "Properties".

Now select "AppZone" on the left side of the window, and on the right choose the packet with the same name as the firmware version to be used. Then click on "OK" (or "Apply") button.

Create a project with the new plug-in

To use the new libraries, create a new project: "File"-> "New" -> "Telit Project"

Select the new firmware version (37.00.xx0-B037) and create an empty project.