Mebm
1.0.0
|
MEBM stands for: Mouse's Ethernet Based Messaging, and is a super-simple protocol for sending messages between Arduinos over Ethernet based TCP/IP (i.e. Arduino devices with Ethernet shields on them, the integrated Arduino Ethernet board, Nanode and so on).
Each Arduino sends and receives MEBM Protocol messages using the Mebm object, which implements methods for constructing correctly formatted messages, sending them, and handling incoming messages.
Mebm messages are fixed size structures with the following fields:
Fields are NULL padded up to their length.
A typical message might be that a magstripe has been read by a Mebm with the name "MagReader":
Which, once encoded would look like this if examined with hexdump:
00000000 4d 65 42 6d 4d 61 67 52 65 61 64 65 72 00 00 00 |MeBmMagReader...| 00000010 52 65 61 64 43 61 72 64 00 00 00 00 3b 31 32 33 |ReadCard....;123| 00000020 34 35 36 37 38 39 30 41 42 43 44 45 46 3b 30 30 |4567890ABCDEF;00| 00000030 30 30 30 30 30 30 30 30 31 00 00 00 00 00 00 00 |000000001.......| 00000040 00 00 00 00 00 00 00 00 00 00 00 00 |............| 0000004c
Mebm messages are sent over TCP/IP on port 2300.
This library implements MebmClass, which includes functionality for sending and receiving Mebm protocol messages. In the style of the Arduino Ethernet, Serial and other libraries, the Mebm library provides an instance of MebmClass named Mebm, which is configured using Mebm.begin(). See the examples provided, and MebmClass documentation for details.
Handling of incoming messages is done by registering callback functions with a From and Type filter (see MebmClass::addResponder). Incoming messages which match both filters will trigger the callback. Filters can match either specific From / Type values or anything (using the "*" wildcard). For example:
In this case, the callback will be called when any message is sent to the node, because both filters match any incoming value. A less promiscuous filter might look like this: