Add use of DomoticaServer API for Bluetooth Addresses
This commit is contained in:
@@ -126,14 +126,14 @@ int main(int argc, char** argv)
|
|||||||
std::shared_ptr<PresenceDetection::Bluetooth::Device> pBluetoothDevice;
|
std::shared_ptr<PresenceDetection::Bluetooth::Device> pBluetoothDevice;
|
||||||
if (bluetooth)
|
if (bluetooth)
|
||||||
{
|
{
|
||||||
std::string devices;
|
std::string inventoryURL;
|
||||||
boost::optional<boost::property_tree::ptree&> bluetoothDevices = pt.get_child_optional("Bluetooth.Devices");
|
boost::optional<boost::property_tree::ptree&> bluetoothInventoryURL = pt.get_child_optional("Bluetooth.Inventory");
|
||||||
if (bluetoothDevices)
|
if (bluetoothInventoryURL)
|
||||||
devices = pt.get<std::string>("Bluetooth.Devices");
|
inventoryURL = pt.get<std::string>("Bluetooth.Inventory");
|
||||||
else
|
else
|
||||||
throw std::runtime_error("Bluetooth Devices directive missing in ini file.");
|
throw std::runtime_error("Bluetooth Inventory directive missing in ini file.");
|
||||||
|
|
||||||
pBluetoothDevice = std::make_shared<PresenceDetection::Bluetooth::Device>(devices, target);
|
pBluetoothDevice = std::make_shared<PresenceDetection::Bluetooth::Device>(inventoryURL, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
sigset_t wset;
|
sigset_t wset;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
#include "Util/JSON.h"
|
||||||
#include "Functions.h"
|
#include "Functions.h"
|
||||||
#include "Device.h"
|
#include "Device.h"
|
||||||
|
|
||||||
@@ -8,10 +9,16 @@
|
|||||||
namespace PresenceDetection {
|
namespace PresenceDetection {
|
||||||
namespace Bluetooth {
|
namespace Bluetooth {
|
||||||
|
|
||||||
Device::Device(const std::string& devices, const std::string& target) :
|
Device::Device(const std::string& inventoryURL, const std::string& target) :
|
||||||
m_target(target)
|
m_target(target)
|
||||||
{
|
{
|
||||||
boost::split(m_devices, devices, boost::is_any_of(","));
|
std::string devices = m_httpClient.GetUrlContents(inventoryURL);
|
||||||
|
Util::JSON json = Util::JSON::parse(devices);
|
||||||
|
|
||||||
|
for (auto& element : json)
|
||||||
|
if (element["bluetooth"] != "")
|
||||||
|
m_devices.push_back(element["bluetooth"]);
|
||||||
|
|
||||||
Start();
|
Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ namespace Bluetooth {
|
|||||||
class Device
|
class Device
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Device(const std::string& devices, const std::string& target);
|
Device(const std::string& inventoryURL, const std::string& target);
|
||||||
~Device();
|
~Device();
|
||||||
|
|
||||||
void Start();
|
void Start();
|
||||||
|
|||||||
@@ -11,4 +11,4 @@ Password =
|
|||||||
CookieFile = /tmp/UniFi_Cookies
|
CookieFile = /tmp/UniFi_Cookies
|
||||||
|
|
||||||
[Bluetooth]
|
[Bluetooth]
|
||||||
Devices =
|
Inventory =
|
||||||
|
|||||||
Reference in New Issue
Block a user