The initial release of firmware for the System On a Module (SOM) lacked support for the BOOT button, Low Power Mode (LPM), or the second UART on the SOM. Now, there is a new/second release of firmware for the M18Qx module that supports these functions. To obtain this latest firmware, you must contact your Avnet Account Manager or FAE ( or make a post to the Avnet CloudConnectKits forum) and request a copy of the firmware and tools necessary for the firmware upgrade. Once this upgrade is performed the 2nd release of example software demonstrates its use. This BLOG discusses the implementation of these new features and the hardware modifications that are necessary.
Boot Button Operation
Now that the BOOT button is enabled, adding support for it involves creating a boot button object and defining press/release handlers. The Boot button is connected to GPIO 1 on the SOM and is active when in the LOW state. In the example software, the button press/release is captured, the status LED color is managed, and the state of the LPM (it simply toggles between on and off) is managed:
Button boot_button(GPIO_PIN_1, BUTTON_ACTIVE_LOW, bb_release); //handle the boot button void bb_release( int dur ) { status_led.action(Led::UNLOCK); status_led.action(current_action, current_color); if( dur < 1 ) return; switch (lpm_enabled) { case NO_LPM: lpm_enabled = ENTER_LPM; break; case IN_LPM: lpm_enabled = EXIT_LPM; break; default: break; } } void bb_press( void ) { current_color = status_led.color(Led::CURRENT); status_led.action(Led::LED_ON,Led::WHITE); current_action= status_led.action(Led::LOCK); }
All the button handling is contained within azIoTClient.cpp
UART2 Operation
There have been several requests for example software to support UART2. To do this a MikroE Click board, the USB UART clickUSB UART click was used. This board mounts on theIoT Breakout BoardIoT Breakout Board with the TX/RX connections jumped to the SOM TX/RX connections (below). If you want to mount the UART Click in socket #2, you would jump to the TX2/RX2 connections. While the MikroE Click board was used in this example software, the TX/RX signals on the SOM header (J9) are level-shifted to 3.3V so many different adapters could be connected.
With the TX/RX jumpers in place, the example software communicates using UART2 to an externally connected device. Connecting minicom (or another terminal program) to the Click USB, you can then enter the command 'lpm on' to cause the SOM to enter LPM (similar to if you had pressed the BOOT button), enter 'lpm off' to exit LPM, and enter 'exit' to terminate the example program. The software needed to implement UART operation is standard Linux:
uart2_fd = open("/dev/ttyHSL0", O_RDWR | O_NOCTTY | O_NDELAY); if (uart2_fd == -1) { printf("Unable to open UART2!"); exit(EXIT_FAILURE); } else { fcntl(uart2_fd, F_SETFL, FNDELAY); tcgetattr(uart2_fd, &options); cfsetspeed(&options, B115200); tcsetattr(uart2_fd, TCSANOW, &options); int n = write(uart2_fd, "Using UART2!\n",13); if (n < 0) { printf("Write to UART2 failed!"); exit(EXIT_FAILURE); } }
Reading is similar:
int n = read(uart2_fd, buffer, sizeof(buffer)); if( n>0 ){ buffer[n] = '\0'; sprintf(buff2,"Read (%d bytes): ",n-1); write(uart2_fd, buff2,strlen(buff2)); sprintf(buff2,"%s\n",buffer); write(uart2_fd, buff2,strlen(buff2)); if( strstr(buffer,"lpm") ) { if( strstr(buffer, "on") ) lpm_enabled = ENTER_LPM; if( strstr(buffer, "off") ) lpm_enabled = EXIT_LPM; } if( strstr(buffer, "exit") ) done = true; }
In the example program, the same data that is sent to the monitor is sent to UART2 as if you had enabled the verbose flag during program startup.
Low Power Mode
A new JSON command has been added to the MAL manager and with a hardware modification, it is now possible to enable LPM on the SOM. The hardware modification is necessary to allow the WNC module to enter LPM because without it, the WNC module believes a USB device is connected and low power mode is disabled. This modification is as shown below:
After this hardware modification and implementation of the new Low Power MAL command, the SOM will drop to ~16mA when in low power mode.
In the example software, operation of LPM is controlled by either pressing the BOOT button or by issuing the 'lpm on/off' command from the second UART terminal session. When LPM is enabled, no communications with Azure takes place, the cellular module is powered down, and the status LED blinks RED at a 2 second interval. While in sleep mode, the duration of sleep is displayed on the monitor:
Enter Low Power Mode. Low Power Mode active, Sleeping ( 14 seconds)
When in LPM, if the BOOT button is pressed again (or the lpm off command entered), the cellular module is restarted, the Azure connection is re-established, and messages are again sent:
Exit Low Power Mode, restart Cellular Connection (36) (0004)Send IoTHubClient Message@19:12:17 - OK
The overall operation of the software in release #2 is the same as it was in release #1, except for the addition of these three new functions.
To obtain the example program source you, clone it from github: git clone --recurse https://github.com/Avnet/M18QxAzureIoT
then following the instructions for building which can be found starting at: Using The Avnet LTE IoT Starter Kit with Microsoft Azure
Note: Some additional features available in the latest release of Firmware include Geo-Fencing and RNDIS Ethernet over USB. Details of these features are available in the latest documents/release-notes but they are not covered in this BLOG.