2
0

BellUtils.h 558 B

12345678910111213141516171819202122232425262728293031
  1. #ifndef EUPHONIUM_BELL_UTILS
  2. #define EUPHONIUM_BELL_UTILS
  3. #include <random>
  4. #include <string.h>
  5. #include <vector>
  6. namespace bell {
  7. std::string generateRandomUUID();
  8. void freeAndNull(void *&ptr);
  9. } // namespace bell
  10. #ifdef ESP_PLATFORM
  11. #include <freertos/FreeRTOS.h>
  12. #define BELL_SLEEP_MS(ms) vTaskDelay(ms / portTICK_PERIOD_MS)
  13. #define BELL_YIELD() taskYIELD()
  14. #elif defined(_WIN32)
  15. #define BELL_SLEEP_MS(ms) Sleep(ms)
  16. #define BELL_YIELD() ;
  17. #else
  18. #include <unistd.h>
  19. #define BELL_SLEEP_MS(ms) usleep(ms * 1000)
  20. #define BELL_YIELD() ;
  21. #endif
  22. #endif