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)
This commit is contained in:
committed by
GitHub
parent
719f7bcece
commit
f620255c41
@@ -1,4 +1,5 @@
|
||||
#include <Tactility/file/ObjectFile.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/service/gps/GpsService.h>
|
||||
#include <Tactility/service/ServicePaths.h>
|
||||
|
||||
@@ -9,16 +10,16 @@ using tt::hal::gps::GpsDevice;
|
||||
|
||||
namespace tt::service::gps {
|
||||
|
||||
constexpr const char* TAG = "GpsService";
|
||||
static const auto LOGGER = Logger("GpsService");
|
||||
|
||||
bool GpsService::getConfigurationFilePath(std::string& output) const {
|
||||
if (paths == nullptr) {
|
||||
TT_LOG_E(TAG, "Can't add configuration: service not started");
|
||||
LOGGER.error("Can't add configuration: service not started");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!file::findOrCreateDirectory(paths->getUserDataDirectory(), 0777)) {
|
||||
TT_LOG_E(TAG, "Failed to find or create path %s", paths->getUserDataDirectory().c_str());
|
||||
LOGGER.error("Failed to find or create path {}", paths->getUserDataDirectory());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -34,21 +35,21 @@ bool GpsService::getGpsConfigurations(std::vector<hal::gps::GpsConfiguration>& c
|
||||
|
||||
// If file does not exist, return empty list
|
||||
if (access(path.c_str(), F_OK) != 0) {
|
||||
TT_LOG_W(TAG, "No configurations (file not found: %s)", path.c_str());
|
||||
LOGGER.warn("No configurations (file not found: {})", path);
|
||||
return true;
|
||||
}
|
||||
|
||||
TT_LOG_I(TAG, "Reading configuration file %s", path.c_str());
|
||||
LOGGER.info("Reading configuration file {}", path);
|
||||
auto reader = file::ObjectFileReader(path, sizeof(hal::gps::GpsConfiguration));
|
||||
if (!reader.open()) {
|
||||
TT_LOG_E(TAG, "Failed to open configuration file");
|
||||
LOGGER.error("Failed to open configuration file");
|
||||
return false;
|
||||
}
|
||||
|
||||
hal::gps::GpsConfiguration configuration;
|
||||
while (reader.hasNext()) {
|
||||
if (!reader.readNext(&configuration)) {
|
||||
TT_LOG_E(TAG, "Failed to read configuration");
|
||||
LOGGER.error("Failed to read configuration");
|
||||
reader.close();
|
||||
return false;
|
||||
} else {
|
||||
@@ -67,12 +68,12 @@ bool GpsService::addGpsConfiguration(hal::gps::GpsConfiguration configuration) {
|
||||
|
||||
auto appender = file::ObjectFileWriter(path, sizeof(hal::gps::GpsConfiguration), 1, true);
|
||||
if (!appender.open()) {
|
||||
TT_LOG_E(TAG, "Failed to open/create configuration file");
|
||||
LOGGER.error("Failed to open/create configuration file");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!appender.write(&configuration)) {
|
||||
TT_LOG_E(TAG, "Failed to add configuration");
|
||||
LOGGER.error("Failed to add configuration");
|
||||
appender.close();
|
||||
return false;
|
||||
}
|
||||
@@ -89,7 +90,7 @@ bool GpsService::removeGpsConfiguration(hal::gps::GpsConfiguration configuration
|
||||
|
||||
std::vector<hal::gps::GpsConfiguration> configurations;
|
||||
if (!getGpsConfigurations(configurations)) {
|
||||
TT_LOG_E(TAG, "Failed to get gps configurations");
|
||||
LOGGER.error("Failed to get gps configurations");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -101,7 +102,7 @@ bool GpsService::removeGpsConfiguration(hal::gps::GpsConfiguration configuration
|
||||
|
||||
auto writer = file::ObjectFileWriter(path, sizeof(hal::gps::GpsConfiguration), 1, false);
|
||||
if (!writer.open()) {
|
||||
TT_LOG_E(TAG, "Failed to open configuration file");
|
||||
LOGGER.error("Failed to open configuration file");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <Tactility/service/gps/GpsService.h>
|
||||
|
||||
#include <Tactility/file/File.h>
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/Logger.h>
|
||||
#include <Tactility/service/ServicePaths.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
#include <Tactility/service/ServiceRegistration.h>
|
||||
@@ -10,7 +10,7 @@ using tt::hal::gps::GpsDevice;
|
||||
|
||||
namespace tt::service::gps {
|
||||
|
||||
constexpr const char* TAG = "GpsService";
|
||||
static const auto LOGGER = Logger("GpsService");
|
||||
extern const ServiceManifest manifest;
|
||||
|
||||
constexpr bool hasTimeElapsed(TickType_t now, TickType_t timeInThePast, TickType_t expireTimeInTicks) {
|
||||
@@ -73,7 +73,7 @@ void GpsService::onStop(ServiceContext& serviceContext) {
|
||||
}
|
||||
|
||||
bool GpsService::startGpsDevice(GpsDeviceRecord& record) {
|
||||
TT_LOG_I(TAG, "[device %lu] starting", record.device->getId());
|
||||
LOGGER.info("[device {}] starting", record.device->getId());
|
||||
|
||||
auto lock = mutex.asScopedLock();
|
||||
lock.lock();
|
||||
@@ -81,7 +81,7 @@ bool GpsService::startGpsDevice(GpsDeviceRecord& record) {
|
||||
auto device = record.device;
|
||||
|
||||
if (!device->start()) {
|
||||
TT_LOG_E(TAG, "[device %lu] starting failed", record.device->getId());
|
||||
LOGGER.error("[device {}] starting failed", record.device->getId());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ bool GpsService::startGpsDevice(GpsDeviceRecord& record) {
|
||||
}
|
||||
|
||||
bool GpsService::stopGpsDevice(GpsDeviceRecord& record) {
|
||||
TT_LOG_I(TAG, "[device %lu] stopping", record.device->getId());
|
||||
LOGGER.info("[device {}] stopping", record.device->getId());
|
||||
|
||||
auto device = record.device;
|
||||
|
||||
@@ -116,7 +116,7 @@ bool GpsService::stopGpsDevice(GpsDeviceRecord& record) {
|
||||
record.rmcSubscriptionId = -1;
|
||||
|
||||
if (!device->stop()) {
|
||||
TT_LOG_E(TAG, "[device %lu] stopping failed", record.device->getId());
|
||||
LOGGER.error("[device {}] stopping failed", record.device->getId());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -124,10 +124,10 @@ bool GpsService::stopGpsDevice(GpsDeviceRecord& record) {
|
||||
}
|
||||
|
||||
bool GpsService::startReceiving() {
|
||||
TT_LOG_I(TAG, "Start receiving");
|
||||
LOGGER.info("Start receiving");
|
||||
|
||||
if (getState() != State::Off) {
|
||||
TT_LOG_E(TAG, "Already receiving");
|
||||
LOGGER.error("Already receiving");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -140,13 +140,13 @@ bool GpsService::startReceiving() {
|
||||
|
||||
std::vector<hal::gps::GpsConfiguration> configurations;
|
||||
if (!getGpsConfigurations(configurations)) {
|
||||
TT_LOG_E(TAG, "Failed to get GPS configurations");
|
||||
LOGGER.error("Failed to get GPS configurations");
|
||||
setState(State::Off);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (configurations.empty()) {
|
||||
TT_LOG_E(TAG, "No GPS configurations");
|
||||
LOGGER.error("No GPS configurations");
|
||||
setState(State::Off);
|
||||
return false;
|
||||
}
|
||||
@@ -174,7 +174,7 @@ bool GpsService::startReceiving() {
|
||||
}
|
||||
|
||||
void GpsService::stopReceiving() {
|
||||
TT_LOG_I(TAG, "Stop receiving");
|
||||
LOGGER.info("Stop receiving");
|
||||
|
||||
setState(State::OffPending);
|
||||
|
||||
@@ -191,11 +191,11 @@ void GpsService::stopReceiving() {
|
||||
}
|
||||
|
||||
void GpsService::onGgaSentence(hal::Device::Id deviceId, const minmea_sentence_gga& gga) {
|
||||
TT_LOG_D(TAG, "[device %lu] LAT %f LON %f, satellites: %d", deviceId, minmea_tocoord(&gga.latitude), minmea_tocoord(&gga.longitude), gga.satellites_tracked);
|
||||
LOGGER.debug("[device {}] LAT {} LON {}, satellites: {}", deviceId, minmea_tocoord(&gga.latitude), minmea_tocoord(&gga.longitude), gga.satellites_tracked);
|
||||
}
|
||||
|
||||
void GpsService::onRmcSentence(hal::Device::Id deviceId, const minmea_sentence_rmc& rmc) {
|
||||
TT_LOG_D(TAG, "[device %lu] LAT %f LON %f, speed: %.2f", deviceId, minmea_tocoord(&rmc.latitude), minmea_tocoord(&rmc.longitude), minmea_tofloat(&rmc.speed));
|
||||
LOGGER.debug("[device {}] LAT {} LON {}, speed: {}", deviceId, minmea_tocoord(&rmc.latitude), minmea_tocoord(&rmc.longitude), minmea_tofloat(&rmc.speed));
|
||||
}
|
||||
|
||||
State GpsService::getState() const {
|
||||
|
||||
Reference in New Issue
Block a user