Hello all,

I am developing a system that uses CZMQ's zbeacon (broadcast on UDP) for
app discovery. Beacon sender is Windows box and receiver is RaspberryPi3.

As the subject says, no message is reaching the zbeacon actor.

Using czmq3.0.2 and zmq4.1.6 built directly on pi to rule out
cross-compiling issues.

Calling just zbeacon_test() returns "OK" without assertions errors.

Broadcast messages are indeed reaching the pi, as shown by tcpdump:

    pi@raspberrypi:~ $ sudo tcpdump udp port 5670
    tcpdump: verbose output suppressed, use -v or -vv for full protocol
decode
    listening on wlan0, link-type EN10MB (Ethernet), capture size 262144
bytes
    13:33:56.203230 IP [REDACTED].5670 > 192.168.1.255.5670: UDP, length 22
    13:34:01.072476 IP [REDACTED].5670 > 192.168.1.255.5670: UDP, length 22

The code used to test is based on zbeacon_test function:

    zactor_t *listener = zactor_new (zbeacon, NULL);
    assert (listener);
    zsock_send (listener, "si", "CONFIGURE", 5670);
    hostname = zstr_recv (listener);
    assert (*hostname);
    free (hostname);

    zsock_send (listener, "sb", "SUBSCRIBE", "", 0);

    zpoller_t *poller = zpoller_new (listener, NULL);
    assert (poller);
    int64_t stop_at = zclock_mono () + 10000; // wait 10 seconds
    while (zclock_mono () < stop_at) {
        long timeout = (long) (stop_at - zclock_mono ());
        if (timeout < 0)
            timeout = 0;
        void *which = zpoller_wait (poller, timeout * ZMQ_POLL_MSEC);
        if (which) {
            char *ipaddress, *received;
            zstr_recvx (which, &ipaddress, &received, NULL);
            printf("From address %s:%s\n", ipaddress, received);
            zstr_free (&ipaddress);
            zstr_free (&received);
        }
    }
    zpoller_destroy (&poller);

    //  Stop listening
    zstr_sendx (listener, "UNSUBSCRIBE", NULL);

    //  Destroy the test nodes
    zactor_destroy (&listener);

I cross-compiled a simple Qt app with a QUdpSocket (below) and the messages
were received without issues:

    #include <QtNetwork/QUdpSocket>

    TestUDP::TestUDP(QObject *parent) :
        QObject(parent)
    {
        qDebug() << "Binding UDP Socket";
        socket = new QUdpSocket(this);
        socket->bind(QHostAddress::Any, 5670);
        connect(socket, &QUdpSocket::readyRead,this, &TestUDP::readyRead);
        qDebug() << "Ready Read signal connected0, waiting for broadcasts";
    }

    void TestUDP::readyRead(){
        QByteArray buffer;
        buffer.resize(socket->pendingDatagramSize());
        //var to store headers from udp
        QHostAddress sender;
        quint16 sender_port;
        socket->readDatagram(buffer.data(),buffer.size(), &sender,
&sender_port);
        qDebug() << "Message from " << sender << " port " << sender_port;
        qDebug() << "Msg: " << buffer;
    }

Maybe the problem is at the way zbeacon is dealing with the UDP socket...

Has anyone successfully used a zbeacon on RPI3?

Thanks in advance!

Rodrigo Madruga.
_______________________________________________
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to