munim-wifi 0.1.0 → 0.1.2

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.
Files changed (37) hide show
  1. package/README.md +132 -8
  2. package/ios/HybridMunimWifi.swift +248 -155
  3. package/lib/typescript/src/specs/munim-wifi.nitro.d.ts +47 -5
  4. package/lib/typescript/src/specs/munim-wifi.nitro.d.ts.map +1 -1
  5. package/nitrogen/generated/android/MunimWifi+autolinking.cmake +1 -0
  6. package/nitrogen/generated/android/c++/JConnectionOptions.hpp +66 -0
  7. package/nitrogen/generated/android/c++/JCurrentNetworkInfo.hpp +97 -0
  8. package/nitrogen/generated/android/c++/JHybridMunimWifiSpec.cpp +72 -0
  9. package/nitrogen/generated/android/c++/JHybridMunimWifiSpec.hpp +4 -0
  10. package/nitrogen/generated/android/c++/JVariant_NullType_CurrentNetworkInfo.cpp +26 -0
  11. package/nitrogen/generated/android/c++/JVariant_NullType_CurrentNetworkInfo.hpp +74 -0
  12. package/nitrogen/generated/android/c++/JWifiNetwork.hpp +9 -9
  13. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/ConnectionOptions.kt +44 -0
  14. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/CurrentNetworkInfo.kt +53 -0
  15. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/HybridMunimWifiSpec.kt +16 -0
  16. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/Variant_NullType_CurrentNetworkInfo.kt +59 -0
  17. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/WifiNetwork.kt +3 -3
  18. package/nitrogen/generated/ios/MunimWifi-Swift-Cxx-Bridge.cpp +16 -0
  19. package/nitrogen/generated/ios/MunimWifi-Swift-Cxx-Bridge.hpp +133 -0
  20. package/nitrogen/generated/ios/MunimWifi-Swift-Cxx-Umbrella.hpp +6 -0
  21. package/nitrogen/generated/ios/c++/HybridMunimWifiSpecSwift.hpp +38 -0
  22. package/nitrogen/generated/ios/swift/ConnectionOptions.swift +66 -0
  23. package/nitrogen/generated/ios/swift/CurrentNetworkInfo.swift +113 -0
  24. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  25. package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__CurrentNetworkInfo_.swift +59 -0
  26. package/nitrogen/generated/ios/swift/HybridMunimWifiSpec.swift +4 -0
  27. package/nitrogen/generated/ios/swift/HybridMunimWifiSpec_cxx.swift +90 -0
  28. package/nitrogen/generated/ios/swift/Variant_NullType_CurrentNetworkInfo.swift +18 -0
  29. package/nitrogen/generated/ios/swift/WifiNetwork.swift +18 -6
  30. package/nitrogen/generated/shared/c++/ConnectionOptions.hpp +92 -0
  31. package/nitrogen/generated/shared/c++/CurrentNetworkInfo.hpp +105 -0
  32. package/nitrogen/generated/shared/c++/HybridMunimWifiSpec.cpp +4 -0
  33. package/nitrogen/generated/shared/c++/HybridMunimWifiSpec.hpp +10 -0
  34. package/nitrogen/generated/shared/c++/WifiNetwork.hpp +9 -9
  35. package/package.json +2 -2
  36. package/src/index.ts +45 -0
  37. package/src/specs/munim-wifi.nitro.ts +56 -6
@@ -358,6 +358,96 @@ open class HybridMunimWifiSpec_cxx {
358
358
  }
359
359
  }
360
360
 
361
+ @inline(__always)
362
+ public final func getCurrentNetwork() -> bridge.Result_std__shared_ptr_Promise_std__variant_nitro__NullType__CurrentNetworkInfo____ {
363
+ do {
364
+ let __result = try self.__implementation.getCurrentNetwork()
365
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__variant_nitro__NullType__CurrentNetworkInfo___ in
366
+ let __promise = bridge.create_std__shared_ptr_Promise_std__variant_nitro__NullType__CurrentNetworkInfo___()
367
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__variant_nitro__NullType__CurrentNetworkInfo___(__promise)
368
+ __result
369
+ .then({ __result in __promiseHolder.resolve({ () -> bridge.std__variant_nitro__NullType__CurrentNetworkInfo_ in
370
+ switch __result {
371
+ case .first(let __value):
372
+ return bridge.create_std__variant_nitro__NullType__CurrentNetworkInfo_(margelo.nitro.NullType.null)
373
+ case .second(let __value):
374
+ return bridge.create_std__variant_nitro__NullType__CurrentNetworkInfo_(__value)
375
+ }
376
+ }().variant) })
377
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
378
+ return __promise
379
+ }()
380
+ return bridge.create_Result_std__shared_ptr_Promise_std__variant_nitro__NullType__CurrentNetworkInfo____(__resultCpp)
381
+ } catch (let __error) {
382
+ let __exceptionPtr = __error.toCpp()
383
+ return bridge.create_Result_std__shared_ptr_Promise_std__variant_nitro__NullType__CurrentNetworkInfo____(__exceptionPtr)
384
+ }
385
+ }
386
+
387
+ @inline(__always)
388
+ public final func connectToNetwork(options: ConnectionOptions) -> bridge.Result_std__shared_ptr_Promise_void___ {
389
+ do {
390
+ let __result = try self.__implementation.connectToNetwork(options: options)
391
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
392
+ let __promise = bridge.create_std__shared_ptr_Promise_void__()
393
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
394
+ __result
395
+ .then({ __result in __promiseHolder.resolve() })
396
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
397
+ return __promise
398
+ }()
399
+ return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
400
+ } catch (let __error) {
401
+ let __exceptionPtr = __error.toCpp()
402
+ return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
403
+ }
404
+ }
405
+
406
+ @inline(__always)
407
+ public final func disconnect() -> bridge.Result_std__shared_ptr_Promise_void___ {
408
+ do {
409
+ let __result = try self.__implementation.disconnect()
410
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
411
+ let __promise = bridge.create_std__shared_ptr_Promise_void__()
412
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
413
+ __result
414
+ .then({ __result in __promiseHolder.resolve() })
415
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
416
+ return __promise
417
+ }()
418
+ return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
419
+ } catch (let __error) {
420
+ let __exceptionPtr = __error.toCpp()
421
+ return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
422
+ }
423
+ }
424
+
425
+ @inline(__always)
426
+ public final func getIPAddress() -> bridge.Result_std__shared_ptr_Promise_std__variant_nitro__NullType__std__string____ {
427
+ do {
428
+ let __result = try self.__implementation.getIPAddress()
429
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__variant_nitro__NullType__std__string___ in
430
+ let __promise = bridge.create_std__shared_ptr_Promise_std__variant_nitro__NullType__std__string___()
431
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__variant_nitro__NullType__std__string___(__promise)
432
+ __result
433
+ .then({ __result in __promiseHolder.resolve({ () -> bridge.std__variant_nitro__NullType__std__string_ in
434
+ switch __result {
435
+ case .first(let __value):
436
+ return bridge.create_std__variant_nitro__NullType__std__string_(margelo.nitro.NullType.null)
437
+ case .second(let __value):
438
+ return bridge.create_std__variant_nitro__NullType__std__string_(std.string(__value))
439
+ }
440
+ }().variant) })
441
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
442
+ return __promise
443
+ }()
444
+ return bridge.create_Result_std__shared_ptr_Promise_std__variant_nitro__NullType__std__string____(__resultCpp)
445
+ } catch (let __error) {
446
+ let __exceptionPtr = __error.toCpp()
447
+ return bridge.create_Result_std__shared_ptr_Promise_std__variant_nitro__NullType__std__string____(__exceptionPtr)
448
+ }
449
+ }
450
+
361
451
  @inline(__always)
362
452
  public final func addListener(eventName: std.string) -> bridge.Result_void_ {
363
453
  do {
@@ -0,0 +1,18 @@
1
+ ///
2
+ /// Variant_NullType_CurrentNetworkInfo.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * An Swift enum with associated values representing a Variant/Union type.
12
+ * JS type: `null | struct`
13
+ */
14
+ @frozen
15
+ public indirect enum Variant_NullType_CurrentNetworkInfo {
16
+ case first(NullType)
17
+ case second(CurrentNetworkInfo)
18
+ }
@@ -19,8 +19,20 @@ public extension WifiNetwork {
19
19
  /**
20
20
  * Create a new instance of `WifiNetwork`.
21
21
  */
22
- init(ssid: String, bssid: String, rssi: Double, frequency: Double, channel: Double?, capabilities: String?, isSecure: Bool?, timestamp: Double?) {
23
- self.init(std.string(ssid), std.string(bssid), rssi, frequency, { () -> bridge.std__optional_double_ in
22
+ init(ssid: String, bssid: String, rssi: Double?, frequency: Double?, channel: Double?, capabilities: String?, isSecure: Bool?, timestamp: Double?) {
23
+ self.init(std.string(ssid), std.string(bssid), { () -> bridge.std__optional_double_ in
24
+ if let __unwrappedValue = rssi {
25
+ return bridge.create_std__optional_double_(__unwrappedValue)
26
+ } else {
27
+ return .init()
28
+ }
29
+ }(), { () -> bridge.std__optional_double_ in
30
+ if let __unwrappedValue = frequency {
31
+ return bridge.create_std__optional_double_(__unwrappedValue)
32
+ } else {
33
+ return .init()
34
+ }
35
+ }(), { () -> bridge.std__optional_double_ in
24
36
  if let __unwrappedValue = channel {
25
37
  return bridge.create_std__optional_double_(__unwrappedValue)
26
38
  } else {
@@ -58,13 +70,13 @@ public extension WifiNetwork {
58
70
  }
59
71
 
60
72
  @inline(__always)
61
- var rssi: Double {
62
- return self.__rssi
73
+ var rssi: Double? {
74
+ return self.__rssi.value
63
75
  }
64
76
 
65
77
  @inline(__always)
66
- var frequency: Double {
67
- return self.__frequency
78
+ var frequency: Double? {
79
+ return self.__frequency.value
68
80
  }
69
81
 
70
82
  @inline(__always)
@@ -0,0 +1,92 @@
1
+ ///
2
+ /// ConnectionOptions.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+ #include <string>
34
+ #include <optional>
35
+
36
+ namespace margelo::nitro::munimwifi {
37
+
38
+ /**
39
+ * A struct which can be represented as a JavaScript object (ConnectionOptions).
40
+ */
41
+ struct ConnectionOptions final {
42
+ public:
43
+ std::string ssid SWIFT_PRIVATE;
44
+ std::optional<std::string> password SWIFT_PRIVATE;
45
+ std::optional<bool> isWEP SWIFT_PRIVATE;
46
+
47
+ public:
48
+ ConnectionOptions() = default;
49
+ explicit ConnectionOptions(std::string ssid, std::optional<std::string> password, std::optional<bool> isWEP): ssid(ssid), password(password), isWEP(isWEP) {}
50
+
51
+ public:
52
+ friend bool operator==(const ConnectionOptions& lhs, const ConnectionOptions& rhs) = default;
53
+ };
54
+
55
+ } // namespace margelo::nitro::munimwifi
56
+
57
+ namespace margelo::nitro {
58
+
59
+ // C++ ConnectionOptions <> JS ConnectionOptions (object)
60
+ template <>
61
+ struct JSIConverter<margelo::nitro::munimwifi::ConnectionOptions> final {
62
+ static inline margelo::nitro::munimwifi::ConnectionOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
63
+ jsi::Object obj = arg.asObject(runtime);
64
+ return margelo::nitro::munimwifi::ConnectionOptions(
65
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ssid"))),
66
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "password"))),
67
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isWEP")))
68
+ );
69
+ }
70
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::munimwifi::ConnectionOptions& arg) {
71
+ jsi::Object obj(runtime);
72
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "ssid"), JSIConverter<std::string>::toJSI(runtime, arg.ssid));
73
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "password"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.password));
74
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "isWEP"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.isWEP));
75
+ return obj;
76
+ }
77
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
78
+ if (!value.isObject()) {
79
+ return false;
80
+ }
81
+ jsi::Object obj = value.getObject(runtime);
82
+ if (!nitro::isPlainObject(runtime, obj)) {
83
+ return false;
84
+ }
85
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ssid")))) return false;
86
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "password")))) return false;
87
+ if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isWEP")))) return false;
88
+ return true;
89
+ }
90
+ };
91
+
92
+ } // namespace margelo::nitro
@@ -0,0 +1,105 @@
1
+ ///
2
+ /// CurrentNetworkInfo.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+ #include <string>
34
+ #include <optional>
35
+ #include <vector>
36
+
37
+ namespace margelo::nitro::munimwifi {
38
+
39
+ /**
40
+ * A struct which can be represented as a JavaScript object (CurrentNetworkInfo).
41
+ */
42
+ struct CurrentNetworkInfo final {
43
+ public:
44
+ std::string ssid SWIFT_PRIVATE;
45
+ std::string bssid SWIFT_PRIVATE;
46
+ std::optional<std::string> ipAddress SWIFT_PRIVATE;
47
+ std::optional<std::string> subnetMask SWIFT_PRIVATE;
48
+ std::optional<std::string> gateway SWIFT_PRIVATE;
49
+ std::optional<std::vector<std::string>> dnsServers SWIFT_PRIVATE;
50
+
51
+ public:
52
+ CurrentNetworkInfo() = default;
53
+ explicit CurrentNetworkInfo(std::string ssid, std::string bssid, std::optional<std::string> ipAddress, std::optional<std::string> subnetMask, std::optional<std::string> gateway, std::optional<std::vector<std::string>> dnsServers): ssid(ssid), bssid(bssid), ipAddress(ipAddress), subnetMask(subnetMask), gateway(gateway), dnsServers(dnsServers) {}
54
+
55
+ public:
56
+ friend bool operator==(const CurrentNetworkInfo& lhs, const CurrentNetworkInfo& rhs) = default;
57
+ };
58
+
59
+ } // namespace margelo::nitro::munimwifi
60
+
61
+ namespace margelo::nitro {
62
+
63
+ // C++ CurrentNetworkInfo <> JS CurrentNetworkInfo (object)
64
+ template <>
65
+ struct JSIConverter<margelo::nitro::munimwifi::CurrentNetworkInfo> final {
66
+ static inline margelo::nitro::munimwifi::CurrentNetworkInfo fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
67
+ jsi::Object obj = arg.asObject(runtime);
68
+ return margelo::nitro::munimwifi::CurrentNetworkInfo(
69
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ssid"))),
70
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bssid"))),
71
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ipAddress"))),
72
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subnetMask"))),
73
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "gateway"))),
74
+ JSIConverter<std::optional<std::vector<std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "dnsServers")))
75
+ );
76
+ }
77
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::munimwifi::CurrentNetworkInfo& arg) {
78
+ jsi::Object obj(runtime);
79
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "ssid"), JSIConverter<std::string>::toJSI(runtime, arg.ssid));
80
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "bssid"), JSIConverter<std::string>::toJSI(runtime, arg.bssid));
81
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "ipAddress"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.ipAddress));
82
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "subnetMask"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.subnetMask));
83
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "gateway"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.gateway));
84
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "dnsServers"), JSIConverter<std::optional<std::vector<std::string>>>::toJSI(runtime, arg.dnsServers));
85
+ return obj;
86
+ }
87
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
88
+ if (!value.isObject()) {
89
+ return false;
90
+ }
91
+ jsi::Object obj = value.getObject(runtime);
92
+ if (!nitro::isPlainObject(runtime, obj)) {
93
+ return false;
94
+ }
95
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ssid")))) return false;
96
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bssid")))) return false;
97
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ipAddress")))) return false;
98
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "subnetMask")))) return false;
99
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "gateway")))) return false;
100
+ if (!JSIConverter<std::optional<std::vector<std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "dnsServers")))) return false;
101
+ return true;
102
+ }
103
+ };
104
+
105
+ } // namespace margelo::nitro
@@ -25,6 +25,10 @@ namespace margelo::nitro::munimwifi {
25
25
  prototype.registerHybridMethod("getBSSID", &HybridMunimWifiSpec::getBSSID);
26
26
  prototype.registerHybridMethod("getChannelInfo", &HybridMunimWifiSpec::getChannelInfo);
27
27
  prototype.registerHybridMethod("getNetworkInfo", &HybridMunimWifiSpec::getNetworkInfo);
28
+ prototype.registerHybridMethod("getCurrentNetwork", &HybridMunimWifiSpec::getCurrentNetwork);
29
+ prototype.registerHybridMethod("connectToNetwork", &HybridMunimWifiSpec::connectToNetwork);
30
+ prototype.registerHybridMethod("disconnect", &HybridMunimWifiSpec::disconnect);
31
+ prototype.registerHybridMethod("getIPAddress", &HybridMunimWifiSpec::getIPAddress);
28
32
  prototype.registerHybridMethod("addListener", &HybridMunimWifiSpec::addListener);
29
33
  prototype.registerHybridMethod("removeListeners", &HybridMunimWifiSpec::removeListeners);
30
34
  });
@@ -21,6 +21,10 @@ namespace margelo::nitro::munimwifi { struct ScanOptions; }
21
21
  namespace margelo::nitro::munimwifi { struct WifiFingerprint; }
22
22
  // Forward declaration of `ChannelInfo` to properly resolve imports.
23
23
  namespace margelo::nitro::munimwifi { struct ChannelInfo; }
24
+ // Forward declaration of `CurrentNetworkInfo` to properly resolve imports.
25
+ namespace margelo::nitro::munimwifi { struct CurrentNetworkInfo; }
26
+ // Forward declaration of `ConnectionOptions` to properly resolve imports.
27
+ namespace margelo::nitro::munimwifi { struct ConnectionOptions; }
24
28
 
25
29
  #include <NitroModules/Promise.hpp>
26
30
  #include "WifiNetwork.hpp"
@@ -32,6 +36,8 @@ namespace margelo::nitro::munimwifi { struct ChannelInfo; }
32
36
  #include <NitroModules/Null.hpp>
33
37
  #include <variant>
34
38
  #include "ChannelInfo.hpp"
39
+ #include "CurrentNetworkInfo.hpp"
40
+ #include "ConnectionOptions.hpp"
35
41
 
36
42
  namespace margelo::nitro::munimwifi {
37
43
 
@@ -75,6 +81,10 @@ namespace margelo::nitro::munimwifi {
75
81
  virtual std::shared_ptr<Promise<std::variant<nitro::NullType, std::string>>> getBSSID(const std::string& ssid) = 0;
76
82
  virtual std::shared_ptr<Promise<std::variant<nitro::NullType, ChannelInfo>>> getChannelInfo(const std::string& ssid) = 0;
77
83
  virtual std::shared_ptr<Promise<std::variant<nitro::NullType, WifiNetwork>>> getNetworkInfo(const std::string& ssid) = 0;
84
+ virtual std::shared_ptr<Promise<std::variant<nitro::NullType, CurrentNetworkInfo>>> getCurrentNetwork() = 0;
85
+ virtual std::shared_ptr<Promise<void>> connectToNetwork(const ConnectionOptions& options) = 0;
86
+ virtual std::shared_ptr<Promise<void>> disconnect() = 0;
87
+ virtual std::shared_ptr<Promise<std::variant<nitro::NullType, std::string>>> getIPAddress() = 0;
78
88
  virtual void addListener(const std::string& eventName) = 0;
79
89
  virtual void removeListeners(double count) = 0;
80
90
 
@@ -42,8 +42,8 @@ namespace margelo::nitro::munimwifi {
42
42
  public:
43
43
  std::string ssid SWIFT_PRIVATE;
44
44
  std::string bssid SWIFT_PRIVATE;
45
- double rssi SWIFT_PRIVATE;
46
- double frequency SWIFT_PRIVATE;
45
+ std::optional<double> rssi SWIFT_PRIVATE;
46
+ std::optional<double> frequency SWIFT_PRIVATE;
47
47
  std::optional<double> channel SWIFT_PRIVATE;
48
48
  std::optional<std::string> capabilities SWIFT_PRIVATE;
49
49
  std::optional<bool> isSecure SWIFT_PRIVATE;
@@ -51,7 +51,7 @@ namespace margelo::nitro::munimwifi {
51
51
 
52
52
  public:
53
53
  WifiNetwork() = default;
54
- explicit WifiNetwork(std::string ssid, std::string bssid, double rssi, double frequency, std::optional<double> channel, std::optional<std::string> capabilities, std::optional<bool> isSecure, std::optional<double> timestamp): ssid(ssid), bssid(bssid), rssi(rssi), frequency(frequency), channel(channel), capabilities(capabilities), isSecure(isSecure), timestamp(timestamp) {}
54
+ explicit WifiNetwork(std::string ssid, std::string bssid, std::optional<double> rssi, std::optional<double> frequency, std::optional<double> channel, std::optional<std::string> capabilities, std::optional<bool> isSecure, std::optional<double> timestamp): ssid(ssid), bssid(bssid), rssi(rssi), frequency(frequency), channel(channel), capabilities(capabilities), isSecure(isSecure), timestamp(timestamp) {}
55
55
 
56
56
  public:
57
57
  friend bool operator==(const WifiNetwork& lhs, const WifiNetwork& rhs) = default;
@@ -69,8 +69,8 @@ namespace margelo::nitro {
69
69
  return margelo::nitro::munimwifi::WifiNetwork(
70
70
  JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ssid"))),
71
71
  JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bssid"))),
72
- JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rssi"))),
73
- JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "frequency"))),
72
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rssi"))),
73
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "frequency"))),
74
74
  JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "channel"))),
75
75
  JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "capabilities"))),
76
76
  JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isSecure"))),
@@ -81,8 +81,8 @@ namespace margelo::nitro {
81
81
  jsi::Object obj(runtime);
82
82
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "ssid"), JSIConverter<std::string>::toJSI(runtime, arg.ssid));
83
83
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "bssid"), JSIConverter<std::string>::toJSI(runtime, arg.bssid));
84
- obj.setProperty(runtime, PropNameIDCache::get(runtime, "rssi"), JSIConverter<double>::toJSI(runtime, arg.rssi));
85
- obj.setProperty(runtime, PropNameIDCache::get(runtime, "frequency"), JSIConverter<double>::toJSI(runtime, arg.frequency));
84
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "rssi"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.rssi));
85
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "frequency"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.frequency));
86
86
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "channel"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.channel));
87
87
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "capabilities"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.capabilities));
88
88
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "isSecure"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.isSecure));
@@ -99,8 +99,8 @@ namespace margelo::nitro {
99
99
  }
100
100
  if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ssid")))) return false;
101
101
  if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bssid")))) return false;
102
- if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rssi")))) return false;
103
- if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "frequency")))) return false;
102
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rssi")))) return false;
103
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "frequency")))) return false;
104
104
  if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "channel")))) return false;
105
105
  if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "capabilities")))) return false;
106
106
  if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isSecure")))) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "munim-wifi",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "munim-wifi is a react native package built with Nitro",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "module": "./lib/module/index.js",
@@ -119,4 +119,4 @@
119
119
  ]
120
120
  ]
121
121
  }
122
- }
122
+ }
package/src/index.ts CHANGED
@@ -7,6 +7,8 @@ import type {
7
7
  ScanOptions,
8
8
  ChannelInfo,
9
9
  Location,
10
+ CurrentNetworkInfo,
11
+ ConnectionOptions,
10
12
  } from './specs/munim-wifi.nitro'
11
13
 
12
14
  const MunimWifi =
@@ -127,6 +129,7 @@ export function getChannelInfo(ssid: string): Promise<ChannelInfo | null> {
127
129
 
128
130
  /**
129
131
  * Get all available information for a specific network by SSID.
132
+ * Note: On iOS, RSSI, channel, and frequency will be undefined.
130
133
  *
131
134
  * @param ssid - The SSID of the network.
132
135
  * @returns Promise resolving to WifiNetwork object, or null if network not found.
@@ -135,6 +138,44 @@ export function getNetworkInfo(ssid: string): Promise<WifiNetwork | null> {
135
138
  return MunimWifi.getNetworkInfo(ssid)
136
139
  }
137
140
 
141
+ /**
142
+ * Get information about the currently connected Wi-Fi network.
143
+ *
144
+ * @returns Promise resolving to current network info, or null if not connected.
145
+ */
146
+ export function getCurrentNetwork(): Promise<CurrentNetworkInfo | null> {
147
+ return MunimWifi.getCurrentNetwork()
148
+ }
149
+
150
+ /**
151
+ * Connect to a Wi-Fi network.
152
+ * Note: Requires appropriate permissions and capabilities on both platforms.
153
+ *
154
+ * @param options - Connection options including SSID and password.
155
+ * @returns Promise resolving when connection is attempted.
156
+ */
157
+ export function connectToNetwork(options: ConnectionOptions): Promise<void> {
158
+ return MunimWifi.connectToNetwork(options)
159
+ }
160
+
161
+ /**
162
+ * Disconnect from the current Wi-Fi network.
163
+ *
164
+ * @returns Promise resolving when disconnection is complete.
165
+ */
166
+ export function disconnect(): Promise<void> {
167
+ return MunimWifi.disconnect()
168
+ }
169
+
170
+ /**
171
+ * Get IP address information for the current Wi-Fi connection.
172
+ *
173
+ * @returns Promise resolving to IP address string, or null if not connected.
174
+ */
175
+ export function getIPAddress(): Promise<string | null> {
176
+ return MunimWifi.getIPAddress()
177
+ }
178
+
138
179
  // ========== Event Management ==========
139
180
 
140
181
  /**
@@ -214,6 +255,10 @@ export default {
214
255
  getBSSID,
215
256
  getChannelInfo,
216
257
  getNetworkInfo,
258
+ getCurrentNetwork,
259
+ connectToNetwork,
260
+ disconnect,
261
+ getIPAddress,
217
262
  addNetworkFoundListener,
218
263
  addEventListener,
219
264
  addListener,
@@ -12,18 +12,35 @@ export interface ChannelInfo {
12
12
  frequency: number
13
13
  }
14
14
 
15
+ // Current network information
16
+ export interface CurrentNetworkInfo {
17
+ ssid: string
18
+ bssid: string
19
+ ipAddress?: string
20
+ subnetMask?: string
21
+ gateway?: string
22
+ dnsServers?: string[]
23
+ }
24
+
15
25
  // Wi-Fi Network information
16
26
  export interface WifiNetwork {
17
27
  ssid: string
18
28
  bssid: string
19
- rssi: number
20
- frequency: number
21
- channel?: number
29
+ rssi?: number // Not available on iOS
30
+ frequency?: number // Not available on iOS
31
+ channel?: number // Not available on iOS
22
32
  capabilities?: string
23
33
  isSecure?: boolean
24
34
  timestamp?: number
25
35
  }
26
36
 
37
+ // Connection options
38
+ export interface ConnectionOptions {
39
+ ssid: string
40
+ password?: string
41
+ isWEP?: boolean
42
+ }
43
+
27
44
  // Wi-Fi Fingerprint data
28
45
  export interface WifiFingerprint {
29
46
  networks: WifiNetwork[]
@@ -84,7 +101,7 @@ export interface MunimWifi
84
101
 
85
102
  /**
86
103
  * Get Wi-Fi fingerprint containing all network information.
87
- * This includes SSIDs, BSSIDs, RSSI, channels, and frequencies.
104
+ * Note: On iOS, RSSI, channel, and frequency are not available.
88
105
  *
89
106
  * @returns Promise resolving to Wi-Fi fingerprint data.
90
107
  */
@@ -92,9 +109,10 @@ export interface MunimWifi
92
109
 
93
110
  /**
94
111
  * Get RSSI (signal strength) for a specific network by SSID.
112
+ * Note: Not available on iOS - returns null.
95
113
  *
96
114
  * @param ssid - The SSID of the network.
97
- * @returns Promise resolving to RSSI value in dBm, or null if network not found.
115
+ * @returns Promise resolving to RSSI value in dBm, or null if network not found or not available.
98
116
  */
99
117
  getRSSI(ssid: string): Promise<number | null>
100
118
 
@@ -108,20 +126,52 @@ export interface MunimWifi
108
126
 
109
127
  /**
110
128
  * Get channel and frequency information for a specific network by SSID.
129
+ * Note: Not available on iOS - returns null.
111
130
  *
112
131
  * @param ssid - The SSID of the network.
113
- * @returns Promise resolving to object with channel and frequency, or null if network not found.
132
+ * @returns Promise resolving to object with channel and frequency, or null if network not found or not available.
114
133
  */
115
134
  getChannelInfo(ssid: string): Promise<ChannelInfo | null>
116
135
 
117
136
  /**
118
137
  * Get all available information for a specific network by SSID.
138
+ * Note: On iOS, RSSI, channel, and frequency will be undefined.
119
139
  *
120
140
  * @param ssid - The SSID of the network.
121
141
  * @returns Promise resolving to WifiNetwork object, or null if network not found.
122
142
  */
123
143
  getNetworkInfo(ssid: string): Promise<WifiNetwork | null>
124
144
 
145
+ /**
146
+ * Get information about the currently connected Wi-Fi network.
147
+ *
148
+ * @returns Promise resolving to current network info, or null if not connected.
149
+ */
150
+ getCurrentNetwork(): Promise<CurrentNetworkInfo | null>
151
+
152
+ /**
153
+ * Connect to a Wi-Fi network.
154
+ * Note: Requires appropriate permissions and capabilities on both platforms.
155
+ *
156
+ * @param options - Connection options including SSID and password.
157
+ * @returns Promise resolving when connection is attempted.
158
+ */
159
+ connectToNetwork(options: ConnectionOptions): Promise<void>
160
+
161
+ /**
162
+ * Disconnect from the current Wi-Fi network.
163
+ *
164
+ * @returns Promise resolving when disconnection is complete.
165
+ */
166
+ disconnect(): Promise<void>
167
+
168
+ /**
169
+ * Get IP address information for the current Wi-Fi connection.
170
+ *
171
+ * @returns Promise resolving to IP address string, or null if not connected.
172
+ */
173
+ getIPAddress(): Promise<string | null>
174
+
125
175
  // ========== Event Management ==========
126
176
 
127
177
  /**