aqhome: more work on new event/ipc interface.

This commit is contained in:
Martin Preuss
2025-02-26 20:59:20 +01:00
parent f63079af11
commit 8968f14122
34 changed files with 1233 additions and 126 deletions

View File

@@ -23,8 +23,8 @@
#include "aqhome/ipc2/nodemsgreader.h"
#include "aqhome/ipc2/msgreader.h"
#include "aqhome/ipc2/msgwriter.h"
#include "aqhome/ipc2/nodeendpoint.h"
#include "aqhome/ipc2/endpoint.h"
#include "aqhome/ipc2/tty_endpoint.h"
#include "aqhome/aqhome.h"
@@ -480,7 +480,7 @@ int testTty(int argc, char **argv)
int fd;
AQH_OBJECT *ttyReadObject;
AQH_OBJECT *msgReaderObject;
AQH_OBJECT *nodeEndpointObject;
AQH_OBJECT *endpointObject;
int rv;
if (argc<2) {
@@ -504,7 +504,7 @@ int testTty(int argc, char **argv)
ttyReadObject=AQH_TtyObject_new(eventLoop, fd, AQH_FDOBJECT_FDMODE_READ);
AQH_FdObject_FlushInput(ttyReadObject);
msgReaderObject=AQH_NodeMsgReader_new(eventLoop, ttyReadObject);
nodeEndpointObject=AQH_NodeEndpoint_new(eventLoop, msgReaderObject, NULL);
endpointObject=AQH_Endpoint_new(eventLoop, msgReaderObject, NULL);
AQH_Object_Enable(msgReaderObject);
@@ -517,6 +517,44 @@ int testTty(int argc, char **argv)
int testTty2(int argc, char **argv)
{
const char *deviceName;
AQH_EVENT_LOOP *eventLoop;
struct termios initialTermiosState;
int fd;
AQH_OBJECT *endpointObject;
int rv;
if (argc<2) {
fprintf(stderr, "Missing device name\n");
return 1;
}
rv=AQH_Init();
if (rv<0) {
}
deviceName=argv[1];
eventLoop=AQH_EventLoop_new();
fd=AQH_TtyObject_OpenAndInitDevice(deviceName, &initialTermiosState);
if (fd<0) {
fprintf(stderr, "Error opening device \"%s\"\n", deviceName);
return 2;
}
endpointObject=AQH_TtyEndpoint2_new(eventLoop, fd);
for (;;) {
AQH_EventLoop_Run(eventLoop);
}
return 0;
}
int main(int argc, char **argv)
{
@@ -526,7 +564,7 @@ int main(int argc, char **argv)
//return testMqttSubscribe2(argc, argv);
//return testHttpDaemon();
//return testMqttSubscribe3(argc, argv);
return testTty(argc, argv);
return testTty2(argc, argv);
return 0;
}