diff --git a/app/http.c b/app/http.c index b3f48c0..2b1b532 100644 --- a/app/http.c +++ b/app/http.c @@ -14,7 +14,7 @@ */ // Central store for Microvisor resource handles used in this code. // See `https://www.twilio.com/docs/iot/microvisor/syscalls#handles` -struct { +static struct { MvNotificationHandle notification; MvNetworkHandle network; MvChannelHandle channel; @@ -23,10 +23,9 @@ struct { // Central store for HTTP request management notification records. // Holds HTTP_NT_BUFFER_SIZE_R records at a time -- each record is 16 bytes in size. static struct MvNotification http_notification_center[HTTP_NT_BUFFER_SIZE_R] __attribute__((aligned(8))); -// Modified in ISR static volatile uint32_t current_notification_index = 0; -// Defined in `main.c`, modified in ISR +// Defined in `main.c` extern volatile bool received_request; extern volatile bool channel_was_closed; @@ -130,7 +129,7 @@ void http_setup_notification_center(void) { // Ask Microvisor to establish the notification center // and confirm that it has accepted the request enum MvStatus status = mvSetupNotifications(&http_notification_setup, &http_handles.notification); - do_assert(status == MV_STATUS_OKAY, "Could not set up HTTP channel NC"); + do_assert(status == MV_STATUS_OKAY, "Could not set up HTTP channel Notification Center"); // Start the notification IRQ NVIC_ClearPendingIRQ(TIM8_BRK_IRQn); @@ -183,7 +182,7 @@ enum MvStatus http_send_request(uint32_t item_number) { // Issue the request -- and check its status enum MvStatus status = mvSendHttpRequest(http_handles.channel, &request_config); if (status == MV_STATUS_OKAY) { - server_log("Request sent to Microvisor Cloud"); + server_log("Request sent to the Microvisor Cloud"); } else if (status == MV_STATUS_CHANNELCLOSED) { server_error("HTTP channel %lu already closed", (uint32_t)http_handles.channel); } else { diff --git a/app/logging.c b/app/logging.c index 22ba1bb..450181e 100644 --- a/app/logging.c +++ b/app/logging.c @@ -1,6 +1,6 @@ /** * - * Microvisor HTTP Communications Demo + * Microvisor C Demos * * Copyright © 2024, KORE Wireless * Licence: MIT @@ -25,9 +25,9 @@ static uint8_t log_buffer[LOG_BUFFER_SIZE_B] __attribute__((aligned(512))) = {0 static uint32_t log_state = USER_HANDLE_LOGGING_OFF; // Entities for local serial logging +static bool uart_available = false; // Declared in `uart_logging.c` extern UART_HandleTypeDef uart; -static bool uart_available = false; /** diff --git a/app/logging.h b/app/logging.h index 5c2328d..3236b25 100644 --- a/app/logging.h +++ b/app/logging.h @@ -1,6 +1,6 @@ /** * - * Microvisor HTTP Communications Demo + * Microvisor C Demos * * Copyright © 2024, KORE Wireless * Licence: MIT diff --git a/app/main.c b/app/main.c index 615d285..880ea54 100644 --- a/app/main.c +++ b/app/main.c @@ -207,7 +207,6 @@ static void task_http(void *argument) { // Run the thread's main loop while (1) { - MvChannelHandle channel_handle = http_get_handle(); uint32_t tick = HAL_GetTick(); if (tick - send_tick > REQUEST_SEND_PERIOD_MS) { // Display the current count @@ -215,12 +214,12 @@ static void task_http(void *argument) { server_log("Ping %lu", ping_count++); // No channel open? The try and open a new one - if (channel_handle == 0 && http_open_channel()) { + if (http_get_handle() == 0 && http_open_channel()) { if (http_send_request(ping_count) != 0) do_close_channel = true; kill_time = tick; } else { - server_error("Channel handle not zero"); - if (channel_handle != 0) do_close_channel = true; + server_error("Channel handle not zero or could not open channel"); + if (http_get_handle() != 0) do_close_channel = true; } } @@ -230,7 +229,7 @@ static void task_http(void *argument) { // Respond to unexpected channel closure if (channel_was_closed) { enum MvClosureReason reason = 0; - if (mvGetChannelClosureReason(channel_handle, &reason) == MV_STATUS_OKAY) { + if (mvGetChannelClosureReason(http_get_handle(), &reason) == MV_STATUS_OKAY) { server_log("Closure reason: %lu", (uint32_t)reason); } diff --git a/app/network.c b/app/network.c index 62fefb1..b0b7d91 100644 --- a/app/network.c +++ b/app/network.c @@ -1,6 +1,6 @@ /** * - * Microvisor HTTP Communications Demo + * Microvisor C Demos * * Copyright © 2024, KORE Wireless * Licence: MIT diff --git a/app/network.h b/app/network.h index f0e6cbc..0a2553a 100644 --- a/app/network.h +++ b/app/network.h @@ -1,6 +1,6 @@ /** * - * Microvisor HTTP Communications Demo + * Microvisor C Demos * * Copyright © 2024, KORE Wireless * Licence: MIT