per1234 / EtherEvent

Easy to use password authenticated Ethernet communication between Arduinos and EventGhost Network Event Sender/Receiver or TCPEvents plugins.
MIT License
0 stars 0 forks source link
arduino arduino-library eventghost

EtherEvent

Easy to use Arduino library for password authenticated network communication via Ethernet between Arduinos and EventGhost, or any other program compatible with the EventGhost Network Event Sender and Receiver plugins. Compatible with Arduino Ethernet, Ethernet Shield, and other devices using the W5100/W5200/W5500 Ethernet controller.

Compatible Software

Related Programs

Installation

About Events and Payloads

Events are used to trigger an action. The payload is information that accompanies the event. An example is an event code that triggers the display of the payload. Some events don't require a payload and in this case the payload may be left blank.

Usage

See the example sketches at File > Examples > EtherEvent and the EventGhost tree files in the examples/EventGhost-example-trees folder for demonstration of library usage.

#include <EtherEvent.h>

Allow access to the functions of the EtherEvent library.

#define ETHEREVENT_NO_AUTHENTICATION

Add this line above the #include <EtherEvent.h> line in your sketch to disable password authentication. Requires my version of the TCPEvents plugin with the password fields left blank in the configurations for communication with EventGhost. With authentication disabled the ArduinoMD5 library is not required, no need to set the password, memory usage is decreased significantly, and event transmission speed is increased. See the NoAuthentication example for a demonstration.

#define ETHEREVENT_FAST_SEND

Increase sending speed at the expense of increased memory use. Add this line above the #include <EtherEvent.h> line in your sketch. This significantly increases the speed of sending __FlashStringHelper(F() macro) events/payloads but also increases the sketch size and SRAM usage during the send process. ETHEREVENT_FAST_SEND also increases the speed of sending some other event/payload types.

EtherEvent.begin([eventLengthMax, payloadLengthMax])

Initialize EtherEvent.

EtherEvent.setPassword(password)

Set the password. This is not required if authentication is disabled.

EtherEvent.availableEvent(ethernetServer[, cookie[, password]])

Receives new event if an event is not already buffered.

EtherEvent.availableEvent()
EtherEvent.availablePayload()

EtherEvent.availableEvent() must be called first.

EtherEvent.readEvent(eventBuffer)

Puts the event in the passed array. EtherEvent.availableEvent() must be called first, size a char array according to the result and pass it to EtherEvent.readEvent(). After that it will contain the event.

EtherEvent.readEvent()
EtherEvent.readPayload(payloadBuffer)

Puts the payload string in the passed array. EtherEvent.availableEvent() must be called first, size a char array according to the result and pass it to EtherEvent.readPayload(). After that it will contain the payload.

EtherEvent.readPayload()
EtherEvent.senderIP()

Returns the IP address of the sender of the most recent event. Must have the modified Ethernet library installed for this function to be available.

EtherEvent.flushReceiver()

Clear any buffered event and payload data so a new event can be received.

EtherEvent.send(ethernetClient, target, port, event[, payload[, password]])

Send an event and payload.

EtherEvent.setSendDoubleDecimalPlaces(decimalPlaces)

Set the number of decimal places when sending double or float type events and payloads. This function is only available if ETHEREVENT_FAST_SEND is defined. In normal mode only two decimal places are supported.

EtherEvent.getTimeout()

Returns the current timeout duration setting.

EtherEvent.setTimeout(timeout)

Set the timeout duration(Stream functions).

Troubleshooting

Security Considerations

Authentication Process

EventGhost uses MD5 encrypted APOP style authentication to avoid sending passwords in plaintext.

Contributing

Pull requests or issue reports are welcome! Please see the contribution rules for instructions.