Interacting with the Kit at CLI via tmo_shell
Introduction
This document guides the reader on how to interact with the IoT Developer Kit at command line.
Prerequisites
- The T-Mobile DevEdge IoT Developer Kit.
- A computer with Windows 10 or later installed
- Git installed on your computer
- Internet access
- Tera Term installed on your computer
For demonstration purposes we will be using Tera Term in the rest of this document. Windows 10 is the operating system that Tera Term is installed on. Using a different serial app, however, on a different OS is perfectly acceptable.
Interacting with the Kit at CLI via the tmo_shell
What is the tmo_shell?
The tmo_shell is T-Mobile's general-purpose interactive app for testing many features on the DevEdge IoT Developer Kit. It is an application based on the Zephyr RTOS. Note that the tmo_shell is already installed on the DevEdge IoT Developer Kit.
Where can I find the code for the tmo_shell?
You can find the code for the tmo_shell at https://github.com/tmobile/DevEdge-IoTDevKit-ZephyrSDK.
How do I connect to the tmo_shell?
On a computer with several USB-A ports, install a serial app (e.g. Tera Term on Windows, 'screen' or Picocom on Linux). You will need this app to communicate with the serial ports on the T-Mobile DevEdge IoT Developer Kit.
Connect your IoT Developer Kit to your computer like in the screenshot below.
- On your computer, open the Tera Term app. The Tera Term: New Connection window opens.
Select the "Serial" radio button then from the drop down select the port that your T-Mobile DevEdge IoT Developer Kit is connected to. Click OK.
- Under Setup > Serial port... the settings for the kit's port need to be assigned the following way or you will not be able to connect to the kit:
- Speed / Baud Rate: 9600
- Data: 8
- Parity: none
- Stop bits: 1
- Flow control: none
Click New setting if you had to change any of these values. Cancel if you did not. The Tera Term command line appears.
In the Tera Term command line console press Enter on your keyboard. The Zephyr uart command line appears.
-
Type
tmo
. This will display all of the commands available in the tmo_shell. Below is a list of things you may want to do at CLI.
What are some things I would want to do at tmo_shell CLI?
Connect to Wi-Fi
-
Enter
tmo ifaces
in Tera Term. Based on the Data Sheet, the murata.1sc is the LTE CAT-M1/NB1 cellular modem and the RS9116W is the Wi-Fi/BLE radio device. -
Scan for available networks by running
tmo wifi scan <iface_id>
. -
Connect to a network by running
tmo wifi connect <iface> "<ssid>" 0 "<psk>"
ortmo wifi connect <iface> "<ssid>"
if your network lacks a password. If the connection is successful you should receive a "Connected" response.
-
Check the status of the Wi-Fi connection by entering
tmo wifi status <iface>
.You can also see that you are connected to your chosen Wi-Fi by looking at your smartphone > DevEdge IoT companion app > Home > Connectivity section.
Testing TCP connect/send/recv/close
Create a TCP socket by calling
tmo tcp create <iface>
.For this to work, you must be connected to Wi-Fi. The error "Socket creation failed, errno = 0" indicates that you are not connected to Wi-Fi and, as a result, the TCP socket cannot be created.
-
If the socket is created properly a <socket_number> will appear. In the case of the screenshot below the socket number is 0.
-
To list all open sockets type
tmo sockets
. -
Connect the socket to a server by calling
tmo tcp connect <socket_number> <ip_addr> <port>
:You will need an echo server IP address in order to complete this part of the exercise.
The message "Connected socket 0" appears if the call was made successfully.
-
Send data by calling
tmo tcp send <socket_number> "<data>"
. When you hit Enter on your keyboard Tera Term will simple go back to the uart prompt. -
To see the data you just sent, call
tmo tcp recv <socket_number>
. -
Close the socket by calling
tmo tcp close <socket_number>
.
Testing UDP connect/send/recv/close
-
Create a UDP socket by calling
tmo udp create <iface>
.For this to work, you must be connected to Wi-Fi. The error "Socket creation failed, errno = 0" indicates that you are not connected to Wi-Fi and, as a result, the UDP socket cannot be created.
If the socket is created properly a <socket_number> will appear. In the case of the screenshot below the socket number is 0.
-
Connect the socket to a server by calling
tmo udp connect <socket_number> <ip_addr> <port>
.You will need an echo server IP address in order to complete this part of the exercise.
-
The message "Connected socket 0" appears if the call was made successfully.
Send data by calling
tmo udp send <socket_number> "<data>"
.Receive data by calling
tmo udp recv <socket_number>
.-
Close the socket by calling
tmo udp close <socket_number>
. - To check that the socket is closed type
tmo sockets
.
Testing UDP sendto/recvfrom
-
Create a UDP socket by calling
tmo udp create <iface>
.For this to work, you must be connected to Wi-Fi. The error "Socket creation failed, errno = 0" indicates that you are not connected to Wi-Fi and, as a result, the UDP socket cannot be created.
-
If the socket is created properly a <socket_number> will appear. In the case of the screenshot below the socket number is 0.
-
Send data to by calling
tmo udp sendto <socket_number> <server_ip> <server_port> "<data>"
.You will need an echo server IP address in order to complete this part of the exercise.
-
Receive data by calling
tmo udp recvfrom <socket_number>
. -
Close the socket by calling
tmo udp close <socket_number>
.
Testing SMS send message
Enter
modem list
.-
Enter
modem sms send <modem index> <phone number> "<message>"
.Remember to replace 5555555555 with your cell phone number. In addition, spaces are not allowed in the message. If there are, please use quotes (single or double) around the message.
Check you phone for a text message from your IoT Developer Kit.
Testing SMS receive message
Send an SMS from your phone back to the device then receive it on the device with this command.
-
Enter
modem sms recv 0 10
.
Testing DNS Resolution
To perform DNS resolve, use the syntax shown below.
For this to work, you must be connected to Wi-Fi. The error "zsock_getaddrinfo failed (-2)" indicates that you are not connected to Wi-Fi and, as a result, the DNS call will fail.
Enter
tmo ifaces
.Enter
tmo dns <iface> t-mobile.com
.-
The IoT Developer Kit returns address information, IP address and more.
Testing BLE SMP Pairing
Some things to note:
- For Bluetooth Low Energy (BLE) features you need a BLE monitoring app. T-Mobile recommends the LightBlue app.
- For Secure Manager Protocol (SMP) pairing, you may need to unpair the kit from the smartphone to test pairing again. This can be done in your smartphone's Bluetooth settings.
To enable SMP pairing enter tmo ble smp enable
. After SMP is enabled if you try and pair your DevEdge IoT companion app to your IoT Developer Kit a "Connected <bluetooth_address> (random)" appears. A passkey appears as well. Enter this passkey in your smartphone's DevEdge IoT companion app.
The result on your smartphone looks like the below. Again, enter this passkey in your companion app.
To disable SMP pairing enter tmo ble smp disable
.
To choose the pairing verification methodology, simply enable the relevant IO capabilities using the tmo ble smp toggle
and tmo ble smp callbacks
commands. For example, to test key entry on a device enable only keyboard enter the following at CLI:
uart:~$ tmo ble smp enable
SMP Enabled.
uart:~$ tmo ble smp callbacks
CONFIRM: disabled
DISPLAY: enabled
KEYBOARD: disabled
uart:~$ tmo ble smp toggle display
Display is now disabled
uart:~$ tmo ble smp toggle keyboard
Keyboard is now enabled
uart:~$ tmo ble smp callbacks
CONFIRM: disabled
DISPLAY: disabled
KEYBOARD: enabled
uart:~$
Find the IMEI
Enter
tmo ifaces
. Based on the Data Sheet, the murata.1sc is the LTE CAT-M1/NB1 cellular modem and the RS9116W is the Wi-Fi/BLE radio device.Enter
tmo modem
.Enter
tmo modem 1 imei
.-
The IMEI for your IoT Developer Kit appears.
View JSON Data
-
Enter
tmo json payload
then press Enter on your keyboard.
Turn on the Green LED
This command is utilizing the Zephyr shell instead of the tmo_shell. Please see the document API Sample Requests to learn more.
-
Enter
led on pwmleds 2
. -
The green light on the IoT Developer Kit turns on.
Find the tmo_shell / SDK Version Number
-
Type
tmo version
then press Enter on your keyboard.
Further Resources
Beyond the list above, there are other commands available at tmo_shell. Take a look at the table below.
tmo_shell Commands
Commands |
Command Description |
Subcommands |
Subcommand Descriptions |
Required Arguments |
Example Syntax |
---|---|---|---|---|---|
battery |
Battery and charger status. |
|
| Not applicable. |
|
ble | Various Bluetooth Low Energy (BLE) commands. |
|
|
| |
buzzer | Buzzer test. |
|
|
|
|
certs | CA cert commands. Load, list, or dump certificates of authority on to your kit. |
|
|
| |
dfu | Device firmware (FW) updates. |
|
| <iface> |
|
dns | Performs a DNS lookup. | None | Not applicable | <devid> <hostname> | tmo dns 2 t-mobile.com |
file | File commands. |
|
|
| |
gnssversion | Displays the GNSS / GPS device's firmware version number. | None | Not applicable | Not applicable | tmo gnssversion |
http | Get http URL. | None | Not applicable | <devid> <URL> | tmo http 2 http://www.t-mobile.com |
hwid | Read the HWID divider voltage. | None | Not applicable | tmo hwid | |
ifaces | List all the interfaces available on the kit with their ID number. | None | Not applicable | Not applicable. | tmo ifaces |
json | JSON data options. This set of commands allows the user to send JSON data to a particular base URL and path (endpoint). It also allows for the printing of the JSON payload at CLI. |
|
| <iface> |
|
kermit | Embedded kermit. |
|
|
| |
location | Get latitude, longitude, Sats, HDOP, TTFF, and 1PPS data. | None | Not applicable. | Not applicable. | tmo location |
modem | Modem status and control. | None | Not applicable | <iface> <cmd_str>
| tmo modem 1 imei |
ping | Test and verify if a particular destination IP address exists. |
|
| <iface> | tmo ping [-c count] [-s packetsize] [-t timeout] 2 t-mobile.com |
pm | Device power management controls. |
|
| Use the command
|
|
| Synchronize your kit's system time with a server of your choice. | None | Not applicable | Not applicable | tmo sntp <iface> <server> |
sockets | Lists all the open sockets available on the kit. | None | Not applicable | Not applicable | tmo sockets |
sys_pm | System power management controls. |
|
| Not applicable |
|
tcp | Send/receive TCP packets. |
|
|
| tmo tcp create <iface_id> |
test | Run automated tests. |
|
| Not applicable. | tmo test mfg |
udp | Send/receive UDP packets. |
|
|
| tmo udp connect <socket_number> <ip_addr> <port> |
version | Print the version details for the tmo_shell. Use this command to understand what version of the tmo_shell your IoT Developer Kit is on. | None | Not applicable. | Not applicable. | tmo version |
wifi | Wi-Fi controls. Connect to Wi-Fi using these commands. |
|
|
|
|
tmo_shell Glossary
Term |
Definition |
---|---|
FTDI | An acronym for Future Technology Devices International. |
HDOP | An acronym for the phrase "Horizontal Dilution Of Precision". Please read this Wikipedia article to learn more about this GNSS data value. |
<iface> | Interface ID. |
<payload> | The data to be sent. |
<psk> | Password for your SSID or Wi-Fi network. |
<port> | Port number. |
<socket> | Socket ID. |
<SSID> | A wireless local area network identifier. |
TTFF | An acronym for the phrase "Time To First Fix". Please read this Wikipedia article to learn more about this GNSS data value. |
Troubleshooting
- Issue 1 - I cannot connect to my IoT Developer Kit via serial app? What am I doing wrong?
-
Solution 1 - Please check to ensure that the J-Link USB-C Debug port is plugged into your computer like in the picture below. If it is plugged in any other way you will not be able to connect your serial port to your kit.
FAQ
- Question 1 - What API calls can I make to the sensors via CLI?
- Answer 1 - Please read the API Sample Requests document to learn more.
- Question 2 - What format is the resulting sensor data in?
- Answer 2 - JSON
- Question 3 - Why am I seeing a "Disconnected from 01:23:45:67:89:01 (random) (reason 0x13)" message in Tera Term / my serial app? What is the caused from?
-
Answer 3 - When you disconnect the Bluetooth DevEdge IoT mobile app from the DevEdge IoT Developer Kit, the above message is what appears in your serial app.
- In your mobile app:
In your serial app:
- In your mobile app:
In your serial app:
- Question 4 - Why am I seeing a "Connected 01:23:45:67:89:01 (random)" message in Tera Term / my serial app?
- Answer 4 - In the mobile app, when you tap the T-Mobile DevEdge device, the bluetooth connection creates this message.
- In your mobile app:
In your serial app:
- In your mobile app:
In your serial app:
- Question 5 - When using the command
tmo wifi connect 2 "<SSID>" 0 "<psk>"
I get the following error: "Connection request failed (8)". What does this mean? - Answer 5 - Your password is not being accepting by the Wi-Fi connection. Re-check your password and try again.