--- title: Capability Query --- # Capability Query This example shows how to query modem capabilities at compile time using capability detection traits. This is particularly useful when working with multiple modem types in the same codebase. ## Benefits - Type-safe capability detection - Works correctly with multiple modem types - Compile-time evaluation (C++11 compatible) - No runtime overhead ## Available Capability Detection Traits - `TinyGsmCapabilities::has_ssl` - SSL/TLS secure connections - `TinyGsmCapabilities::can_specify_certs` - Certificate specification for SSL - `TinyGsmCapabilities::can_load_certs` - Certificate loading for SSL - `TinyGsmCapabilities::has_gps` - GPS/GNSS positioning - `TinyGsmCapabilities::has_gprs` - GPRS/cellular data - `TinyGsmCapabilities::has_wifi` - WiFi connectivity - `TinyGsmCapabilities::has_sms` - SMS messaging - `TinyGsmCapabilities::has_calling` - Voice calls - `TinyGsmCapabilities::has_battery` - Battery status reporting - `TinyGsmCapabilities::has_temperature` - Temperature sensor - `TinyGsmCapabilities::has_ntp` - Network Time Protocol - `TinyGsmCapabilities::has_time` - Clock/time functions - `TinyGsmCapabilities::has_gsm_location` - GSM-based location - `TinyGsmCapabilities::has_bluetooth` - Bluetooth connectivity - `TinyGsmCapabilities::has_tcp` - TCP socket connections --- ## The Complete Code ```cpp /** ============================================================================ * @example{lineno} CapabilityQuery.ino * * @brief Demonstrates compile-time modem capability detection. * * This example shows how to query modem capabilities at compile time using * capability detection traits. This is particularly useful when working with * multiple modem types in the same codebase. * * @author Sara Damiano * @license LGPL-3.0 * @date 2026 * ========================================================================== */ // Select your modem: // #define TINY_GSM_MODEM_SIM800 // #define TINY_GSM_MODEM_SIM808 // #define TINY_GSM_MODEM_SIM868 // #define TINY_GSM_MODEM_SIM900 // #define TINY_GSM_MODEM_SIM7000 // #define TINY_GSM_MODEM_SIM7000SSL // #define TINY_GSM_MODEM_SIM7080 // #define TINY_GSM_MODEM_SIM5360 // #define TINY_GSM_MODEM_SIM7600 // #define TINY_GSM_MODEM_A7672X // #define TINY_GSM_MODEM_UBLOX // #define TINY_GSM_MODEM_SARAR4 // #define TINY_GSM_MODEM_SARAR5 // #define TINY_GSM_MODEM_M95 // #define TINY_GSM_MODEM_BG95 // #define TINY_GSM_MODEM_BG96 // #define TINY_GSM_MODEM_A6 // #define TINY_GSM_MODEM_A7 // #define TINY_GSM_MODEM_M590 // #define TINY_GSM_MODEM_MC60 // #define TINY_GSM_MODEM_MC60E // #define TINY_GSM_MODEM_ESP32 // #define TINY_GSM_MODEM_ESP8266 // #define TINY_GSM_MODEM_ESP8266_NONOS // #define TINY_GSM_MODEM_XBEE // #define TINY_GSM_MODEM_SEQUANS_MONARCH // Set serial for debug console (to the Serial Monitor) #define SerialMon Serial // Set serial for AT commands (to the module) // Use Hardware Serial on Mega, Leonardo, Micro #if !defined(__AVR_ATmega328P__) && !defined(SerialAT) #define SerialAT Serial1 // or Software Serial on Uno, Nano #elif !defined(SerialAT) #include SoftwareSerial SerialAT(2, 3); // RX, TX #endif #include #include #if (defined(ARDUINO_NRF52840_FEATHER)) && !defined(ADAFRUIT_TINYUSB_H_) #include // for Serial #endif // Create the modem object TinyGsm modem(SerialAT); void setup() { SerialMon.begin(115200); delay(10); SerialMon.println(F("\n\n===========================================")); SerialMon.println(F("TinyGSM Capability Query Example")); SerialMon.println(F("===========================================\n")); // Print the modem type SerialMon.print(F("Modem: ")); SerialMon.print(modem.getConfiguredModem()); SerialMon.println('\n'); // Query capabilities using compile-time traits // Note: These traits are evaluated at compile time, even with C++11 SerialMon.println(F("Compile-time capability detection:")); SerialMon.println(F("----------------------------------")); // SSL/TLS capabilities if (TinyGsmCapabilities::has_ssl::value) { SerialMon.println(F("✓ SSL/TLS support: YES")); if (TinyGsmCapabilities::can_specify_certs::value) { SerialMon.println(F(" ✓ Can specify certificates")); } if (TinyGsmCapabilities::can_load_certs::value) { SerialMon.println(F(" ✓ Can load certificates")); } } else { SerialMon.println(F("✗ SSL/TLS support: NO")); } // GPS capability if (TinyGsmCapabilities::has_gps::value) { SerialMon.println(F("✓ GPS/GNSS support: YES")); } else { SerialMon.println(F("✗ GPS/GNSS support: NO")); } // Cellular data capability if (TinyGsmCapabilities::has_gprs::value) { SerialMon.println(F("✓ GPRS/Cellular data: YES")); } else { SerialMon.println(F("✗ GPRS/Cellular data: NO")); } // WiFi capability if (TinyGsmCapabilities::has_wifi::value) { SerialMon.println(F("✓ WiFi support: YES")); } else { SerialMon.println(F("✗ WiFi support: NO")); } // SMS capability if (TinyGsmCapabilities::has_sms::value) { SerialMon.println(F("✓ SMS messaging: YES")); } else { SerialMon.println(F("✗ SMS messaging: NO")); } // Voice calling capability if (TinyGsmCapabilities::has_calling::value) { SerialMon.println(F("✓ Voice calling: YES")); } else { SerialMon.println(F("✗ Voice calling: NO")); } // Battery status capability if (TinyGsmCapabilities::has_battery::value) { SerialMon.println(F("✓ Battery status: YES")); } else { SerialMon.println(F("✗ Battery status: NO")); } // Temperature sensor capability if (TinyGsmCapabilities::has_temperature::value) { SerialMon.println(F("✓ Temperature sensor: YES")); } else { SerialMon.println(F("✗ Temperature sensor: NO")); } // Network Time Protocol capability if (TinyGsmCapabilities::has_ntp::value) { SerialMon.println(F("✓ NTP support: YES")); } else { SerialMon.println(F("✗ NTP support: NO")); } // Time/clock functions capability if (TinyGsmCapabilities::has_time::value) { SerialMon.println(F("✓ Time/clock functions: YES")); } else { SerialMon.println(F("✗ Time/clock functions: NO")); } // GSM-based location capability if (TinyGsmCapabilities::has_gsm_location::value) { SerialMon.println(F("✓ GSM location: YES")); } else { SerialMon.println(F("✗ GSM location: NO")); } // Bluetooth capability if (TinyGsmCapabilities::has_bluetooth::value) { SerialMon.println(F("✓ Bluetooth support: YES")); } else { SerialMon.println(F("✗ Bluetooth support: NO")); } // TCP sockets capability (should always be true) if (TinyGsmCapabilities::has_tcp::value) { SerialMon.println(F("✓ TCP sockets: YES")); } else { SerialMon.println(F("✗ TCP sockets: NO")); } SerialMon.println(F("\n===========================================\n")); } void loop() { // Nothing to do here } ``` ------------------------------- Generated by [Doxygen](https://www.doxygen.nl) and [m.css](https://mcss.mosra.cz/) with templates from [doxybook2](https://github.com/matusnovak/doxybook2) Updated on 2026-09-11