added doxygen
This commit is contained in:
		| @ -1,3 +1,13 @@ | |||||||
|  | /** | ||||||
|  | * @file HTTPS_Client.c | ||||||
|  | * @brief Used to download the OTA image from the server | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * Additional Infos: Connects via HTTPS and HTTPS Basic Auth to the Server. | ||||||
|  | * Downloads the image in segments | ||||||
|  | */ | ||||||
|  |  | ||||||
| #include "HTTPS_Client.h" | #include "HTTPS_Client.h" | ||||||
|  |  | ||||||
| static const char *TAG = "https_client"; | static const char *TAG = "https_client"; | ||||||
| @ -17,6 +27,16 @@ https_client_ret_t errHTTPSClientConnectToServer(void); | |||||||
| https_client_ret_t errHTTPSClientValidateServer(void); | https_client_ret_t errHTTPSClientValidateServer(void); | ||||||
| https_client_ret_t errHTTPSClientSendRequest(void); | https_client_ret_t errHTTPSClientSendRequest(void); | ||||||
|  |  | ||||||
|  | /** | ||||||
|  | * @fn https_client_ret_t errHTTPSClientInitialize(void) | ||||||
|  | * @brief Initialize the client | ||||||
|  | * @param void | ||||||
|  | * @return HTTPS_Client error code | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * Initialize embedTLS | ||||||
|  | */ | ||||||
| https_client_ret_t errHTTPSClientInitialize(void) | https_client_ret_t errHTTPSClientInitialize(void) | ||||||
| { | { | ||||||
|     https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK; |     https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK; | ||||||
| @ -31,6 +51,18 @@ https_client_ret_t errHTTPSClientInitialize(void) | |||||||
|     return i32RetHTTPClient; |     return i32RetHTTPClient; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  | * @fn https_client_ret_t errHTTPSClientRetrieveData(char* const cpu8Data, const uint32_t* const cpcu32DataLenght, uint32_t* pu32BytesRead) | ||||||
|  | * @brief receive a image segment from server | ||||||
|  | * @param cpu8Data data buffer | ||||||
|  | * @param cpcu32DataLenght desired byte amount | ||||||
|  | * @param pu32BytesRead actual received byte amount  | ||||||
|  | * @return HTTPS_Client error code | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * Read segement and handle all events like EOF or timeout | ||||||
|  | */ | ||||||
| https_client_ret_t errHTTPSClientRetrieveData(char* const cpu8Data, const uint32_t* const cpcu32DataLenght, uint32_t* pu32BytesRead) | https_client_ret_t errHTTPSClientRetrieveData(char* const cpu8Data, const uint32_t* const cpcu32DataLenght, uint32_t* pu32BytesRead) | ||||||
| { | { | ||||||
|     https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK; |     https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK; | ||||||
| @ -86,6 +118,16 @@ https_client_ret_t errHTTPSClientRetrieveData(char* const cpu8Data, const uint32 | |||||||
|     return i32RetHTTPClient; |     return i32RetHTTPClient; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  | * @fn https_client_ret_t errHTTPSClientReset(void) | ||||||
|  | * @brief reset client for next receive of image | ||||||
|  | * @param void | ||||||
|  | * @return HTTPS_Client error code | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * reset session | ||||||
|  | */ | ||||||
| https_client_ret_t errHTTPSClientReset(void) | https_client_ret_t errHTTPSClientReset(void) | ||||||
| { | { | ||||||
|     https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK; |     https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK; | ||||||
| @ -103,9 +145,18 @@ https_client_ret_t errHTTPSClientReset(void) | |||||||
|     return i32RetHTTPClient; |     return i32RetHTTPClient; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  | * @fn https_client_ret_t https_clientInitEmbedTLS(void) | ||||||
|  | * @brief init embedTLS | ||||||
|  | * @param void | ||||||
|  | * @return HTTPS_Client error code | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * attach certs for tls | ||||||
|  | */ | ||||||
| https_client_ret_t https_clientInitEmbedTLS(void) | https_client_ret_t https_clientInitEmbedTLS(void) | ||||||
| { | { | ||||||
|  |  | ||||||
|     https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK; |     https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK; | ||||||
|     int32_t i32RetEmbedTLS = ESP_OK; |     int32_t i32RetEmbedTLS = ESP_OK; | ||||||
|     static bool bAlreadySetup = false; |     static bool bAlreadySetup = false; | ||||||
| @ -168,20 +219,13 @@ https_client_ret_t https_clientInitEmbedTLS(void) | |||||||
|                     i32RetEmbedTLS = mbedtls_ssl_setup(&sHTTPS_ClientConfig.ssl, &sHTTPS_ClientConfig.conf); //call this only once |                     i32RetEmbedTLS = mbedtls_ssl_setup(&sHTTPS_ClientConfig.ssl, &sHTTPS_ClientConfig.conf); //call this only once | ||||||
|                     if(i32RetEmbedTLS != ESP_OK) |                     if(i32RetEmbedTLS != ESP_OK) | ||||||
|                         { |                         { | ||||||
|                             ESP_LOGE(TAG, "mbedtls_ssl_setup returned 0x%x\n\n", i32RetEmbedTLS); |                             ESP_LOGE(TAG, "mbedtls_ssl_setup returned 0x%x\n", i32RetEmbedTLS); | ||||||
|  |  | ||||||
|                             // uint8_t buffer[20]; |  | ||||||
|                             //mbedtls_strerror(i32RetEmbedTLS, buffer, 20); |  | ||||||
|                             //ESP_LOGE(TAG, "%s", buffer); |  | ||||||
|                         } |                         } | ||||||
|                     else |                     else | ||||||
|                         { |                         { | ||||||
|                             bAlreadySetup = true; |                             bAlreadySetup = true; | ||||||
|                         } |                         } | ||||||
|  |  | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|  |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     if(i32RetEmbedTLS == ESP_OK) |     if(i32RetEmbedTLS == ESP_OK) | ||||||
| @ -197,6 +241,16 @@ https_client_ret_t https_clientInitEmbedTLS(void) | |||||||
|     return i32RetHTTPClient; |     return i32RetHTTPClient; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  | * @fn https_client_ret_t errHTTPSClientConnectToServer(void) | ||||||
|  | * @brief connect to server | ||||||
|  | * @param void | ||||||
|  | * @return HTTPS_Client error code | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * open TLS session | ||||||
|  | */ | ||||||
| https_client_ret_t errHTTPSClientConnectToServer(void) | https_client_ret_t errHTTPSClientConnectToServer(void) | ||||||
| { | { | ||||||
|     https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK; |     https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK; | ||||||
| @ -230,6 +284,16 @@ https_client_ret_t errHTTPSClientConnectToServer(void) | |||||||
|     return i32RetHTTPClient; |     return i32RetHTTPClient; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  | * @fn https_client_ret_t errHTTPSClientValidateServer(void) | ||||||
|  | * @brief validate server | ||||||
|  | * @param void | ||||||
|  | * @return HTTPS_Client error code | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * check CDN and cert | ||||||
|  | */ | ||||||
| https_client_ret_t errHTTPSClientValidateServer(void) | https_client_ret_t errHTTPSClientValidateServer(void) | ||||||
| { | { | ||||||
|     https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK; |     https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK; | ||||||
| @ -248,6 +312,16 @@ https_client_ret_t errHTTPSClientValidateServer(void) | |||||||
|     return i32RetHTTPClient; |     return i32RetHTTPClient; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  | * @fn https_client_ret_t errHTTPSClientSendRequest(void) | ||||||
|  | * @brief send request to server | ||||||
|  | * @param void | ||||||
|  | * @return HTTPS_Client error code | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * send HTTP GET request | ||||||
|  | */ | ||||||
| https_client_ret_t errHTTPSClientSendRequest(void) | https_client_ret_t errHTTPSClientSendRequest(void) | ||||||
| { | { | ||||||
|     https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK; |     https_client_ret_t i32RetHTTPClient = HTTPS_CLIENT_OK; | ||||||
|  | |||||||
| @ -1,9 +1,16 @@ | |||||||
|  | /** | ||||||
|  | * @file Mesh_Network.c | ||||||
|  | * @brief Mesh network layer used by OTA and APP | ||||||
|  | * @author Hendrik Schutter, init based in ESP32-IDE code | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * Additional Infos: Start network and send and receive data. | ||||||
|  | */ | ||||||
|  |  | ||||||
| #include "Mesh_Network.h" | #include "Mesh_Network.h" | ||||||
|  |  | ||||||
| static const char *LOG_TAG = "mesh_network"; | static const char *LOG_TAG = "mesh_network"; | ||||||
|  |  | ||||||
|  |  | ||||||
| //w: errMeshNetworkInitialize | //w: errMeshNetworkInitialize | ||||||
| //r: errMeshNetworkInitialize;vMeshNetworkGetOwnAddr;errMeshNetworkGetChildren | //r: errMeshNetworkInitialize;vMeshNetworkGetOwnAddr;errMeshNetworkGetChildren | ||||||
| uint8_t u8ownMAC[6]; | uint8_t u8ownMAC[6]; | ||||||
| @ -30,7 +37,17 @@ void (*pOTAChildConnectHandle)(const uint8_t* const); | |||||||
| void (*pOTAMessageHandle)(const MESH_PACKET_t* const); | void (*pOTAMessageHandle)(const MESH_PACKET_t* const); | ||||||
| void (*pChangeStateOfServerWorkerHandle)(const bool ); | void (*pChangeStateOfServerWorkerHandle)(const bool ); | ||||||
|  |  | ||||||
| esp_err_t errMeshNetworkInitialize() | /** | ||||||
|  | * @fn esp_err_t errMeshNetworkInitialize() | ||||||
|  | * @brief Starts the mesh network | ||||||
|  | * @param void | ||||||
|  | * @return ESP32 error code | ||||||
|  | * @author Hendrik Schutter, init based in ESP32-IDE code | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * Initialize the network | ||||||
|  | */ | ||||||
|  | esp_err_t errMeshNetworkInitialize(void) | ||||||
| { | { | ||||||
|     //init module variables |     //init module variables | ||||||
|     esp_err_t err; |     esp_err_t err; | ||||||
| @ -107,6 +124,16 @@ esp_err_t errMeshNetworkInitialize() | |||||||
|     return ESP_OK; |     return ESP_OK; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  | * @fn esp_err_t errMeshNetworkInitializeWiFi() | ||||||
|  | * @brief Starts the WiFI | ||||||
|  | * @param void | ||||||
|  | * @return ESP32 error code | ||||||
|  | * @author Hendrik Schutter, init based in ESP32-IDE code | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * start the wifi | ||||||
|  | */ | ||||||
| esp_err_t errMeshNetworkInitializeWiFi() | esp_err_t errMeshNetworkInitializeWiFi() | ||||||
| { | { | ||||||
| //wifi initialization | //wifi initialization | ||||||
| @ -119,6 +146,16 @@ esp_err_t errMeshNetworkInitializeWiFi() | |||||||
|     return err; |     return err; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  | * @fn esp_err_t errMeshNetworkInitializeRouter(mesh_cfg_t* cfg) | ||||||
|  | * @brief Starts the router | ||||||
|  | * @param cfg router config | ||||||
|  | * @return ESP32 error code | ||||||
|  | * @author Hendrik Schutter, init based in ESP32-IDE code | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * Initialize the network | ||||||
|  | */ | ||||||
| esp_err_t errMeshNetworkInitializeRouter(mesh_cfg_t* cfg) | esp_err_t errMeshNetworkInitializeRouter(mesh_cfg_t* cfg) | ||||||
| { | { | ||||||
| //router initialization | //router initialization | ||||||
| @ -131,24 +168,56 @@ esp_err_t errMeshNetworkInitializeRouter(mesh_cfg_t* cfg) | |||||||
|     return err; |     return err; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  | * @fn esp_err_t errMeshNetworkSetChildConnectedHandle(void (*pChildConnectHandleTmp)(const uint8_t* const cpcu8Data)) | ||||||
|  | * @brief set callback for event when child connects | ||||||
|  | * @param (*pChildConnectHandleTmp)(const uint8_t* const cpcu8Data) function pointer | ||||||
|  | * @return ESP32 error code | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | */ | ||||||
| esp_err_t errMeshNetworkSetChildConnectedHandle(void (*pChildConnectHandleTmp)(const uint8_t* const cpcu8Data)) | esp_err_t errMeshNetworkSetChildConnectedHandle(void (*pChildConnectHandleTmp)(const uint8_t* const cpcu8Data)) | ||||||
| { | { | ||||||
|     pOTAChildConnectHandle = pChildConnectHandleTmp; |     pOTAChildConnectHandle = pChildConnectHandleTmp; | ||||||
|     return ESP_OK; |     return ESP_OK; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  | * @fn esp_err_t errMeshNetworkSetAppReceiveHandle(void (*pAppRxHandleTmp)(const uint8_t* const cpcu8Data, const uint8_t* const pu8Sender)) | ||||||
|  | * @brief set callback for event when application data is received | ||||||
|  | * @param (*pAppRxHandleTmp)(const uint8_t* const cpcu8Data, const uint8_t* const pu8Sender) function pointer | ||||||
|  | * @return ESP32 error code | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | */ | ||||||
| esp_err_t errMeshNetworkSetAppReceiveHandle(void (*pAppRxHandleTmp)(const uint8_t* const cpcu8Data, const uint8_t* const pu8Sender)) | esp_err_t errMeshNetworkSetAppReceiveHandle(void (*pAppRxHandleTmp)(const uint8_t* const cpcu8Data, const uint8_t* const pu8Sender)) | ||||||
| { | { | ||||||
|     pAppRxHandle = pAppRxHandleTmp; //set handle from app as receive handle if an app packet is received |     pAppRxHandle = pAppRxHandleTmp; //set handle from app as receive handle if an app packet is received | ||||||
|     return ESP_OK; |     return ESP_OK; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  | * @fn esp_err_t errMeshNetworkSetOTAMessageHandleHandle(void (*pOTAMessageHandleTmp)(const MESH_PACKET_t* const cpcuMeshPacket)) | ||||||
|  | * @brief set callback for event when OTA message is received | ||||||
|  | * @param (*pOTAMessageHandleTmp)(const MESH_PACKET_t* const cpcuMeshPacket) function pointer | ||||||
|  | * @return ESP32 error code | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | */ | ||||||
| esp_err_t errMeshNetworkSetOTAMessageHandleHandle(void (*pOTAMessageHandleTmp)(const MESH_PACKET_t* const cpcuMeshPacket)) | esp_err_t errMeshNetworkSetOTAMessageHandleHandle(void (*pOTAMessageHandleTmp)(const MESH_PACKET_t* const cpcuMeshPacket)) | ||||||
| { | { | ||||||
|     pOTAMessageHandle = pOTAMessageHandleTmp; |     pOTAMessageHandle = pOTAMessageHandleTmp; | ||||||
|     return ESP_OK; |     return ESP_OK; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  | * @fn esp_err_t errMeshNetworkSetChangeStateOfServerWorkerHandle(void (*pChangeStateOfServerWorkerHandleTmp)(const bool cbState)) | ||||||
|  | * @brief set callback for event when connectify to server is changed | ||||||
|  | * @param (*pChangeStateOfServerWorkerHandleTmp)(const bool cbState) function pointer | ||||||
|  | * @return ESP32 error code | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | */ | ||||||
| esp_err_t errMeshNetworkSetChangeStateOfServerWorkerHandle(void (*pChangeStateOfServerWorkerHandleTmp)(const bool cbState)) | esp_err_t errMeshNetworkSetChangeStateOfServerWorkerHandle(void (*pChangeStateOfServerWorkerHandleTmp)(const bool cbState)) | ||||||
| { | { | ||||||
|     pChangeStateOfServerWorkerHandle = pChangeStateOfServerWorkerHandleTmp; |     pChangeStateOfServerWorkerHandle = pChangeStateOfServerWorkerHandleTmp; | ||||||
|  | |||||||
| @ -1,8 +1,28 @@ | |||||||
|  |  | ||||||
|  | /** | ||||||
|  | * @file Mesh_Network_Handler.c | ||||||
|  | * @brief Handler for events from mesh network (no messages) | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * Additional Infos: IP event received or parrent or child connected or disconnected | ||||||
|  | */ | ||||||
|  |  | ||||||
| #include "Mesh_Network.h" | #include "Mesh_Network.h" | ||||||
|  |  | ||||||
| static const char *LOG_TAG = "mesh_network_handler"; | static const char *LOG_TAG = "mesh_network_handler"; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  | * @fn void vMeshNetworkIpEventHandler(void *arg, esp_event_base_t event_base, int32_t i32EventID, void *vpEventData) | ||||||
|  | * @brief received an IP event | ||||||
|  | * @param arg | ||||||
|  | * @param event_base | ||||||
|  | * @param i32EventID | ||||||
|  | * @param vpEventData | ||||||
|  | * @return void | ||||||
|  | * @author ESP-IDF | ||||||
|  | * @date 20.01.2021 | ||||||
|  | */ | ||||||
| void vMeshNetworkIpEventHandler(void *arg, esp_event_base_t event_base, int32_t i32EventID, void *vpEventData) | void vMeshNetworkIpEventHandler(void *arg, esp_event_base_t event_base, int32_t i32EventID, void *vpEventData) | ||||||
| { | { | ||||||
|     ip_event_got_ip_t *event = (ip_event_got_ip_t *) vpEventData; |     ip_event_got_ip_t *event = (ip_event_got_ip_t *) vpEventData; | ||||||
| @ -13,6 +33,17 @@ void vMeshNetworkIpEventHandler(void *arg, esp_event_base_t event_base, int32_t | |||||||
|         } |         } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  | * @fn void vMeshNetworkMeshEventHandler(void *arg, esp_event_base_t event_base, int32_t i32EventID, void* vpEventData) | ||||||
|  | * @brief received an mesh event | ||||||
|  | * @param arg | ||||||
|  | * @param event_base | ||||||
|  | * @param i32EventID | ||||||
|  | * @param vpEventData | ||||||
|  | * @return void | ||||||
|  | * @author ESP-IDF | ||||||
|  | * @date 20.01.2021 | ||||||
|  | */ | ||||||
| void vMeshNetworkMeshEventHandler(void *arg, esp_event_base_t event_base, int32_t i32EventID, void* vpEventData) | void vMeshNetworkMeshEventHandler(void *arg, esp_event_base_t event_base, int32_t i32EventID, void* vpEventData) | ||||||
| { | { | ||||||
|     mesh_addr_t id = {0,}; |     mesh_addr_t id = {0,}; | ||||||
|  | |||||||
| @ -1,3 +1,13 @@ | |||||||
|  | /** | ||||||
|  | * @file HTTPS_Client.h | ||||||
|  | * @brief Used to download the OTA image from the server | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * Additional Infos: Connects via HTTPS and HTTPS Basic Auth to the Server. | ||||||
|  | * Downloads the image in segments | ||||||
|  | */ | ||||||
|  |  | ||||||
| #ifndef H_HTTPS_CLIENT | #ifndef H_HTTPS_CLIENT | ||||||
| #define H_HTTPS_CLIENT | #define H_HTTPS_CLIENT | ||||||
|  |  | ||||||
|  | |||||||
| @ -1,13 +1,32 @@ | |||||||
|  | /** | ||||||
|  | * @file Blinky_LED.c | ||||||
|  | * @brief Demo application using the mesh network | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * Additional Infos: If button "BOOT" on ESP32-Module is pressed, all LED2 (blue) in the network will toggle the state. | ||||||
|  | */ | ||||||
|  |  | ||||||
| #include "Blinky_LED.h" | #include "Blinky_LED.h" | ||||||
|  |  | ||||||
| static const char *LOG_TAG = "blinky_led"; | static const char *LOG_TAG = "blinky_led"; | ||||||
| static bool bLEDisOn = false; //set led default off | static bool bLEDisOn = false; //set led default off | ||||||
| static mesh_addr_t addrParent;  //addr of parent node | static mesh_addr_t addrParent; //addr of parent node | ||||||
| static mesh_addr_t childrenAddr[CONFIG_MESH_ROUTE_TABLE_SIZE]; //array of children attached to this node | static mesh_addr_t childrenAddr[CONFIG_MESH_ROUTE_TABLE_SIZE]; //array of children attached to this node | ||||||
| static uint16_t u16ChildrenSize; //number of children attached to this node | static uint16_t u16ChildrenSize; //number of children attached to this node | ||||||
| xQueueHandle queueBlinkyLEDPackets; //handle for led action queue | xQueueHandle queueBlinkyLEDPackets; //handle for led action queue | ||||||
|  |  | ||||||
| esp_err_t errBlinkyLEDInitialize() | /** | ||||||
|  | * @fn esp_err_t errBlinkyLEDInitialize() | ||||||
|  | * @brief Starts the demp app | ||||||
|  | * @param void | ||||||
|  | * @return ESP32 error code | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * Initialize the queue and starts the tasks | ||||||
|  | */ | ||||||
|  | esp_err_t errBlinkyLEDInitialize(void) | ||||||
| { | { | ||||||
|     esp_err_t err = ESP_OK; |     esp_err_t err = ESP_OK; | ||||||
|     BaseType_t xReturned; |     BaseType_t xReturned; | ||||||
| @ -45,7 +64,17 @@ esp_err_t errBlinkyLEDInitialize() | |||||||
|     return err; |     return err; | ||||||
| } | } | ||||||
|  |  | ||||||
| void vGPIOInitialize() | /** | ||||||
|  | * @fn void vGPIOInitialize(void) | ||||||
|  | * @brief sets the GPIO pins to correct modes | ||||||
|  | * @param void | ||||||
|  | * @return void | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * Initialize GPIO | ||||||
|  | */ | ||||||
|  | void vGPIOInitialize(void) | ||||||
| { | { | ||||||
|     gpio_config_t gpioConf; |     gpio_config_t gpioConf; | ||||||
|  |  | ||||||
| @ -62,6 +91,17 @@ void vGPIOInitialize() | |||||||
|     gpio_config(&gpioConf); |     gpio_config(&gpioConf); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  | * @fn void rxHandle(const uint8_t* const pu8Data, const uint8_t* const pu8Sender) | ||||||
|  | * @brief callback handler from mesh network layer | ||||||
|  | * @param pu8Data data received | ||||||
|  | * @param pu8Sender sender node from data | ||||||
|  | * @return void | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * Adds the data into queue | ||||||
|  | */ | ||||||
| void rxHandle(const uint8_t* const pu8Data, const uint8_t* const pu8Sender) | void rxHandle(const uint8_t* const pu8Data, const uint8_t* const pu8Sender) | ||||||
| { | { | ||||||
|     //send payload to app queue |     //send payload to app queue | ||||||
| @ -74,6 +114,16 @@ void rxHandle(const uint8_t* const pu8Data, const uint8_t* const pu8Sender) | |||||||
|         } |         } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  | * @fn void vTaskReadUserInput(void *arg) | ||||||
|  | * @brief FreeRTOS task reading the user input (button) | ||||||
|  | * @param args parameter for task | ||||||
|  | * @return void | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * Adds a button press to the queue | ||||||
|  | */ | ||||||
| void vTaskReadUserInput(void *arg) | void vTaskReadUserInput(void *arg) | ||||||
| { | { | ||||||
|     esp_err_t err = ESP_OK; |     esp_err_t err = ESP_OK; | ||||||
| @ -129,6 +179,16 @@ void vTaskReadUserInput(void *arg) | |||||||
|         } |         } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  | * @fn void vTaskReceiveData(void *arg) | ||||||
|  | * @brief FreeRTOS task reading queue and setting the LED | ||||||
|  | * @param args parameter for task | ||||||
|  | * @return void | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * Sets the LED off or on based on data in queue | ||||||
|  | */ | ||||||
| void vTaskReceiveData(void *arg) | void vTaskReceiveData(void *arg) | ||||||
| { | { | ||||||
|     esp_err_t err = ESP_OK; |     esp_err_t err = ESP_OK; | ||||||
|  | |||||||
| @ -1,3 +1,12 @@ | |||||||
|  | /** | ||||||
|  | * @file Blinky_LED.h | ||||||
|  | * @brief Demo application using the mesh network | ||||||
|  | * @author Hendrik Schutter | ||||||
|  | * @date 20.01.2021 | ||||||
|  | * | ||||||
|  | * Additional Infos: If button "BOOT" on ESP32-Module is pressed, all LED2 (blue) in the network will toggle the state. | ||||||
|  | */ | ||||||
|  |  | ||||||
| #ifndef H_BLINKY_LED | #ifndef H_BLINKY_LED | ||||||
| #define H_BLINKY_LED | #define H_BLINKY_LED | ||||||
|  |  | ||||||
| @ -29,8 +38,8 @@ struct blinky_packet | |||||||
|  |  | ||||||
| typedef struct blinky_packet BLINKY_PACKET_t; | typedef struct blinky_packet BLINKY_PACKET_t; | ||||||
|  |  | ||||||
| esp_err_t errBlinkyLEDInitialize(); | esp_err_t errBlinkyLEDInitialize(void); | ||||||
| void vGPIOInitialize(); | void vGPIOInitialize(void); | ||||||
| void rxHandle(const uint8_t* const pu8Data, const uint8_t* const pu8Sender); | void rxHandle(const uint8_t* const pu8Data, const uint8_t* const pu8Sender); | ||||||
| void vTaskReadUserInput(void *arg); | void vTaskReadUserInput(void *arg); | ||||||
| void vTaskReceiveData(void *arg); | void vTaskReceiveData(void *arg); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user