Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
flash62au committed Dec 27, 2023
2 parents 0ab80d2 + 361fefc commit 9ac7482
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
41 changes: 41 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,47 @@ Once the `DCCEXProtocol` object is instantiated, a connection must be made to th

It is also recommended to enable logging to an Arduino Stream using the `setLogStream(&stream)` method.

An example using an ESP32 with WiFi to connect to EX-CommandStation, with logging to the serial console:

.. code-block:: cpp
WiFiClient client;
DCCEXProtocol dccexProtocol;
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while(WiFi.status() != WL_CONNECTED) delay(1000);
if (!client.connect(serverAddress, serverPort)) {
while(1) delay(1000);
}
dccexProtocol.setLogStream(&Serial);
dccexProtocol.connect(&client);
}
void loop() {
dccexProtocol.check();
// other code here
}
An example using STM32F103C8 Bluepill with hardware serial port 1 connecting to EX-CommandStation, and logging to the USB serial console:

.. code-block:: cpp
DCCEXProtocol dccexProtocol;
void setup() {
Serial.begin(115200);
Serial1.begin(115200);
dccexProtocol.setLogStream(&Serial);
dccexProtocol.connect(&Serial1);
}
void loop() {
dccexProtocol.check();
// other code here
}
As covered in the design principles above, you must include the `check()` method as often as possible to receive command responses and broadcasts and have these processed by the library and any event handlers defined in your custom `DCCEXProtocolDelegate` class.

Refer to the :doc:`examples` to see how this may be implemented.
Expand Down
6 changes: 3 additions & 3 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=DCCEXProtocol
version=0.0.4
author=Peter Akers <[email protected]>, David Zuhn <[email protected]>
maintainer=Peter Akers <[email protected]>
author=Peter Cole, Peter Akers <[email protected]>
maintainer=Peter Cole, Peter Akers <[email protected]>
sentence=DCC-EX Native Protocol implementation
paragraph=This library implements the DCC-EX Native protocol, allowing a device to connect to the server and act as a client (such as a dedicated fast clock device or a hardware based throttle).
category=Other
url=https://github.com/DCC-EX/DCCEXProtocol
url=https://dcc-ex.com/DCCEXProtocol/index.html
architectures=*
6 changes: 6 additions & 0 deletions src/DCCEXProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
/*
Version information:
0.0.4 - No functional changes, update author/maintainer and URL library properties
0.0.3 - Add getByAddress method to ConsistLoco
- Fix bug when removing locos from a consist
- Tidy setTrackType() method
0.0.2 - Add TrackManager configuration method and broadcast processing
- Add TrackManager, SSID, and mDNS examples
0.0.1 - Initial library release via the Arduino Library Manager
*/

Expand Down

0 comments on commit 9ac7482

Please sign in to comment.