zephyr/samples/net/nats_clients/publisher
Anas Nashif d622b09bc0 samples: tests: remove obsolete KERNEL_TYPE and kernel variables
Remove those from Makefiles and testcase.ini, we now support unified kernel
only and sanitycheck script now knows how to deal with this.

Change-Id: I853ebcadfa7b56a4de5737d95f2ba096babb2e13
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-11-04 15:47:25 -04:00
..
src
Makefile samples: tests: remove obsolete KERNEL_TYPE and kernel variables 2016-11-04 15:47:25 -04:00
README
prj_galileo.conf
testcase.ini

README

NATS publisher

This sample code demonstrates how to write a NATS publisher 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

* Start the NATS subscriber client. Open another terminal window and type:

    nats-sub  -t sensors

  This command will start the NATS subscriber client. The terminal
  window will show the following text:

    Listening on [sensors]

* 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.
    --------------------------------
    NATS PUB: OK
    --------------------------------
    NATS PUB: OK
    --------------------------------
    NATS PUB: OK
    --------------------------------

* The NATS subscriber terminal window will display:

    2016/07/27 17:44:22 [#1] Received on [sensors]: 'DOOR3:OPEN'
    2016/07/27 17:44:23 [#2] Received on [sensors]: 'DOOR3:OPEN'
    2016/07/27 17:44:24 [#3] Received on [sensors]: 'DOOR3:OPEN'

* If the NATS server sends a PING message:

    [30741] 2016/07/27 18:58:28.289650 [DBG] 192.168.1.110:1025 - cid:1 - Client Ping Timer

  the application will print:

    --------------------------------
    Ping-pong message processed
    NATS PUB: OK
    --------------------------------


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]