Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
sdk:sdk [2017/06/14 12:33]
juraschek [Helpful Functions]
sdk:sdk [2024/02/22 14:44] (current)
juraschek ↷ Links adapted because of a move operation
Line 5: Line 5:
   - A NetModule-specific Application Programming Interface (API), which ships with a comprehensive set of functions for accessing hardware interfaces (e.g. digital IO ports, GPS, external storage media, serial ports) but also for retrieving system status parameters, sending E-Mail or SMS messages or simply just to configure the router. ​   - A NetModule-specific Application Programming Interface (API), which ships with a comprehensive set of functions for accessing hardware interfaces (e.g. digital IO ports, GPS, external storage media, serial ports) but also for retrieving system status parameters, sending E-Mail or SMS messages or simply just to configure the router. ​
  
-Anyone, reasonably experienced in the C language, will find an environment that is easy to dig in. However, feel free to contact us via [[router@support.netmodule.com]] and we will happily support you in finding a programming solution to your specific problem.+Anyone, reasonably experienced in the C language, will find an environment that is easy to dig in. However, feel free to contact us via [[support@netmodule.com]] and we will happily support you in finding a programming solution to your specific problem.
 ===== The Language ===== ===== The Language =====
 The arena scripting language offers a broad range of POSIX functions (like printf or open) and provides, together with tailor-made API functions, a simple platform for implementing any sort of applications to interconnect your favourite device or service with the router. The arena scripting language offers a broad range of POSIX functions (like printf or open) and provides, together with tailor-made API functions, a simple platform for implementing any sort of applications to interconnect your favourite device or service with the router.
Line 14: Line 14:
 * otherwise we 'd have to send a short message . * otherwise we 'd have to send a short message .
 */ */
-for ( attempts = 0; attempts < 3; attempts ++) { +for ( attempts=0; attempts<​3;​ attempts ++) { 
-  if ( nb_serial_read (" serial0 ") == " Knock Knock !") { +  if ( nb_serial_read ("​serial0"​) == "Knock Knock !") { 
-    nb_serial_write (" serial0 ", "Who 's there ?"); +    nb_serial_write ("​serial0",​ "Who 's there ?"); 
-    if ( nb_serial_read (" serial0 ") == " Santa ") {+    if ( nb_serial_read ("​serial0"​) == " Santa ") {
       printf (" Hurray !\n");       printf (" Hurray !\n");
-      nb_dio_set (" out1 ", 1);+      nb_dio_set ("​out1",​ 1);
     }     }
   }   }
 } }
-nb_sms_send (" +123456789 ", "No presents this year :(")+nb_sms_send ("​+123456789",​ "No presents this year :(")
 </​code>​ </​code>​
-A set of example scripts can be downloaded directly from the router, you can find a list of them in the appendix. The [[ftp://​share.netmodule.com/router/​public/​system-software/​latest/NB_SDK_Arena_Manual.pdf|SDK language manual]] gives a detailed introduction of the language, including a description+A set of example scripts can be downloaded directly from the router, you can find a list of them in the appendix. The [[https://​share.netmodule.com/​public/​system-software/​4.8/4.8.0.102/​NB_SDK_Arena_Manual_4.8.0.102.pdf|SDK language manual]] gives a detailed introduction of the language, including a description
 of all available functions. of all available functions.
  
Line 55: Line 55:
   - Encode functions (coming soon)   - Encode functions (coming soon)
   - Other system-related functions   - Other system-related functions
-The [[ftp://​share.netmodule.com/router/​public/​system-software/​latest/NB_SDK_API_Manual.pdf|SDK API manual]] provides an overview but also explains all functions in detail.+The [[https://​share.netmodule.com/​public/​system-software/​4.8/4.8.0.102/​NB_SDK_API_Manual_4.8.0.102.pdf|SDK API manual]] provides an overview but also explains all functions in detail.
  
 Please note that some functions require the corresponding services (e.g. E-Mail, SMS) to be properly configured prior to utilizing them in the SDK. Let us now pay some attention to the very powerful API function ''​nb_status''​. It can be used to query the router’s status values in the same manner as they can be shown with the CLI. It returns a structure of variables for a specific section (a list of available sections can be obtained by running ''​cli status -h''​). Please note that some functions require the corresponding services (e.g. E-Mail, SMS) to be properly configured prior to utilizing them in the SDK. Let us now pay some attention to the very powerful API function ''​nb_status''​. It can be used to query the router’s status values in the same manner as they can be shown with the CLI. It returns a structure of variables for a specific section (a list of available sections can be obtained by running ''​cli status -h''​).
Line 104: Line 104:
 The SDK host (sdkhost) corresponds to the daemon managing the scripts and their operations and thus avoiding any harm to the system. In terms of resources, it will limit CPU and memory for running scripts and also provide a pre-defined portion of the available flash storage. You may, however, extend it by external USB storage or (depending on your model) SD cards. Files written to /tmp will be hold in memory and will be cleared upon a restart of the script. As your scripts operate in the sandbox, you will have no access to tools on the system (such as ''​ifconfig''​). The SDK host (sdkhost) corresponds to the daemon managing the scripts and their operations and thus avoiding any harm to the system. In terms of resources, it will limit CPU and memory for running scripts and also provide a pre-defined portion of the available flash storage. You may, however, extend it by external USB storage or (depending on your model) SD cards. Files written to /tmp will be hold in memory and will be cleared upon a restart of the script. As your scripts operate in the sandbox, you will have no access to tools on the system (such as ''​ifconfig''​).
  
-===== Testing =====+===== Simple How-To & Testing =====
   * [[sdk:​Testing the SMS send script]]   * [[sdk:​Testing the SMS send script]]
  
Line 113: Line 113:
   * [[sdk:​customized-web-gui-extension-display-and-change-custom-config-paramters|Custom Configuration Parameters]]   * [[sdk:​customized-web-gui-extension-display-and-change-custom-config-paramters|Custom Configuration Parameters]]
   * [[sdk:​customized-web-gui-extension-display-and-change-custom-config-paramters|Web GUI extension]]   * [[sdk:​customized-web-gui-extension-display-and-change-custom-config-paramters|Web GUI extension]]
 +  * [[sdk:​custom-wegpage-for-digital-output-pulse|Webpage Extention to send a Pulse on the Digital Output]]
  
 ==== Configurations ==== ==== Configurations ====
   * [[sdk:​set-default-route-based-on-current-ssid|Set fake default route dynamically based on SSID]]   * [[sdk:​set-default-route-based-on-current-ssid|Set fake default route dynamically based on SSID]]
   * [[sdk:​softwareupdate-on-change| Start softwareupdate if newer version is available]]   * [[sdk:​softwareupdate-on-change| Start softwareupdate if newer version is available]]
 +  * [[sdk:​remote-configdownload | Request a unique remote config-file from a fileserver and delete it afterwards]]
 ==== Status Parameters ==== ==== Status Parameters ====
   * [[sdk::​connection-statistics|Connection Statistics]]   * [[sdk::​connection-statistics|Connection Statistics]]
Line 128: Line 130:
   * [[sdk:​alarm-via-voice| Create a Phonecall Alarm]]   * [[sdk:​alarm-via-voice| Create a Phonecall Alarm]]
   * [[sdk:​log-to-syslog| Log Status Values to Syslog]]   * [[sdk:​log-to-syslog| Log Status Values to Syslog]]
-   +  * [[sdk:​wwan_switcher|Change WWAN Hotlink according to the Service Type]] 
 +==== GPS ==== 
 +  * [[sdk:​gps-udp-broadcast|Broadcast selected GPS NMEA data to different UDP ports]] 
 +  * [[sdk:​gps-udp-client-GNSStoGPS|Send GNSS data to a remote UDP port in $GP instead of $GN format ]] 
 ==== Serial ==== ==== Serial ====
   * [[sdk:​serial-point-to-multipoint|Serial Point to Multipoint]]   * [[sdk:​serial-point-to-multipoint|Serial Point to Multipoint]]
-  * [[sdk::​gps2serial|Write the GPS NMEA Frames to the Serial Interface]]+  * [[sdk::​gps2serial|Write the GNSS NMEA Frames to the Serial Interface]] 
 +  * [[sdk::​gps2serial-gnsstogps|Write the GNSS NMEA Frames to the Serial Interface converted to GPS]] 
 +  * [[sdk::​serialDatalogger|Read data from the serial port and write it to files in the flash]] 
 +  * [[sdk::​hex2serial|Write non ASCII String to the Serial Port]]
 ==== HTTP ==== ==== HTTP ====
   * [[sdk::​ftp2sms|Forward File Content of Files on FTP Server via SMS]]   * [[sdk::​ftp2sms|Forward File Content of Files on FTP Server via SMS]]
Line 139: Line 148:
   * [[sdk::​dio2modbusTCP|Access to the digital I/Os via Modbus TCP]]   * [[sdk::​dio2modbusTCP|Access to the digital I/Os via Modbus TCP]]
   * [[sdk::​ReadInputRegister-ModbusTCP-TempAlam|Read out a Modbus TCP Temperatur Sensor and send an alarm Email]]   * [[sdk::​ReadInputRegister-ModbusTCP-TempAlam|Read out a Modbus TCP Temperatur Sensor and send an alarm Email]]
 +  * [[sdk::​ReadModbus-Janitza-UMG511|Read out a Janitza UMG511 via Modbus TCP]]
 +==== MQTT ====
 +  * [[sdk::​mqtt_simple_status|Send Router Status Informations to an MQTT Broker]]
 +  * [[sdk::​mqtt_advanced_status|Send Router Status Informations to an MQTT Broker - Advanced Version]]
 +  * [[sdk::​mqtt_dio| Publish changes of the Digitial In or Out Interfaces via MQTT]]
 +==== Web Services ====
 +  * [[sdk::​webservices_get|HTTP GET pass URL parameters/​query strings]]
 +  * [[sdk::​webservices_post|HTTP POST pass URL parameters/​query strings]]
 +  * [[sdk::​webservices_send_postion|send actual GNSS location via URL]]
 +==== Wifi / WLAN ====
 +  * [[sdk::​wifimodechanger|Change Wifi Mode based on SSID]]
 +  * [[sdk::​wifiprobingclients|Show probing WiFi clients]]
 ==== Various ==== ==== Various ====
   * [[sdk:​telnet-run-a-command-using-telnet|Run a command using Telnet]]   * [[sdk:​telnet-run-a-command-using-telnet|Run a command using Telnet]]
   * [[sdk::​tcp2sms| Sending SMS via TCP]]   * [[sdk::​tcp2sms| Sending SMS via TCP]]
-  * [[sdk::​opcuaExample| Publish OPC-UA datas to the Web as JSON-Object also monitoring values]] +  * [[internal:opcuaexample| Publish OPC-UA datas to the Web as JSON-Object also monitoring values]] 
-   +   ​
- +
- +
-   +
-   +
-   +
- +
- +
- +
-  ​+
  
  
Line 162: Line 174:
     * [[sdk:​ibis2ascii|Convert IBIS Telegrams to valid ASCII Strings (Umlaute)]]     * [[sdk:​ibis2ascii|Convert IBIS Telegrams to valid ASCII Strings (Umlaute)]]
     * [[sdk:​castInt2float|Cast two Modbus Register on to one float variable]]     * [[sdk:​castInt2float|Cast two Modbus Register on to one float variable]]
 +    * [[sdk:​block-check-calculator|Calculate block check character]]
  
  
Line 178: Line 191:
 |[[sdk:​scripts:​gps-udp-client-compat|gps-udp-client-compat.txt]]| This script sends the local GPS NMEA stream (incl. serial/​checksum) to a remote UDP server.| |[[sdk:​scripts:​gps-udp-client-compat|gps-udp-client-compat.txt]]| This script sends the local GPS NMEA stream (incl. serial/​checksum) to a remote UDP server.|
 |[[sdk:​scripts:​gps-udp-client|gps-udp-client.txt]]| This script sends the local GPS NMEA stream to a remote UDP server.| |[[sdk:​scripts:​gps-udp-client|gps-udp-client.txt]]| This script sends the local GPS NMEA stream to a remote UDP server.|
 +|[[sdk:​scripts:​gps2serial-gnsstogps|gps2serial-gnsstogps.txt]]| This script sends the local GPS NMEA stream to the internal serial interface. t checks for the correct CR/LF end of line characters and convert messages $GN to $GP.|
 |[[sdk:​scripts:​gps-upd-client-compat|gps-upd-client-compat.txt]]| This script sends the local GPS NMEA stream to a remote UDP server (incl. device identity).| |[[sdk:​scripts:​gps-upd-client-compat|gps-upd-client-compat.txt]]| This script sends the local GPS NMEA stream to a remote UDP server (incl. device identity).|
 |[[sdk:​scripts:​led|led.txt]]| This script can be used to set a LED| |[[sdk:​scripts:​led|led.txt]]| This script can be used to set a LED|
Line 224: Line 238:
 |[[sdk:​scripts:​webpage|webpage.txt]]| This script will generate a page which can be viewed in the Web Manager| |[[sdk:​scripts:​webpage|webpage.txt]]| This script will generate a page which can be viewed in the Web Manager|
 |[[sdk:​scripts:​write-config|write-config.txt]]| This script can be used to set a configuration parameter.| |[[sdk:​scripts:​write-config|write-config.txt]]| This script can be used to set a configuration parameter.|
 +
 +
 +===== Access the Filesystem =====
 +
 +You can acces the SDK Filesystem externaly via SCP:
 +
 +With Windows you can use the opensource software [[https://​winscp.net/​eng/​download.php|WinSCP]]
 +
 +Connect with the Protocoal SPC, User "​root"​ and your admin password:
 +
 +{{ :​sdk:​screenshot_-_08222017_-_11_04_08_am.png?​nolink | WinSCP Configuration}}
 +
 +Please then go to the folder ​
 +
 +<​code>​
 +/​home/​sdk/​sandbox/​
 +</​code>​
 +
 +Where you find the Filesystem which is usable from the SDK
 +
 +
 +{{ :​sdk:​screenshot_-_08222017_-_11_03_05_am.png?​nolink | WinSCP Remote SDK Folder}}
 +