Skip to content

Commit

Permalink
Move BLE out of RobotController
Browse files Browse the repository at this point in the history
  • Loading branch information
YannLocatelli committed Feb 1, 2024
1 parent 8748b73 commit ac30fce
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 29 deletions.
41 changes: 41 additions & 0 deletions app/os/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
#include "rtos/ThisThread.h"
#include "rtos/Thread.h"

#include "BLEKit.h"
#include "BLEServiceBattery.h"
#include "BLEServiceCommands.h"
#include "BLEServiceConfig.h"
#include "BLEServiceDeviceInformation.h"
#include "BLEServiceFileExchange.h"
#include "BLEServiceMagicCard.h"
#include "BLEServiceMonitoring.h"
#include "BLEServiceUpdate.h"

#include "ActivityKit.h"
#include "ChooseReinforcer.h"
#include "CoreBattery.h"
Expand Down Expand Up @@ -281,6 +291,34 @@ auto motionkit = MotionKit {motors::left::motor, motors::right::motor, imukit, m
auto behaviorkit = BehaviorKit {videokit, ledkit, motors::left::motor, motors::right::motor};
auto reinforcerkit = ReinforcerKit {videokit, ledkit, motionkit};

namespace blekit {

BLEKit instance {};
namespace service {
BLEServiceBattery battery {};
BLEServiceCommands commands {};
BLEServiceDeviceInformation device_information {};
BLEServiceMonitoring monitoring {};
BLEServiceConfig config {};
BLEServiceMagicCard magic_card {};
BLEServiceFileExchange file_exchange {};
BLEServiceUpdate update {};

} // namespace service

auto services = std::to_array<interface::BLEService *>({
&service::battery,
&service::commands,
&service::device_information,
&service::monitoring,
&service::config,
&service::magic_card,
&service::file_exchange,
&service::update,
});

} // namespace blekit

namespace command {

namespace internal {
Expand Down Expand Up @@ -559,6 +597,9 @@ auto main() -> int
sd::init();
firmware::initializeFlash();

blekit::instance.setServices(blekit::services);
blekit::instance.init();

commandkit.registerCommand(command::list);
activitykit.registerActivities(activities::activities);

Expand Down
29 changes: 0 additions & 29 deletions libs/RobotKit/include/RobotController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@
#include "platform/mbed_power_mgmt.h"
#include "rtos/ThisThread.h"

#include "BLEKit.h"
#include "BLEServiceBattery.h"
#include "BLEServiceCommands.h"
#include "BLEServiceConfig.h"
#include "BLEServiceDeviceInformation.h"
#include "BLEServiceFileExchange.h"
#include "BLEServiceMagicCard.h"
#include "BLEServiceMonitoring.h"
#include "BLEServiceUpdate.h"

#include "ActivityKit.h"
#include "BatteryKit.h"
#include "BehaviorKit.h"
Expand Down Expand Up @@ -323,9 +313,6 @@ class RobotController : public interface::RobotController

_rfidkit.init();

_ble.setServices(services);
_ble.init();

auto _serial_number = _serialnumberkit.getSerialNumber();
_service_device_information.setSerialNumber(_serial_number);

Expand Down Expand Up @@ -588,22 +575,6 @@ class RobotController : public interface::RobotController

FileReception file_reception {};

BLEKit _ble {};

BLEServiceBattery _service_battery {};
BLEServiceCommands _service_commands {};
BLEServiceDeviceInformation _service_device_information {};
BLEServiceMonitoring _service_monitoring {};
BLEServiceConfig _service_config {};
BLEServiceMagicCard _service_magic_card {};
BLEServiceFileExchange _service_file_exchange {};
BLEServiceUpdate _service_update {};

std::array<interface::BLEService *, 8> services = {
&_service_battery, &_service_commands, &_service_device_information, &_service_monitoring,
&_service_config, &_service_magic_card, &_service_file_exchange, &_service_update,
};

uint8_t _emergency_stop_counter {0};
};

Expand Down

0 comments on commit ac30fce

Please sign in to comment.