some updates and fixes
This commit is contained in:
@@ -32,6 +32,6 @@
|
||||
/*
|
||||
* firmeware version string
|
||||
*/
|
||||
#define __FIRMWARE__ "2020081803"
|
||||
#define __FIRMWARE__ "2020081902"
|
||||
|
||||
#endif // _CONFIG_H
|
||||
|
||||
@@ -103,34 +103,38 @@ void bluetooth_call_msg_pharse( char* msg ) {
|
||||
log_e("bluetooth call deserializeJson() failed: %s", error.c_str() );
|
||||
}
|
||||
else {
|
||||
if( !strcmp( doc["t"], "call" ) && !strcmp( doc["cmd"], "accept" ) ) {
|
||||
statusbar_hide( true );
|
||||
if ( powermgm_get_event( POWERMGM_STANDBY ) ) {
|
||||
standby = true;
|
||||
if ( doc["t"] && doc["cmd"] ) {
|
||||
if( !strcmp( doc["t"], "call" ) && !strcmp( doc["cmd"], "accept" ) ) {
|
||||
statusbar_hide( true );
|
||||
if ( powermgm_get_event( POWERMGM_STANDBY ) ) {
|
||||
standby = true;
|
||||
}
|
||||
else {
|
||||
standby = false;
|
||||
}
|
||||
|
||||
powermgm_set_event( POWERMGM_WAKEUP_REQUEST );
|
||||
mainbar_jump_to_tilenumber( bluetooth_call_tile_num, LV_ANIM_OFF );
|
||||
if ( doc["number"] ) {
|
||||
lv_label_set_text( bluetooth_call_number_label, doc["number"] );
|
||||
}
|
||||
else {
|
||||
lv_label_set_text( bluetooth_call_number_label, "" );
|
||||
}
|
||||
lv_obj_align( bluetooth_call_number_label, bluetooth_call_img, LV_ALIGN_OUT_BOTTOM_MID, 0, 5 );
|
||||
lv_obj_invalidate( lv_scr_act() );
|
||||
motor_vibe(100);
|
||||
}
|
||||
else {
|
||||
standby = false;
|
||||
}
|
||||
|
||||
powermgm_set_event( POWERMGM_WAKEUP_REQUEST );
|
||||
mainbar_jump_to_tilenumber( bluetooth_call_tile_num, LV_ANIM_OFF );
|
||||
if ( doc["number"] ) {
|
||||
lv_label_set_text( bluetooth_call_number_label, doc["number"] );
|
||||
}
|
||||
else {
|
||||
lv_label_set_text( bluetooth_call_number_label, "" );
|
||||
}
|
||||
lv_obj_align( bluetooth_call_number_label, bluetooth_call_img, LV_ALIGN_OUT_BOTTOM_MID, 0, 5 );
|
||||
lv_obj_invalidate( lv_scr_act() );
|
||||
motor_vibe(100);
|
||||
}
|
||||
|
||||
if( !strcmp( doc["t"], "call" ) && !strcmp( doc["cmd"], "start" ) ) {
|
||||
if ( standby == true ) {
|
||||
powermgm_set_event( POWERMGM_STANDBY_REQUEST );
|
||||
if ( doc["t"] && doc["cmd"] ) {
|
||||
if( !strcmp( doc["t"], "call" ) && !strcmp( doc["cmd"], "start" ) ) {
|
||||
if ( standby == true ) {
|
||||
powermgm_set_event( POWERMGM_STANDBY_REQUEST );
|
||||
}
|
||||
mainbar_jump_to_maintile( LV_ANIM_OFF );
|
||||
lv_obj_invalidate( lv_scr_act() );
|
||||
}
|
||||
mainbar_jump_to_maintile( LV_ANIM_OFF );
|
||||
lv_obj_invalidate( lv_scr_act() );
|
||||
}
|
||||
}
|
||||
doc.clear();
|
||||
|
||||
@@ -143,8 +143,12 @@ void bluetooth_message_msg_pharse( char* msg ) {
|
||||
lv_img_set_src( bluetooth_message_img, &message_32px );
|
||||
}
|
||||
|
||||
|
||||
if ( doc["body"] )
|
||||
lv_label_set_text( bluetooth_message_msg_label, doc["body"] );
|
||||
else
|
||||
lv_label_set_text( bluetooth_message_msg_label, "" );
|
||||
|
||||
|
||||
if ( doc["title"] )
|
||||
lv_label_set_text( bluetooth_message_sender_label, doc["title"] );
|
||||
|
||||
@@ -209,7 +209,7 @@ void update_Task( void * pvParameters ) {
|
||||
log_i("start update task");
|
||||
|
||||
if ( xEventGroupGetBits( update_event_handle) & UPDATE_GET_VERSION_REQUEST ) {
|
||||
int64_t firmware_version = update_check_new_version();
|
||||
int64_t firmware_version = update_check_new_version( update_setup_get_url() );
|
||||
if ( firmware_version > atol( __FIRMWARE__ ) && firmware_version > 0 ) {
|
||||
char version_msg[48] = "";
|
||||
snprintf( version_msg, sizeof( version_msg ), "new version: %lld", firmware_version );
|
||||
@@ -224,7 +224,7 @@ void update_Task( void * pvParameters ) {
|
||||
}
|
||||
lv_obj_invalidate( lv_scr_act() );
|
||||
}
|
||||
if ( xEventGroupGetBits( update_event_handle) & UPDATE_REQUEST ) {
|
||||
if ( ( xEventGroupGetBits( update_event_handle) & UPDATE_REQUEST ) && ( update_get_url() != NULL ) ) {
|
||||
if( WiFi.status() == WL_CONNECTED ) {
|
||||
|
||||
uint32_t display_timeout = display_get_timeout();
|
||||
@@ -237,7 +237,7 @@ void update_Task( void * pvParameters ) {
|
||||
|
||||
httpUpdate.rebootOnUpdate( false );
|
||||
|
||||
t_httpUpdate_return ret = httpUpdate.update( client, "http://www.neo-guerillaz.de/ttgo-t-watch2020_v1.ino.bin" );
|
||||
t_httpUpdate_return ret = httpUpdate.update( client, update_get_url() );
|
||||
|
||||
switch(ret) {
|
||||
case HTTP_UPDATE_FAILED:
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
#define UPDATE_REQUEST _BV(0)
|
||||
#define UPDATE_GET_VERSION_REQUEST _BV(1)
|
||||
|
||||
#define FIRMWARE_LOCATION "https://github.com/sharandac/My-TTGO-Watch/blob/master/ttgo-t-watch2020_v1.ino.bin"
|
||||
|
||||
void update_tile_setup( void );
|
||||
void update_check_version( void );
|
||||
void update_update_firmware( void );
|
||||
|
||||
@@ -23,15 +23,15 @@
|
||||
#include "HTTPClient.h"
|
||||
|
||||
#include "update_check_version.h"
|
||||
|
||||
#include "hardware/json_psram_allocator.h"
|
||||
|
||||
uint64_t update_check_new_version( void ) {
|
||||
char url[512]="";
|
||||
int httpcode = -1;
|
||||
uint64_t version = -1;
|
||||
char *firmwarehost = NULL;
|
||||
char *firmwarefile = NULL;
|
||||
char* firmwareurl = NULL;
|
||||
int64_t firmwareversion = -1;
|
||||
|
||||
snprintf( url, sizeof( url ), "http://%s/%s", FIRMWARE_HOST, FIRMWARE_VERSION_FILE );
|
||||
int64_t update_check_new_version( char *url ) {
|
||||
int httpcode = -1;
|
||||
|
||||
HTTPClient check_update_client;
|
||||
|
||||
@@ -58,8 +58,77 @@ uint64_t update_check_new_version( void ) {
|
||||
|
||||
check_update_client.end();
|
||||
|
||||
version = atoll( doc["version"] );
|
||||
if ( doc["host"] ) {
|
||||
if ( firmwarehost == NULL ) {
|
||||
firmwarehost = (char*)ps_calloc( strlen( doc["host"] ) + 1, 1 );
|
||||
if ( firmwarehost == NULL ) {
|
||||
log_e("ps_calloc error");
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
char * tmp_firmwarehost = (char*)ps_realloc( firmwarehost, strlen( doc["host"] ) + 1 );
|
||||
if ( tmp_firmwarehost == NULL ) {
|
||||
log_e("ps_realloc error");
|
||||
while(true);
|
||||
}
|
||||
firmwarehost = tmp_firmwarehost;
|
||||
}
|
||||
strcpy( firmwarehost, doc["host"] );
|
||||
log_i("firmwarehost: %s", firmwarehost );
|
||||
}
|
||||
|
||||
if ( doc["file"] ) {
|
||||
if ( firmwarefile == NULL ) {
|
||||
firmwarefile = (char*)ps_calloc( strlen( doc["file"] ) + 1, 1 );
|
||||
if ( firmwarefile == NULL ) {
|
||||
log_e("ps_calloc error");
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
char * tmp_firmwarefile = (char*)ps_realloc( firmwarefile, strlen( doc["file"] ) + 1 );
|
||||
if ( tmp_firmwarefile == NULL ) {
|
||||
log_e("ps_realloc error");
|
||||
while(true);
|
||||
}
|
||||
firmwarefile = tmp_firmwarefile;
|
||||
}
|
||||
strcpy( firmwarefile, doc["file"] );
|
||||
log_i("firmwarefile: %s", firmwarefile );
|
||||
}
|
||||
|
||||
if ( firmwarehost != NULL && firmwarefile != NULL ) {
|
||||
if ( firmwareurl == NULL ) {
|
||||
firmwareurl = (char*)ps_calloc( strlen( firmwarehost ) + strlen( firmwarefile ) + 5, 1 );
|
||||
if ( firmwareurl == NULL ) {
|
||||
log_e("ps_calloc error");
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
char * tmp_firmwareurl = (char*)ps_realloc( firmwareurl, strlen( firmwarehost ) + strlen( firmwarefile ) + 5 );
|
||||
if ( tmp_firmwareurl == NULL ) {
|
||||
log_e("ps_realloc error");
|
||||
while(true);
|
||||
}
|
||||
firmwareurl = tmp_firmwareurl;
|
||||
}
|
||||
snprintf( firmwareurl, strlen( firmwarehost ) + strlen( firmwarefile ) + 5, "%s/%s", firmwarehost, firmwarefile );
|
||||
log_i("firmwareurl: %s", firmwareurl );
|
||||
}
|
||||
|
||||
if ( doc["version"] ) {
|
||||
firmwareversion = atoll( doc["version"] );
|
||||
}
|
||||
|
||||
doc.clear();
|
||||
return( version );
|
||||
return( firmwareversion );
|
||||
}
|
||||
|
||||
const char* update_get_url( void ) {
|
||||
if ( firmwareversion > 0 ) {
|
||||
return( (const char*)firmwareurl );
|
||||
}
|
||||
return( NULL );
|
||||
}
|
||||
@@ -24,12 +24,9 @@
|
||||
|
||||
#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 UPDATE_JSON_BUFFER_SIZE 200
|
||||
|
||||
uint64_t update_check_new_version();
|
||||
int64_t update_check_new_version( char *url );
|
||||
const char* update_get_url( void );
|
||||
|
||||
#endif // _UPDATE_CHECK_VERSION_H
|
||||
@@ -128,6 +128,7 @@ void update_save_config( void ) {
|
||||
SpiRamJsonDocument doc( 1000 );
|
||||
|
||||
doc["autosync"] = update_config.autosync;
|
||||
doc["updateurl"] = update_config.updateurl;
|
||||
|
||||
if ( serializeJsonPretty( doc, file ) == 0) {
|
||||
log_e("Failed to write config file");
|
||||
@@ -153,6 +154,7 @@ void update_read_config( void ) {
|
||||
}
|
||||
else {
|
||||
update_config.autosync = doc["autosync"].as<bool>();
|
||||
strlcpy( update_config.updateurl, doc["updateurl"] | FIRMWARE_UPDATE_URL, sizeof( update_config.updateurl ) );
|
||||
}
|
||||
doc.clear();
|
||||
}
|
||||
@@ -184,3 +186,7 @@ void update_read_config( void ) {
|
||||
bool update_setup_get_autosync( void ) {
|
||||
return( update_config.autosync );
|
||||
}
|
||||
|
||||
char* update_setup_get_url( void ) {
|
||||
return( update_config.updateurl );
|
||||
}
|
||||
@@ -27,11 +27,15 @@
|
||||
#define UPDATE_CONFIG_FILE "/update.cfg"
|
||||
#define UPDATE_JSON_CONFIG_FILE "/update.json"
|
||||
|
||||
#define FIRMWARE_UPDATE_URL "http://www.neo-guerillaz.de/ttgo-t-watch2020_v1.version.json"
|
||||
|
||||
typedef struct {
|
||||
bool autosync = true;
|
||||
char updateurl[512] = FIRMWARE_UPDATE_URL;
|
||||
} update_config_t;
|
||||
|
||||
void update_setup_tile_setup( uint32_t tile_num );
|
||||
bool update_setup_get_autosync( void );
|
||||
char* update_setup_get_url( void );
|
||||
|
||||
#endif // _UPDATE_SETUP_H
|
||||
@@ -26,6 +26,8 @@
|
||||
#include <esp_wifi.h>
|
||||
#include <time.h>
|
||||
#include "driver/adc.h"
|
||||
#include "esp_pm.h"
|
||||
|
||||
|
||||
#include "pmu.h"
|
||||
#include "bma.h"
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
{"version":"2020081803","host":"http://www.neo-guerillaz.de","file":"ttgo-t-watch2020_v1.ino.bin"}
|
||||
{"version":"2020081902","host":"http://www.neo-guerillaz.de","file":"ttgo-t-watch2020_v1.ino.bin"}
|
||||
|
||||
Reference in New Issue
Block a user