NeuralPi bug fixes.
This commit is contained in:
+2
-2
@@ -13,8 +13,8 @@ using BleDevice_Interfaces = sdbus::ProxyInterfaces<
|
||||
class BleDeviceProxy : public BleDevice_Interfaces
|
||||
{
|
||||
public:
|
||||
BleDeviceProxy(std::string destination, std::string path)
|
||||
: BleDevice_Interfaces(std::move(destination),std::move(path))
|
||||
BleDeviceProxy(std::string devicePath)
|
||||
: BleDevice_Interfaces("org.bluez",std::move(devicePath))
|
||||
{
|
||||
registerProxy();
|
||||
}
|
||||
|
||||
+63
-9
@@ -1,11 +1,18 @@
|
||||
#include "bluez_adaptor.h"
|
||||
#include "bluez.h"
|
||||
#include <thread>
|
||||
|
||||
#include "catch.hpp"
|
||||
#include "gsl/gsl"
|
||||
|
||||
#define TEST_UUID "6b49786f-271d-415d-8e2c-bd5ef8aa6f47"
|
||||
using TestAdvertisementInterfaces = sdbus::AdaptorInterfaces<org::bluez::LEAdvertisement1_adaptor>;
|
||||
|
||||
|
||||
static const char* SERVICE_NAME="com.twoplay.pipedal.onboarding";
|
||||
static const char* SERVICE_PATH="/com/twoplay/pipedal/onboarding";
|
||||
|
||||
|
||||
class TestAdvertisement: public TestAdvertisementInterfaces
|
||||
{
|
||||
private:
|
||||
@@ -18,7 +25,7 @@ public:
|
||||
}
|
||||
private:
|
||||
|
||||
virtual void Release() { delete this; }
|
||||
virtual void Release() { }
|
||||
|
||||
private:
|
||||
virtual std::string Type() { return "peripheral"; }
|
||||
@@ -40,19 +47,66 @@ private:
|
||||
|
||||
};
|
||||
|
||||
void RunService()
|
||||
{
|
||||
const char* SERVICE_NAME="com.twoplay.pipedal.onboarding";
|
||||
const char* SERVICE_PATH="/com/twoplay/pipedal/onboarding";
|
||||
|
||||
auto connector = sdbus::createSystemBusConnection(SERVICE_NAME);
|
||||
TestAdvertisement testAdvertisement(*connector,SERVICE_PATH);
|
||||
using namespace gsl;
|
||||
using namespace std;
|
||||
|
||||
}
|
||||
class TestServer {
|
||||
private:
|
||||
std::string devicePath;
|
||||
|
||||
std::unique_ptr<TestAdvertisement> advertisement;
|
||||
|
||||
private:
|
||||
|
||||
void ListenProc()
|
||||
{
|
||||
|
||||
}
|
||||
public:
|
||||
TestServer(const std::string &devicePath)
|
||||
: devicePath(devicePath)
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Run()
|
||||
{
|
||||
|
||||
auto connector = sdbus::createSystemBusConnection(SERVICE_NAME);
|
||||
std::unique_ptr<TestAdvertisement> advertisement = std::make_unique<TestAdvertisement>(*connector,SERVICE_PATH);
|
||||
|
||||
std::unique_ptr<org::bluez::BleDeviceProxy> device = std::make_unique<org::bluez::BleDeviceProxy>(devicePath);
|
||||
|
||||
|
||||
std::map<std::string,sdbus::Variant> advertisementOptions;
|
||||
device->RegisterAdvertisement(advertisement->getObjectPath(),advertisementOptions);
|
||||
|
||||
auto _ = finally([&device,&advertisement] {
|
||||
device->UnregisterAdvertisement(advertisement->getObjectPath());
|
||||
});
|
||||
|
||||
std::thread thread(
|
||||
[this] () {
|
||||
this->ListenProc();
|
||||
}
|
||||
);
|
||||
|
||||
thread.join();
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
TEST_CASE( "Bluetooth service", "[bluetooth_service]" ) {
|
||||
org::bluez::BleDeviceProxy device("org.bluez","/org/bluez/hci0");
|
||||
org::bluez::BleDeviceProxy device("/org/bluez/hci0");
|
||||
|
||||
auto includes = device.SupportedIncludes();
|
||||
|
||||
TestServer server {"/org/bluez/hci0"};
|
||||
|
||||
server.Run();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user