Programming Telit modems through an Electron app

June 11th 2019

We recently completed a project that challenged us to use AT commands and Electron in order to program a Telit modem. Telit modems have a default firmware, but our client wanted to be able to quickly program modems with their own firmware and configuration file. For this, we need to use AT commands – the commands used to control the modem. It’s a simple concept, but working with the modem and AT commands can be confusing. Here are some of the issues we ran into, and how we remedied them.

What are Telit and AT commands?

Telit is a brand of IOT modules, which includes the LE910-SV that we were tasked to work with. These modems respond to a set of commands called AT commands. Each command is prefixed with AT, short for ATtention. We also used the M2M set of commands in order to write the files and program the modems with user applications.


The AT commander package requires serialport 5.0.0. You’ll also need to do an electron-rebuild after each npm install, and build serialport from source. Serialport’s installation section has more information.

npm install [email protected] --build-from-source
npx electron-rebuild


Electron has two processes – the main process, and renderer process. The renderer process handles all front-end UI logic like responding to button clicks. The main process handles any lower-level system stuff you might need. A common Electron mistake is to put non-view logic in the renderer process – it is possible to do, but if your business logic has to connect with something outside of the app, it has go in the main process. Therefore, all AT commands have to be in the main process.

You’ll have to communicate between the two processes, so we use an electron tool called IPC (interprocess communication).

In renderer process (app.component.ts):

ipcRenderer.on(‘connect-to-modem', (event, args) => {
// Update your UI with anything returned from main process
ipcRenderer.send('connect-to-modem’, {});    // Send a message to the main process, perhaps originating from a button click

In main process (electron/main.ts):

ipcMain.on(‘connect-to-modem', (event, args) => {
// Call your AT command and other main process stuff here
event.sender.send(‘connect-to-modem', {});    // Send any information back to the renderer process

AT Commander package quirks

Commands will time out unless the expected response is exact, so pay attention to the regex. There are several newlines in the responses, and they should be taken into account. For example, a standard ‘OK’ response should be sought for by /(^(.+)rnrnOKrn)|OKrn/, which looks for any amount of rn before the OK.

Files need to be read in in the main process, so you can pass the path to your main process if you need the user to select their locations. After the file is created on the modem (see below), the file can be written to the modem via modem.addCommand(fileBuffer)

The AT command package has two functions to run commands – run and addCommand; run instantly starts the command regardless if there’s a command already running, so you should use addCommand to avoid race conflicts.

The AT Commander can return different states – make sure you know the difference between these! For example, you’ll get a rejected state when you try to run a command while another command is already running, but a failed state if the returned command value is not what it expected.

Most used commands

Telit has a decent example guide for installing binaries using AT commands and you should refer to that for the full instructions, but these are the commands we used most.

ATE0              // Perform this command first in order to disable the command echo, so we don’t have to always look for the command - note, you’ll need to expect the ATE0 in this response only, e.g. /^((ATE0rnrn)?)OKrn/
AT+M2M?           // Checks what run mode the modem is in
AT+M2M=0          // Sets the run mode to 0, which means it will reboot and not run any preinstalled user programs
AT#M2MCHDIR="..”        // Move to top level directory, config files should be installed here
AT#M2MDEL=“filename”    // Delete a file
AT#M2MWRITE=“filename”,size , /^(>>>)/    // Create the empty file of name and size on the modem, can write the file after we receive a >>>
AT#M2MCHDIR="MOD”       // Move to the MOD folder, where firmware binaries need to be created
AT#M2MRUN=2,"filename”  // Set the run permission of the firmware, and resets run permission of all other files in the MOD directory
AT+M2M=1          // Reboot the modem and tell it to start the user program upon reboot

Wrap up

After jumping the hurdle of learning how the modems work, communicating with Telit modems is definitely feasible. Be sure to read the documentation links we included above – knowing what to expect from the modem and your packages is half the battle. Happy coding!


is a software engineering agency. We build applications and teach businesses how to use new technologies like machine learning and virtual reality. We write about software, business, and business software culture.