You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Features:
11
11
* Send different kind of messages with a simple and lightweight message format.
12
12
* Send status updates of the device (e.g. for pushing new sensor values via Serial Interface).
13
13
* Send arbitrary types of messages.
14
-
* Get/Set an ID from and to the EEPROM.
14
+
* Get/Set an ID from and to the EEPROM (If the target board has one available).
15
15
# Folder structure
16
16
*`src` contains the source code.
17
17
*`examples` contains an example sketch.
@@ -44,7 +44,7 @@ The StreamCommander will be initialised with the standard `Serial`-Object by def
44
44
7. Send status updates with `updateStatus`-function.
45
45
1. If the status has changed since the last update, a new status message will automatically be sent.
46
46
2. If the device is not activated, possible status updates won't be sent out. They can still be queried manually with the `status`-command.
47
-
8. In case you need the device to have an ID (for example if you need to adress multiple devices separately), set an id with the `setid`-command the first time you boot the device.
47
+
8. In case you need the device to have an ID (for example if you need to adress multiple devices separately), set an id with the `setid`-command the first time you boot the device. If an EEPROM is available on the board:
48
48
1. The ID will be persisted in the EEPROM of the device, and will automatically be loaded on every initialisation of the StreamCommander. No need to hardcode this.
49
49
2. The ID will only be updated in the EEPROM if it really changes, which extends the lifespan of the EEPROM.
voidinit( // Init function for setting up the StreamCommander correctly, after it has been successfuly constructed.
113
-
bool active = true, // Whether the StreamCommander is set to active or not. This only influences the automatic status updates.
114
-
char commandDelimiter = COMMAND_DELIMITER, // Character which delimits a command from its' arguments.
115
-
char messageDelimiter = MESSAGE_DELIMITER, // Character which delimits a message from its' contents.
116
-
bool echoCommands = false, // Should commands be echoed at arrival or not?
117
-
bool addStandardCommands = true, // Should the standard commands be added or not?
118
-
long streamBufferTimeout = STREAM_BUFFER_TIMEOUT // Sets the timeout of the specific streams' buffer.
163
+
// Init function for setting up the StreamCommander correctly, after it has been successfuly constructed.
164
+
voidinit(
165
+
// Whether the StreamCommander is set to active or not. This only influences the automatic status updates.
166
+
bool active = true,
167
+
168
+
// Character which delimits a command from its' arguments.
169
+
char commandDelimiter = COMMAND_DELIMITER,
170
+
171
+
// Character which delimits a message from its' contents.
172
+
char messageDelimiter = MESSAGE_DELIMITER,
173
+
174
+
// Should commands be echoed at arrival or not?
175
+
bool echoCommands = false,
176
+
177
+
// Should the standard commands be added or not?
178
+
bool addStandardCommands = true,
179
+
180
+
// Sets the timeout of the specific streams' buffer.
181
+
long streamBufferTimeout = STREAM_BUFFER_TIMEOUT
119
182
);
120
-
voidsetActive( bool active ); // Sets whether the automatic status updates are activated or not (true/false).
121
-
boolisActive(); // Returns if the automatic status updates are activated.
122
-
voidsetCommandDelimiter( char commandDelimiter ); // Sets the command delimiter, separating the command from a potential argument.
123
-
chargetCommandDelimiter(); // Gets the command delimiter.
124
-
voidsetMessageDelimiter( char messageDelimiter ); // Sets the message delimiter, separating the type from the content.
125
-
chargetMessageDelimiter(); // Gets the message delimiter.
126
-
voidsetEchoCommands( bool echoCommands ); // Sets whether all incoming commands should be echoed or not (true/false).
127
-
boolshouldEchoCommands(); // Returns if all incomming commands should be echoed.
128
-
voidsetStreamBufferTimeout( long streamBufferTimeout ); // Sets the timeout of the specific streams' buffer.
129
-
longgetStreamBufferTimeout(); // Returns the timeout of the specific streams' buffer.
130
-
voidsetId( String id ); // Sets the ID of the StreamCommander/Device.
131
-
String getId(); // Gets the ID of the StreamCommander/Device.
132
-
133
-
voidupdateStatus( String status ); // Update the status of the StreamCommander/Device; updates the status and sends an automatic status message only if the status changed.
134
-
voidsetStatus( String status ); // Sets the current status StreamCommander/Device.
135
-
String getStatus(); // Gets the current status StreamCommander/Device.
136
-
137
-
voidaddCommand( String command, CommandCallbackFunction commandCallback ); // Registers a new command; a command name tied to a command callback.
138
-
intgetNumCommands(); // Gets the number of the registered commands.
139
-
String getCommandList(); // Gets a list of all registered commands.
140
-
voidsetDefaultCallback( DefaultCallbackFunction defaultCallbackFunction ); // Sets the default callback which gets called in case a sent command is not registered.
141
-
DefaultCallbackFunction getDefaultCallback(); // Gets the default callback.
142
-
143
-
voidfetchCommand(); // Fetches and interprets incoming commands, and invokes the corresponding callbacks. This should be called in the loop or after an interrupt/event.
144
-
145
-
voidsendMessage( String type, String content ); // Sends a message with a specific type and content separated by our delimiter.
146
-
voidsendResponse( String response ); // Sends a message of type MessageType::RESPONSE.
147
-
voidsendInfo( String info ); // Sends a message of type MessageType::INFO.
148
-
voidsendError( String error ); // Sends a message of type MessageType::ERROR.
149
-
voidsendPing(); // Sends a message of type MessageType::PING, contains a "reply".
150
-
voidsendStatus(); // Sends a message of type MessageType::STATUS, contains the current status.
151
-
voidsendId(); // Sends a message of type MessageType::ID, contains the current ID.
152
-
voidsendIsActive(); // Sends a message of type MessageType::ACTIVE, contains the current active status.
153
-
voidsendEcho( String echo ); // Sends a message of type MessageType::ECHO.
154
-
voidsendCommands(); // Sends a message of type MessageType::COMMANDS, contains a list of currently registered commands.
183
+
184
+
// Sets whether the automatic status updates are activated or not (true/false).
185
+
voidsetActive( bool active );
186
+
187
+
// Returns if the automatic status updates are activated.
188
+
boolisActive();
189
+
190
+
// Sets the command delimiter, separating the command from a potential argument.
191
+
voidsetCommandDelimiter( char commandDelimiter );
192
+
193
+
// Gets the command delimiter.
194
+
chargetCommandDelimiter();
195
+
196
+
// Sets the message delimiter, separating the type from the content.
197
+
voidsetMessageDelimiter( char messageDelimiter );
198
+
199
+
// Gets the message delimiter.
200
+
chargetMessageDelimiter();
201
+
202
+
// Sets whether all incoming commands should be echoed or not (true/false).
203
+
voidsetEchoCommands( bool echoCommands );
204
+
205
+
// Returns if all incomming commands should be echoed.
206
+
boolshouldEchoCommands();
207
+
208
+
// Sets the timeout of the specific streams' buffer.
209
+
voidsetStreamBufferTimeout( long streamBufferTimeout );
210
+
211
+
// Returns the timeout of the specific streams' buffer.
212
+
longgetStreamBufferTimeout();
213
+
214
+
// Sets the ID of the StreamCommander/Device.
215
+
// The ID gets only saved to an EEPROM if one is available.
216
+
voidsetId( String id );
217
+
218
+
// Gets the ID of the StreamCommander/Device.
219
+
String getId();
220
+
221
+
// Update the status of the StreamCommander/Device; updates the status and sends an automatic status message only if the status changed.
222
+
voidupdateStatus( String status );
223
+
224
+
// Sets the current status StreamCommander/Device.
225
+
voidsetStatus( String status );
226
+
227
+
// Gets the current status StreamCommander/Device.
228
+
String getStatus();
229
+
230
+
// Registers a new command; a command name tied to a command callback.
0 commit comments