File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 1616
1717#define RESET_METHOD " $/reset"
1818#define BIND_METHOD " $/register"
19+ #define GET_VERSION_METHOD " $/version"
20+
1921// #define BRIDGE_ERROR "$/bridgeLog"
2022
2123#define UPDATE_THREAD_STACK_SIZE 500
@@ -157,6 +159,8 @@ class BridgeClass {
157159
158160 bool started = false ;
159161
162+ MsgPack::str_t router_ver;
163+
160164public:
161165
162166 explicit BridgeClass (HardwareSerial& serial) {
@@ -204,6 +208,10 @@ class BridgeClass {
204208 return res;
205209 }
206210
211+ bool getRouterVersion (MsgPack::str_t & version) {
212+ return call (GET_VERSION_METHOD).result (version);
213+ }
214+
207215 template <typename F>
208216 bool provide (const MsgPack::str_t & name, F&& func) {
209217 k_mutex_lock (&bridge_mutex, K_FOREVER);
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ class BridgeMonitor: public Stream {
3131 RingBufferN<BufferSize> temp_buffer;
3232 struct k_mutex monitor_mutex{};
3333 bool _connected = false ;
34+ bool _compatibility_mode;
3435
3536public:
3637 explicit BridgeMonitor (BridgeClass& bridge): bridge(&bridge) {}
@@ -55,6 +56,8 @@ class BridgeMonitor: public Stream {
5556
5657 bool out = false ;
5758 _connected = bridge->call (MON_CONNECTED_METHOD).result (out) && out;
59+ MsgPack::str_t ver;
60+ _compatibility_mode = !bridge->call (GET_VERSION_METHOD).result (ver);
5861 k_mutex_unlock (&monitor_mutex);
5962 return out;
6063 }
@@ -117,10 +120,15 @@ class BridgeMonitor: public Stream {
117120 send_buffer += static_cast <char >(buffer[i]);
118121 }
119122
120- size_t written;
121- const bool ret = bridge->call (MON_WRITE_METHOD, send_buffer).result (written);
123+ size_t written = 0 ;
122124
123- return ret? written : 0 ;
125+ if (_compatibility_mode) {
126+ bridge->call (MON_WRITE_METHOD, send_buffer).result (written);
127+ } else {
128+ bridge->notify (MON_WRITE_METHOD, send_buffer);
129+ }
130+
131+ return written;
124132 }
125133
126134 bool reset () {
You can’t perform that action at this time.
0 commit comments