/Arduino-Pub-Sub

A simple pub sub solution for connecting multiple arduinios and pc's together

Primary LanguageC#

Arduino Pub-Sub Project
======================================
This project was created as a messaging system targeting Home Automation.  The messages are light weight over TCP using a centralized message broker that handles routing messages to subscribers.  This project was written using C# for the event broker and PC Clients and Arduinos with Ethernet shields are used as hardware device clients.  

Release
======================================
Alpha 0.1 - which means some things work but I have a lot to build out

Getting Started
======================================
Open the ArduinoPubSub.sln solution and compile it.  Everything you need is compiled to the Deploy directory (except the arduino sketches).  

Message Broker:
The Message Broker must be started first as it is the primary conduit for all messages.  You can run the Arduino.PubSubBroker.Console.exe console application as the message broker or install the Arduino.PubSubBroker.WinService.exe as a windows service.  I like to use the console application while I am working out the code for new publishers or subscribers. Before you start the message broker make sure you edit the .config file for the port you want the broker to listen for messages on.  The message broker needs to be on a fixed IP.

Arduino Sketches:
I have one sketch (Arduino.Sketches\HeartbeatPublishExample.pde) currently that just sends a heartbeat message every 5 seconds.  Keep in mind you need the Ethernet shield to send and receive messages with the Arduino.  Make sure you edit the mac, arduino ip broker ip and broker port settings before you compile and download the sketch into the arduino.

.Net Test Subscriber:
The Client\Arduino.TestSubscriber.Console.exe console application will subscribe to the heartbeat message that is being sent by the arduino sketch.  Make sure you change the .config file to have the broker ip and port as well as the ip and port that you want the broker to send the message too.

.Net Test Publisher:
The Client\Arduino.TestPublisher.Console.exe console application can be used to build up test messages to publish.

Message Format
======================================
Two messages that are built into the broker are subscribe and unsubscribe. You use these messages to manage your subscriptions.
  
Subscribe Message
  sub:msg:ip:port
    sub   - fixed string
    msg   - is the message type you want to subscribe to
    ip    - is the ip you want the broker to send the message to
    port  - is the port you want the broker to send the message to

  Example: sub:HB:192.168.254.3:9997

Unsubscribe Message
  unsub:msg:ip:port
    unsub - fixed string
    msg   - is the message type you want to unsubscribe from
    ip    - is the ip that was used when you subscribed
    port  - is the port that was used when you subscribed

  Example: unsub:HB:192.168.254.3:9997

For other message formats take a look at the comments on the Message Processors in the Arduino.Processors project.