97 lines
2.5 KiB
C++
97 lines
2.5 KiB
C++
#include "Bluetooth/Functions.h"
|
|
#include "Logic/Logic.h"
|
|
#include "WiFi/Functions.h"
|
|
#include <INIReader.h>
|
|
#include <algorithm>
|
|
#include <iostream>
|
|
#include <string>
|
|
|
|
|
|
void print()
|
|
{
|
|
std::cout << "Print" << std::endl;
|
|
}
|
|
|
|
void TestINIReader()
|
|
{
|
|
std::cout << "--------------------------------" << std::endl;
|
|
std::cout << "TestINIReader" << std::endl << std::endl;
|
|
|
|
INIReader reader("PresenceDetection.ini");
|
|
|
|
std::string target = reader.Get("PresenceDetection", "Target", "");
|
|
if (!target.empty())
|
|
std::cout << "Error" << std::endl;
|
|
std::cout << target.size() << " " << target << std::endl;
|
|
|
|
bool wifi = reader.GetBoolean("PresenceDetection", "WiFi", false);
|
|
if (wifi)
|
|
std::cout << "WiFi On" << std::endl;
|
|
else
|
|
std::cout << "WiFi Off" << std::endl;
|
|
|
|
bool test = reader.GetBoolean("PresenceDetection", "Test", false);
|
|
if (test)
|
|
std::cout << "Test On" << std::endl;
|
|
else
|
|
std::cout << "Test Off" << std::endl;
|
|
|
|
std::cout << "--------------------------------" << std::endl << std::endl;
|
|
}
|
|
|
|
void TestLogic()
|
|
{
|
|
std::cout << "--------------------------------" << std::endl;
|
|
std::cout << "TestLogic" << std::endl << std::endl;
|
|
|
|
PresenceDetection::Logic::Logic logic("http://DomoticaPi:8080/api/inventory/WirelessDevice");
|
|
|
|
logic.LoadDevicesFromConfiguration();
|
|
logic.UpdateDevicesFromInventory();
|
|
|
|
logic.DumpDevices();
|
|
|
|
std::cout << "--------------------------------" << std::endl << std::endl;
|
|
}
|
|
|
|
void TestPing()
|
|
{
|
|
std::cout << "--------------------------------" << std::endl;
|
|
std::cout << "TestPing" << std::endl << std::endl;
|
|
|
|
bool wifi = PresenceDetection::WiFi::Functions::Ping("192.168.1.174");
|
|
if (wifi)
|
|
std::cout << "192.168.1.174 Online" << std::endl;
|
|
else
|
|
std::cout << "192.168.1.174 Offline" << std::endl;
|
|
|
|
bool bluetooth = PresenceDetection::Bluetooth::Functions::Ping("64:C7:53:77:2A:32");
|
|
if (bluetooth)
|
|
std::cout << "64:C7:53:77:2A:32 Online" << std::endl;
|
|
else
|
|
std::cout << "64:C7:53:77:2A:32 Offline" << std::endl;
|
|
|
|
bluetooth = PresenceDetection::Bluetooth::Functions::Ping("C8:BC:C8:22:94:68");
|
|
if (bluetooth)
|
|
std::cout << "C8:BC:C8:22:94:68 Online" << std::endl;
|
|
else
|
|
std::cout << "C8:BC:C8:22:94:68 Offline" << std::endl;
|
|
|
|
bluetooth = PresenceDetection::Bluetooth::Functions::Ping("E8:9E:B4:25:E1:E8");
|
|
if (bluetooth)
|
|
std::cout << "E8:9E:B4:25:E1:E8 Online" << std::endl;
|
|
else
|
|
std::cout << "E8:9E:B4:25:E1:E8 Offline" << std::endl;
|
|
|
|
std::cout << "--------------------------------" << std::endl << std::endl;
|
|
}
|
|
|
|
int main(int /*argc*/, char** /*argv[]*/)
|
|
{
|
|
//TestINIReader();
|
|
//TestLogic();
|
|
TestPing();
|
|
|
|
return 0;
|
|
}
|