Files
tactility/Tactility/Source/service/espnow/EspNow.cpp
T
Ken Van Hoeylandt f620255c41 New logging and more (#446)
- `TT_LOG_*` macros are replaced by `Logger` via `#include<Tactility/Logger.h>`
- Changed default timezone to Europe/Amsterdam
- Fix for logic bug in unPhone hardware
- Fix for init/deinit in DRV2605 driver
- Other fixes
- Removed optimization that broke unPhone (disabled the moving of heap-related functions to flash)
2026-01-06 22:35:39 +01:00

85 lines
1.9 KiB
C++

#ifdef ESP_PLATFORM
#include <sdkconfig.h>
#endif
#ifdef CONFIG_ESP_WIFI_ENABLED
#include <Tactility/service/espnow/EspNow.h>
#include <Tactility/service/espnow/EspNowService.h>
#include <Tactility/Logger.h>
namespace tt::service::espnow {
static const auto LOGGER = Logger("EspNow");
void enable(const EspNowConfig& config) {
auto service = findService();
if (service != nullptr) {
service->enable(config);
} else {
LOGGER.error("Service not found");
}
}
void disable() {
auto service = findService();
if (service != nullptr) {
service->disable();
} else {
LOGGER.error("Service not found");
}
}
bool isEnabled() {
auto service = findService();
if (service != nullptr) {
return service->isEnabled();
} else {
return false;
}
}
bool addPeer(const esp_now_peer_info_t& peer) {
auto service = findService();
if (service != nullptr) {
return service->addPeer(peer);
} else {
LOGGER.error("Service not found");
return false;
}
}
bool send(const uint8_t* address, const uint8_t* buffer, size_t bufferLength) {
auto service = findService();
if (service != nullptr) {
return service->send(address, buffer, bufferLength);
} else {
LOGGER.error("Service not found");
return false;
}
}
ReceiverSubscription subscribeReceiver(std::function<void(const esp_now_recv_info_t* receiveInfo, const uint8_t* data, int length)> onReceive) {
auto service = findService();
if (service != nullptr) {
return service->subscribeReceiver(onReceive);
} else {
LOGGER.error("Service not found");
return -1;
}
}
void unsubscribeReceiver(ReceiverSubscription subscription) {
auto service = findService();
if (service != nullptr) {
service->unsubscribeReceiver(subscription);
} else {
LOGGER.error("Service not found");
}
}
}
#endif // ESP_PLATFORM