RemoteLogRK
|
Sends out debug logs as Particle events. More...
#include <RemoteLogRK.h>
Public Member Functions | |
RemoteLogEventServer (const char *eventName) | |
Constructor. More... | |
virtual | ~RemoteLogEventServer () |
Destructor. More... | |
void | loop (size_t &readIndex) |
Perform loop time operations such as reading and writing sockets. More... | |
Public Member Functions inherited from RemoteLogServer | |
RemoteLogServer () | |
Base class constructor. Doesn't do anything. | |
virtual | ~RemoteLogServer () |
This class is not typically deleted, because you can't unregister one. | |
virtual void | setup () |
Perform setup operations. More... | |
virtual void | reset () |
Reset is about to occur, do things like disconnect sockets. More... | |
Protected Member Functions | |
void | stateWaitForMessage (size_t &readIndex) |
State handler to wait for cloud connected and messages to send. Called from loop(). More... | |
void | stateTryPublish (size_t &readIndex) |
If still connected to the cloud and it has been at least 1010 milliseconds, publish. More... | |
void | stateFutureWait (size_t &readIndex) |
Wait for the publish to succeed or fail. More... | |
Protected Member Functions inherited from RemoteLogServer | |
RemoteLogServer (const RemoteLogServer &)=delete | |
This class is not copyable. | |
RemoteLogServer & | operator= (const RemoteLogServer &)=delete |
This class is not copyable. | |
Protected Attributes | |
String | eventName |
The event name to publish, passed to the constructor. | |
char | buf [particle::protocol::MAX_EVENT_DATA_LENGTH+1] |
Buffer to hold the event to be published. More... | |
unsigned long | lastPublish = 0 |
The millis() counter at the time of the last publish. More... | |
particle::Future< bool > | publishFuture |
The Future used to determine if the publish has completed yet. | |
std::function< void(RemoteLogEventServer &, size_t &readIndex)> | stateHandler = &RemoteLogEventServer::stateWaitForMessage |
State handler, called from loop. | |
Sends out debug logs as Particle events.
Works on both cellular and Wi-Fi. Automatically meters out data at 1 second intervals to avoid event throttling. Sends multiple messages in a single publish up to the maximum publish size of 622 bytes if there are multiple messages queued. However, if there is only one available, that one will be sent immediately to keep the events in approximately real-time.
RemoteLogEventServer::RemoteLogEventServer | ( | const char * | eventName | ) |
Constructor.
eventName | The event name to use for the publish |
|
virtual |
Destructor.
This object is not typically deleted as you can't unregister a server, so deleting it would cause a dangling pointer.
|
virtual |
Perform loop time operations such as reading and writing sockets.
Calls the state handler in stateHandler.
Reimplemented from RemoteLogServer.
|
protected |
Wait for the publish to succeed or fail.
Next state: stateWaitForMessage (success) or stateTryPublish (failure)
|
protected |
If still connected to the cloud and it has been at least 1010 milliseconds, publish.
The publish is non-blocking using a future.
Previous state: stateWaitForMessage Next state: stateFutureWait
|
protected |
State handler to wait for cloud connected and messages to send. Called from loop().
If cloud connected and there is a message, the message is consumed and copied into buf.
Next state: stateTryPublish
|
protected |
Buffer to hold the event to be published.
It's copied into a buffer because otherwise it would need to lock the main circular buffer during the entire publish operation, which would take way too long.
|
protected |
The millis() counter at the time of the last publish.
This is used to prevent publishing more than once every 1010 milliseconds.