diff --git a/CMakeLists.txt b/CMakeLists.txt index b26d4661..2e8a237d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -554,7 +554,11 @@ else() endif() -# TODO: Check if CPP is supported on ESP32 +# TODO: C++ support for ESP32 platform +if (WITH_CPP AND ESP_PLATFORM) + message(FATAL_ERROR "C++ support is not available for ESP32 platform!") +endif() + if (WITH_CPP AND NOT ESP_PLATFORM) # TODO: Tests # fntest/pubnub_fntest_medium.cpp diff --git a/freertos/pbpal_freertos_blocking_io.c b/freertos/pbpal_freertos_blocking_io.c index 4151ee45..b1da72ad 100644 --- a/freertos/pbpal_freertos_blocking_io.c +++ b/freertos/pbpal_freertos_blocking_io.c @@ -2,12 +2,13 @@ #include "pbpal.h" #include "pubnub_internal.h" +#include "pubnub_log.h" #include int pbpal_set_blocking_io(pubnub_t *pb) { - // TODO: WHATAHELL? + PUBNUB_LOG_WARNING("pbpal_set_blocking_io() - Unsupported\n"); return -1; } diff --git a/freertos/pbpal_resolv_and_connect_freertos_tcp.c b/freertos/pbpal_resolv_and_connect_freertos_tcp.c index 3bf360a4..edd77c10 100644 --- a/freertos/pbpal_resolv_and_connect_freertos_tcp.c +++ b/freertos/pbpal_resolv_and_connect_freertos_tcp.c @@ -22,7 +22,7 @@ enum pbpal_resolv_n_connect_result pbpal_resolv_and_connect(pubnub_t *pb) PUBNUB_ASSERT_OPT((pb->state == PBS_READY) || (pb->state == PBS_WAIT_DNS_SEND) || (pb->state == PBS_WAIT_DNS_RCV)); addr.sin_port = htons(HTTP_PORT); - // TODO: how to do this on ESP? + #if ESP_PLATFORM PUBNUB_LOG_TRACE("pbpal_resolv_and_connect: gethostbyname(%s)\n", PUBNUB_ORIGIN_SETTABLE ? pb->origin : PUBNUB_ORIGIN); @@ -45,6 +45,7 @@ enum pbpal_resolv_n_connect_result pbpal_resolv_and_connect(pubnub_t *pb) return pbpal_resolv_failed_processing; } #endif + pb->pal.socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (pb->pal.socket == SOCKET_INVALID) { return pbpal_connect_resource_failure; diff --git a/freertos/pubnub_config.h b/freertos/pubnub_config.h index 663f5109..e85527e3 100644 --- a/freertos/pubnub_config.h +++ b/freertos/pubnub_config.h @@ -161,7 +161,6 @@ #define PUBNUB_USE_AUTO_HEARTBEAT 1 #endif - #ifndef PUBNUB_USE_SSL /** If true (!=0), will enable SSL/TLS support. If false (==0), will disable SSL/TLS support. If not defined, will enable SSL/TLS diff --git a/mbedtls/pbpal_connect_mbedtls.c b/mbedtls/pbpal_connect_mbedtls.c index ffc569ef..3a303391 100644 --- a/mbedtls/pbpal_connect_mbedtls.c +++ b/mbedtls/pbpal_connect_mbedtls.c @@ -95,8 +95,6 @@ static const char* get_origin(pubnub_t* pb) #define PUBNUB_PORT "443" -// TODO: https://github.com/espressif/esp-idf/blob/v5.2.1/examples/protocols/https_mbedtls/main/https_mbedtls_example_main.c -// reference for mbedtls usage enum pbpal_tls_result pbpal_start_tls(pubnub_t* pb) { struct pubnub_pal* pal = &pb->pal; @@ -107,7 +105,6 @@ enum pbpal_tls_result pbpal_start_tls(pubnub_t* pb) alloc_setup(pb); -// TODO: Think about pubnub_config.h and where or which to use PUBNUB_ASSERT(SOCKET_INVALID != pb->pal.socket); PUBNUB_LOG_TRACE("pbpal_start_tls(pb=%p) socket=%d\n", pb, pb->pal.socket); diff --git a/mbedtls/pbpal_mbedtls.c b/mbedtls/pbpal_mbedtls.c index ab376fbd..3abac889 100644 --- a/mbedtls/pbpal_mbedtls.c +++ b/mbedtls/pbpal_mbedtls.c @@ -128,13 +128,18 @@ int pbpal_send_status(pubnub_t* pb) return 0; } + PUBNUB_LOG_TRACE("STATE = %d\n", pb->sock_state); + PUBNUB_LOG_TRACE("is sending %d\n", pb->sock_state == STATE_SENDING_DATA); PUBNUB_ASSERT(pb->sock_state == STATE_SENDING_DATA); + PUBNUB_LOG_TRACE("check for null"); if (NULL == pb->pal.ssl) { PUBNUB_LOG_ERROR("pbpal_send_status(pb=%p) called with NULL SSL context\n", pb); return -1; } + PUBNUB_LOG_TRACE("not a null"); + PUBNUB_LOG_TRACE("will write..."); if (0 >= (result = mbedtls_ssl_write(pb->pal.ssl, pb->ptr, pb->len))) { result = pbpal_handle_socket_condition(result, pb, __FILE__, __LINE__); } else { @@ -143,12 +148,14 @@ int pbpal_send_status(pubnub_t* pb) pb->len -= result; result = (0 == pb->len) ? 0 : +1; } + PUBNUB_LOG_TRACE("written"); if (0 >= result) { pb->sock_state = STATE_NONE; pb->unreadlen = 0; pb->ptr = (uint8_t*)pb->core.http_buf; } + PUBNUB_LOG_TRACE("sent"); return result; } @@ -338,27 +345,36 @@ int pbpal_close(pubnub_t* pb) if (pb->pal.ssl != NULL) { mbedtls_ssl_close_notify(pb->pal.ssl); + PUBNUB_LOG_TRACE("pb=%p: SSL session closed\n", pb); mbedtls_ssl_session_reset(pb->pal.ssl); + PUBNUB_LOG_TRACE("pb=%p: SSL reset\n", pb); mbedtls_ssl_free(pb->pal.ssl); pb->pal.ssl = NULL; + PUBNUB_LOG_TRACE("pb=%p: SSL context freed\n", pb); mbedtls_ssl_config_free(pb->pal.ssl_config); pb->pal.ssl_config = NULL; + PUBNUB_LOG_TRACE("pb=%p: SSL config freed\n", pb); mbedtls_net_free(pb->pal.server_fd); pb->pal.server_fd = NULL; + PUBNUB_LOG_TRACE("pb=%p: server_fd freed\n", pb); mbedtls_net_free(pb->pal.net); pb->pal.net = NULL; + PUBNUB_LOG_TRACE("pb=%p: net freed\n", pb); mbedtls_x509_crt_free(pb->pal.ca_certificates); pb->pal.ca_certificates = NULL; + PUBNUB_LOG_TRACE("pb=%p: ca_certificates freed\n", pb); mbedtls_entropy_free(pb->pal.entropy); pb->pal.entropy = NULL; + PUBNUB_LOG_TRACE("pb=%p: entropy freed\n", pb); mbedtls_ctr_drbg_free(pb->pal.ctr_drbg); pb->pal.ctr_drbg = NULL; + PUBNUB_LOG_TRACE("pb=%p: ctr_drbg freed\n", pb); } PUBNUB_LOG_TRACE("pb=%p: pbpal_close() returning 0\n", pb); diff --git a/mbedtls/pubnub_pal.h b/mbedtls/pubnub_pal.h index df40572e..29e5816c 100644 --- a/mbedtls/pubnub_pal.h +++ b/mbedtls/pubnub_pal.h @@ -18,8 +18,6 @@ struct pubnub_pal { mbedtls_entropy_context* entropy; mbedtls_ctr_drbg_context* ctr_drbg; pbmsref_t connection_timer; - - //TODO: is this socket needed? int socket; };