Skip to content

Commit

Permalink
Fix the SAO app driver
Browse files Browse the repository at this point in the history
  • Loading branch information
robotman2412 committed Jul 30, 2023
1 parent 38d9672 commit fed8531
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 36 deletions.
46 changes: 30 additions & 16 deletions main/menus/sao.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,30 @@ void set_sao_neopixel(uint32_t color) {
}
}

static void sao_start_app_wrapper(xQueueHandle button_queue, char const name[SAO_MAX_FIELD_LENGTH+1]) {
if (strnlen(name, SAO_MAX_FIELD_LENGTH + 1) > SAO_MAX_FIELD_LENGTH) {
return;
}

if (!sao_is_app_installed(name)) {
if (connect_to_wifi()) {
render_message("Installing app...");
display_flush();
if (sao_install_app(button_queue, name)) {
sao_start_app(name);
} else {
render_message("Failed to install app");
display_flush();
wait_for_button();
}
}
} else {
render_message("Starting app...");
display_flush();
sao_start_app(name);
}
}

void menu_sao(xQueueHandle button_queue) {
rp2040_input_message_t buttonMessage = {0};
while (xQueueReceive(button_queue, &buttonMessage, 0) == pdTRUE) {
Expand Down Expand Up @@ -604,23 +628,13 @@ void menu_sao(xQueueHandle button_queue) {
exit = true;
break;
case RP2040_INPUT_BUTTON_ACCEPT:
if ((sao.type == SAO_BINARY) && (strncmp(sao.drivers[0].name, "badgeteam_app_link", strlen("badgeteam_app_link")) == 0)) {
if (!sao_is_app_installed((char*) sao.drivers[0].data)) {
if (connect_to_wifi()) {
render_message("Installing app...");
display_flush();
if (sao_install_app(button_queue, (char*) sao.drivers[0].data)) {
sao_start_app((char*) sao.drivers[0].data);
} else {
render_message("Failed to install app");
display_flush();
wait_for_button();
}
if (sao.type == SAO_BINARY) {
size_t n_drv = sao.amount_of_drivers < SAO_MAX_NUM_DRIVERS
? sao.amount_of_drivers : SAO_MAX_NUM_DRIVERS;
for (size_t i = 0; i < n_drv; i++) {
if (!strncmp(sao.drivers[i].name, SAO_DRIVER_APP_NAME, SAO_MAX_FIELD_LENGTH)) {
sao_start_app_wrapper(button_queue, (char const*) sao.drivers[i].data);
}
} else {
render_message("Starting app...");
display_flush();
sao_start_app((char*) sao.drivers[0].data);
}
}
identify = true;
Expand Down
30 changes: 10 additions & 20 deletions sdkconfig
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ CONFIG_BOOTLOADER_SPI_WP_PIN=7
CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V=y
# CONFIG_BOOTLOADER_FACTORY_RESET is not set
# CONFIG_BOOTLOADER_APP_TEST is not set
CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE=y
CONFIG_BOOTLOADER_WDT_ENABLE=y
# CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE is not set
CONFIG_BOOTLOADER_WDT_TIME_MS=9000
Expand Down Expand Up @@ -98,9 +97,6 @@ CONFIG_ESPTOOLPY_FLASHFREQ="80m"
# CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set
# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
# CONFIG_ESPTOOLPY_FLASHSIZE_32MB is not set
# CONFIG_ESPTOOLPY_FLASHSIZE_64MB is not set
# CONFIG_ESPTOOLPY_FLASHSIZE_128MB is not set
CONFIG_ESPTOOLPY_FLASHSIZE="16MB"
CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y
CONFIG_ESPTOOLPY_BEFORE_RESET=y
Expand Down Expand Up @@ -270,8 +266,8 @@ CONFIG_EFUSE_MAX_BLK_LEN=192
#
CONFIG_ESP_TLS_USING_MBEDTLS=y
# CONFIG_ESP_TLS_USE_SECURE_ELEMENT is not set
# CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set
# CONFIG_ESP_TLS_SERVER is not set
# CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set
# CONFIG_ESP_TLS_PSK_VERIFICATION is not set
# CONFIG_ESP_TLS_INSECURE is not set
# end of ESP-TLS
Expand Down Expand Up @@ -529,13 +525,6 @@ CONFIG_ESP_PHY_REDUCE_TX_POWER=y
# CONFIG_PM_ENABLE is not set
# end of Power Management

#
# ESP Ringbuf
#
# CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH is not set
# CONFIG_RINGBUF_PLACE_ISR_FUNCTIONS_INTO_FLASH is not set
# end of ESP Ringbuf

#
# ESP System Settings
#
Expand Down Expand Up @@ -620,8 +609,6 @@ CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y
# CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is not set
# CONFIG_ESP_WIFI_GMAC_SUPPORT is not set
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=y
# CONFIG_ESP_WIFI_SLP_BEACON_LOST_OPT is not set
CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=7
# end of Wi-Fi

#
Expand Down Expand Up @@ -700,7 +687,11 @@ CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE=20
CONFIG_FMB_CONTROLLER_STACK_SIZE=4096
CONFIG_FMB_EVENT_QUEUE_TIMEOUT=20
# CONFIG_FMB_TIMER_PORT_ENABLED is not set
# CONFIG_FMB_TIMER_USE_ISR_DISPATCH_METHOD is not set
CONFIG_FMB_TIMER_GROUP=0
CONFIG_FMB_TIMER_INDEX=0
CONFIG_FMB_MASTER_TIMER_GROUP=0
CONFIG_FMB_MASTER_TIMER_INDEX=0
# CONFIG_FMB_TIMER_ISR_IN_IRAM is not set
# end of Modbus configuration

#
Expand Down Expand Up @@ -858,7 +849,6 @@ CONFIG_LWIP_TCP_SYNMAXRTX=12
CONFIG_LWIP_TCP_MSS=1440
CONFIG_LWIP_TCP_TMR_INTERVAL=250
CONFIG_LWIP_TCP_MSL=60000
CONFIG_LWIP_TCP_FIN_WAIT_TIMEOUT=20000
CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5744
CONFIG_LWIP_TCP_WND_DEFAULT=5744
CONFIG_LWIP_TCP_RECVMBOX_SIZE=6
Expand Down Expand Up @@ -1113,7 +1103,6 @@ CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y
#
# NVS
#
# CONFIG_NVS_ASSERT_ERROR_CHECK is not set
# end of NVS

#
Expand Down Expand Up @@ -1251,6 +1240,7 @@ CONFIG_VFS_SUPPORT_TERMIOS=y
# Host File System I/O (Semihosting)
#
CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1
CONFIG_VFS_SEMIHOSTFS_HOST_PATH_MAX_LEN=128
# end of Host File System I/O (Semihosting)
# end of Virtual file system

Expand All @@ -1267,7 +1257,6 @@ CONFIG_WL_SECTOR_SIZE=4096
#
CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16
CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30
CONFIG_WIFI_PROV_BLE_FORCE_ENCRYPTION=y
# end of Wi-Fi Provisioning Manager

#
Expand All @@ -1280,8 +1269,6 @@ CONFIG_WPA_MBEDTLS_CRYPTO=y
# CONFIG_WPA_TESTING_OPTIONS is not set
# CONFIG_WPA_WPS_STRICT is not set
# CONFIG_WPA_11KV_SUPPORT is not set
# CONFIG_WPA_MBO_SUPPORT is not set
# CONFIG_WPA_DPP_SUPPORT is not set
# end of Supplicant

#
Expand Down Expand Up @@ -1424,6 +1411,8 @@ CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE=20
CONFIG_MB_CONTROLLER_STACK_SIZE=4096
CONFIG_MB_EVENT_QUEUE_TIMEOUT=20
# CONFIG_MB_TIMER_PORT_ENABLED is not set
CONFIG_MB_TIMER_GROUP=0
CONFIG_MB_TIMER_INDEX=0
# CONFIG_ENABLE_STATIC_TASK_CLEAN_UP_HOOK is not set
CONFIG_TIMER_TASK_PRIORITY=1
CONFIG_TIMER_TASK_STACK_DEPTH=2048
Expand Down Expand Up @@ -1466,4 +1455,5 @@ CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED=y
CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT=y
CONFIG_SUPPORT_TERMIOS=y
CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS=1
CONFIG_SEMIHOSTFS_HOST_PATH_MAX_LEN=128
# End of deprecated options

0 comments on commit fed8531

Please sign in to comment.