zephyr/samples/net/nats_clients/subscriber/README

105 lines
2.7 KiB
Plaintext

NATS subscriber
This sample code demonstrates how to write a NATS subscriber sample
application.
See: http://nats.io/documentation/internals/nats-protocol/ for more
information about the NATS protocol.
Requirements
------------
* Ethernet LAN for testing purposes.
* Galileo Gen 2 Development Board.
* USB-UART cable: CH340, FTDI 6-pin or equivalent for debugging.
* NATS server, subscriber and publisher applications. See:
http://nats.io/documentation/tutorials/gnatsd-install/
http://nats.io/documentation/clients/nats-clients/
https://github.com/nats-io/nats
Building instructions
---------------------
* Read src/main.c, change the IP addresses according to the LAN
environment.
* On a terminal window, type:
make pristine && make
* To load the binary into the Galileo Dev Board, follow the steps
indicated here:
https://www.zephyrproject.org/doc/board/galileo.html
Usage
-----
* Follow nats.io documentation to setup the server and client
applications.
* Start the NATS server: open a terminal window and type:
gnatsd -D
The terminal window must display something like this:
[2045] 2016/07/27 17:40:20.928840 [INF] Starting nats-server version 0.8.2
[2045] 2016/07/27 17:40:20.928913 [DBG] Go build version go1.5.4
[2045] 2016/07/27 17:40:20.928922 [INF] Listening for client connections on 0.0.0.0:4222
[2045] 2016/07/27 17:40:20.929035 [DBG] Server id is X6QdoKdcVHDeWQcVIpJcb5
[2045] 2016/07/27 17:40:20.929048 [INF] Server is ready
* Connect the USB-UART cable to the Galileo. Open a terminal and run:
screen /dev/ttyUSB0 115200
* Connect Galileo to the LAN, Turn on the board.
* On the screen terminal window, the following text will appear:
WARNING: no console will be available to OS
error: no suitable video mode found.
--------------------------------
--------------------------------
* Run the NATS publisher client. Open a terminal window and type:
nats-pub sensors DOOR89:CLOSED
The terminal window will display:
Published [sensors] : 'DOOR89:CLOSED'
* On the screen terminal window, the following message will appear:
--------------------------------
Subject: [7] sensors
Sid: [2] z1
Reply-to: not found
Payload: [13] DOOR89:CLOSED
--------------------------------
Final remarks
-------------
Full NATS support is not yet achieved. However, current publisher
and subscriber routines are enough to write basic NATS applications.
Compiler Warnings
-----------------
The network layer used in this sample code will be replaced once the
new IP stack is ready. So, "netz" is tagged as "deprecated" and the
following warnings will be displayed by the compiler:
warning: 'netz_tx' is deprecated [-Wdeprecated-declarations]