STM32F103C8T6_WIFI_Heating_system
Dependencies: mbed mbed-STM32F103C8T6 eeprom_flash Watchdog PinDetect DS1820
- Bluepill STM32F103C8T6 Heating system
- _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)
Diff: main.cpp
- Revision:
- 55:3378972851fd
- Parent:
- 54:61ccc1036944
- Child:
- 56:522ad08941bb
--- a/main.cpp Sat Sep 29 23:54:21 2018 +0000 +++ b/main.cpp Sat Oct 06 09:16:46 2018 +0000 @@ -86,7 +86,14 @@ int x; int ii; int jj; + + char given_min_mebel; + char given_min_litos; + char given_min_back; + char given_max_hot; + char num[10]; + char config_string[20]; if (recieved == 1) { @@ -94,7 +101,7 @@ __disable_irq(); if (strcmp(a,"AT get all")==0) { - // config_ram|config_rom|mode|status0|status1|status2|status3|status4|temp0|temp1|temp2|temp3|temp4 + // config_ram|config_rom|mode|status0|status1|status2|status3|status4|temp0|temp1|temp2|temp3|temp4|pomp_OFF|heater_OFF pc.printf("%u|%u|", eeprom_config_value, readEEPROMWord(0)); if (working_mode==3 || working_mode==4) { pc.printf("%d|%d|%d|%d|%d|%d|", working_mode, 0, 0, 0, 0, 0); @@ -115,6 +122,35 @@ pc.printf("OK\r\n"); } else if (strcmp(a,"AT get config")==0) { pc.printf("%u|%u\r\n", eeprom_config_value, readEEPROMWord(0)); + } else if (strncmp(a,"AT set config ",14)==0) { + ii = 14; + jj= 0; + //get rest of AT string for config value + while (a[ii]!='\0') { + config_string[jj] = a[ii]; + ii++; + jj++; + }; + config_string[jj] = '\0'; + + // check if given temp in right range + int config_int = atol(config_string); + given_min_mebel = config_int >> 24; + given_min_litos = (config_int >> 16) & 0x000000FF; + given_min_back = (config_int >> 8) & 0x000000FF; + given_max_hot = config_int & 0x000000FF; + + if ( given_min_mebel > 9 && given_min_mebel < 21 + && given_min_litos > 4 && given_min_litos < 16 + && given_min_back > 4 && given_min_back < 21 + && given_max_hot > 14 && given_max_hot < 51) { + // all given temps are in right range + eeprom_config_value = config_int; + pc.printf("%u\r\n", eeprom_config_value); + } else { + pc.printf("Out of range\r\n"); + }; + } else if (strcmp(a,"AT get status")==0) { pc.printf("%d|%d|%d|%d|%d|%d|%d\r\n", temp_error[0], temp_error[1], temp_error[2], temp_error[3], temp_error[4], (uint8_t)pomp_OFF , (uint8_t)heater_OFF); } else if (strcmp(a,"AT get temp")==0) {