some fixes and firmware stabilization
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "note_tile/note_tile.h"
|
||||
#include "app_tile/app_tile.h"
|
||||
#include "gui/keyboard.h"
|
||||
#include "gui/statusbar.h"
|
||||
|
||||
#include "setup_tile/battery_settings/battery_settings.h"
|
||||
#include "setup_tile/wlan_settings/wlan_settings.h"
|
||||
@@ -160,6 +161,7 @@ lv_obj_t *mainbar_get_tile_obj( uint32_t tile_number ) {
|
||||
}
|
||||
|
||||
void mainbar_jump_to_maintile( lv_anim_enable_t anim ) {
|
||||
statusbar_hide( false );
|
||||
if ( tile_entrys != 0 ) {
|
||||
lv_tileview_set_tile_act( mainbar, 0, 0, anim );
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ void update_check_version( void ) {
|
||||
xEventGroupSetBits( update_event_handle, UPDATE_GET_VERSION_REQUEST );
|
||||
xTaskCreate( update_Task, /* Function to implement the task */
|
||||
"update Task", /* Name of the task */
|
||||
2000, /* Stack size in words */
|
||||
5000, /* Stack size in words */
|
||||
NULL, /* Task input parameter */
|
||||
1, /* Priority of the task */
|
||||
&_update_Task ); /* Task handle. */
|
||||
|
||||
@@ -20,81 +20,53 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "config.h"
|
||||
#include <Arduino.h>
|
||||
#include <WiFi.h>
|
||||
#include "ArduinoJson.h"
|
||||
#include "HTTPClient.h"
|
||||
|
||||
#include "update_check_version.h"
|
||||
|
||||
// arduinoJson allocator for external PSRAM
|
||||
// see: https://arduinojson.org/v6/how-to/use-external-ram-on-esp32/
|
||||
struct SpiRamAllocator {
|
||||
void* allocate( size_t size ) { return ps_calloc( size, 1 ); }
|
||||
void deallocate( void* pointer ) { free( pointer ); }
|
||||
};
|
||||
using SpiRamJsonDocument = BasicJsonDocument<SpiRamAllocator>;
|
||||
|
||||
uint64_t update_check_new_version( void ) {
|
||||
|
||||
WiFiClient check_version_client;
|
||||
uint64_t retval = -1;
|
||||
char url[512]="";
|
||||
int httpcode = -1;
|
||||
uint64_t version = -1;
|
||||
|
||||
if ( !check_version_client.connect( FIRMWARE_HOST, FIRMWARE_HOST_PORT ) ) {
|
||||
log_e("connection failed");
|
||||
snprintf( url, sizeof( url ), "http://%s/%s", FIRMWARE_HOST, FIRMWARE_VERSION_FILE );
|
||||
|
||||
HTTPClient check_update_client;
|
||||
|
||||
check_update_client.useHTTP10( true );
|
||||
check_update_client.setUserAgent( "ESP32-" __FIRMWARE__ );
|
||||
check_update_client.begin( url );
|
||||
httpcode = check_update_client.GET();
|
||||
|
||||
if ( httpcode != 200 ) {
|
||||
log_e("HTTPClient error %d", httpcode );
|
||||
check_update_client.end();
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
check_version_client.printf( "GET /" FIRMWARE_VERSION_FILE " HTTP/1.1\r\n"
|
||||
"Host: " FIRMWARE_HOST "\r\n"
|
||||
"Connection: close\r\n"
|
||||
"Pragma: no-cache\r\n"
|
||||
"Cache-Control: no-cache\r\n"
|
||||
"User-Agent: ESP32-" __FIRMWARE__ "\r\n"
|
||||
"Accept: text/html,application/json\r\n\r\n" );
|
||||
|
||||
uint64_t startMillis = millis();
|
||||
while ( check_version_client.available() == 0 ) {
|
||||
if ( millis() - startMillis > 5000 ) {
|
||||
log_e("connection timeout");
|
||||
check_version_client.stop();
|
||||
return( retval );
|
||||
}
|
||||
}
|
||||
|
||||
char *json = (char *)ps_malloc( 200 );
|
||||
if ( json == NULL ) {
|
||||
log_e("memory alloc failed");
|
||||
check_version_client.stop();
|
||||
return( retval );
|
||||
}
|
||||
char *ptr = json;
|
||||
|
||||
bool data_begin = false;
|
||||
while( check_version_client.available() ) {
|
||||
if ( data_begin ) {
|
||||
ptr[ check_version_client.readBytes( ptr, 100 - 1 ) ] = '\0';
|
||||
}
|
||||
else if ( check_version_client.read() == '{' ) {
|
||||
data_begin = true;
|
||||
*ptr = '{';
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
SpiRamJsonDocument doc( check_update_client.getSize() * 2 );
|
||||
|
||||
check_version_client.stop();
|
||||
|
||||
if ( data_begin == false ) {
|
||||
free( json );
|
||||
return( retval );
|
||||
}
|
||||
check_version_client.stop();
|
||||
|
||||
DynamicJsonDocument doc( 400 );
|
||||
|
||||
DeserializationError error = deserializeJson( doc, json);
|
||||
DeserializationError error = deserializeJson( doc, check_update_client.getStream() );
|
||||
if (error) {
|
||||
log_e("update version deserializeJson() failed: ", error.c_str() );
|
||||
log_e("update check deserializeJson() failed: %s", error.c_str() );
|
||||
doc.clear();
|
||||
free( json );
|
||||
return( retval );
|
||||
check_update_client.end();
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
retval = atoll( doc["version"] );
|
||||
check_update_client.end();
|
||||
|
||||
version = atoll( doc["version"] );
|
||||
|
||||
doc.clear();
|
||||
free( json );
|
||||
return( retval );
|
||||
return( version );
|
||||
}
|
||||
@@ -24,9 +24,11 @@
|
||||
|
||||
#include <TTGO.h>
|
||||
|
||||
#define FIRMWARE_HOST "www.neo-guerillaz.de"
|
||||
#define FIRMWARE_HOST_PORT 80
|
||||
#define FIRMWARE_VERSION_FILE "ttgo-t-watch2020_v1.version.json"
|
||||
#define FIRMWARE_HOST "www.neo-guerillaz.de"
|
||||
#define FIRMWARE_HOST_PORT 80
|
||||
#define FIRMWARE_VERSION_FILE "ttgo-t-watch2020_v1.version.json"
|
||||
|
||||
#define UPDATE_JSON_BUFFER_SIZE 200
|
||||
|
||||
uint64_t update_check_new_version();
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -34,7 +34,6 @@
|
||||
|
||||
#include "statusbar.h"
|
||||
|
||||
#include "hardware/motor.h"
|
||||
#include "hardware/powermgm.h"
|
||||
#include "hardware/wifictl.h"
|
||||
|
||||
@@ -193,7 +192,6 @@ void statusbar_wifi_event_cb( lv_obj_t *wifi, lv_event_t event ) {
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
motor_vibe( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +205,6 @@ void statusbar_bluetooth_event_cb( lv_obj_t *wifi, lv_event_t event ) {
|
||||
case( LV_BTN_STATE_PRESSED ): break;
|
||||
default: break;
|
||||
}
|
||||
motor_vibe( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,3 +359,7 @@ void statusbar_update_battery( int32_t percent, bool charging, bool plug ) {
|
||||
}
|
||||
statusbar_refresh();
|
||||
}
|
||||
|
||||
void statusbar_hide( bool hide ) {
|
||||
lv_obj_set_hidden( statusbar, hide );
|
||||
}
|
||||
@@ -83,6 +83,7 @@
|
||||
void statusbar_update_battery( int32_t percent, bool charging, bool plug );
|
||||
void statusbar_wifi_set_state( bool state, const char *wifiname );
|
||||
void statusbar_bluetooth_set_state( bool state );
|
||||
void statusbar_hide( bool hide );
|
||||
|
||||
#endif // _STATUSBAR_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user