Skip to content

Commit

Permalink
Merge pull request #10 from gabryelreyes/development
Browse files Browse the repository at this point in the history
Copyright and general improvements
  • Loading branch information
gabryelreyes authored Apr 26, 2024
2 parents 326179a + 96f6d94 commit 6122004
Show file tree
Hide file tree
Showing 18 changed files with 228 additions and 54 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,4 @@ jobs:
env:
PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_AUTH_TOKEN }}
run: |
TAG=$(git describe --exact-match --tags)
curl -LO $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/$TAG/SerialMuxProt-$TAG.zip
platformio package publish --type library SerialMuxProt-$TAG.zip --non-interactive
platformio package publish --non-interactive
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Gabryel Reyes
Copyright (c) 2023 - 2024 Gabryel Reyes <gabryelrdiaz@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,18 @@ struct Channel
/**
* Channel Notification Prototype Callback.
* Provides the received data in the respective channel to the application.
*
* @param[in] payload Received data.
* @param[in] payloadSize Size of the received data.
* @param[in] userData User data provided by the application.
*/
typedef void (*ChannelCallback)(const uint8_t* payload, const uint8_t payloadSize);
typedef void (*ChannelCallback)(const uint8_t* payload, const uint8_t payloadSize, void* userData);
```
- Callback passes only a pointer to the received Buffer. Data must be copied by application.
- Memory is freed by the protocol after the callback is done.
- DLC is passed as payloadSize to the application.
- The `userData` pointer specified in the constructor is passed to the application.
### State Machine
Expand All @@ -223,6 +228,26 @@ typedef void (*ChannelCallback)(const uint8_t* payload, const uint8_t payloadSiz
- Client is connected and responds to SYNC Commands.
- SYNC Period set to 5 seconds.
### Event Callbacks
It is possible to register `EventCallback` callbacks for the Synced and DeSynced events. These will be called once an event is triggered to notify the user.
```cpp
/**
* Event Notification Prototype Callback.
* Provides a notification to the application on the event it is registered to.
*
* @param[in] userData User data provided by the application.
*/
typedef void (*EventCallback)(void* userData);
/* Called on Sync. */
bool registerOnSyncedCallback(EventCallback callback);
/* Called on DeSync. */
bool registerOnDeSyncedCallback(EventCallback callback);
```

---

## SerialMuxChannels
Expand Down
2 changes: 1 addition & 1 deletion doc/doxygen/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ PROJECT_NAME = SerialMuxProt
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 1.0.1
PROJECT_NUMBER = 2.2.0

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion examples/SerialMuxChannels.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* MIT License
*
* Copyright (c) 2023 Gabryel Reyes <gabryelrdiaz@gmail.com>
* Copyright (c) 2023 - 2024 Gabryel Reyes <gabryelrdiaz@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
30 changes: 29 additions & 1 deletion examples/ServerA/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* MIT License
*
* Copyright (c) 2023 Gabryel Reyes <gabryelrdiaz@gmail.com>
* Copyright (c) 2023 - 2024 Gabryel Reyes <gabryelrdiaz@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -57,6 +57,8 @@
* Prototypes
*****************************************************************************/

static void gOnSyncedCallback(void* userData);

/******************************************************************************
* Local Variables
*****************************************************************************/
Expand Down Expand Up @@ -90,6 +92,8 @@ uint32_t gLastLedSendTimestamp = 0U;
*/
void setup()
{
bool syncedCallbackRegistered = false;

/* Initialize Serial */
Serial.begin(SERIAL_BAUDRATE);

Expand All @@ -98,6 +102,19 @@ void setup()

/* Create Channel for sending LED data. */
gSerialMuxProtChannelIdLedData = gSmpServer.createChannel(LED_CHANNEL_NAME, LED_CHANNEL_DLC);

/* Register Synced Callback. */
syncedCallbackRegistered = gSmpServer.registerOnSyncedCallback(gOnSyncedCallback);

/* Check channel creation and callback register. */
if ((0U == gSerialMuxProtChannelIdLedData) || (false == syncedCallbackRegistered))
{
/* Something went wrong. */
while (true)
{
/* Do nothing. */
}
}
}

/**
Expand Down Expand Up @@ -144,3 +161,14 @@ void loop()
/******************************************************************************
* Local Functions
*****************************************************************************/

/**
* Callback function for Synced event.
*
* @param userData User data passed to the callback.
*/
static void gOnSyncedCallback(void* userData)
{
/* Print Synced message. */
Serial.println("Synced");
}
2 changes: 1 addition & 1 deletion examples/ServerB/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* MIT License
*
* Copyright (c) 2023 Gabryel Reyes <gabryelrdiaz@gmail.com>
* Copyright (c) 2023 - 2024 Gabryel Reyes <gabryelrdiaz@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SerialMuxProt",
"version": "2.1.0",
"version": "2.2.0",
"description": "Communication Protocol based on Streams. Uses Multiplexing to differentiate data channels.",
"keywords": "SerialMuxProt",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion python/SerialMuxProt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# MIT License
#
# Copyright (c) 2023 Gabryel Reyes <gabryelrdiaz@gmail.com>
# Copyright (c) 2023 - 2024 Gabryel Reyes <gabryelrdiaz@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion python/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# MIT License
#
# Copyright (c) 2023 Gabryel Reyes <gabryelrdiaz@gmail.com>
# Copyright (c) 2023 - 2024 Gabryel Reyes <gabryelrdiaz@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion python/serial_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# MIT License
#
# Copyright (c) 2023 Andreas Merkle <web@blue-andi.de>
# Copyright (c) 2023 - 2024 Gabryel Reyes <gabryelrdiaz@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion python/socket_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# MIT License
#
# Copyright (c) 2023 Andreas Merkle <web@blue-andi.de>
# Copyright (c) 2023 - 2024 Gabryel Reyes <gabryelrdiaz@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
54 changes: 30 additions & 24 deletions src/SerialMuxProtCommon.hpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
/* MIT License
Copyright (c) 2023 Gabryel Reyes <gabryelrdiaz@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
*
* Copyright (c) 2023 - 2024 Gabryel Reyes <gabryelrdiaz@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

/*******************************************************************************
DESCRIPTION
Expand All @@ -29,7 +28,6 @@ SOFTWARE.
* @brief Common Constants and Structures of SerialMuxProt.
* @author Gabryel Reyes <gabryelrdiaz@gmail.com>
*
*
* @{
*/

Expand Down Expand Up @@ -94,7 +92,15 @@ SOFTWARE.
* @param[in] payloadSize Size of the received data.
* @param[in] userData User data provided by the application.
*/
typedef void (*ChannelCallback)(const uint8_t* payload, const uint8_t payloadSize, void* userData);
typedef void (*ChannelCallback)(const uint8_t* payload, uint8_t payloadSize, void* userData);

/**
* Event Notification Prototype Callback.
* Provides a notification to the application on the event it is registered to.
*
* @param[in] userData User data provided by the application.
*/
typedef void (*EventCallback)(void* userData);

/**
* Channel Definition.
Expand Down
Loading

0 comments on commit 6122004

Please sign in to comment.