2019-05-30 06:25:37 +08:00
|
|
|
#ifndef RECEIVER_H
|
|
|
|
#define RECEIVER_H
|
|
|
|
|
2021-01-09 02:24:51 +08:00
|
|
|
#include "common.h"
|
|
|
|
|
2019-05-30 06:25:37 +08:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2019-11-24 18:53:00 +08:00
|
|
|
#include "util/net.h"
|
2021-02-01 01:24:35 +08:00
|
|
|
#include "util/thread.h"
|
2019-05-30 06:25:37 +08:00
|
|
|
|
|
|
|
// receive events from the device
|
|
|
|
// managed by the controller
|
|
|
|
struct receiver {
|
|
|
|
socket_t control_socket;
|
2021-02-01 01:24:35 +08:00
|
|
|
sc_thread thread;
|
|
|
|
sc_mutex mutex;
|
2019-05-30 06:25:37 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
bool
|
|
|
|
receiver_init(struct receiver *receiver, socket_t control_socket);
|
|
|
|
|
|
|
|
void
|
|
|
|
receiver_destroy(struct receiver *receiver);
|
|
|
|
|
|
|
|
bool
|
|
|
|
receiver_start(struct receiver *receiver);
|
|
|
|
|
|
|
|
// no receiver_stop(), it will automatically stop on control_socket shutdown
|
|
|
|
|
|
|
|
void
|
|
|
|
receiver_join(struct receiver *receiver);
|
|
|
|
|
|
|
|
#endif
|