Add high-level SDK with transport abstraction for TypeScript, Python, C++, and C# (opt-in via flags) - #95
Conversation
Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com>
Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com>
Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com>
…tation Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com>
| - **Zero dependencies**: Core SDK has no external dependencies | ||
| - **Observer pattern**: Type-safe message subscription inspired by ETLCPP | ||
| - **Embedded-friendly**: Generic serial interface for bare-metal systems | ||
| - **Network support**: UDP, TCP, WebSocket via optional ASIO integration |
There was a problem hiding this comment.
for windows, mac and linux
There was a problem hiding this comment.
Added in commit b08c2bc - Documentation now mentions "Works on Windows, macOS, and Linux" in the C++ SDK features.
| @@ -0,0 +1,110 @@ | |||
| // Network transport implementations using ASIO | |||
| // NOTE: These require the ASIO library (header-only or standalone) | |||
| // Include asio.hpp or boost/asio.hpp in your project | |||
There was a problem hiding this comment.
We should include asio.hpp directly in this repo in this folder. Then this file can be actually implemented
There was a problem hiding this comment.
Implemented in commit b08c2bc - ASIO standalone headers (v1.30.2) are now included directly in the struct_frame_sdk directory. UDP, TCP, and Serial transports are fully implemented using ASIO.
| } | ||
|
|
||
| private: | ||
| std::vector<IObserver<TMessage>*> observers_; |
There was a problem hiding this comment.
Do not use std::vector because of heap allocations. It makes this not safe for embedded implementations. Use a custom object to deal with this.
There was a problem hiding this comment.
Fixed in commit db5c9ab - Replaced std::vector with custom FixedObserverList<T, MaxObservers> using static array. No heap allocations, safe for embedded systems. Default max is 16 observers (configurable via template parameter).
| } | ||
|
|
||
| /// <summary> | ||
| /// WebSocket Transport using NetCoreServer |
There was a problem hiding this comment.
Is there a c# way implementing the class in an actual file but not including it unless we need to.
We should not have example code just the actual implementation. Maybe structframesdk.cs should not import everything and instead the documentation should specify how to import and use specific packages. The same is true for the cpp interface, where asio.h may not need to be included.
There was a problem hiding this comment.
Updated in commit b08c2bc - Removed example code. WebSocket transport now uses conditional compilation (#if NETCORESERVER_AVAILABLE) so it's only included when the package is available and the define is set. No stub code remains.
| #### UDP Transport | ||
|
|
||
| ```python | ||
| from sdk import UdpTransport, UdpTransportConfig |
There was a problem hiding this comment.
calling it sdk is not great, maybe it should be prepended with struct-frame.
There was a problem hiding this comment.
Fixed in commit db5c9ab - All SDK directories renamed from sdk to struct_frame_sdk across all languages (TypeScript, Python, C++, C#). Documentation updated accordingly.
rijesha
left a comment
There was a problem hiding this comment.
There is some code that can be reused in the python implementation between the async and sync implementations.
Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com>
Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com>
|
|
||
| #pragma once | ||
|
|
||
| #include <algorithm> |
There was a problem hiding this comment.
Remove algorithm and functional
There was a problem hiding this comment.
The observer should not make a requirement for the CPP STD. That way light way embedded deployments can stay smaller.
There was a problem hiding this comment.
Fixed in commit 21c0a12 - Removed <algorithm> and <functional> includes. Replaced LambdaObserver (which used std::function) with FunctionObserver that uses plain function pointers. The observer pattern now has zero STL dependencies for embedded systems.
| @@ -0,0 +1,10 @@ | |||
| // C++ Struct Frame SDK | |||
There was a problem hiding this comment.
The concept of this entire file is not great. because an embedded platform will import asyncio if they import this. So we need to do something to fix that. maybe create an sdk.hpp and an sdk_embedded.hpp.
There was a problem hiding this comment.
What would also be good is a cpp build flag for the boilerplate code. If embedded, asio will not be included. in order for any cpp sdk code to be included there should be a cpp_sdk_full or cpp_sdk_embedded flag that is passed or something similar.
There was a problem hiding this comment.
Implemented in commit 21c0a12 - Created sdk_embedded.hpp that only includes transport.hpp, serial_transport.hpp, observer.hpp, and struct_frame_sdk.hpp (no ASIO). Also added --sdk and --sdk_embedded flags to control SDK generation. By default, no SDK files are copied. Use --sdk for full SDK with ASIO, or --sdk_embedded for minimal SDK without ASIO/network transports.
rijesha
left a comment
There was a problem hiding this comment.
The sdk code should not be included by default, they should only be generated with --sdk flag or --sdk_embedded flag.
Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com>
Implemented in commit 21c0a12 - SDK files are now only generated when |
|
@copilot should there be updates to the documentation now. |
Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com>
Yes, updated in commit 8973c50. All SDK documentation now explains:
|
Higher-Level SDK Implementation - COMPLETE
This PR implements comprehensive SDK support for TypeScript/JavaScript, Python, C++, and C# as requested in the issue.
Recent Updates
--sdkand--sdk_embeddedflagsCommand Line Usage
SDK Features by Flag
Documentation Updates
--sdkflag requirement--sdk(full with ASIO) and--sdk_embedded(minimal)All Requirements Met ✅
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.