14 #define LOG_TAG "player_nfc"
20 int err_amqlisten = 0;
22 amqp_envelope_t envelope;
23 amqp_connection_state_t conn;
33 LOGM(
"FREQ - %s sock=%d", params->
sensor, sock);
36 LOGM(
" NFC ready waiting data from amqp");
38 if (err_amqlisten == 0)
41 LOGM(
"NFC send to nfcd size=%d, on socket=%d", size, sock);
51 LOGW(
"Unable to connect to hardware device %s (:%d)", params->
sensor, params->
port);
56 struct timespec duration = {0, params->
frequency * 1000};
57 nanosleep(&duration, NULL);
Utilities for consuming RabbitMQ messages.
char sensor[BUF_SIZE]
Sensor name.
Parameter for sensor threads.
void * listen_NFC(void *args)
Listen to AMQP and send data to the NFC sensor in the VM.
int amqp_listen_retry(const char *hostname, int port, const char *bindingkey, amqp_connection_state_t *conn, const unsigned int tries)
Setup a consumer for a specific queue.
int socket_t
Alias to differenciate between regular ints and socket fds.
int write_protobuf(socket_t sock, amqp_envelope_t *envelope)
Write a protobuf, with a varint32 framing, and padding at the end from an envelope.
char queue[BUF_SIZE]
Queue name.
Defines ports and structures for sensor threads.
char exchange[BUF_SIZE]
Exchange name.
int amqp_consume(amqp_connection_state_t *conn, amqp_envelope_t *envelope)
Consume one message from a connection object.
#define LOGM(...)
Log at MESSAGE level.
int32_t frequency
Sensor throttling.
#define LOGW(...)
Log at WARNING level.
socket_t open_socket_reuseaddr(const char *ip, short port)
Open a socket with SO_REUSEADDR.
#define SOCKET_ERROR
Alias for the recv() return value in case of error.
Define common buffer sizes.
Define socket utilities to simplify networking.
Utility to convert framing to varint32 for google’s parser.
const char * amqp_host
AMQP host.