Compare commits

...

8 Commits

6 changed files with 51 additions and 94 deletions

1
.gitignore vendored
View File

@ -8,3 +8,4 @@
.vscode/settings.json .vscode/settings.json
firmware/ firmware/
release/ release/
.vscode/extensions.json

78
.vscode/settings.json vendored
View File

@ -1,78 +0,0 @@
{
"C_Cpp.errorSquiggles": "enabled",
"files.associations": {
"*.cps": "javascript",
"string": "cpp",
"optional": "cpp",
"istream": "cpp",
"ostream": "cpp",
"system_error": "cpp",
"array": "cpp",
"functional": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"*.d": "cpp",
"*.html": "cpp",
"*.tcc": "cpp",
"regex": "cpp"
},
"C_Cpp_Runner.msvcBatchPath": "",
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false,
"cmake.sourceDirectory": "D:/Git/iot-firmware/.pio/libdeps/full/Adafruit BusIO"
}

2
Jenkinsfile vendored
View File

@ -4,7 +4,7 @@ pipeline {
stages { stages {
stage('Build') { stage('Build') {
steps { steps {
git branch: 'main', url: 'https://git.siwatsystem.com/ise-senior-iot/iot-firmware.git' git branch: 'lcd_upload', url: 'https://git.siwatsystem.com/ise-senior-iot/iot-firmware.git'
sh 'export PLATFORMIO_PATH=/root/.platformio/penv/bin/platformio' sh 'export PLATFORMIO_PATH=/root/.platformio/penv/bin/platformio'
sh '/usr/bin/python3 gen_release.py' sh '/usr/bin/python3 gen_release.py'
stash includes: 'release/**/*', name: 'release_binaries' stash includes: 'release/**/*', name: 'release_binaries'

View File

@ -547,6 +547,24 @@ void ota_begin()
} }
} }
}); });
otaserver.on("/lcd_update",HTTP_POST,[]() {
otaserver.sendHeader("Connection","close");
},[](){
for(int i=0;i<otaserver.headers();i++) {
// Print all headers
Serial.printf("HEADER[%s]:[%s]\n", otaserver.headerName(i).c_str(), otaserver.header(i).c_str());
}
HTTPUpload &upload = otaserver.upload();
size_t file_size = 0;
if(upload.status == UPLOAD_FILE_START) {
Serial.println(file_size);
lcd_upload_start(file_size);
} else if (upload.status == UPLOAD_FILE_WRITE) {
lcd_upload_write(upload.buf, upload.currentSize);
} else if (upload.status == UPLOAD_FILE_END) {
Serial.println("Upload END.");
}
});
otaserver.begin(); otaserver.begin();
} }
#endif #endif

View File

@ -1,6 +1,8 @@
#include <user_code.hpp> #include <user_code.hpp>
#include <espmega_iot_lcd.hpp> #include <espmega_iot_lcd.hpp>
int lcd_byte_counter = 0;
/** /**
* @brief Sends stop bit to LCD. * @brief Sends stop bit to LCD.
* *
@ -70,9 +72,11 @@ bool lcd_upload_start(size_t size)
Serial.print("connect"); Serial.print("connect");
lcd_send_stop_bit(); lcd_send_stop_bit();
delay(1000); delay(1000);
Serial.print("whmi-wri 1024,115200,res0"); Serial.print("whmi-wri ");
Serial.print(size);
Serial.print(",115200,res0");
lcd_send_stop_bit(); lcd_send_stop_bit();
lcd_wait_ack(); return lcd_wait_ack();
} }
/** /**
@ -87,9 +91,15 @@ bool lcd_upload_write(uint8_t *data, size_t size)
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
{ {
Serial.write(data[i]); Serial.write(data[i]);
lcd_byte_counter++;
if (lcd_byte_counter == 4096)
{
lcd_wait_ack();
lcd_byte_counter = 0;
} }
} }
return true;
}
/** /**
* Waits for an acknowledgement signal from the LCD. * Waits for an acknowledgement signal from the LCD.
* @return true if acknowledgement signal is received, false otherwise. * @return true if acknowledgement signal is received, false otherwise.
@ -97,13 +107,16 @@ bool lcd_upload_write(uint8_t *data, size_t size)
bool lcd_wait_ack() bool lcd_wait_ack()
{ {
bool data_ok = false; bool data_ok = false;
for (int i; i < 50; i++) for (int i = 0; i < 50; i++)
{
if (Serial.available())
{ {
if (Serial.read() == 0x05) if (Serial.read() == 0x05)
{ {
data_ok = true; data_ok = true;
break; break;
} }
}
delay(100); delay(100);
} }
return data_ok; return data_ok;

View File

@ -23,11 +23,14 @@ R"=====(<button type="button" class="conf" onclick="window.location.href='config
var form = $("#upload_form")[0]; var form = $("#upload_form")[0];
var data = new FormData(form); var data = new FormData(form);
$.ajax({ $.ajax({
url: "/update", url: "/lcd_update",
type: "POST", type: "POST",
data: data, data: data,
contentType: false, contentType: false,
processData: false, processData: false,
headers: {
"Content-Length": data.length
},
xhr: function () { xhr: function () {
var xhr = new window.XMLHttpRequest(); var xhr = new window.XMLHttpRequest();
xhr.upload.addEventListener( xhr.upload.addEventListener(