Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mathieu52/gpsp
Arduino General Purpose Serial Protocol
https://github.com/mathieu52/gpsp
Last synced: 9 days ago
JSON representation
Arduino General Purpose Serial Protocol
- Host: GitHub
- URL: https://github.com/mathieu52/gpsp
- Owner: Mathieu52
- License: mit
- Created: 2022-11-22T17:50:34.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-29T23:16:34.000Z (almost 2 years ago)
- Last Synced: 2023-07-31T16:23:22.272Z (over 1 year ago)
- Language: C++
- Size: 87.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# General Purpose Serial Protocol (GPSP)
Serial protocol library for Arduino
Purpose of this library is to enable programmers to use a simple protocol to share accross all their Arduino based projects, allowing for simpler communication between their arduino and less confusion when trying to communicate between or with projects
This project was heavily inspired by AT command as this protocol syntax was inspired by it.
Before we can start using library, we need to include library to our sketch
``` C++
#include
```
First, we create simple GPSP object and pass it the Stream we want to use.
``` C++
GPSP protocol(Serial); // Or any other Serial, including a SoftwareSerial
```
Then we can create some function to link to our protocol.
``` C++
// Exemple:
// The stream in which this function was called
// Args : Array of c-string
// Size : The number of arguments
void ECHO(Stream &stream, const char args[][50], int size) {
}
```If your function encounters an issue those methods are at your disposition.
``` C++
GPSP::printError(Stream &stream, const char *errorMessage);
```Then we can define and link our commands
``` C++
void setup() {
// Structure: Function, Command name, Command description
protocol.defineCommand({ECHO, "ECHO", "Does something"});
}
```The next step is to periodically update our protocol.
``` C++
void loop() {
protocol.update();
}```
Exemple call :
```
ECHO;
OR
ECHO\n
OR
ECHO=Arg1,Arg2,...;
OR
ECHO=Arg1,Arg2,...\n
```