add debuginfo for json memory allocation

This commit is contained in:
sharandac
2020-08-11 10:27:01 +02:00
parent e5cda949ac
commit 77703b42b0
6 changed files with 41 additions and 13 deletions

View File

@@ -31,11 +31,24 @@
// 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 ); }
struct WeatherSpiRamAllocator {
void* allocate( size_t size ) {
void *psram = ps_calloc( size, 1 );
if ( psram ) {
log_i("allocate %dbytes(%p) json psram", size, psram );
return( psram );
}
else {
log_e("allocate %dbytes(%p) json psram failed", size, psram );
while(1);
}
}
void deallocate( void* pointer ) {
log_i("deallocate (%p) json psram", pointer );
free( pointer );
}
};
using SpiRamJsonDocument = BasicJsonDocument<SpiRamAllocator>;
using WeatherSpiRamJsonDocument = BasicJsonDocument<WeatherSpiRamAllocator>;
/* Utility function to convert numbers to directions */
static void weather_wind_to_string( weather_forcast_t* container, int speed, int directionDegree);
@@ -58,7 +71,7 @@ int weather_fetch_today( weather_config_t *weather_config, weather_forcast_t *we
return( -1 );
}
SpiRamJsonDocument doc( today_client.getSize() * 2 );
WeatherSpiRamJsonDocument doc( today_client.getSize() * 2 );
DeserializationError error = deserializeJson( doc, today_client.getStream() );
if (error) {
@@ -103,7 +116,7 @@ int weather_fetch_forecast( weather_config_t *weather_config, weather_forcast_t
return( -1 );
}
SpiRamJsonDocument doc( forecast_client.getSize() * 2 );
WeatherSpiRamJsonDocument doc( forecast_client.getSize() * 2 );
DeserializationError error = deserializeJson( doc, forecast_client.getStream() );
if (error) {

View File

@@ -135,7 +135,9 @@ void weather_forecast_tile_setup( uint32_t tile_num ) {
// regster callback for wifi sync
WiFi.onEvent( [](WiFiEvent_t event, WiFiEventInfo_t info) {
weather_forecast_sync_request();
weather_config_t *weather_config = weather_get_config();
if ( weather_config->autosync )
weather_forecast_sync_request();
}, WiFiEvent_t::SYSTEM_EVENT_STA_GOT_IP );
weather_forecast_event_handle = xEventGroupCreate();

View File

@@ -32,6 +32,6 @@
/*
* firmeware version string
*/
#define __FIRMWARE__ "2020081101"
#define __FIRMWARE__ "2020081102"
#endif // _CONFIG_H

View File

@@ -27,11 +27,24 @@
// 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 ); }
struct UpdateSpiRamAllocator {
void* allocate( size_t size ) {
void *psram = ps_calloc( size, 1 );
if ( psram ) {
log_i("allocate %dbytes(%p) json psram", size, psram );
return( psram );
}
else {
log_e("allocate %dbytes(%p) json psram failed", size, psram );
while(1);
}
}
void deallocate( void* pointer ) {
log_i("deallocate (%p) json psram", pointer );
free( pointer );
}
};
using SpiRamJsonDocument = BasicJsonDocument<SpiRamAllocator>;
using SpiRamJsonDocument = BasicJsonDocument<UpdateSpiRamAllocator>;
uint64_t update_check_new_version( void ) {
char url[512]="";

Binary file not shown.

View File

@@ -1 +1 @@
{"version":"2020081101","host":"http://www.neo-guerillaz.de","file":"ttgo-t-watch2020_v1.ino.bin"}
{"version":"2020081102","host":"http://www.neo-guerillaz.de","file":"ttgo-t-watch2020_v1.ino.bin"}