Loading system/test/rootcanal/bluetooth_hci.cc +7 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ namespace V1_1 { namespace sim { using android::hardware::hidl_vec; using ::bluetooth::hci::Address; using rootcanal::AsyncTaskId; using rootcanal::DualModeController; using rootcanal::HciDevice; Loading Loading @@ -109,7 +110,12 @@ Return<void> BluetoothHci::initialize_impl( char mac_property[PROPERTY_VALUE_MAX] = ""; property_get("vendor.bt.rootcanal_mac_address", mac_property, "3C:5A:B4:01:02:03"); controller_->Initialize({"dmc", std::string(mac_property)}); auto addr = Address::FromString(std::string(mac_property)); if (addr) { controller_->SetAddress(*addr); } else { LOG_ALWAYS_FATAL("Invalid address: %s", mac_property); } controller_->RegisterEventChannel( [this, cb](std::shared_ptr<std::vector<uint8_t>> packet) { Loading tools/rootcanal/model/controller/dual_mode_controller.cc +0 −11 Original line number Diff line number Diff line Loading @@ -38,17 +38,6 @@ constexpr uint16_t kLeMaximumDataLength = 64; constexpr uint16_t kLeMaximumDataTime = 0x148; // Device methods. void DualModeController::Initialize(const std::vector<std::string>& args) { if (args.size() < 2) return; Address addr{}; if (Address::FromString(args[1], addr)) { properties_.SetAddress(addr); } else { LOG_ALWAYS_FATAL("Invalid address: %s", args[1].c_str()); } }; std::string DualModeController::GetTypeString() const { return "Simulated Bluetooth Controller"; } Loading tools/rootcanal/model/controller/dual_mode_controller.h +0 −2 Original line number Diff line number Diff line Loading @@ -62,8 +62,6 @@ class DualModeController : public Device { ~DualModeController() = default; // Device methods. virtual void Initialize(const std::vector<std::string>& args) override; virtual std::string GetTypeString() const override; virtual void IncomingPacket( Loading tools/rootcanal/model/devices/beacon.cc +11 −11 Original line number Diff line number Diff line Loading @@ -40,6 +40,17 @@ Beacon::Beacon() { 'c'}); } Beacon::Beacon(const vector<std::string>& args) : Beacon() { if (args.size() >= 2) { Address addr{}; if (Address::FromString(args[1], addr)) properties_.SetLeAddress(addr); } if (args.size() >= 3) { SetAdvertisementInterval(std::chrono::milliseconds(std::stoi(args[2]))); } } std::string Beacon::GetTypeString() const { return "beacon"; } std::string Beacon::ToString() const { Loading @@ -49,17 +60,6 @@ std::string Beacon::ToString() const { return dev; } void Beacon::Initialize(const vector<std::string>& args) { if (args.size() < 2) return; Address addr{}; if (Address::FromString(args[1], addr)) properties_.SetLeAddress(addr); if (args.size() < 3) return; SetAdvertisementInterval(std::chrono::milliseconds(std::stoi(args[2]))); } void Beacon::TimerTick() { if (IsAdvertisementAvailable()) { last_advertisement_ = std::chrono::steady_clock::now(); Loading tools/rootcanal/model/devices/beacon.h +4 −4 Original line number Diff line number Diff line Loading @@ -27,9 +27,12 @@ namespace rootcanal { class Beacon : public Device { public: Beacon(); Beacon(const std::vector<std::string>& args); virtual ~Beacon() = default; static std::shared_ptr<Device> Create() { return std::make_shared<Beacon>(); } static std::shared_ptr<Device> Create(const std::vector<std::string>& args) { return std::make_shared<Beacon>(args); } // Return a string representation of the type of device. virtual std::string GetTypeString() const override; Loading @@ -37,9 +40,6 @@ class Beacon : public Device { // Return a string representation of the device. virtual std::string ToString() const override; // Set the address and advertising interval from string args. virtual void Initialize(const std::vector<std::string>& args) override; virtual void IncomingPacket( model::packets::LinkLayerPacketView packet) override; Loading Loading
system/test/rootcanal/bluetooth_hci.cc +7 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ namespace V1_1 { namespace sim { using android::hardware::hidl_vec; using ::bluetooth::hci::Address; using rootcanal::AsyncTaskId; using rootcanal::DualModeController; using rootcanal::HciDevice; Loading Loading @@ -109,7 +110,12 @@ Return<void> BluetoothHci::initialize_impl( char mac_property[PROPERTY_VALUE_MAX] = ""; property_get("vendor.bt.rootcanal_mac_address", mac_property, "3C:5A:B4:01:02:03"); controller_->Initialize({"dmc", std::string(mac_property)}); auto addr = Address::FromString(std::string(mac_property)); if (addr) { controller_->SetAddress(*addr); } else { LOG_ALWAYS_FATAL("Invalid address: %s", mac_property); } controller_->RegisterEventChannel( [this, cb](std::shared_ptr<std::vector<uint8_t>> packet) { Loading
tools/rootcanal/model/controller/dual_mode_controller.cc +0 −11 Original line number Diff line number Diff line Loading @@ -38,17 +38,6 @@ constexpr uint16_t kLeMaximumDataLength = 64; constexpr uint16_t kLeMaximumDataTime = 0x148; // Device methods. void DualModeController::Initialize(const std::vector<std::string>& args) { if (args.size() < 2) return; Address addr{}; if (Address::FromString(args[1], addr)) { properties_.SetAddress(addr); } else { LOG_ALWAYS_FATAL("Invalid address: %s", args[1].c_str()); } }; std::string DualModeController::GetTypeString() const { return "Simulated Bluetooth Controller"; } Loading
tools/rootcanal/model/controller/dual_mode_controller.h +0 −2 Original line number Diff line number Diff line Loading @@ -62,8 +62,6 @@ class DualModeController : public Device { ~DualModeController() = default; // Device methods. virtual void Initialize(const std::vector<std::string>& args) override; virtual std::string GetTypeString() const override; virtual void IncomingPacket( Loading
tools/rootcanal/model/devices/beacon.cc +11 −11 Original line number Diff line number Diff line Loading @@ -40,6 +40,17 @@ Beacon::Beacon() { 'c'}); } Beacon::Beacon(const vector<std::string>& args) : Beacon() { if (args.size() >= 2) { Address addr{}; if (Address::FromString(args[1], addr)) properties_.SetLeAddress(addr); } if (args.size() >= 3) { SetAdvertisementInterval(std::chrono::milliseconds(std::stoi(args[2]))); } } std::string Beacon::GetTypeString() const { return "beacon"; } std::string Beacon::ToString() const { Loading @@ -49,17 +60,6 @@ std::string Beacon::ToString() const { return dev; } void Beacon::Initialize(const vector<std::string>& args) { if (args.size() < 2) return; Address addr{}; if (Address::FromString(args[1], addr)) properties_.SetLeAddress(addr); if (args.size() < 3) return; SetAdvertisementInterval(std::chrono::milliseconds(std::stoi(args[2]))); } void Beacon::TimerTick() { if (IsAdvertisementAvailable()) { last_advertisement_ = std::chrono::steady_clock::now(); Loading
tools/rootcanal/model/devices/beacon.h +4 −4 Original line number Diff line number Diff line Loading @@ -27,9 +27,12 @@ namespace rootcanal { class Beacon : public Device { public: Beacon(); Beacon(const std::vector<std::string>& args); virtual ~Beacon() = default; static std::shared_ptr<Device> Create() { return std::make_shared<Beacon>(); } static std::shared_ptr<Device> Create(const std::vector<std::string>& args) { return std::make_shared<Beacon>(args); } // Return a string representation of the type of device. virtual std::string GetTypeString() const override; Loading @@ -37,9 +40,6 @@ class Beacon : public Device { // Return a string representation of the device. virtual std::string ToString() const override; // Set the address and advertising interval from string args. virtual void Initialize(const std::vector<std::string>& args) override; virtual void IncomingPacket( model::packets::LinkLayerPacketView packet) override; Loading