A Telegram BOT for this awesome all-in-one board.

Dependencies:   BSP_B-L475E-IOT01 mbed es_wifi jsmn

Telegram Bot for DISCO_L475VG_IOT01

This application embeds aTelegram chatbot into the DISCO_L475VG_IOT01 board.

The Bot answers to the users queries about:

  • Real time environmental data taken from the on board sensors.
  • Environmental data history of the latest 24 hours stored on board.
  • Camera images taken from the Arducam-mini-2mp (optional).

This software uses:

Compilation

Import in your compiler and modify the following defines:

  • WIFI_SSID
  • WIFI_PASSWORD
  • TELEGRAM_BOT_APIKEY

Please follow the Telegram bots documentation (https://core.telegram.org/bots) to better understand how the Telegram API works and how to create your bot.

In order to support the Arducam-Mini-2MP set WITH_ARDUCAM_2640 #define to 1.

Screenshots

/media/uploads/dvddnr/screenshot_20180130-073732.png /media/uploads/dvddnr/screenshot_20180130-073703.png /media/uploads/dvddnr/arducam.jpeg /media/uploads/dvddnr/screenshot_20180216-102601.png

Security

The Inventek wifi module creates the ssl connection but does not authenticate the server's certificate ( AT cmd P9=0 ).

For more details http://www.inventeksys.com/IWIN/programming-certificates-tcp-ssltls/

Revision:
4:9926288a8703
Parent:
3:d6d4d692f167
Child:
5:f204a47aa813
diff -r d6d4d692f167 -r 9926288a8703 main.cpp
--- a/main.cpp	Wed Jan 24 11:51:07 2018 +0000
+++ b/main.cpp	Thu Jan 25 15:27:29 2018 +0000
@@ -17,8 +17,8 @@
 #define WIFI_READ_TIMEOUT 10000
 #define CONNECTION_TRIAL_MAX 10
 
-// serial output
-Serial pc(SERIAL_TX, SERIAL_RX);
+// LED 
+DigitalOut g_alivenessLED(LED1);
 
 // wifi interfaces
 ES_WIFIObject_t g_es_wifi_ctx;
@@ -57,25 +57,8 @@
 int main()
 {
 
-    pc.baud(115200);
+    printf("> DISCO_L475VG_IOT01-Telegram-BOT started\r\n");
 
-    /*Initialize  WIFI module */
-    printf("> Setup wifi connection ...");
-    if (wifi_connect())
-    {
-        printf(" OK\r\n");
-    }
-    else
-    {
-        printf(" KO\r\n");
-        while (1)
-            ;
-    }
-    printf("> IP Address : %d.%d.%d.%d\r\n", 
-            g_es_wifi_ctx.NetSettings.IP_Addr[0],
-            g_es_wifi_ctx.NetSettings.IP_Addr[1],
-            g_es_wifi_ctx.NetSettings.IP_Addr[2],
-            g_es_wifi_ctx.NetSettings.IP_Addr[3]);
            
     /* Setup env sensors */
     BSP_TSENSOR_Init();
@@ -94,16 +77,25 @@
     int json_results;
     bool well_done = false;
 
-
+    if(wifi_connect())
+        printf("> Wifi connected\r\n");
+    else
+    {
+        NVIC_SystemReset();
+    }
 
     while (1)
     {
+        g_alivenessLED = !g_alivenessLED;
+        
         // Get updates -- API method getUpdates
         printf("> Get updates\r\n");
         g_json_io_buffer[0]=0;
         if (telegram_get_update(update_id + 1) == false)
         {
-            printf("> ERROR telegram_get_update\r\n");
+            printf("> ERROR telegram_get_update\r\n> Reset wifi connection\r\n");
+            ES_WIFI_ResetModule(&g_es_wifi_ctx);
+            wifi_connect();
             continue;
         }
         printf("> JSON content: %s\r\n", g_json_io_buffer);