|
LCC Fusion Project 1.0
LCC Automation
|
Bridges ESP_NOW with the CAN bus. More...
#include <LccNodeNowBridge.h>
Inherits Executable.

Classes | |
| class | WritePort |
| State machine running in the OpenMRN cooperative executor, registered to receive data that needs to be sent to the port. More... | |
Public Member Functions | |
| LccNodeNowBridge (CanHubFlow *pCanHub, bool isServer) | |
| Constructor. More... | |
| ~LccNodeNowBridge () | |
| Destructor. | |
| void | run () |
| Called by the loop to check for possible serial or GridConnect packets to be read and processed. More... | |
Private Member Functions | |
| void | _loop_for_read () |
| Handles reading a GC packet from ESP_NOW and sending to OpenMRN Grid Connect Hub. | |
| void | _loop_for_write () |
| Handles processing OpenMRN GridConnect packet and sending the GC packet to ESP_NOW. More... | |
| bool | _isGcPacketWriteBuf (char *pGcData, size_t size) |
| Decodes a GridConnect packet into a CAN frame (structure) Supports multiple frames of data within a packet, but only processes one frame of data per invocation (uses writeOfs_ to keep position within the packet) More... | |
| const char * | _generateIdentMessage () |
| Generates an identification message from the NodeID. More... | |
| void | _printHex (const uint8_t *data, const uint8_t length) |
| Print data in hexadecimal form for debugging. More... | |
Private Attributes | |
| Service * | pService_ |
| Access to the stack's executor. | |
| HubFlow | txtHub_ { pService_ } |
| Hub for the textual data. | |
| Buffer< HubData > * | pWriteBuffer_ { nullptr } |
| Buffer for outgoing data. | |
| WritePort | writePort_ { this, pService_ } |
| State flow with queues for output frames generated by the stack. | |
| size_t | writeOfs_ |
| Offset into GC packet of data being processed (in case there is more than one frame within the packet) | |
| uint8_t | broadcastAddress_ [6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } |
| Broadcast MAC address. | |
| bool | isServer_ |
| true when configuring a ESP_NOW server | |
| NowMessage | outgoingMessage_ |
| Outgoing message structure. | |
Bridges ESP_NOW with the CAN bus.
This class handles bridging between ESP_NOW and OpenMRN GridConnect using GC packet format
Definition at line 65 of file LccNodeNowBridge.h.
|
inline |
Constructor.
| pCanHub | Core CAN frame router of the OpenMRN stack, usually from stack()->pCanHub(). |
| isServer | true indicates a ESP_NOW server (Hub)) is to be configured, else a client (non-Hub) is configured. |
Definition at line 74 of file LccNodeNowBridge.h.
|
inlineprivate |
Generates an identification message from the NodeID.
Definition at line 344 of file LccNodeNowBridge.h.
|
inlineprivate |
Decodes a GridConnect packet into a CAN frame (structure) Supports multiple frames of data within a packet, but only processes one frame of data per invocation (uses writeOfs_ to keep position within the packet)
< Get start of a packet's CAN frame
< Check next character
< update offset as packet is processed
< Packet found?
Definition at line 243 of file LccNodeNowBridge.h.

|
inlineprivate |
Handles processing OpenMRN GridConnect packet and sending the GC packet to ESP_NOW.
< Clear the buffer after writing
< Wake up state flow to release buffer and take next from the queue, also reset writeOfs_ to zero.
Definition at line 222 of file LccNodeNowBridge.h.


|
inlineprivate |
Print data in hexadecimal form for debugging.
| data | Data to print. |
| length | Length of the data. |
Definition at line 376 of file LccNodeNowBridge.h.

|
inline |
Called by the loop to check for possible serial or GridConnect packets to be read and processed.
< Read from serial slcan frames, convert to GC packets, queue with GC hub.
< Send to ESP_NOW queued GridConnect CAN packets.
Definition at line 124 of file LccNodeNowBridge.h.
