Skip to content
المشاريع

حول

Lightweight cellular modem host AT library

أدوات التطوير

كيف تُقاس هذه الأرقام

489 نجمة169 التفرعات +1 خلال 24 ساعة

ما يمكنك فعله

  • Written in C (C11), compatible with stdint.h data types
  • Supports SIM800/SIM900 (2G) and SIM7070G (NB-IoT LTE) modules
  • Provided examples for ARM Cortex-M or Win32 platforms
  • Allows different configurations to optimize user requirements

النمو المقاس للنجوم

خلال 24 ساعة
+١
خلال 7 أيام
+١
خلال 15 يومًا
+١
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

LwCELL — Lightweight cellular modem AT parser for embedded systems

Release License: MIT Documentation

LwCELL is a lightweight, platform independent library that adds cellular connectivity to any microcontroller by talking to a modem over UART using AT commands. It currently targets SIMCOM modules: SIM800/SIM900 (2G) and SIM7070G (NB-IoT LTE). Written in C11, it gives the host a clean API for SMS, voice calls, phonebook, USSD, TCP/UDP connections and MQTT. Its main targets are embedded devices like ARM Cortex-M, AVR and PIC, but it works under Windows, Linux and macOS too.

📖 Documentation · Changelog · Releases

Features

  • Written in C (C11), compatible with stdint.h data types
  • Supports SIM800/SIM900 (2G) and SIM7070G (NB-IoT LTE) modules
  • Platform independent and very easy to port
    • Provided examples for ARM Cortex-M or Win32 platforms
  • Allows different configurations to optimize user requirements
  • Supports operating-system implementations with advanced inter-thread communication
    • Currently only OS mode is supported
    • 2 different threads handling user data and received data
      • First (producer) thread (collects user commands from user threads and starts the command processing)
      • Second (process) thread reads the data from GSM device and does the job accordingly
  • Allows sequential API for connections in client mode
  • Full SMS API to send, read, delete and list messages
  • Voice call API to start, answer and hang up calls
  • Phonebook API to add, edit, delete, read, list and search entries
  • Supports USSD code execution
  • Includes several applications built on top of the library:
    • MQTT client for MQTT connection
  • User friendly MIT license

Quick start

#include <stdio.h>
#include "lwcell/lwcell.h"
#include "lwcell/lwcell_network_api.h"

/* Global event callback */
static lwcellr_t
prv_lwcell_evt(lwcell_evt_t* evt) {
    switch (lwcell_evt_get_type(evt)) {
        case LWCELL_EVT_SMS_RECV: printf("New SMS received\r\n"); break;
        default: break;
    }
    return lwcellOK;
}

/* Application thread */
void
app_thread(void const* arg) {
    (void)arg;

    /* Initialize library, blocking mode */
    lwcell_init(prv_lwcell_evt, 1);
    lwcell_sim_pin_enter("1234", NULL, NULL, 1); /* Only if the SIM card is PIN protected */

    /* Send SMS */
    lwcell_sms_enable(NULL, NULL, 1);
    lwcell_sms_send("+0123456789", "Hello from LwCELL", NULL, NULL, 1);

    /* Attach to the network for data connections */
    lwcell_network_set_credentials("internet", "", ""); /* Your operator's APN */
    if (lwcell_network_request_attach() == lwcellOK) {
        /* Use the netconn API or MQTT client */
    }
}

SMS and network functions require LWCELL_CFG_SMS, LWCELL_CFG_NETWORK and LWCELL_CFG_CONN to be enabled in the configuration. Complete examples for Win32 and STM32 are in examples, with shared application code in snippets.

Porting

LwCELL needs two platform-specific parts:

  • Low-level driver: sends AT commands to the modem and passes received data to the library, typically over UART with DMA
  • System functions: threads, mutexes, semaphores and message queues of your operating system

Ready-made implementations are in lwcell/src/system: low-level drivers for STM32, ESP32 and Win32, and system ports for CMSIS-OS, FreeRTOS, ThreadX and Win32. See the documentation for details.

Configuration

Enabled modules (SMS, calls, phonebook, network, netconn, MQTT, ...), buffer sizes and timeouts are configured in the lwcell_opts.h file. Copy lwcell/src/include/lwcell/lwcell_opts_template.h to your project, rename it to lwcell_opts.h, and override the defaults listed in lwcell_opt.h. See Getting started in the documentation for details.

Add to your project

CMake

set(LWCELL_OPTS_FILE ${CMAKE_CURRENT_LIST_DIR}/lwcell_opts.h) # Optional, default options are used otherwise
set(LWCELL_SYS_PORT "cmsis_os")                               # One of: cmsis_os, freeRTOS, threadx, win32
add_subdirectory(path/to/lwcell/lwcell)
target_link_libraries(${PROJECT_NAME} PRIVATE lwcell lwcell_api lwcell_apps)

lwcell_api adds the netconn and network API, and lwcell_apps adds the applications (MQTT client). Both can be left out if not needed. Add a low-level driver from lwcell/src/system/, or your own, to your project sources. Optional compiler options and definitions can be set with LWCELL_COMPILE_OPTIONS and LWCELL_COMPILE_DEFINITIONS, see lwcell/library.cmake.

Any other build system

  1. Copy the lwcell folder to your project
  2. Add lwcell/src/include and the system port folder lwcell/src/include/system/port/<port> to the include path
  3. Add the source files from lwcell/src/lwcell/ to the build, and optionally lwcell/src/api/ and lwcell/src/apps/
  4. Add a low-level driver and a system port from lwcell/src/system/, or write your own
  5. Create lwcell_opts.h in a folder on the include path (see Configuration)

Contribute

Fresh contributions are always welcome. Simple instructions to proceed:

  1. Fork Github repository
  2. Follow C style & coding rules and use clang-format to format the code
  3. Create a pull request to develop branch with new features or bug fixes

Alternatively you may:

  1. Report a bug
  2. Ask for a feature request

License

LwCELL is released under the MIT license.

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…