The changes I’ve made are:
1 ) #define CONFIG_OTA_UPDATE_DEMO_ENABELD in aws_demo_config.h
2 ) Specifying MQTT ( not HTTP ) in aws_ota_agent_config.h
3 ) Specifying WiFi ( not BLE ) in aws_iot_network_config.h
4 ) Setting the WiFi’s SSID, password, security, and thing name in aws_credentials.h
5 ) Setting the “keys” in aws_credentials_keys.h
6 ) Re-defining the partition table from
to
for the 8MB WROVER module I’m using.
7 ) Setting the “code signing certificate” in aws_ota_codesigner_certificate.h.
8 ) Setting the “APP_VERSION” for both the “old” and “new” code builds.
Otherwise, I don’t believe I’ve made any changes.
BUT, I am calling the DEMO_RUNNER_RunDemos() function as shown below from a “setup()” routine that I will be using to merge my Arduino code into. Most of this code has been “cut and pasted” from the FreeRTOS 202007 demo code, but if you see anything I don’t have setup correctly, please let me know!
Tom
/* Logging Task Defines. */
#define mainLOGGING_MESSAGE_QUEUE_LENGTH ( 32 )
#define mainLOGGING_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 4 )
#define mainDEVICE_NICK_NAME “Espressif_Demo”
//#define configSUPPORT_STATIC_ALLOCATION 1
QueueHandle_t spp_uart_queue = NULL;
static void prvMiscInitialization( void );
// extern HardwareSerial Serial;
// HardwareSerial Serial(0);
extern “C” bool Iot_CreateDetachedThread( IotThreadRoutine_t threadRoutine,
void * pArgument,
int32_t priority,
size_t stackSize );
extern “C” BaseType_t xLoggingTaskInitialize( uint16_t usStackSize,
UBaseType_t uxPriority,
UBaseType_t uxQueueLength );
// extern “C” void runDemoTask( void * pArgument );
/* Can run ‘make menuconfig’ to choose the GPIO to blink,
or you can edit the following line and set a number here.
*/
#define CONFIG_BLINK_GPIO 33
#define BLINK_GPIO (gpio_num_t)CONFIG_BLINK_GPIO
#ifndef LED_BUILTIN
#define LED_BUILTIN 33 // 33 = GREEN, 32 = ORANGE
#endif
#if defined( democonfigOTA_UPDATE_TASK_STACK_SIZE )
#undef democonfigDEMO_STACKSIZE
#define democonfigDEMO_STACKSIZE democonfigOTA_UPDATE_TASK_STACK_SIZE
#endif
#if defined( democonfigOTA_UPDATE_TASK_TASK_PRIORITY )
#undef democonfigDEMO_PRIORITY
#define democonfigDEMO_PRIORITY democonfigOTA_UPDATE_TASK_TASK_PRIORITY
#endif
// Forward declaration of demo entry function to be renamed from #define in aws_demo_config.h /
int DEMO_entryFUNCTION( bool awsIotMqttMode,
const char * pIdentifier,
void * pNetworkServerInfo,
void * pNetworkCredentialInfo,
const IotNetworkInterface_t * pNetworkInterface );
/* Forward declaration of network connected DEMO callback to be renamed from #define in aws_demo_config.h */
#ifdef DEMO_networkConnectedCallback
void DEMO_networkConnectedCallback( bool awsIotMqttMode,
const char * pIdentifier,
void * pNetworkServerInfo,
void * pNetworkCredentialInfo,
const IotNetworkInterface_t * pNetworkInterface );
#else
#define DEMO_networkConnectedCallback ( NULL )
#endif
/* Forward declaration of network disconnected DEMO callback to be renamed from #define in aws_demo_config.h */
#ifdef DEMO_networkDisconnectedCallback
void DEMO_networkDisconnectedCallback( const IotNetworkInterface_t * pNetworkInterface );
#else
#define DEMO_networkDisconnectedCallback ( NULL )
#endif
// Copied from “…/amazon-freertos/vendors/espressif/esp-idf/components/esp32/freertos_hook.c”
// void IRAM_ATTR esp_vApplicationTickHook();
extern “C” void IRAM_ATTR esp_vApplicationTickHook();
extern “C” void esp_vApplicationIdleHook();
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
prvMiscInitialization();
if( SYSTEM_Init() == pdPASS )
{
vDevModeKeyProvisioning();
ESP_ERROR_CHECK( esp_bt_controller_mem_release( ESP_BT_MODE_CLASSIC_BT ) );
ESP_ERROR_CHECK( esp_bt_controller_mem_release( ESP_BT_MODE_BLE ) );
DEMO_RUNNER_RunDemos();
}
}
void loop() {
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
Serial.println(“Hello, from loop!”);
delay(2500);
}
////////////////////////////////////////////////////////////////////////////////
#if CONFIG_FREERTOS_UNICORE
#define ARDUINO_RUNNING_CORE 0
#else
#define ARDUINO_RUNNING_CORE 1
#endif
void loopTask(void *pvParameters)
{
setup();
for(; {
// micros(); //update overflow
loop();
}
}
// int main()
// nt app_main(void)
extern “C” void app_main(void)
{
initArduino();
xTaskCreatePinnedToCore(loopTask, “loopTask”, 8192, NULL, 1, NULL, ARDUINO_RUNNING_CORE);
// return 0;
}
////////////////////////////////////////////////////////////////////////////////
// *
//------------------------------------------------------------//
extern void vApplicationIPInit( void );
static void prvMiscInitialization( void )
{
// Initialize NVS /
esp_err_t ret = nvs_flash_init();
if( ( ret == ESP_ERR_NVS_NO_FREE_PAGES ) || ( ret == ESP_ERR_NVS_NEW_VERSION_FOUND ) )
{
ESP_ERROR_CHECK( nvs_flash_erase() );
ret = nvs_flash_init();
}
ESP_ERROR_CHECK( ret );
// #if BLE_ENABLED
// NumericComparisonInit();
// spp_uart_init();
// #endif
// Create tasks that are not dependent on the WiFi being initialized. /
//extern “C” xLoggingTaskInitialize( mainLOGGING_TASK_STACK_SIZE,
xLoggingTaskInitialize( mainLOGGING_TASK_STACK_SIZE,
tskIDLE_PRIORITY + 5,
mainLOGGING_MESSAGE_QUEUE_LENGTH );
#if AFR_ESP_LWIP
// configPRINTF( (“Initializing lwIP TCP stack\r\n”) );
tcpip_adapter_init();
#else
// configPRINTF( (“Initializing FreeRTOS TCP stack\r\n”) );
vApplicationIPInit();
#endif
}
//-----------------------------------------------------------/
// extern void esp_vApplicationTickHook();
extern “C” void esp_vApplicationTickHook();
extern “C” void IRAM_ATTR vApplicationTickHook()
{
esp_vApplicationTickHook();
}
//-----------------------------------------------------------/
// extern void esp_vApplicationIdleHook();
extern “C” void esp_vApplicationIdleHook();
extern “C” void vApplicationIdleHook()
{
esp_vApplicationIdleHook();
}
//-----------------------------------------------------------/
// void vApplicationDaemonTaskStartupHook( void )
extern “C” void vApplicationDaemonTaskStartupHook( void )
{
}
#if !AFR_ESP_LWIP
//-----------------------------------------------------------/
// void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
extern “C” void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
{
uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
system_event_t evt;
if( eNetworkEvent == eNetworkUp )
{
// Print out the network configuration, which may have come from a DHCP
// server.
FreeRTOS_GetAddressConfiguration(
&ulIPAddress,
&ulNetMask,
&ulGatewayAddress,
&ulDNSServerAddress );
evt.event_id = SYSTEM_EVENT_STA_GOT_IP;
evt.event_info.got_ip.ip_changed = true;
evt.event_info.got_ip.ip_info.ip.addr = ulIPAddress;
evt.event_info.got_ip.ip_info.netmask.addr = ulNetMask;
evt.event_info.got_ip.ip_info.gw.addr = ulGatewayAddress;
esp_event_send( &evt );
}
}
#endif