Test.cc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #include "Bluetooth/Functions.h"
  2. #include "Logic/Logic.h"
  3. #include "WiFi/Functions.h"
  4. #include <INIReader.h>
  5. #include <algorithm>
  6. #include <iostream>
  7. #include <string>
  8. void print()
  9. {
  10. std::cout << "Print" << std::endl;
  11. }
  12. void TestINIReader()
  13. {
  14. std::cout << "--------------------------------" << std::endl;
  15. std::cout << "TestINIReader" << std::endl << std::endl;
  16. INIReader reader("PresenceDetection.ini");
  17. std::string target = reader.Get("PresenceDetection", "Target", "");
  18. if (!target.empty())
  19. std::cout << "Error" << std::endl;
  20. std::cout << target.size() << " " << target << std::endl;
  21. bool wifi = reader.GetBoolean("PresenceDetection", "WiFi", false);
  22. if (wifi)
  23. std::cout << "WiFi On" << std::endl;
  24. else
  25. std::cout << "WiFi Off" << std::endl;
  26. bool test = reader.GetBoolean("PresenceDetection", "Test", false);
  27. if (test)
  28. std::cout << "Test On" << std::endl;
  29. else
  30. std::cout << "Test Off" << std::endl;
  31. std::cout << "--------------------------------" << std::endl << std::endl;
  32. }
  33. void TestLogic()
  34. {
  35. std::cout << "--------------------------------" << std::endl;
  36. std::cout << "TestLogic" << std::endl << std::endl;
  37. PresenceDetection::Logic::Logic logic("http://DomoticaPi:8080/api/inventory/WirelessDevice");
  38. logic.LoadDevicesFromConfiguration();
  39. logic.UpdateDevicesFromInventory();
  40. logic.DumpDevices();
  41. std::cout << "--------------------------------" << std::endl << std::endl;
  42. }
  43. void TestPing()
  44. {
  45. std::cout << "--------------------------------" << std::endl;
  46. std::cout << "TestPing" << std::endl << std::endl;
  47. bool wifi = PresenceDetection::WiFi::Functions::Ping("192.168.1.174");
  48. if (wifi)
  49. std::cout << "192.168.1.174 Online" << std::endl;
  50. else
  51. std::cout << "192.168.1.174 Offline" << std::endl;
  52. bool bluetooth = PresenceDetection::Bluetooth::Functions::Ping("64:C7:53:77:2A:32");
  53. if (bluetooth)
  54. std::cout << "64:C7:53:77:2A:32 Online" << std::endl;
  55. else
  56. std::cout << "64:C7:53:77:2A:32 Offline" << std::endl;
  57. bluetooth = PresenceDetection::Bluetooth::Functions::Ping("C8:BC:C8:22:94:68");
  58. if (bluetooth)
  59. std::cout << "C8:BC:C8:22:94:68 Online" << std::endl;
  60. else
  61. std::cout << "C8:BC:C8:22:94:68 Offline" << std::endl;
  62. bluetooth = PresenceDetection::Bluetooth::Functions::Ping("E8:9E:B4:25:E1:E8");
  63. if (bluetooth)
  64. std::cout << "E8:9E:B4:25:E1:E8 Online" << std::endl;
  65. else
  66. std::cout << "E8:9E:B4:25:E1:E8 Offline" << std::endl;
  67. std::cout << "--------------------------------" << std::endl << std::endl;
  68. }
  69. int main(int /*argc*/, char** /*argv[]*/)
  70. {
  71. //TestINIReader();
  72. //TestLogic();
  73. TestPing();
  74. return 0;
  75. }