Include cleanup: components

This commit is contained in:
okaestne 2020-11-15 15:05:51 +01:00
parent c3475b92fa
commit 1516573df4
No known key found for this signature in database
GPG Key ID: 06A81B143EA9588F
35 changed files with 207 additions and 124 deletions

View File

@ -1,8 +1,7 @@
#include <drivers/include/nrfx_saadc.h> #include "BatteryController.h"
#include <hal/nrf_gpio.h> #include <hal/nrf_gpio.h>
#include <libraries/log/nrf_log.h> #include <libraries/log/nrf_log.h>
#include <algorithm> #include <algorithm>
#include "BatteryController.h"
using namespace Pinetime::Controllers; using namespace Pinetime::Controllers;

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <cstdint>
#include <drivers/include/nrfx_saadc.h> #include <drivers/include/nrfx_saadc.h>
namespace Pinetime { namespace Pinetime {
namespace Controllers { namespace Controllers {
class Battery { class Battery {

View File

@ -1,7 +1,7 @@
#include <systemtask/SystemTask.h>
#include "NotificationManager.h"
#include "AlertNotificationClient.h" #include "AlertNotificationClient.h"
#include <algorithm>
#include "NotificationManager.h"
#include "systemtask/SystemTask.h"
using namespace Pinetime::Controllers; using namespace Pinetime::Controllers;
constexpr ble_uuid16_t AlertNotificationClient::ansServiceUuid; constexpr ble_uuid16_t AlertNotificationClient::ansServiceUuid;
@ -159,8 +159,8 @@ void AlertNotificationClient::OnNotification(ble_gap_event *event) {
const auto maxBufferSize{maxMessageSize + headerSize}; const auto maxBufferSize{maxMessageSize + headerSize};
const auto dbgPacketLen = OS_MBUF_PKTLEN(event->notify_rx.om); const auto dbgPacketLen = OS_MBUF_PKTLEN(event->notify_rx.om);
size_t bufferSize = min(dbgPacketLen + stringTerminatorSize, maxBufferSize); size_t bufferSize = std::min(dbgPacketLen + stringTerminatorSize, maxBufferSize);
auto messageSize = min(maxMessageSize, (bufferSize - headerSize)); auto messageSize = std::min(maxMessageSize, (bufferSize - headerSize));
NotificationManager::Notification notif; NotificationManager::Notification notif;
os_mbuf_copydata(event->notify_rx.om, headerSize, messageSize - 1, notif.message.data()); os_mbuf_copydata(event->notify_rx.om, headerSize, messageSize - 1, notif.message.data());

View File

@ -1,13 +1,23 @@
#pragma once #pragma once
#include <cstdint> #include <cstdint>
#include <array> #include <functional>
#define min // workaround: nimble's min/max macros conflict with libstdc++
#define max
#include <host/ble_gap.h> #include <host/ble_gap.h>
#undef max
#undef min
#include "BleClient.h" #include "BleClient.h"
namespace Pinetime { namespace Pinetime {
namespace System {
class SystemTask;
}
namespace Controllers { namespace Controllers {
class NotificationManager;
class AlertNotificationClient : public BleClient { class AlertNotificationClient : public BleClient {
public: public:
explicit AlertNotificationClient(Pinetime::System::SystemTask &systemTask, explicit AlertNotificationClient(Pinetime::System::SystemTask &systemTask,

View File

@ -1,10 +1,9 @@
#include <hal/nrf_rtc.h>
#include "NotificationManager.h"
#include <systemtask/SystemTask.h>
#include "AlertNotificationService.h" #include "AlertNotificationService.h"
#include <hal/nrf_rtc.h>
#include <cstring> #include <cstring>
#include <algorithm>
#include "NotificationManager.h"
#include "systemtask/SystemTask.h"
using namespace Pinetime::Controllers; using namespace Pinetime::Controllers;
@ -60,8 +59,8 @@ int AlertNotificationService::OnAlert(uint16_t conn_handle, uint16_t attr_handle
const auto maxBufferSize{maxMessageSize + headerSize}; const auto maxBufferSize{maxMessageSize + headerSize};
const auto dbgPacketLen = OS_MBUF_PKTLEN(ctxt->om); const auto dbgPacketLen = OS_MBUF_PKTLEN(ctxt->om);
size_t bufferSize = min(dbgPacketLen + stringTerminatorSize, maxBufferSize); size_t bufferSize = std::min(dbgPacketLen + stringTerminatorSize, maxBufferSize);
auto messageSize = min(maxMessageSize, (bufferSize-headerSize)); auto messageSize = std::min(maxMessageSize, (bufferSize-headerSize));
NotificationManager::Notification notif; NotificationManager::Notification notif;
os_mbuf_copydata(ctxt->om, headerSize, messageSize-1, notif.message.data()); os_mbuf_copydata(ctxt->om, headerSize, messageSize-1, notif.message.data());

View File

@ -1,10 +1,20 @@
#pragma once #pragma once
#include <cstdint> #include <cstdint>
#include <array> #include <array>
#define min // workaround: nimble's min/max macros conflict with libstdc++
#define max
#include <host/ble_gap.h> #include <host/ble_gap.h>
#undef max
#undef min
namespace Pinetime { namespace Pinetime {
namespace System {
class SystemTask;
}
namespace Controllers { namespace Controllers {
class NotificationManager;
class AlertNotificationService { class AlertNotificationService {
public: public:
AlertNotificationService(Pinetime::System::SystemTask &systemTask, AlertNotificationService(Pinetime::System::SystemTask &systemTask,

View File

@ -1,5 +1,9 @@
#pragma once #pragma once
#define min // workaround: nimble's min/max macros conflict with libstdc++
#define max
#include <host/ble_gap.h> #include <host/ble_gap.h>
#undef max
#undef min
namespace Pinetime { namespace Pinetime {
namespace System { namespace System {

View File

@ -1,5 +1,3 @@
#include <cstring>
#include <cstdlib>
#include "BleController.h" #include "BleController.h"
using namespace Pinetime::Controllers; using namespace Pinetime::Controllers;

View File

@ -1,8 +1,7 @@
#pragma once #pragma once
#include <FreeRTOS.h>
#include <queue.h>
#include <array> #include <array>
#include <cstdint>
namespace Pinetime { namespace Pinetime {
namespace Controllers { namespace Controllers {

View File

@ -1,5 +1,6 @@
#include <hal/nrf_rtc.h>
#include "CurrentTimeClient.h" #include "CurrentTimeClient.h"
#include <hal/nrf_rtc.h>
#include "components/datetime/DateTimeController.h"
using namespace Pinetime::Controllers; using namespace Pinetime::Controllers;

View File

@ -1,13 +1,15 @@
#pragma once #pragma once
#include <cstdint> #define min // workaround: nimble's min/max macros conflict with libstdc++
#include <array> #define max
#include "components/datetime/DateTimeController.h"
#include "BleClient.h"
#include <host/ble_gap.h> #include <host/ble_gap.h>
#undef max
#undef min
#include <cstdint>
#include "BleClient.h"
namespace Pinetime { namespace Pinetime {
namespace Controllers { namespace Controllers {
class DateTime;
class CurrentTimeClient : public BleClient { class CurrentTimeClient : public BleClient {
public: public:

View File

@ -3,7 +3,11 @@
#include <array> #include <array>
#include "components/datetime/DateTimeController.h" #include "components/datetime/DateTimeController.h"
#define min // workaround: nimble's min/max macros conflict with libstdc++
#define max
#include <host/ble_gap.h> #include <host/ble_gap.h>
#undef max
#undef min
namespace Pinetime { namespace Pinetime {
namespace Controllers { namespace Controllers {

View File

@ -1,9 +1,10 @@
#pragma once #pragma once
#include <cstdint> #define min // workaround: nimble's min/max macros conflict with libstdc++
#include <array> #define max
#include <host/ble_gap.h> #include <host/ble_gap.h>
#include <Version.h> #undef max
#undef min
#include "Version.h"
namespace Pinetime { namespace Pinetime {
namespace Controllers { namespace Controllers {

View File

@ -1,8 +1,8 @@
#include <cstring>
#include "components/ble/BleController.h"
#include "systemtask/SystemTask.h"
#include "DfuService.h" #include "DfuService.h"
#include <cstring>
#include "components/ble/BleController.h"
#include "drivers/SpiNorFlash.h"
#include "systemtask/SystemTask.h"
using namespace Pinetime::Controllers; using namespace Pinetime::Controllers;

View File

@ -3,7 +3,11 @@
#include <cstdint> #include <cstdint>
#include <array> #include <array>
#define min // workaround: nimble's min/max macros conflict with libstdc++
#define max
#include <host/ble_gap.h> #include <host/ble_gap.h>
#undef max
#undef min
namespace Pinetime { namespace Pinetime {
namespace System { namespace System {

View File

@ -1,7 +1,7 @@
#include <systemtask/SystemTask.h>
#include <cstring>
#include "ImmediateAlertService.h" #include "ImmediateAlertService.h"
#include "AlertNotificationService.h" #include <cstring>
#include "NotificationManager.h"
#include "systemtask/SystemTask.h"
using namespace Pinetime::Controllers; using namespace Pinetime::Controllers;

View File

@ -1,5 +1,9 @@
#pragma once #pragma once
#define min // workaround: nimble's min/max macros conflict with libstdc++
#define max
#include <host/ble_gap.h> #include <host/ble_gap.h>
#undef max
#undef min
namespace Pinetime { namespace Pinetime {
namespace System { namespace System {

View File

@ -15,8 +15,8 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
#include <systemtask/SystemTask.h>
#include "MusicService.h" #include "MusicService.h"
#include "systemtask/SystemTask.h"
int MSCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) { int MSCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) {
auto musicService = static_cast<Pinetime::Controllers::MusicService *>(arg); auto musicService = static_cast<Pinetime::Controllers::MusicService *>(arg);

View File

@ -18,10 +18,13 @@
#pragma once #pragma once
#include <cstdint> #include <cstdint>
#include <array> #include <string>
#define min // workaround: nimble's min/max macros conflict with libstdc++
#define max
#include <host/ble_gap.h> #include <host/ble_gap.h>
#include <host/ble_uuid.h> #include <host/ble_uuid.h>
#include <string> #undef max
#undef min
//c7e50000-78fc-48fe-8e23-43b37a1942d0 //c7e50000-78fc-48fe-8e23-43b37a1942d0
#define MUSIC_SERVICE_UUID_BASE {0xd0, 0x42, 0x19, 0x3a, 0x3b, 0x43, 0x23, 0x8e, 0xfe, 0x48, 0xfc, 0x78, 0x00, 0x00, 0xe5, 0xc7} #define MUSIC_SERVICE_UUID_BASE {0xd0, 0x42, 0x19, 0x3a, 0x3b, 0x43, 0x23, 0x8e, 0xfe, 0x48, 0xfc, 0x78, 0x00, 0x00, 0xe5, 0xc7}

View File

@ -1,15 +1,19 @@
#include "components/datetime/DateTimeController.h"
#include <systemtask/SystemTask.h>
#include "components/ble/NotificationManager.h"
#include <hal/nrf_rtc.h>
#include "NimbleController.h" #include "NimbleController.h"
#include "MusicService.h" #include <hal/nrf_rtc.h>
#include <services/gatt/ble_svc_gatt.h> #define min // workaround: nimble's min/max macros conflict with libstdc++
#include <services/gap/ble_svc_gap.h> #define max
#include <host/util/util.h>
#include <host/ble_hs_id.h>
#include <host/ble_hs.h>
#include <host/ble_gap.h> #include <host/ble_gap.h>
#include <host/ble_hs.h>
#include <host/ble_hs_id.h>
#include <host/util/util.h>
#undef max
#undef min
#include <services/gap/ble_svc_gap.h>
#include <services/gatt/ble_svc_gatt.h>
#include "components/ble/BleController.h"
#include "components/ble/NotificationManager.h"
#include "components/datetime/DateTimeController.h"
#include "systemtask/SystemTask.h"
using namespace Pinetime::Controllers; using namespace Pinetime::Controllers;

View File

@ -2,24 +2,35 @@
#include <cstdint> #include <cstdint>
#include "AlertNotificationService.h" #define min // workaround: nimble's min/max macros conflict with libstdc++
#include "AlertNotificationClient.h" #define max
#include "DeviceInformationService.h"
#include "CurrentTimeClient.h"
#include "DfuService.h"
#include "CurrentTimeService.h"
#include "MusicService.h"
#include "BatteryInformationService.h"
#include "ImmediateAlertService.h"
#include "ServiceDiscovery.h"
#include <host/ble_gap.h> #include <host/ble_gap.h>
#undef max
#undef min
#include "AlertNotificationClient.h"
#include "AlertNotificationService.h"
#include "BatteryInformationService.h"
#include "CurrentTimeClient.h"
#include "CurrentTimeService.h"
#include "DeviceInformationService.h"
#include "DfuService.h"
#include "ImmediateAlertService.h"
#include "MusicService.h"
#include "ServiceDiscovery.h"
namespace Pinetime { namespace Pinetime {
namespace Drivers { namespace Drivers {
class SpiNorFlash; class SpiNorFlash;
} }
namespace System {
class SystemTask;
}
namespace Controllers { namespace Controllers {
class Ble;
class DateTime; class DateTime;
class NotificationManager;
class NimbleController { class NimbleController {

View File

@ -1,6 +1,6 @@
#include "NotificationManager.h"
#include <cstring> #include <cstring>
#include <algorithm> #include <algorithm>
#include "NotificationManager.h"
using namespace Pinetime::Controllers; using namespace Pinetime::Controllers;

View File

@ -2,6 +2,8 @@
#include <array> #include <array>
#include <atomic> #include <atomic>
#include <cstddef>
#include <cstdint>
namespace Pinetime { namespace Pinetime {
namespace Controllers { namespace Controllers {
@ -27,7 +29,7 @@ namespace Pinetime {
bool ClearNewNotificationFlag(); bool ClearNewNotificationFlag();
bool AreNewNotificationsAvailable(); bool AreNewNotificationsAvailable();
static constexpr uint8_t MaximumMessageSize() { return MessageSize; }; static constexpr size_t MaximumMessageSize() { return MessageSize; };
size_t NbNotifications() const; size_t NbNotifications() const;
private: private:

View File

@ -1,5 +1,7 @@
#include <libraries/log/nrf_log.h>
#include "ServiceDiscovery.h" #include "ServiceDiscovery.h"
#include <libraries/log/nrf_log.h>
#include "BleClient.h"
using namespace Pinetime::Controllers; using namespace Pinetime::Controllers;
ServiceDiscovery::ServiceDiscovery(std::array<BleClient*, 2>&& clients) : clients{clients} { ServiceDiscovery::ServiceDiscovery(std::array<BleClient*, 2>&& clients) : clients{clients} {

View File

@ -1,12 +1,12 @@
#pragma once #pragma once
#include <array> #include <array>
#include <functional> #include <cstdint>
#include <memory>
#include "BleClient.h"
namespace Pinetime { namespace Pinetime {
namespace Controllers { namespace Controllers {
class BleClient;
class ServiceDiscovery { class ServiceDiscovery {
public: public:
ServiceDiscovery(std::array<BleClient*, 2>&& bleClients); ServiceDiscovery(std::array<BleClient*, 2>&& bleClients);

View File

@ -1,5 +1,5 @@
#include <hal/nrf_gpio.h>
#include "BrightnessController.h" #include "BrightnessController.h"
#include <hal/nrf_gpio.h>
using namespace Pinetime::Controllers; using namespace Pinetime::Controllers;

View File

@ -1,8 +1,8 @@
#include <drivers/InternalFlash.h>
#include <hal/nrf_rtc.h>
#include "FirmwareValidator.h" #include "FirmwareValidator.h"
#include <hal/nrf_rtc.h>
#include "drivers/InternalFlash.h"
using namespace Pinetime::Controllers; using namespace Pinetime::Controllers;
bool FirmwareValidator::IsValidated() const { bool FirmwareValidator::IsValidated() const {

View File

@ -1,8 +1,5 @@
#include <libraries/svc/nrf_svci.h>
#include <FreeRTOS.h>
#include <task.h>
#include "Gfx.h" #include "Gfx.h"
#include "../../drivers/St7789.h" #include "drivers/St7789.h"
using namespace Pinetime::Components; using namespace Pinetime::Components;
Gfx::Gfx(Pinetime::Drivers::St7789 &lcd) : lcd{lcd} { Gfx::Gfx(Pinetime::Drivers::St7789 &lcd) : lcd{lcd} {

View File

@ -1,10 +1,10 @@
#pragma once #pragma once
#include <cstdint>
#include <nrf_font.h>
#include <drivers/BufferProvider.h>
#include <FreeRTOS.h> #include <FreeRTOS.h>
#include <nrf_font.h>
#include <task.h> #include <task.h>
#include <cstddef>
#include <cstdint>
#include "drivers/BufferProvider.h"
namespace Pinetime { namespace Pinetime {
namespace Drivers { namespace Drivers {

View File

@ -1,9 +1,8 @@
#include "NrfLogger.h"
#include <libraries/log/nrf_log.h>
#include <libraries/log/nrf_log_ctrl.h> #include <libraries/log/nrf_log_ctrl.h>
#include <libraries/log/nrf_log_default_backends.h> #include <libraries/log/nrf_log_default_backends.h>
#include <FreeRTOS.h>
#include <task.h>
#include <libraries/log/nrf_log.h>
#include "NrfLogger.h"
using namespace Pinetime::Logging; using namespace Pinetime::Logging;

View File

@ -1,6 +1,9 @@
#pragma once #pragma once
#include "Logger.h" #include "Logger.h"
#include <FreeRTOS.h>
#include <task.h>
namespace Pinetime { namespace Pinetime {
namespace Logging{ namespace Logging{
class NrfLogger : public Logger { class NrfLogger : public Logger {

View File

@ -1,32 +1,44 @@
// nrf
#include <hal/nrf_rtc.h>
#include <hal/nrf_wdt.h>
#include <legacy/nrf_drv_clock.h>
#include <libraries/gpiote/app_gpiote.h>
#include <libraries/timer/app_timer.h>
#include <softdevice/common/nrf_sdh.h>
// nimble
#define min // workaround: nimble's min/max macros conflict with libstdc++
#define max
#include <controller/ble_ll.h>
#include <host/ble_hs.h>
#include <host/util/util.h>
#include <nimble/nimble_port.h>
#include <nimble/nimble_port_freertos.h>
#include <nimble/npl_freertos.h>
#include <os/os_cputime.h>
#include <services/gap/ble_svc_gap.h>
#include <transport/ram/ble_hci_ram.h>
#undef max
#undef min
// FreeRTOS
#include <FreeRTOS.h> #include <FreeRTOS.h>
#include <task.h> #include <task.h>
#include <timers.h> #include <timers.h>
#include <legacy/nrf_drv_clock.h>
#include <hal/nrf_rtc.h>
#include <hal/nrf_wdt.h>
#include <os/os_cputime.h>
#include <libraries/timer/app_timer.h>
#include <libraries/gpiote/app_gpiote.h>
#include "displayapp/DisplayApp.h"
#include <softdevice/common/nrf_sdh.h>
#include "components/datetime/DateTimeController.h"
#include "components/battery/BatteryController.h" #include "components/battery/BatteryController.h"
#include "components/ble/BleController.h" #include "components/ble/BleController.h"
#include "components/ble/NotificationManager.h" #include "components/ble/NotificationManager.h"
#include <drivers/St7789.h> #include "components/datetime/DateTimeController.h"
#include <drivers/SpiMaster.h> #include "displayapp/DisplayApp.h"
#include <drivers/Spi.h>
#include "displayapp/LittleVgl.h" #include "displayapp/LittleVgl.h"
#include <systemtask/SystemTask.h> #include "drivers/Spi.h"
#include <nimble/nimble_port_freertos.h> #include "drivers/SpiMaster.h"
#include <nimble/npl_freertos.h> #include "drivers/SpiNorFlash.h"
#include <nimble/nimble_port.h> #include "drivers/St7789.h"
#include <host/ble_hs.h> #include "drivers/TwiMaster.h"
#include <controller/ble_ll.h> #include "drivers/Cst816s.h"
#include <transport/ram/ble_hci_ram.h> #include "systemtask/SystemTask.h"
#include <host/util/util.h>
#include <services/gap/ble_svc_gap.h>
#if NRF_LOG_ENABLED #if NRF_LOG_ENABLED
#include "logging/NrfLogger.h" #include "logging/NrfLogger.h"

View File

@ -2,6 +2,7 @@
#include <FreeRTOS.h> #include <FreeRTOS.h>
#include <timers.h> #include <timers.h>
#include <nrfx_gpiote.h>
void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action); void nrfx_gpiote_evt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action);
void DebounceTimerCallback(TimerHandle_t xTimer); void DebounceTimerCallback(TimerHandle_t xTimer);

View File

@ -1,19 +1,27 @@
#include <libraries/log/nrf_log.h> #include "SystemTask.h"
#include <libraries/gpiote/app_gpiote.h> #define min // workaround: nimble's min/max macros conflict with libstdc++
#include <drivers/Cst816s.h> #define max
#include "displayapp/LittleVgl.h" #include <host/ble_gap.h>
#include <hal/nrf_rtc.h>
#include "components/ble/NotificationManager.h"
#include <host/ble_gatt.h> #include <host/ble_gatt.h>
#include <host/ble_hs_adv.h> #include <host/ble_hs_adv.h>
#include "SystemTask.h"
#include <nimble/hci_common.h>
#include <host/ble_gap.h>
#include <host/util/util.h> #include <host/util/util.h>
#include <drivers/InternalFlash.h> #include <nimble/hci_common.h>
#undef max
#undef min
#include <hal/nrf_rtc.h>
#include <libraries/gpiote/app_gpiote.h>
#include <libraries/log/nrf_log.h>
#include "BootloaderVersion.h"
#include "components/ble/BleController.h"
#include "displayapp/LittleVgl.h"
#include "drivers/Cst816s.h"
#include "drivers/St7789.h"
#include "drivers/InternalFlash.h"
#include "drivers/SpiMaster.h"
#include "drivers/SpiNorFlash.h"
#include "drivers/TwiMaster.h"
#include "main.h" #include "main.h"
#include "components/ble/NimbleController.h"
#include "../BootloaderVersion.h"
using namespace Pinetime::System; using namespace Pinetime::System;

View File

@ -4,17 +4,23 @@
#include <FreeRTOS.h> #include <FreeRTOS.h>
#include <task.h> #include <task.h>
#include <drivers/SpiMaster.h> #include <timers.h>
#include <drivers/St7789.h>
#include "components/battery/BatteryController.h"
#include "displayapp/DisplayApp.h"
#include <drivers/Watchdog.h>
#include <drivers/SpiNorFlash.h>
#include "SystemMonitor.h" #include "SystemMonitor.h"
#include "components/battery/BatteryController.h"
#include "components/ble/NimbleController.h" #include "components/ble/NimbleController.h"
#include "timers.h" #include "components/ble/NotificationManager.h"
#include "displayapp/DisplayApp.h"
#include "drivers/Watchdog.h"
namespace Pinetime { namespace Pinetime {
namespace Drivers {
class Cst816S;
class SpiMaster;
class SpiNorFlash;
class St7789;
class TwiMaster;
}
namespace System { namespace System {
class SystemTask { class SystemTask {
public: public: