network_status.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include "network_manager.h"
  3. #include "cJSON.h"
  4. #include "Configurator.h"
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. extern sys_Status status;
  9. char* network_status_alloc_get_ip_info_json();
  10. /**
  11. * @brief Tries to get access to json buffer mutex.
  12. *
  13. * The HTTP server can try to access the json to serve clients while the wifi manager thread can try
  14. * to update it. These two tasks are synchronized through a mutex.
  15. *
  16. * The mutex is used by both the access point list json and the connection status json.\n
  17. * These two resources should technically have their own mutex but we lose some flexibility to save
  18. * on memory.
  19. *
  20. * This is a simple wrapper around freeRTOS function xSemaphoreTake.
  21. *
  22. * @param xTicksToWait The time in ticks to wait for the semaphore to become available.
  23. * @return true in success, false otherwise.
  24. */
  25. bool network_status_lock_structure(TickType_t xTicksToWait);
  26. /**
  27. * @brief Releases the json buffer mutex.
  28. */
  29. void network_status_unlock_structure();
  30. /**
  31. * @brief Generates the connection status json: ssid and IP addresses.
  32. * @note This is not thread-safe and should be called only if network_status_lock_json_buffer call is successful.
  33. */
  34. void network_status_update_ip_info(sys_UPDATE_REASONS update_reason_code);
  35. void init_network_status();
  36. void destroy_network_status();
  37. void network_status_clear_ip();
  38. void network_status_safe_reset_sta_ip();
  39. #ifdef __cplusplus
  40. }
  41. #endif