4#include <NimBLEDevice.h>
14#define BLE_TaskPriority 1
19#define BLE_CoreID CONFIG_BT_NIMBLE_PINNED_TO_CORE
22#define BLE_StackDepth 2048
25#define ConnectDelayInSeconds 5
76 void Drive(
const int16_t minPwrPerc,
const int16_t pwrPerc);
99 bool Connect(
const uint8_t watchdogTimeOutInTensOfSeconds);
111 virtual void NotifyCallback(NimBLERemoteCharacteristic *pBLERemoteCharacteristic, uint8_t *pData,
size_t length,
bool isNotify) = 0;
115 void dumpPData(uint8_t *pData,
size_t length);
BLEHubChannel
Definition BLEHubChannel.h:5
MessageType
Definition BLEHub.h:27
@ PORT_INPUT_FORMAT_SINGLE
@ PORT_INPUT_FORMAT_SETUP_COMBINEDMODE
@ PORT_OUTPUT_COMMAND_FEEDBACK
@ PORT_INPUT_FORMAT_COMBINEDMODE
@ PORT_MODE_INFORMATION_REQUEST
@ PORT_VALUE_COMBINEDMODE
@ PORT_INPUT_FORMAT_SETUP_SINGLE
@ PORT_INFORMATION_REQUEST
@ FW_UPDATE_GO_INTO_BOOT_MODE
@ FW_UPDATE_LOCK_STATUS_REQUEST
Definition BLEClientCallback.h:7
Definition BLEDeviceCallbacks.h:7
Definition BLEHubChannelController.h:10
Definition BLEHubConfiguration.h:46
bool _ebrake
Definition BLEHub.h:138
NimBLEAdvertisedDeviceCallbacks * _advertisedDeviceCallback
Definition BLEHub.h:134
NimBLERemoteService * _remoteControlService
Definition BLEHub.h:144
void SetHubLedColor(HubLedColor color)
Definition BLEHub.cpp:91
std::string GetRawAddress()
Definition BLEHub.cpp:47
void SetConnectCallback(std::function< void(bool)> callback)
Definition BLEHub.cpp:42
void initChannelControllers()
Definition BLEHub.cpp:218
bool attachCharacteristic(NimBLEUUID serviceUUID, NimBLEUUID characteristicUUID)
Definition BLEHub.cpp:270
void SetManualBrake(const bool enabled)
Definition BLEHub.cpp:102
void Execute(MCLocoAction *action)
Definition BLEHub.cpp:73
NimBLEAddress GetAddress()
Definition BLEHub.cpp:52
uint16_t _watchdogTimeOutInTensOfSeconds
Definition BLEHub.h:143
NimBLERemoteCharacteristic * _remoteControlCharacteristic
Definition BLEHub.h:145
void setTargetPwrPercByAttachedDevice(DeviceType device, int16_t minPwrPerc, int16_t pwrPerc)
Definition BLEHub.cpp:229
bool _blinkLights
Definition BLEHub.h:139
virtual void DriveTaskLoop()=0
bool _isConnected
Definition BLEHub.h:142
TaskHandle_t _driveTaskHandle
Definition BLEHub.h:132
BLEHub(BLEHubConfiguration *config)
Definition BLEHub.cpp:11
bool Connect(const uint8_t watchdogTimeOutInTensOfSeconds)
Definition BLEHub.cpp:136
HubLedColor getRawLedColorForController(BLEHubChannelController *controller)
Definition BLEHub.cpp:239
virtual void NotifyCallback(NimBLERemoteCharacteristic *pBLERemoteCharacteristic, uint8_t *pData, size_t length, bool isNotify)=0
void dumpPData(uint8_t *pData, size_t length)
Definition BLEHub.cpp:321
void Drive(const int16_t minPwrPerc, const int16_t pwrPerc)
Definition BLEHub.cpp:57
virtual int16_t MapPwrPercToRaw(int pwrPerc)=0
bool IsDiscovered()
Definition BLEHub.cpp:32
static void driveTaskImpl(void *)
Definition BLEHub.cpp:297
BLEHubChannelController * findControllerByChannel(BLEHubChannel channel)
Definition BLEHub.cpp:259
ulong _blinkUntil
Definition BLEHub.h:140
void connected()
Definition BLEHub.cpp:302
BLEHubConfiguration * _config
Definition BLEHub.h:129
std::function< void(bool)> _onConnectionChangedCallback
Definition BLEHub.h:127
virtual bool SetWatchdogTimeout(const uint8_t watchdogTimeOutInTensOfSeconds)=0
bool IsConnected()
Definition BLEHub.cpp:37
std::vector< BLEHubChannelController * > _channelControllers
Definition BLEHub.h:130
bool _mbrake
Definition BLEHub.h:137
NimBLEClient * _hub
Definition BLEHub.h:135
uint8_t getRawChannelPwrForController(BLEHubChannelController *controller)
Definition BLEHub.cpp:249
NimBLEAdvertisedDevice * _advertisedDevice
Definition BLEHub.h:133
int16_t GetCurrentDrivePwrPerc()
Definition BLEHub.cpp:62
bool startDriveTask()
Definition BLEHub.cpp:287
bool _isDiscovered
Definition BLEHub.h:141
void BlinkLights(int durationInMs)
Definition BLEHub.cpp:86
void disconnected()
Definition BLEHub.cpp:310
void SetEmergencyBrake(const bool enabled)
Definition BLEHub.cpp:120
NimBLEClientCallbacks * _clientCallback
Definition BLEHub.h:136
Definition MCLocoAction.h:9
HubLedColor
Definition enums.h:40
DeviceType
Definition enums.h:20
MTC4BTController * controller
Definition main.cpp:17