Various improvements (#264)
- Replace C function pointers with C++ `std::function` in `Thread`, `Timer` and `DispatcherThread` - Rename `SystemEvent`-related functions - WiFi: fix auto-connect when WiFi disconnects from bad signal - WiFi: fix auto-connect when WiFi fails to auto-connect - WiFi: implement disconnect() when tapping connected WiFi ap in WiFi management app
This commit is contained in:
committed by
GitHub
parent
d72852a6e2
commit
3f1bfee3f5
@@ -2,7 +2,9 @@
|
||||
|
||||
#include "RtosCompatTimers.h"
|
||||
#include "Thread.h"
|
||||
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
|
||||
namespace tt {
|
||||
|
||||
@@ -10,7 +12,8 @@ class Timer {
|
||||
|
||||
public:
|
||||
|
||||
typedef void (*Callback)(std::shared_ptr<void> context);
|
||||
typedef std::function<void()> Callback;
|
||||
// typedef std::function<void(uint32_t)> PendingCallback;
|
||||
typedef void (*PendingCallback)(void* context, uint32_t arg);
|
||||
|
||||
private:
|
||||
@@ -22,7 +25,6 @@ private:
|
||||
};
|
||||
|
||||
Callback callback;
|
||||
std::shared_ptr<void> callbackContext;
|
||||
std::unique_ptr<std::remove_pointer_t<TimerHandle_t>, TimerHandleDeleter> handle;
|
||||
|
||||
static void onCallback(TimerHandle_t hTimer);
|
||||
@@ -42,9 +44,8 @@ public:
|
||||
/**
|
||||
* @param[in] type The timer type
|
||||
* @param[in] callback The callback function
|
||||
* @param callbackContext The callback context
|
||||
*/
|
||||
Timer(Type type, Callback callback, std::shared_ptr<void> callbackContext = nullptr);
|
||||
Timer(Type type, Callback callback);
|
||||
|
||||
~Timer();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user