@dittolive/ditto 4.10.2 → 4.11.0-preview.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DittoReactNative.podspec +1 -17
- package/README.md +4 -80
- package/node/ditto.cjs.js +444 -81
- package/node/ditto.darwin-arm64.node +0 -0
- package/node/ditto.darwin-x64.node +0 -0
- package/node/ditto.linux-arm64.node +0 -0
- package/node/ditto.linux-x64.node +0 -0
- package/node/ditto.win32-x64.node +0 -0
- package/package.json +1 -1
- package/react-native/android/build.gradle +29 -34
- package/react-native/android/cpp-adapter.cpp +10 -11
- package/react-native/android/dittoffi/src/ditto_transaction.cpp +1 -0
- package/react-native/android/dittoffi/src/ditto_transaction.h +91 -0
- package/react-native/android/dittoffi/src/dittoffi.h +587 -390
- package/react-native/android/dittoffi/src/dittoffi_java.cpp +3360 -1358
- package/react-native/android/dittoffi/src/dittoffi_java.h +59 -10
- package/react-native/android/dittoffi/src/dittoffi_java.i +2 -0
- package/react-native/android/dittoffi/src/dittostore_java.i +48 -0
- package/react-native/android/dittoffi/src/mesh_java_interfaces.h +81 -109
- package/react-native/android/gradle.properties +6 -5
- package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKModule.kt +23 -15
- package/react-native/cpp/include/DQL.h +1 -0
- package/react-native/cpp/include/Differ.h +14 -0
- package/react-native/cpp/include/Lifecycle.h +1 -1
- package/react-native/cpp/include/Transaction.h +18 -0
- package/react-native/cpp/include/Transports.h +1 -0
- package/react-native/cpp/include/Utils.h +27 -3
- package/react-native/cpp/include/main.h +2 -0
- package/react-native/cpp/src/DQL.cpp +21 -0
- package/react-native/cpp/src/Differ.cpp +57 -0
- package/react-native/cpp/src/Lifecycle.cpp +17 -7
- package/react-native/cpp/src/Misc.cpp +50 -32
- package/react-native/cpp/src/Transaction.cpp +195 -0
- package/react-native/cpp/src/Transports.cpp +77 -1
- package/react-native/cpp/src/Utils.cpp +11 -0
- package/react-native/cpp/src/main.cpp +18 -1
- package/react-native/ditto.es6.js +1 -1
- package/react-native/ios/DittoRNSDK.mm +2 -4
- package/types/ditto.d.ts +271 -33
- package/web/ditto.es6.js +1 -1
- package/web/ditto.umd.js +1 -1
- package/web/ditto.wasm +0 -0
- package/react-native/ios/YeetJSIUtils.h +0 -60
- package/react-native/ios/YeetJSIUtils.mm +0 -196
|
@@ -57,6 +57,57 @@ protected:
|
|
|
57
57
|
Swig::BoolArray<3> swig_override;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
+
class SwigDirector_TransactionCompletionContinuation : public TransactionCompletionContinuation, public Swig::Director {
|
|
61
|
+
|
|
62
|
+
public:
|
|
63
|
+
void swig_connect_director(JNIEnv *jenv, jobject jself, jclass jcls, bool swig_mem_own, bool weak_global);
|
|
64
|
+
SwigDirector_TransactionCompletionContinuation(JNIEnv *jenv);
|
|
65
|
+
virtual ~SwigDirector_TransactionCompletionContinuation();
|
|
66
|
+
virtual void java_retain();
|
|
67
|
+
virtual void java_release();
|
|
68
|
+
virtual void invoke(dittoffi_result_dittoffi_transaction_completion_action_t result);
|
|
69
|
+
public:
|
|
70
|
+
bool swig_overrides(int n) {
|
|
71
|
+
return (n < 3 ? swig_override[n] : false);
|
|
72
|
+
}
|
|
73
|
+
protected:
|
|
74
|
+
Swig::BoolArray<3> swig_override;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
class SwigDirector_TransactionExecuteContinuation : public TransactionExecuteContinuation, public Swig::Director {
|
|
78
|
+
|
|
79
|
+
public:
|
|
80
|
+
void swig_connect_director(JNIEnv *jenv, jobject jself, jclass jcls, bool swig_mem_own, bool weak_global);
|
|
81
|
+
SwigDirector_TransactionExecuteContinuation(JNIEnv *jenv);
|
|
82
|
+
virtual ~SwigDirector_TransactionExecuteContinuation();
|
|
83
|
+
virtual void java_retain();
|
|
84
|
+
virtual void java_release();
|
|
85
|
+
virtual void invoke(dittoffi_result_dittoffi_query_result_ptr_t result);
|
|
86
|
+
public:
|
|
87
|
+
bool swig_overrides(int n) {
|
|
88
|
+
return (n < 3 ? swig_override[n] : false);
|
|
89
|
+
}
|
|
90
|
+
protected:
|
|
91
|
+
Swig::BoolArray<3> swig_override;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
class SwigDirector_BeginTransactionContinuation : public BeginTransactionContinuation, public Swig::Director {
|
|
95
|
+
|
|
96
|
+
public:
|
|
97
|
+
void swig_connect_director(JNIEnv *jenv, jobject jself, jclass jcls, bool swig_mem_own, bool weak_global);
|
|
98
|
+
SwigDirector_BeginTransactionContinuation(JNIEnv *jenv);
|
|
99
|
+
virtual ~SwigDirector_BeginTransactionContinuation();
|
|
100
|
+
virtual void java_retain();
|
|
101
|
+
virtual void java_release();
|
|
102
|
+
virtual void invoke(dittoffi_result_dittoffi_transaction_ptr_t result);
|
|
103
|
+
public:
|
|
104
|
+
bool swig_overrides(int n) {
|
|
105
|
+
return (n < 3 ? swig_override[n] : false);
|
|
106
|
+
}
|
|
107
|
+
protected:
|
|
108
|
+
Swig::BoolArray<3> swig_override;
|
|
109
|
+
};
|
|
110
|
+
|
|
60
111
|
class SwigDirector_WifiAwareRust : public WifiAwareRust, public Swig::Director {
|
|
61
112
|
|
|
62
113
|
public:
|
|
@@ -73,16 +124,16 @@ public:
|
|
|
73
124
|
virtual void serverStopAdvertising();
|
|
74
125
|
virtual void serverUpdatePeer(char const *announce,ConnectState_t state);
|
|
75
126
|
virtual void updateParameterU64(dittoffi_wifi_aware_system_parameter_u64 parameter,uint64_t value);
|
|
76
|
-
virtual void
|
|
77
|
-
virtual void
|
|
78
|
-
virtual void addWifiAwareServerAdvertiser(CDitto *ditto);
|
|
79
|
-
virtual void removeWifiAwareServerAdvertiser();
|
|
127
|
+
virtual void addWifiAwareTransport(CDitto *ditto);
|
|
128
|
+
virtual void removeWifiAwareTransport();
|
|
80
129
|
virtual void clientPeerAppeared(char const *announce);
|
|
81
130
|
virtual void clientPeerDisappeared(char const *announce);
|
|
82
131
|
virtual void clientScanningStateChanged(OnlineState_t state,TransportCondition_t result);
|
|
83
132
|
virtual void clientNetworkDidCreate(char const *announce,char const *hostname,uint16_t port);
|
|
84
133
|
virtual void clientNetworkDidNotCreate(char const *announce);
|
|
85
134
|
virtual void serverAdvertisingStateChanged(OnlineState_t state,TransportCondition_t result);
|
|
135
|
+
virtual void serverNetworkScopeIdAdded(uint32_t scope_id);
|
|
136
|
+
virtual void serverNetworkScopeIdRemoved(uint32_t scope_id);
|
|
86
137
|
virtual void goOnlineRequest();
|
|
87
138
|
virtual void goOfflineRequest();
|
|
88
139
|
public:
|
|
@@ -116,10 +167,8 @@ public:
|
|
|
116
167
|
virtual int sendL2capToPeripheral(char const peripheralUuid[],size_t uuidLen,char const data[],size_t len);
|
|
117
168
|
virtual int readL2capFromCentral(char const centralUuid[],size_t uuidLen,slice_mut_uint8_t data);
|
|
118
169
|
virtual int sendL2capToCentral(char const centralUuid[],size_t uuidLen,char const data[],size_t len);
|
|
119
|
-
virtual void
|
|
120
|
-
virtual void
|
|
121
|
-
virtual void dropBleClientTransport();
|
|
122
|
-
virtual void dropBleServerTransport();
|
|
170
|
+
virtual void addBleTransport(CDitto *ditto);
|
|
171
|
+
virtual void dropBleTransport();
|
|
123
172
|
virtual void advertisementHeard(char const peripheralUuid[],size_t uuidLen,char const manufacturerData[],size_t manufacturerDataLen,bool manufacturerDataIncludesId,char *name,float rssi);
|
|
124
173
|
virtual void connectionStateChanged(char const peripheralUuid[],size_t uuidLen,ConnectState_t state,bool l2cap_available,int mtu);
|
|
125
174
|
virtual void peripheralMtuUpdated(char const uuid[],size_t uuidLen,int mtu);
|
|
@@ -138,10 +187,10 @@ public:
|
|
|
138
187
|
virtual void centralL2capDataAvailable(char const uuid[],size_t uuidLen);
|
|
139
188
|
public:
|
|
140
189
|
bool swig_overrides(int n) {
|
|
141
|
-
return (n <
|
|
190
|
+
return (n < 35 ? swig_override[n] : false);
|
|
142
191
|
}
|
|
143
192
|
protected:
|
|
144
|
-
Swig::BoolArray<
|
|
193
|
+
Swig::BoolArray<35> swig_override;
|
|
145
194
|
};
|
|
146
195
|
|
|
147
196
|
class SwigDirector_StatusRust : public StatusRust, public Swig::Director {
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
%{
|
|
13
13
|
#include "logger_cb.h"
|
|
14
14
|
#include "logger_export.h"
|
|
15
|
+
#include "ditto_transaction.h"
|
|
15
16
|
%}
|
|
16
17
|
// 🐉🐉
|
|
17
18
|
// Make sure to have this `%include` before that of dependent classes.
|
|
@@ -21,6 +22,7 @@
|
|
|
21
22
|
%include "retainable.h"
|
|
22
23
|
%include "logger_cb.h"
|
|
23
24
|
%include "logger_export.h"
|
|
25
|
+
%include "ditto_transaction.h"
|
|
24
26
|
%include "dittomesh_java.i"
|
|
25
27
|
%include "dittostore_java.i"
|
|
26
28
|
extern "C" {
|
|
@@ -285,6 +285,54 @@
|
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
+
/* Ditto for `SWIGTYPE_p_dittoffi_query_result_item[] -> slice_ref_dittoffi_query_result_item_ptr_t`: */
|
|
289
|
+
// High-level Java type (corresponding to Kotlin's `Array<SWIGTYPE_p_dittoffi_query_result_item>`):
|
|
290
|
+
%typemap(jstype) slice_ref_dittoffi_query_result_item_ptr_t "SWIGTYPE_p_dittoffi_query_result_item[]"
|
|
291
|
+
// JNI-compatible Java type
|
|
292
|
+
%typemap(jtype) slice_ref_dittoffi_query_result_item_ptr_t "SWIGTYPE_p_dittoffi_query_result_item[]"
|
|
293
|
+
// Conversion from the former to the latter (inwards)
|
|
294
|
+
%typemap(javain) slice_ref_dittoffi_query_result_item_ptr_t "$javainput"
|
|
295
|
+
// C JNI-equivalent to the `jtype`:
|
|
296
|
+
%typemap(jni) slice_ref_dittoffi_query_result_item_ptr_t "jobjectArray"
|
|
297
|
+
// Conversion from it to the C FFI type
|
|
298
|
+
%typemap(in) slice_ref_dittoffi_query_result_item_ptr_t {
|
|
299
|
+
size_t arr_len = (size_t) JCALL1(GetArrayLength, jenv, $input);
|
|
300
|
+
if (arr_len == 0) {
|
|
301
|
+
$1 = (slice_ref_dittoffi_query_result_item_ptr_t) { .ptr = (dittoffi_query_result_item * const *)0xbad000, .len = 0 };
|
|
302
|
+
} else {
|
|
303
|
+
$1 = (slice_ref_dittoffi_query_result_item_ptr_t) {
|
|
304
|
+
.len = arr_len,
|
|
305
|
+
};
|
|
306
|
+
$1.ptr = (typeof($1.ptr)) calloc(sizeof(*$1.ptr), $1.len);
|
|
307
|
+
// Prepare to call `SWIGTYPE_p_dittoffi_query_result_item.getCPtr()` as done above
|
|
308
|
+
jclass jcls_SWIGTYPE_p_dittoffi_query_result_item = JCALL1(FindClass, jenv
|
|
309
|
+
, "live/ditto/internal/swig/ffi/SWIGTYPE_p_dittoffi_query_result_item"
|
|
310
|
+
);
|
|
311
|
+
ASSERT_AND_THROW_RETURN_NULL(jcls_SWIGTYPE_p_dittoffi_query_result_item != NULL, jenv, "jcls_SWIGTYPE_p_dittoffi_query_result_item is NULL");
|
|
312
|
+
jmethodID getCPtr = JCALL3(GetStaticMethodID, jenv
|
|
313
|
+
, jcls_SWIGTYPE_p_dittoffi_query_result_item
|
|
314
|
+
, "getCPtr"
|
|
315
|
+
, "(Llive/ditto/internal/swig/ffi/SWIGTYPE_p_dittoffi_query_result_item;)J"
|
|
316
|
+
);
|
|
317
|
+
ASSERT_AND_THROW_RETURN_NULL(getCPtr != 0, jenv, "Failed to get method ID for getCPtr");
|
|
318
|
+
for (size_t i = 0; i < $1.len; ++i) {
|
|
319
|
+
jobject jobj = JCALL2(GetObjectArrayElement, jenv, $input, i);
|
|
320
|
+
((dittoffi_query_result_item const * *) $1.ptr)[i] = (dittoffi_query_result_item *)JCALL3(CallStaticLongMethod, jenv
|
|
321
|
+
, jcls_SWIGTYPE_p_dittoffi_query_result_item
|
|
322
|
+
, getCPtr
|
|
323
|
+
, jobj
|
|
324
|
+
);
|
|
325
|
+
JCALL1(DeleteLocalRef, jenv, jobj);
|
|
326
|
+
}
|
|
327
|
+
// Freeing $1.ptr is to be done within the `freearg` typemap
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
%typemap(freearg) slice_ref_dittoffi_query_result_item_ptr_t {
|
|
331
|
+
if ($1.len > 0) {
|
|
332
|
+
free((void *) $1.ptr); // frees calloc
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
288
336
|
/* These SWIG typemaps means that a Java `byte[]` is returned in place of a
|
|
289
337
|
* `slice_boxed_uint8_t` ("outwards")
|
|
290
338
|
*/
|
|
@@ -78,70 +78,52 @@ public:
|
|
|
78
78
|
return inst->updateParameterU64(parameter, value);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
virtual void
|
|
82
|
-
WifiAwareClientCallbacks_t
|
|
81
|
+
virtual void addWifiAwareTransport(struct CDitto *ditto) {
|
|
82
|
+
WifiAwareClientCallbacks_t client_cb = {
|
|
83
83
|
.start_searching = WifiAwareRust::invokeClientStartSearching,
|
|
84
84
|
.stop_searching = WifiAwareRust::invokeClientStopSearching,
|
|
85
85
|
.create_network = WifiAwareRust::invokeClientCreateNetwork,
|
|
86
86
|
.update_peer = WifiAwareRust::invokeClientUpdatePeer,
|
|
87
87
|
};
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
WifiAwareServerCallbacks_t server_cb = {
|
|
89
|
+
.start_advertising = WifiAwareRust::invokeServerStartAdvertising,
|
|
90
|
+
.stop_advertising = WifiAwareRust::invokeServerStopAdvertising,
|
|
91
|
+
.update_peer = WifiAwareRust::invokeServerUpdatePeer,
|
|
92
|
+
.update_parameter_u64 = WifiAwareRust::invokeUpdateParameterU64,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
auto handle = ditto_add_wifi_aware_transport(
|
|
96
|
+
ditto, client_cb, server_cb, this, WifiAwareRust::invokeRetain,
|
|
97
|
+
WifiAwareRust::invokeRelease);
|
|
91
98
|
atomic_store(
|
|
92
|
-
&
|
|
93
|
-
std::shared_ptr<
|
|
94
|
-
handle, [](
|
|
95
|
-
|
|
99
|
+
&transportHandle,
|
|
100
|
+
std::shared_ptr<TransportHandle_WifiAwarePlatformEvent_t>(
|
|
101
|
+
handle, [](TransportHandle_WifiAwarePlatformEvent_t *h) {
|
|
102
|
+
ditto_wifi_aware_transport_free_handle(h);
|
|
96
103
|
}));
|
|
97
104
|
}
|
|
98
105
|
|
|
99
|
-
virtual void
|
|
106
|
+
virtual void removeWifiAwareTransport() {
|
|
100
107
|
atomic_store(
|
|
101
|
-
&
|
|
102
|
-
std::shared_ptr<
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
virtual void addWifiAwareServerAdvertiser(struct CDitto *ditto) {
|
|
106
|
-
WifiAwareServerCallbacks_t cb = {
|
|
107
|
-
.start_advertising = WifiAwareRust::invokeServerStartAdvertising,
|
|
108
|
-
.stop_advertising = WifiAwareRust::invokeServerStopAdvertising,
|
|
109
|
-
.update_peer = WifiAwareRust::invokeServerUpdatePeer,
|
|
110
|
-
.update_parameter_u64 = WifiAwareRust::invokeUpdateParameterU64,
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
auto handle = ditto_add_wifi_aware_server_advertiser(
|
|
114
|
-
ditto, cb, this, WifiAwareRust::invokeRetain,
|
|
115
|
-
WifiAwareRust::invokeRelease);
|
|
116
|
-
atomic_store(
|
|
117
|
-
&serverHandle,
|
|
118
|
-
std::shared_ptr<TransportHandle_WifiAwareServerPlatformEvent_t>(
|
|
119
|
-
handle, [](TransportHandle_WifiAwareServerPlatformEvent_t *h) {
|
|
120
|
-
ditto_wifi_aware_server_free_handle(h);
|
|
121
|
-
}));
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
virtual void removeWifiAwareServerAdvertiser() {
|
|
125
|
-
atomic_store(
|
|
126
|
-
&serverHandle,
|
|
127
|
-
std::shared_ptr<TransportHandle_WifiAwareServerPlatformEvent_t>());
|
|
108
|
+
&transportHandle,
|
|
109
|
+
std::shared_ptr<TransportHandle_WifiAwarePlatformEvent_t>());
|
|
128
110
|
}
|
|
129
111
|
|
|
130
112
|
virtual void clientPeerAppeared(const char *announce) {
|
|
131
|
-
auto handle = atomic_load(&
|
|
113
|
+
auto handle = atomic_load(&transportHandle);
|
|
132
114
|
if (handle) {
|
|
133
115
|
ditto_wifi_aware_client_peer_appeared(handle.get(), announce);
|
|
134
116
|
}
|
|
135
117
|
}
|
|
136
118
|
virtual void clientPeerDisappeared(const char *announce) {
|
|
137
|
-
auto handle = atomic_load(&
|
|
119
|
+
auto handle = atomic_load(&transportHandle);
|
|
138
120
|
if (handle) {
|
|
139
121
|
ditto_wifi_aware_client_peer_disappeared(handle.get(), announce);
|
|
140
122
|
}
|
|
141
123
|
}
|
|
142
124
|
virtual void clientScanningStateChanged(OnlineState_t state,
|
|
143
125
|
TransportCondition_t result) {
|
|
144
|
-
auto handle = atomic_load(&
|
|
126
|
+
auto handle = atomic_load(&transportHandle);
|
|
145
127
|
if (handle) {
|
|
146
128
|
ditto_wifi_aware_client_scanning_state_changed(handle.get(), state,
|
|
147
129
|
result);
|
|
@@ -149,14 +131,14 @@ public:
|
|
|
149
131
|
}
|
|
150
132
|
virtual void clientNetworkDidCreate(const char *announce,
|
|
151
133
|
const char *hostname, uint16_t port) {
|
|
152
|
-
auto handle = atomic_load(&
|
|
134
|
+
auto handle = atomic_load(&transportHandle);
|
|
153
135
|
if (handle) {
|
|
154
136
|
ditto_wifi_aware_client_network_did_create(handle.get(), announce,
|
|
155
137
|
hostname, port);
|
|
156
138
|
}
|
|
157
139
|
}
|
|
158
140
|
virtual void clientNetworkDidNotCreate(const char *announce) {
|
|
159
|
-
auto handle = atomic_load(&
|
|
141
|
+
auto handle = atomic_load(&transportHandle);
|
|
160
142
|
if (handle) {
|
|
161
143
|
ditto_wifi_aware_client_peer_did_not_connect(handle.get(), announce);
|
|
162
144
|
}
|
|
@@ -164,37 +146,44 @@ public:
|
|
|
164
146
|
|
|
165
147
|
virtual void serverAdvertisingStateChanged(OnlineState_t state,
|
|
166
148
|
TransportCondition_t result) {
|
|
167
|
-
auto handle = atomic_load(&
|
|
149
|
+
auto handle = atomic_load(&transportHandle);
|
|
168
150
|
if (handle) {
|
|
169
151
|
ditto_wifi_aware_server_advertising_state_changed(handle.get(), state,
|
|
170
152
|
result);
|
|
171
153
|
}
|
|
172
154
|
}
|
|
173
155
|
|
|
174
|
-
virtual void
|
|
175
|
-
auto
|
|
176
|
-
if (
|
|
177
|
-
|
|
156
|
+
virtual void serverNetworkScopeIdAdded(uint32_t scope_id) {
|
|
157
|
+
auto handle = atomic_load(&transportHandle);
|
|
158
|
+
if (handle) {
|
|
159
|
+
ditto_wifi_aware_server_network_scope_id_added(handle.get(), scope_id);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
virtual void serverNetworkScopeIdRemoved(uint32_t scope_id) {
|
|
164
|
+
auto handle = atomic_load(&transportHandle);
|
|
165
|
+
if (handle) {
|
|
166
|
+
ditto_wifi_aware_server_network_scope_id_removed(handle.get(), scope_id);
|
|
178
167
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
virtual void goOnlineRequest() {
|
|
171
|
+
auto handle = atomic_load(&transportHandle);
|
|
172
|
+
if (handle) {
|
|
173
|
+
ditto_wifi_aware_server_go_online_request(handle.get());
|
|
174
|
+
ditto_wifi_aware_client_go_online_request(handle.get());
|
|
182
175
|
}
|
|
183
176
|
}
|
|
184
177
|
|
|
185
178
|
virtual void goOfflineRequest() {
|
|
186
|
-
auto
|
|
187
|
-
if (
|
|
188
|
-
ditto_wifi_aware_server_go_offline_request(
|
|
189
|
-
|
|
190
|
-
auto client_handle = atomic_load(&clientHandle);
|
|
191
|
-
if (client_handle) {
|
|
192
|
-
ditto_wifi_aware_client_go_offline_request(client_handle.get());
|
|
179
|
+
auto handle = atomic_load(&transportHandle);
|
|
180
|
+
if (handle) {
|
|
181
|
+
ditto_wifi_aware_server_go_offline_request(handle.get());
|
|
182
|
+
ditto_wifi_aware_client_go_offline_request(handle.get());
|
|
193
183
|
}
|
|
194
184
|
}
|
|
195
185
|
|
|
196
|
-
std::shared_ptr<
|
|
197
|
-
std::shared_ptr<TransportHandle_WifiAwareServerPlatformEvent_t> serverHandle;
|
|
186
|
+
std::shared_ptr<TransportHandle_WifiAwarePlatformEvent_t> transportHandle;
|
|
198
187
|
};
|
|
199
188
|
|
|
200
189
|
#ifdef SWIG
|
|
@@ -335,8 +324,8 @@ public:
|
|
|
335
324
|
return inst->sendL2capToCentral((const char *)central_uuid, 16,
|
|
336
325
|
(char const *)data.ptr, data.len);
|
|
337
326
|
}
|
|
338
|
-
virtual void
|
|
339
|
-
BleClientCallbacks_t
|
|
327
|
+
virtual void addBleTransport(struct CDitto *ditto) {
|
|
328
|
+
BleClientCallbacks_t client_cb = {
|
|
340
329
|
.start_scanning = BluetoothLeRadioRust::invokeStartScanning,
|
|
341
330
|
.stop_scanning = BluetoothLeRadioRust::invokeStopScanning,
|
|
342
331
|
.scanning_state = BluetoothLeRadioRust::invokeGetScanningState,
|
|
@@ -348,20 +337,7 @@ public:
|
|
|
348
337
|
BluetoothLeRadioRust::invokeReadL2capFromPeripheral,
|
|
349
338
|
.send_l2cap_to_peripheral =
|
|
350
339
|
BluetoothLeRadioRust::invokeSendL2capToPeripheral};
|
|
351
|
-
|
|
352
|
-
ditto, cb, this, BluetoothLeRadioRust::invokeRetain,
|
|
353
|
-
BluetoothLeRadioRust::invokeRelease);
|
|
354
|
-
atomic_store(&clientHandle,
|
|
355
|
-
std::shared_ptr<TransportHandle_BleClientPlatformEvent_t>(
|
|
356
|
-
handle, [](TransportHandle_BleClientPlatformEvent_t *h) {
|
|
357
|
-
// We own this pointer
|
|
358
|
-
// When nobody is using it any more we will free it via
|
|
359
|
-
// Rust
|
|
360
|
-
ble_client_free_handle(h);
|
|
361
|
-
}));
|
|
362
|
-
}
|
|
363
|
-
virtual void addBleServerTransport(struct CDitto *ditto) {
|
|
364
|
-
BleServerCallbacks_t cb = {
|
|
340
|
+
BleServerCallbacks_t server_cb = {
|
|
365
341
|
.start_advertising = BluetoothLeRadioRust::invokeStartAdvertising,
|
|
366
342
|
.stop_advertising = BluetoothLeRadioRust::invokeStopAdvertising,
|
|
367
343
|
.advertising_state = BluetoothLeRadioRust::invokeGetAdvertisingState,
|
|
@@ -370,31 +346,28 @@ public:
|
|
|
370
346
|
BluetoothLeRadioRust::invokeReadL2capFromCentral,
|
|
371
347
|
.send_l2cap_to_central =
|
|
372
348
|
BluetoothLeRadioRust::invokeSendL2capToCentral};
|
|
373
|
-
auto handle =
|
|
374
|
-
ditto,
|
|
349
|
+
auto handle = ditto_add_ble_transport(
|
|
350
|
+
ditto, client_cb, this, server_cb, this, BluetoothLeRadioRust::invokeRetain,
|
|
375
351
|
BluetoothLeRadioRust::invokeRelease);
|
|
376
|
-
atomic_store(&
|
|
377
|
-
std::shared_ptr<
|
|
378
|
-
handle, [](
|
|
379
|
-
|
|
352
|
+
atomic_store(&transportHandle,
|
|
353
|
+
std::shared_ptr<TransportHandle_BlePlatformEvent_t>(
|
|
354
|
+
handle, [](TransportHandle_BlePlatformEvent_t *h) {
|
|
355
|
+
ditto_ble_transport_free_handle(h);
|
|
380
356
|
}));
|
|
381
357
|
}
|
|
382
|
-
|
|
358
|
+
|
|
359
|
+
virtual void dropBleTransport() {
|
|
383
360
|
// This is how we break the circular ownership when it is time to shut down
|
|
384
361
|
// the transport
|
|
385
|
-
atomic_store(&
|
|
386
|
-
std::shared_ptr<
|
|
387
|
-
}
|
|
388
|
-
virtual void dropBleServerTransport() {
|
|
389
|
-
atomic_store(&serverHandle,
|
|
390
|
-
std::shared_ptr<TransportHandle_BleServerPlatformEvent_t>());
|
|
362
|
+
atomic_store(&transportHandle,
|
|
363
|
+
std::shared_ptr<TransportHandle_BlePlatformEvent_t>());
|
|
391
364
|
}
|
|
392
365
|
virtual void advertisementHeard(const char peripheralUuid[], size_t uuidLen,
|
|
393
366
|
const char manufacturerData[],
|
|
394
367
|
size_t manufacturerDataLen,
|
|
395
368
|
bool manufacturerDataIncludesId, char *name,
|
|
396
369
|
float rssi) {
|
|
397
|
-
auto handle = atomic_load(&
|
|
370
|
+
auto handle = atomic_load(&transportHandle);
|
|
398
371
|
if (handle) {
|
|
399
372
|
ditto_transports_ble_advertisement_heard(
|
|
400
373
|
handle.get(), (uint8_16_array_t const *)peripheralUuid,
|
|
@@ -414,7 +387,7 @@ public:
|
|
|
414
387
|
virtual void connectionStateChanged(const char peripheralUuid[],
|
|
415
388
|
size_t uuidLen, ConnectState_t state,
|
|
416
389
|
bool l2cap_available, int mtu) {
|
|
417
|
-
auto handle = atomic_load(&
|
|
390
|
+
auto handle = atomic_load(&transportHandle);
|
|
418
391
|
assert(uuidLen == 16);
|
|
419
392
|
if (handle) {
|
|
420
393
|
ble_connection_state_changed(handle.get(),
|
|
@@ -425,7 +398,7 @@ public:
|
|
|
425
398
|
}
|
|
426
399
|
virtual void peripheralMtuUpdated(const char uuid[], size_t uuidLen,
|
|
427
400
|
int mtu) {
|
|
428
|
-
auto handle = atomic_load(&
|
|
401
|
+
auto handle = atomic_load(&transportHandle);
|
|
429
402
|
assert(uuidLen == 16);
|
|
430
403
|
if (handle) {
|
|
431
404
|
ble_peripheral_mtu_updated(handle.get(), (uint8_16_array_t const *)uuid,
|
|
@@ -436,7 +409,7 @@ public:
|
|
|
436
409
|
virtual void receivedFromPeripheral(const char peripheralUuid[],
|
|
437
410
|
size_t uuidLen, BleDataType_t dataType,
|
|
438
411
|
const char data[], size_t len) {
|
|
439
|
-
auto handle = atomic_load(&
|
|
412
|
+
auto handle = atomic_load(&transportHandle);
|
|
440
413
|
assert(uuidLen == 16);
|
|
441
414
|
if (handle) {
|
|
442
415
|
ble_received_from_peripheral(
|
|
@@ -450,13 +423,13 @@ public:
|
|
|
450
423
|
}
|
|
451
424
|
virtual void scanningStateChanged(OnlineState_t state,
|
|
452
425
|
TransportCondition_t result) {
|
|
453
|
-
auto handle = atomic_load(&
|
|
426
|
+
auto handle = atomic_load(&transportHandle);
|
|
454
427
|
if (handle) {
|
|
455
428
|
ble_scanning_state_changed(handle.get(), state, result);
|
|
456
429
|
}
|
|
457
430
|
}
|
|
458
431
|
virtual void peripheralReadyToSend(const char uuid[], size_t uuidLen) {
|
|
459
|
-
auto handle = atomic_load(&
|
|
432
|
+
auto handle = atomic_load(&transportHandle);
|
|
460
433
|
assert(uuidLen == 16);
|
|
461
434
|
if (handle) {
|
|
462
435
|
ble_peripheral_ready_to_send(handle.get(),
|
|
@@ -466,7 +439,7 @@ public:
|
|
|
466
439
|
}
|
|
467
440
|
virtual void peripheralL2capReadyToSend(const char uuid[], size_t uuidLen) {
|
|
468
441
|
assert(uuidLen == 16);
|
|
469
|
-
auto handle = atomic_load(&
|
|
442
|
+
auto handle = atomic_load(&transportHandle);
|
|
470
443
|
if (handle) {
|
|
471
444
|
ble_peripheral_l2cap_ready_to_send(handle.get(),
|
|
472
445
|
(uint8_16_array_t const *)uuid);
|
|
@@ -475,7 +448,7 @@ public:
|
|
|
475
448
|
}
|
|
476
449
|
virtual void peripheralL2capDataAvailable(const char uuid[], size_t uuidLen) {
|
|
477
450
|
assert(uuidLen == 16);
|
|
478
|
-
auto handle = atomic_load(&
|
|
451
|
+
auto handle = atomic_load(&transportHandle);
|
|
479
452
|
if (handle) {
|
|
480
453
|
ble_peripheral_l2cap_data_available(handle.get(),
|
|
481
454
|
(uint8_16_array_t const *)uuid);
|
|
@@ -484,13 +457,13 @@ public:
|
|
|
484
457
|
}
|
|
485
458
|
virtual void advertisingStateChanged(OnlineState_t state,
|
|
486
459
|
TransportCondition_t result) {
|
|
487
|
-
auto handle = atomic_load(&
|
|
460
|
+
auto handle = atomic_load(&transportHandle);
|
|
488
461
|
if (handle) {
|
|
489
462
|
ble_advertising_state_changed(handle.get(), state, result);
|
|
490
463
|
}
|
|
491
464
|
}
|
|
492
465
|
virtual void centralMtuUpdated(const char uuid[], size_t uuidLen, int mtu) {
|
|
493
|
-
auto handle = atomic_load(&
|
|
466
|
+
auto handle = atomic_load(&transportHandle);
|
|
494
467
|
assert(uuidLen == 16);
|
|
495
468
|
if (handle) {
|
|
496
469
|
ble_central_mtu_updated(handle.get(), (uint8_16_array_t const *)uuid,
|
|
@@ -501,7 +474,7 @@ public:
|
|
|
501
474
|
virtual void receivedFromCentral(const char centralUuid[], size_t uuidLen,
|
|
502
475
|
BleDataType_t dataType, const char data[],
|
|
503
476
|
size_t len) {
|
|
504
|
-
auto handle = atomic_load(&
|
|
477
|
+
auto handle = atomic_load(&transportHandle);
|
|
505
478
|
assert(uuidLen == 16);
|
|
506
479
|
if (handle) {
|
|
507
480
|
ble_received_from_central(handle.get(),
|
|
@@ -517,7 +490,7 @@ public:
|
|
|
517
490
|
size_t uuidLen, const char data[],
|
|
518
491
|
size_t len, bool l2capAvailable,
|
|
519
492
|
int mtu) {
|
|
520
|
-
auto handle = atomic_load(&
|
|
493
|
+
auto handle = atomic_load(&transportHandle);
|
|
521
494
|
if (handle) {
|
|
522
495
|
ble_central_finished_connecting(handle.get(),
|
|
523
496
|
(uint8_16_array_t const *)centralUuid,
|
|
@@ -530,7 +503,7 @@ public:
|
|
|
530
503
|
}
|
|
531
504
|
virtual void centralUnsubscribed(const char centralUuid[], size_t uuidLen) {
|
|
532
505
|
assert(uuidLen == 16);
|
|
533
|
-
auto handle = atomic_load(&
|
|
506
|
+
auto handle = atomic_load(&transportHandle);
|
|
534
507
|
if (handle) {
|
|
535
508
|
ble_central_unsubscribed(handle.get(),
|
|
536
509
|
(uint8_16_array_t const *)centralUuid);
|
|
@@ -538,7 +511,7 @@ public:
|
|
|
538
511
|
}
|
|
539
512
|
virtual void centralReadyToSend(const char uuid[], size_t uuidLen) {
|
|
540
513
|
assert(uuidLen == 16);
|
|
541
|
-
auto handle = atomic_load(&
|
|
514
|
+
auto handle = atomic_load(&transportHandle);
|
|
542
515
|
if (handle) {
|
|
543
516
|
ble_central_ready_to_send(handle.get(), (uint8_16_array_t const *)uuid);
|
|
544
517
|
}
|
|
@@ -546,7 +519,7 @@ public:
|
|
|
546
519
|
}
|
|
547
520
|
virtual void centralL2capReadyToSend(const char uuid[], size_t uuidLen) {
|
|
548
521
|
assert(uuidLen == 16);
|
|
549
|
-
auto handle = atomic_load(&
|
|
522
|
+
auto handle = atomic_load(&transportHandle);
|
|
550
523
|
if (handle) {
|
|
551
524
|
ble_central_l2cap_ready_to_send(handle.get(),
|
|
552
525
|
(uint8_16_array_t const *)uuid);
|
|
@@ -555,15 +528,14 @@ public:
|
|
|
555
528
|
}
|
|
556
529
|
virtual void centralL2capDataAvailable(const char uuid[], size_t uuidLen) {
|
|
557
530
|
assert(uuidLen == 16);
|
|
558
|
-
auto handle = atomic_load(&
|
|
531
|
+
auto handle = atomic_load(&transportHandle);
|
|
559
532
|
if (handle) {
|
|
560
533
|
ble_central_l2cap_data_available(handle.get(),
|
|
561
534
|
(uint8_16_array_t const *)uuid);
|
|
562
535
|
}
|
|
563
536
|
(void)uuidLen;
|
|
564
537
|
}
|
|
565
|
-
std::shared_ptr<
|
|
566
|
-
std::shared_ptr<TransportHandle_BleServerPlatformEvent_t> serverHandle;
|
|
538
|
+
std::shared_ptr<TransportHandle_BlePlatformEvent_t> transportHandle;
|
|
567
539
|
};
|
|
568
540
|
|
|
569
541
|
#ifdef SWIG
|
|
@@ -649,7 +621,7 @@ public:
|
|
|
649
621
|
#endif
|
|
650
622
|
class DiskUsageObserverRust : public Retainable {
|
|
651
623
|
private:
|
|
652
|
-
DiskUsageObserver *
|
|
624
|
+
DiskUsageObserver *obplatformHandle;
|
|
653
625
|
|
|
654
626
|
public:
|
|
655
627
|
virtual ~DiskUsageObserverRust() {}
|
|
@@ -662,14 +634,14 @@ public:
|
|
|
662
634
|
}
|
|
663
635
|
|
|
664
636
|
virtual void subscribe(struct CDitto *ditto) {
|
|
665
|
-
|
|
637
|
+
obplatformHandle = ditto_register_disk_usage_callback(
|
|
666
638
|
ditto, FsComponent::FS_COMPONENT_ROOT, this,
|
|
667
639
|
DiskUsageObserverRust::invokeRetain,
|
|
668
640
|
DiskUsageObserverRust::invokeRelease,
|
|
669
641
|
DiskUsageObserverRust::invokeDiskUsageUpdated);
|
|
670
642
|
}
|
|
671
643
|
|
|
672
|
-
virtual void stop() { ditto_release_disk_usage_callback(
|
|
644
|
+
virtual void stop() { ditto_release_disk_usage_callback(obplatformHandle); }
|
|
673
645
|
};
|
|
674
646
|
|
|
675
647
|
#ifdef SWIG
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
rnsdk__kotlinVersion=2.0.21
|
|
2
|
+
rnsdk__minSdkVersion=24
|
|
3
|
+
rnsdk__targetSdkVersion=34
|
|
4
|
+
rnsdk__compileSdkVersion=35
|
|
5
|
+
rnsdk__ndkVersion=27.1.12297006
|
|
6
|
+
|
|
@@ -4,16 +4,15 @@ import android.os.Build
|
|
|
4
4
|
import android.util.Log
|
|
5
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
6
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
7
|
-
import com.facebook.react.module.annotations.ReactModule
|
|
8
7
|
import com.facebook.react.bridge.ReactMethod
|
|
9
8
|
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder
|
|
9
|
+
import com.facebook.soloader.SoLoader
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
@ReactModule(name = DittoRNSDKModule.NAME)
|
|
13
11
|
class DittoRNSDKModule(private val reactContext: ReactApplicationContext) :
|
|
14
12
|
ReactContextBaseJavaModule(reactContext) {
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
|
|
14
|
+
override fun getName(): String {
|
|
15
|
+
return NAME
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
private external fun nativeInstall(
|
|
@@ -23,24 +22,27 @@ class DittoRNSDKModule(private val reactContext: ReactApplicationContext) :
|
|
|
23
22
|
defaultDir: String
|
|
24
23
|
)
|
|
25
24
|
|
|
26
|
-
override fun getName(): String = NAME
|
|
27
|
-
|
|
28
25
|
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
29
26
|
fun install(): Boolean {
|
|
30
27
|
return try {
|
|
31
|
-
|
|
28
|
+
SoLoader.init(reactContext, false)
|
|
29
|
+
SoLoader.loadLibrary("dittorn")
|
|
30
|
+
|
|
32
31
|
|
|
33
32
|
val jsContextHolder = reactContext.javaScriptContextHolder
|
|
33
|
+
// Although catalystInstance.jsCallInvokerHolder, it used to be the only
|
|
34
|
+
// way to make it work with older RN project (0.73, I believe), so be sure
|
|
35
|
+
// to check there if modifying.
|
|
34
36
|
val jsCallInvokerHolder = reactContext.catalystInstance.jsCallInvokerHolder
|
|
35
37
|
|
|
36
38
|
if (jsContextHolder != null && jsCallInvokerHolder != null) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
nativeInstall(
|
|
40
|
+
reactContext,
|
|
41
|
+
jsCallInvokerHolder,
|
|
42
|
+
jsContextHolder.get(),
|
|
43
|
+
reactContext.filesDir.absolutePath
|
|
44
|
+
)
|
|
45
|
+
true
|
|
44
46
|
} else {
|
|
45
47
|
Log.e("ReactNative", "JavaScript context or call invoker holder is null.")
|
|
46
48
|
false
|
|
@@ -51,9 +53,15 @@ class DittoRNSDKModule(private val reactContext: ReactApplicationContext) :
|
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
|
|
56
|
+
// This is actually called by the JS SDK.
|
|
57
|
+
@Suppress("unused")
|
|
54
58
|
fun defaultDeviceName(): String {
|
|
55
59
|
val manufacturer = Build.MANUFACTURER
|
|
56
60
|
val model = Build.MODEL
|
|
57
61
|
return if (model.startsWith(manufacturer)) model else "$manufacturer $model"
|
|
58
62
|
}
|
|
63
|
+
|
|
64
|
+
companion object {
|
|
65
|
+
const val NAME = "DittoRNSDK"
|
|
66
|
+
}
|
|
59
67
|
}
|