version 6.0.1
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ endif()
|
||||
project(PIP)
|
||||
set(PIP_MAJOR 6)
|
||||
set(PIP_MINOR 0)
|
||||
set(PIP_REVISION 0)
|
||||
set(PIP_REVISION 1)
|
||||
set(PIP_SUFFIX "")
|
||||
set(PIP_COMPANY SHS)
|
||||
set(PIP_DOMAIN org.SHS)
|
||||
|
||||
@@ -14,96 +14,57 @@ using namespace PIHTTP;
|
||||
|
||||
PIKbdListener kbd;
|
||||
|
||||
MessageMutable createMessage(Code c, const char * path, const MessageConst & msg) {
|
||||
piCout << "path" << path << "args" << msg.pathArguments();
|
||||
return MessageMutable().setCode(c);
|
||||
};
|
||||
int main(int argc, char * argv[]) {
|
||||
// piCout << "start ...";
|
||||
// PIHTTPServer server;
|
||||
// server.registerUnhandled([](const MessageConst & msg) { return createMessage(Code::BadRequest, "unhadled", msg); });
|
||||
// server.registerPath("api/v1/status", Method::Get, [](const MessageConst & msg) {
|
||||
// return createMessage(Code::Accepted, "api/v1/status", msg);
|
||||
// });
|
||||
// server.registerPath("api/v1/plugins", Method::Get, [](const MessageConst & msg) {
|
||||
// return createMessage(Code::Accepted, "api/v1/plugins", msg);
|
||||
// });
|
||||
// server.registerPath("api/v1/task-status", Method::Get, [](const MessageConst & msg) {
|
||||
// return createMessage(Code::Accepted, "api/v1/task-status", msg);
|
||||
// });
|
||||
// server.registerPath("api/v1/task/{taskID}/status", Method::Get, [](const MessageConst & msg) {
|
||||
// return createMessage(Code::Accepted, "api/v1/task/{taskID}/status", msg);
|
||||
// });
|
||||
// server.registerPath("api/v1/bort/list", Method::Get, [](const MessageConst & msg) {
|
||||
// return createMessage(Code::Accepted, "api/v1/bort/list", msg);
|
||||
// });
|
||||
// server.registerPath("api/v1/all", Method::Get, [](const MessageConst & msg) {
|
||||
// return createMessage(Code::Accepted, "api/v1/all", msg);
|
||||
// });
|
||||
// server.registerPath("api/v1/all/bort{A}/f", Method::Get, [](const MessageConst & msg) {
|
||||
// return createMessage(Code::Accepted, "api/v1/all/*/f", msg);
|
||||
// });
|
||||
// server.registerPath("api/v1/all2/**", Method::Get, [](const MessageConst & msg) {
|
||||
// return createMessage(Code::Accepted, "api/v1/all2/**", msg);
|
||||
// });
|
||||
// server.listenAll(12345);
|
||||
PIEthernet tcp(PIEthernet::TCP_Server);
|
||||
tcp.setReadAddress("0.0.0.0:26000");
|
||||
CONNECTL(&tcp, newConnection, [](PIEthernet * c) { piCout << "New client" << c; });
|
||||
piForTimes(10) {
|
||||
piCout << "\nlisten";
|
||||
tcp.listen(true);
|
||||
3_s .sleep();
|
||||
piCout << "stop" << tcp.isOpened();
|
||||
tcp.stopThreadedListen();
|
||||
100_ms .sleep();
|
||||
}
|
||||
return 0;
|
||||
|
||||
// kbd.enableExitCapture('Q');
|
||||
// WAIT_FOR_EXIT
|
||||
// piCout << "exiting ...";
|
||||
// server.stop();
|
||||
// piCout << "ifconfigPath:" << PISystemInfo::instance()->ifconfigPath;
|
||||
// piCout << " execCommand:" << PISystemInfo::instance()->execCommand;
|
||||
// piCout << " hostname:" << PISystemInfo::instance()->hostname;
|
||||
// piCout << " user:" << PISystemInfo::instance()->user;
|
||||
// piCout << " OS_name:" << PISystemInfo::instance()->OS_name;
|
||||
// piCout << " OS_version:" << PISystemInfo::instance()->OS_version;
|
||||
// piCout << "architecture:" << PISystemInfo::instance()->architecture;
|
||||
// piCout << "execDateTime:" << PISystemInfo::instance()->execDateTime;
|
||||
|
||||
// piCout << PISystemInfo::instance()->processorsCount << PISystemInfo::instance()->processorsCountP
|
||||
// << PISystemInfo::instance()->processorsCountE;
|
||||
// piCout << "hello мир!"_u8;
|
||||
// PISerial ser("/dev/ttyUSB0");
|
||||
// ser.open();
|
||||
// return 0;
|
||||
|
||||
// PISystemMonitor mon;
|
||||
// mon.startOnSelf();
|
||||
// PISystemMonitor::totalRAM();
|
||||
// 2_s .sleep();
|
||||
|
||||
// return 0;
|
||||
PIMQTT::Client cl;
|
||||
cl.setConnectTimeout(2_s);
|
||||
|
||||
cl.subscribe("api/v1/all/bort{A}/f",
|
||||
[](const PIMQTT::MessageConst & msg) { piCout << "1" << msg.topicList() << msg.pathArguments() << msg.body().size(); });
|
||||
cl.subscribe("api/v1/all/task{T}/f",
|
||||
[](const PIMQTT::MessageConst & msg) { piCout << "2" << msg.topicList() << msg.pathArguments() << msg.body().size(); });
|
||||
cl.subscribe("api/v1/all/*/f",
|
||||
[](const PIMQTT::MessageConst & msg) { piCout << "3" << msg.topicList() << msg.pathArguments() << msg.body().size(); });
|
||||
cl.subscribe("api/v1/all2/**",
|
||||
[](const PIMQTT::MessageConst & msg) { piCout << "4" << msg.topicList() << msg.pathArguments() << msg.body().size(); });
|
||||
CONNECTL(&cl, connected, [&cl] {
|
||||
piCout << "connected";
|
||||
// cl.subscribe("api/v1/plugins");
|
||||
// cl.subscribe("api/v1/task-status");
|
||||
// cl.subscribe("api/v1/*/{taskID}/status");
|
||||
// cl.subscribe("api/v1/bort/list");
|
||||
// cl.subscribe("api/v1/all");
|
||||
// cl.subscribe("/zigbee2mqtt");
|
||||
// cl.subscribe("/zigbee2mqtt/+/status/");
|
||||
// cl.subscribe("/zigbee2mqtt/*/status/");
|
||||
// cl.subscribe("test/#");
|
||||
// cl.subscribe("#");
|
||||
// cl.unsubscribe("/zigbee2mqtt");
|
||||
// cl.unsubscribe("api/v1/all/bort{A}/f");
|
||||
// cl.unsubscribe("api/v1/all/*/f");
|
||||
// cl.publish("/zigbee2mqtt/abc", "hello from PIP"_a.toAscii());
|
||||
});
|
||||
CONNECTL(&cl, disconnected, [&cl](PIMQTT::Error code) {
|
||||
piCout << "disconnected code" << (int)code;
|
||||
cl.connect("localhost", "PIP");
|
||||
});
|
||||
CONNECTL(&cl, receivedUnhandled, [](const PIMQTT::MessageConst & message) {
|
||||
piCout << "receivedUnhandled" << message.topic() << message.pathArguments() << message.payload().size();
|
||||
});
|
||||
|
||||
cl.connect("localhost", "PIP");
|
||||
|
||||
piSleep(6.);
|
||||
cl.unsubscribeAll();
|
||||
int i = 0;
|
||||
PIThreadPoolLoop pool(8);
|
||||
pool.setPowerPolicy(PIThread::ppEfficiency);
|
||||
pool.setFunction([&i](int) { i = piHash(i); });
|
||||
pool.start(0, 0x7FFFFFFF);
|
||||
piSleep(10);
|
||||
// PIVector<PIThread *> threads;
|
||||
// for (int i = 0; i < 8; ++i) {
|
||||
// threads << new PIThread();
|
||||
// }
|
||||
// for (auto * t: threads) {
|
||||
// t->setPowerPolicy(PIThread::ppPerformance);
|
||||
// t->start([&i] { i = piHash(i); });
|
||||
// }
|
||||
// piSleep(10);
|
||||
// for (auto * t: threads) {
|
||||
// t->stopAndWait();
|
||||
// }
|
||||
// piDeleteAllAndClear(threads);
|
||||
return 0;
|
||||
|
||||
kbd.enableExitCapture('Q');
|
||||
WAIT_FOR_EXIT
|
||||
|
||||
piCout << "exiting ...";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user