STM32F103C8T6_WIFI_Heating_system

Dependencies:   mbed mbed-STM32F103C8T6 eeprom_flash Watchdog PinDetect DS1820

  1. Bluepill STM32F103C8T6 Heating system
    1. _This project is core part of bigger heating system project!_

Features - Reading temperature from four DS18B20 sensors - Making a decision about switching on/off heater and pomp - Executing simple user commands from UART - Storing state parameters to program memory (EEPROM emulation)

Revision:
44:e6efa8be1f9e
Parent:
43:cc47a2e6ae07
Child:
45:abc682827659
--- a/main.cpp	Sat Sep 22 08:42:05 2018 +0000
+++ b/main.cpp	Sat Sep 22 17:33:14 2018 +0000
@@ -71,43 +71,67 @@
 
 
 void at_command(){
+        int x;
+        int ii;
+        int jj;
+        char num[10];
+        
+        
         if (recieved == 1) {
             
             __disable_irq();
-            if (strcmp(a,"AT")==0) {
+            
+            if (strcmp(a,"AT get all")==0) {
+                // config_ram|config_rom|mode|status0|status1|status2|status3|status4|temp0|temp1|temp2|temp3|temp4
+                pc.printf("%u|%u|", eeprom_config_value, readEEPROMWord(0));
+                if (working_mode==3) {
+                    pc.printf("%d|%d|%d|%d|%d|%d|", working_mode, 0, 0, 0, 0, 0);
+                    pc.printf("%3.1f|%3.1f|%3.1f|%3.1f|%3.1f\r\n", simulated_temp[0], simulated_temp[1], simulated_temp[2], simulated_temp[3], simulated_temp[4]);                
+                } else {
+                    pc.printf("%d|%d|%d|%d|%d|%d|", working_mode, temp_error[0], temp_error[1], temp_error[2], temp_error[3], temp_error[4]);
+                    pc.printf("%3.1f|%3.1f|%3.1f|%3.1f|%3.1f\r\n", temp[0], temp[1], temp[2], temp[3], temp[4]);                                    
+                };
+            } else if (strcmp(a,"AT")==0) {
                 pc.printf("OK\r\n");
-            } else if (strcmp(a,"AT check setup")==0) {
+            } else if (strcmp(a,"AT get config")==0) {
                 pc.printf("%u|%u\r\n", eeprom_config_value, readEEPROMWord(0));
             } else if (strcmp(a,"AT get status")==0) {
                 pc.printf("%d|%d|%d|%d|%d\r\n", temp_error[0], temp_error[1], temp_error[2], temp_error[3], temp_error[4]);
             } else if (strcmp(a,"AT get temp")==0) {
                 pc.printf("%3.1f|%3.1f|%3.1f|%3.1f|%3.1f\r\n", temp[0], temp[1], temp[2], temp[3], temp[4]);
-            } else if (strcmp(a,"AT get simulated temp")==0) {
+            } else if (strcmp(a,"AT get sim temp")==0) {
                 pc.printf("%3.1f|%3.1f|%3.1f|%3.1f|%3.1f\r\n", simulated_temp[0], simulated_temp[1], simulated_temp[2], simulated_temp[3], simulated_temp[4]);
             } else if (strcmp(a,"AT get mode")==0) {
                 pc.printf("%d\r\n", working_mode);
+            } else if (strncmp(a,"AT set mode ",12) == 0) {            
+                x= (int)a[12] - 48;                    
+                working_mode = ( x >= 0 && x <=5 ) ? x : working_mode;
+                pc.printf("%d\r\n", working_mode);                
+            } else if (strncmp(a,"AT set sim temp ", 16) == 0) {
+                // from a[16] "t0|t1|t2|t3|t4\0"
+                ii = 16;
+                for (int j=0; j<6; j++) {
+                    jj = 0;
+                    while ( a[ii]!='|' && a[ii]!='\0') {
+                        num[jj] = a[ii];
+                        ii++;
+                        jj++;
+                    };
+                    ii++;
+                    num[jj] = '\0';
+                    simulated_temp[j] = (float)atol(num);
+                };
+                pc.printf("%3.1f|%3.1f|%3.1f|%3.1f|%3.1f\r\n", 
+                            simulated_temp[0], 
+                            simulated_temp[1], 
+                            simulated_temp[2], 
+                            simulated_temp[3], 
+                            simulated_temp[4]
+                        );
             } else {
                 pc.printf("Bad request\r\n");   
             };
             
-            // command was recieved
-            /*
-            if (a[0]=='A' && a[1]=='T') {  
-                
-                if ( a[2]=='\0') {
-                    //pc.printf(a);
-                    pc.printf("RAM=%u FLASH=%u OK\r\n", eeprom_config_value, readEEPROMWord(0));
-                } else {
-                    pc.printf("Wrong command\r\n");      
-                };
-                
-                //readEEPROMWord(0x01);
-            } else {
-                    pc.printf("Bad request\r\n");    
-            };
-            
-            // process_command(a);
-            */
             __enable_irq(); 
 
             // ready for new command