munim-wifi 0.1.0

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 (96) hide show
  1. package/LICENSE +21 -0
  2. package/MunimWifi.podspec +31 -0
  3. package/README.md +591 -0
  4. package/android/CMakeLists.txt +32 -0
  5. package/android/build.gradle +148 -0
  6. package/android/fix-prefab.gradle +51 -0
  7. package/android/gradle.properties +5 -0
  8. package/android/src/main/AndroidManifest.xml +6 -0
  9. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  10. package/android/src/main/java/com/munimwifi/HybridMunimWifi.kt +283 -0
  11. package/android/src/main/java/com/munimwifi/MunimWifiPackage.kt +20 -0
  12. package/ios/Bridge.h +8 -0
  13. package/ios/HybridMunimWifi.swift +222 -0
  14. package/lib/commonjs/index.js +216 -0
  15. package/lib/commonjs/index.js.map +1 -0
  16. package/lib/commonjs/package.json +1 -0
  17. package/lib/commonjs/specs/munim-wifi.nitro.js +6 -0
  18. package/lib/commonjs/specs/munim-wifi.nitro.js.map +1 -0
  19. package/lib/module/index.js +198 -0
  20. package/lib/module/index.js.map +1 -0
  21. package/lib/module/specs/munim-wifi.nitro.js +4 -0
  22. package/lib/module/specs/munim-wifi.nitro.js.map +1 -0
  23. package/lib/typescript/src/index.d.ts +120 -0
  24. package/lib/typescript/src/index.d.ts.map +1 -0
  25. package/lib/typescript/src/specs/munim-wifi.nitro.d.ts +118 -0
  26. package/lib/typescript/src/specs/munim-wifi.nitro.d.ts.map +1 -0
  27. package/nitro.json +24 -0
  28. package/nitrogen/generated/.gitattributes +1 -0
  29. package/nitrogen/generated/android/MunimWifi+autolinking.cmake +85 -0
  30. package/nitrogen/generated/android/MunimWifi+autolinking.gradle +27 -0
  31. package/nitrogen/generated/android/MunimWifiOnLoad.cpp +44 -0
  32. package/nitrogen/generated/android/MunimWifiOnLoad.hpp +25 -0
  33. package/nitrogen/generated/android/c++/JChannelInfo.hpp +61 -0
  34. package/nitrogen/generated/android/c++/JHybridMunimWifiSpec.cpp +262 -0
  35. package/nitrogen/generated/android/c++/JHybridMunimWifiSpec.hpp +78 -0
  36. package/nitrogen/generated/android/c++/JLocation.hpp +61 -0
  37. package/nitrogen/generated/android/c++/JScanOptions.hpp +61 -0
  38. package/nitrogen/generated/android/c++/JVariant_NullType_ChannelInfo.cpp +26 -0
  39. package/nitrogen/generated/android/c++/JVariant_NullType_ChannelInfo.hpp +71 -0
  40. package/nitrogen/generated/android/c++/JVariant_NullType_Double.cpp +26 -0
  41. package/nitrogen/generated/android/c++/JVariant_NullType_Double.hpp +69 -0
  42. package/nitrogen/generated/android/c++/JVariant_NullType_String.cpp +26 -0
  43. package/nitrogen/generated/android/c++/JVariant_NullType_String.hpp +70 -0
  44. package/nitrogen/generated/android/c++/JVariant_NullType_WifiNetwork.cpp +26 -0
  45. package/nitrogen/generated/android/c++/JVariant_NullType_WifiNetwork.hpp +73 -0
  46. package/nitrogen/generated/android/c++/JWifiFingerprint.hpp +89 -0
  47. package/nitrogen/generated/android/c++/JWifiNetwork.hpp +86 -0
  48. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/ChannelInfo.kt +41 -0
  49. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/HybridMunimWifiSpec.kt +107 -0
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/Location.kt +41 -0
  51. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/MunimWifiOnLoad.kt +35 -0
  52. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/ScanOptions.kt +41 -0
  53. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/Variant_NullType_ChannelInfo.kt +59 -0
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/Variant_NullType_Double.kt +59 -0
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/Variant_NullType_String.kt +59 -0
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/Variant_NullType_WifiNetwork.kt +59 -0
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/WifiFingerprint.kt +44 -0
  58. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/WifiNetwork.kt +59 -0
  59. package/nitrogen/generated/ios/MunimWifi+autolinking.rb +60 -0
  60. package/nitrogen/generated/ios/MunimWifi-Swift-Cxx-Bridge.cpp +105 -0
  61. package/nitrogen/generated/ios/MunimWifi-Swift-Cxx-Bridge.hpp +653 -0
  62. package/nitrogen/generated/ios/MunimWifi-Swift-Cxx-Umbrella.hpp +64 -0
  63. package/nitrogen/generated/ios/MunimWifiAutolinking.mm +33 -0
  64. package/nitrogen/generated/ios/MunimWifiAutolinking.swift +26 -0
  65. package/nitrogen/generated/ios/c++/HybridMunimWifiSpecSwift.cpp +11 -0
  66. package/nitrogen/generated/ios/c++/HybridMunimWifiSpecSwift.hpp +189 -0
  67. package/nitrogen/generated/ios/swift/ChannelInfo.swift +35 -0
  68. package/nitrogen/generated/ios/swift/Func_void_WifiFingerprint.swift +47 -0
  69. package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
  70. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  71. package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__ChannelInfo_.swift +59 -0
  72. package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__WifiNetwork_.swift +59 -0
  73. package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__double_.swift +59 -0
  74. package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__std__string_.swift +59 -0
  75. package/nitrogen/generated/ios/swift/Func_void_std__vector_WifiNetwork_.swift +47 -0
  76. package/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift +47 -0
  77. package/nitrogen/generated/ios/swift/HybridMunimWifiSpec.swift +68 -0
  78. package/nitrogen/generated/ios/swift/HybridMunimWifiSpec_cxx.swift +382 -0
  79. package/nitrogen/generated/ios/swift/Location.swift +47 -0
  80. package/nitrogen/generated/ios/swift/ScanOptions.swift +47 -0
  81. package/nitrogen/generated/ios/swift/Variant_NullType_ChannelInfo.swift +18 -0
  82. package/nitrogen/generated/ios/swift/Variant_NullType_Double.swift +18 -0
  83. package/nitrogen/generated/ios/swift/Variant_NullType_String.swift +18 -0
  84. package/nitrogen/generated/ios/swift/Variant_NullType_WifiNetwork.swift +18 -0
  85. package/nitrogen/generated/ios/swift/WifiFingerprint.swift +52 -0
  86. package/nitrogen/generated/ios/swift/WifiNetwork.swift +103 -0
  87. package/nitrogen/generated/shared/c++/ChannelInfo.hpp +87 -0
  88. package/nitrogen/generated/shared/c++/HybridMunimWifiSpec.cpp +33 -0
  89. package/nitrogen/generated/shared/c++/HybridMunimWifiSpec.hpp +90 -0
  90. package/nitrogen/generated/shared/c++/Location.hpp +87 -0
  91. package/nitrogen/generated/shared/c++/ScanOptions.hpp +87 -0
  92. package/nitrogen/generated/shared/c++/WifiFingerprint.hpp +97 -0
  93. package/nitrogen/generated/shared/c++/WifiNetwork.hpp +112 -0
  94. package/package.json +122 -0
  95. package/src/index.ts +221 -0
  96. package/src/specs/munim-wifi.nitro.ts +140 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 sheehanmunim
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,31 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "MunimWifi"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+
13
+ s.platforms = { :ios => min_ios_version_supported, :visionos => 1.0 }
14
+ s.source = { :git => "https://github.com/munimtechnologies/munim-wifi.git", :tag => "#{s.version}" }
15
+
16
+ s.source_files = [
17
+ # Implementation (Swift)
18
+ "ios/**/*.{swift}",
19
+ # Autolinking/Registration (Objective-C++)
20
+ "ios/**/*.{m,mm}",
21
+ # Implementation (C++ objects)
22
+ "cpp/**/*.{hpp,cpp}",
23
+ ]
24
+
25
+ load 'nitrogen/generated/ios/MunimWifi+autolinking.rb'
26
+ add_nitrogen_files(s)
27
+
28
+ s.dependency 'React-jsi'
29
+ s.dependency 'React-callinvoker'
30
+ install_modules_dependencies(s)
31
+ end
package/README.md ADDED
@@ -0,0 +1,591 @@
1
+ <!-- Banner Image -->
2
+
3
+ <p align="center">
4
+ <a href="https://github.com/munimtechnologies/munim-wifi">
5
+ <img alt="Munim Technologies Wi-Fi" height="128" src="./.github/resources/banner.png?v=3">
6
+ <h1 align="center">munim-wifi</h1>
7
+ </a>
8
+ </p>
9
+
10
+ <p align="center">
11
+ <a aria-label="Package version" href="https://www.npmjs.com/package/munim-wifi" target="_blank">
12
+ <img alt="Package version" src="https://img.shields.io/npm/v/munim-wifi.svg?style=flat-square&label=Version&labelColor=000000&color=0066CC" />
13
+ </a>
14
+ <a aria-label="Package is free to use" href="https://github.com/munimtechnologies/munim-wifi/blob/main/LICENSE" target="_blank">
15
+ <img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-success.svg?style=flat-square&color=33CC12" target="_blank" />
16
+ </a>
17
+ <a aria-label="package downloads" href="https://www.npmtrends.com/munim-wifi" target="_blank">
18
+ <img alt="Downloads" src="https://img.shields.io/npm/dm/munim-wifi.svg?style=flat-square&labelColor=gray&color=33CC12&label=Downloads" />
19
+ </a>
20
+ <a aria-label="total package downloads" href="https://www.npmjs.com/package/munim-wifi" target="_blank">
21
+ <img alt="Total Downloads" src="https://img.shields.io/npm/dt/munim-wifi.svg?style=flat-square&labelColor=gray&color=0066CC&label=Total%20Downloads" />
22
+ </a>
23
+ </p>
24
+
25
+ <p align="center">
26
+ <a aria-label="try with expo" href="https://docs.expo.dev/"><b>Works with Expo</b></a>
27
+ &ensp;•&ensp;
28
+ <a aria-label="documentation" href="https://github.com/munimtechnologies/munim-wifi#readme">Read the Documentation</a>
29
+ &ensp;•&ensp;
30
+ <a aria-label="report issues" href="https://github.com/munimtechnologies/munim-wifi/issues">Report Issues</a>
31
+ </p>
32
+
33
+ <h6 align="center">Follow Munim Technologies</h6>
34
+ <p align="center">
35
+ <a aria-label="Follow Munim Technologies on GitHub" href="https://github.com/munimtechnologies" target="_blank">
36
+ <img alt="Munim Technologies on GitHub" src="https://img.shields.io/badge/GitHub-222222?style=for-the-badge&logo=github&logoColor=white" target="_blank" />
37
+ </a>&nbsp;
38
+ <a aria-label="Follow Munim Technologies on LinkedIn" href="https://linkedin.com/in/sheehanmunim" target="_blank">
39
+ <img alt="Munim Technologies on LinkedIn" src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white" target="_blank" />
40
+ </a>&nbsp;
41
+ <a aria-label="Visit Munim Technologies Website" href="https://munimtech.com" target="_blank">
42
+ <img alt="Munim Technologies Website" src="https://img.shields.io/badge/Website-0066CC?style=for-the-badge&logo=globe&logoColor=white" target="_blank" />
43
+ </a>
44
+ </p>
45
+
46
+ ## Introduction
47
+
48
+ **munim-wifi** is a comprehensive React Native library for Wi-Fi network scanning and analysis. This library allows your React Native app to scan for nearby Wi-Fi networks, retrieve detailed network information including SSIDs, BSSIDs (MAC addresses), RSSI (signal strength), channels, frequencies, and perform Wi-Fi fingerprinting for location-based services.
49
+
50
+ **Fully compatible with Expo!** Works seamlessly with both Expo managed and bare workflows.
51
+
52
+ **Built with React Native's Nitro modules architecture** for high performance and reliability.
53
+
54
+ **Note**: This library focuses on reliability and platform compatibility. It supports core Wi-Fi scanning features that work consistently across both Android and iOS platforms.
55
+
56
+ ## Table of contents
57
+
58
+ - [📚 Documentation](#-documentation)
59
+ - [🚀 Features](#-features)
60
+ - [📦 Installation](#-installation)
61
+ - [⚡ Quick Start](#-quick-start)
62
+ - [🔧 API Reference](#-api-reference)
63
+ - [📖 Usage Examples](#-usage-examples)
64
+ - [🔍 Troubleshooting](#-troubleshooting)
65
+ - [👏 Contributing](#-contributing)
66
+ - [📄 License](#-license)
67
+
68
+ ## 📚 Documentation
69
+
70
+ <p>Learn about building Wi-Fi scanning apps <a aria-label="documentation" href="https://github.com/munimtechnologies/munim-wifi#readme">in our documentation!</a></p>
71
+
72
+ - [Getting Started](#-installation)
73
+ - [API Reference](#-api-reference)
74
+ - [Usage Examples](#-usage-examples)
75
+ - [Troubleshooting](#-troubleshooting)
76
+
77
+ ## 🚀 Features
78
+
79
+ ### Wi-Fi Scanning
80
+
81
+ - 📡 **Network Scanning**: Scan for nearby Wi-Fi networks with detailed information
82
+ - 📶 **Signal Strength**: Get RSSI (signal strength) values for all networks
83
+ - 🔍 **Network Details**: Retrieve SSIDs, BSSIDs (MAC addresses), channels, and frequencies
84
+ - 📊 **Wi-Fi Fingerprinting**: Create comprehensive Wi-Fi fingerprints for location services
85
+ - 🔄 **Continuous Scanning**: Support for continuous scanning with event-based updates
86
+ - 📱 **Cross-platform**: Works on both iOS and Android
87
+
88
+ ### Additional Features
89
+
90
+ - 📱 **Cross-platform**: Works on both iOS and Android
91
+ - 🎯 **TypeScript Support**: Full TypeScript definitions included
92
+ - ⚡ **High Performance**: Built with React Native's Nitro modules architecture
93
+ - 🚀 **Expo Compatible**: Works seamlessly with Expo managed and bare workflows
94
+ - 🔐 **Permission Handling**: Built-in permission request helpers
95
+
96
+ ## 📦 Installation
97
+
98
+ ### React Native CLI
99
+
100
+ ```bash
101
+ npm install munim-wifi react-native-nitro-modules
102
+ # or
103
+ yarn add munim-wifi react-native-nitro-modules
104
+ ```
105
+
106
+ ### Expo
107
+
108
+ ```bash
109
+ npx expo install munim-wifi react-native-nitro-modules
110
+ ```
111
+
112
+ > **Note**: This library requires Expo SDK 50+ and works with both managed and bare workflows. To support Nitro modules, you need React Native version v0.78.0 or higher.
113
+
114
+ ### iOS Setup
115
+
116
+ For iOS, the library is automatically linked. However, you need to add the following to your `Info.plist`:
117
+
118
+ ```xml
119
+ <key>NSLocationWhenInUseUsageDescription</key>
120
+ <string>This app uses location services to scan for nearby Wi-Fi networks</string>
121
+ <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
122
+ <string>This app uses location services to scan for nearby Wi-Fi networks</string>
123
+ ```
124
+
125
+ **For Expo projects**, add these permissions to your `app.json`:
126
+
127
+ ```json
128
+ {
129
+ "expo": {
130
+ "ios": {
131
+ "infoPlist": {
132
+ "NSLocationWhenInUseUsageDescription": "This app uses location services to scan for nearby Wi-Fi networks",
133
+ "NSLocationAlwaysAndWhenInUseUsageDescription": "This app uses location services to scan for nearby Wi-Fi networks"
134
+ }
135
+ }
136
+ }
137
+ }
138
+ ```
139
+
140
+ ### Android Setup
141
+
142
+ For Android, add the following permissions to your `AndroidManifest.xml`:
143
+
144
+ ```xml
145
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
146
+ <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
147
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
148
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
149
+ ```
150
+
151
+ **For Expo projects**, add these permissions to your `app.json`:
152
+
153
+ ```json
154
+ {
155
+ "expo": {
156
+ "android": {
157
+ "permissions": [
158
+ "android.permission.ACCESS_WIFI_STATE",
159
+ "android.permission.CHANGE_WIFI_STATE",
160
+ "android.permission.ACCESS_FINE_LOCATION",
161
+ "android.permission.ACCESS_COARSE_LOCATION"
162
+ ]
163
+ }
164
+ }
165
+ }
166
+ ```
167
+
168
+ ## ⚡ Quick Start
169
+
170
+ ### Basic Usage - Scan Networks
171
+
172
+ ```typescript
173
+ import { scanNetworks, requestWifiPermission, isWifiEnabled } from 'munim-wifi'
174
+
175
+ // Check if Wi-Fi is enabled
176
+ const wifiEnabled = await isWifiEnabled()
177
+ if (!wifiEnabled) {
178
+ console.log('Wi-Fi is not enabled')
179
+ return
180
+ }
181
+
182
+ // Request permissions (required for scanning)
183
+ const hasPermission = await requestWifiPermission()
184
+ if (!hasPermission) {
185
+ console.log('Location permission not granted')
186
+ return
187
+ }
188
+
189
+ // Scan for networks
190
+ const networks = await scanNetworks()
191
+ console.log(`Found ${networks.length} networks`)
192
+
193
+ networks.forEach(network => {
194
+ console.log(`SSID: ${network.ssid}`)
195
+ console.log(`BSSID: ${network.bssid}`)
196
+ console.log(`RSSI: ${network.rssi} dBm`)
197
+ console.log(`Channel: ${network.channel}`)
198
+ console.log(`Frequency: ${network.frequency} MHz`)
199
+ console.log(`Secure: ${network.isSecure}`)
200
+ })
201
+ ```
202
+
203
+ ### Get Specific Network Information
204
+
205
+ ```typescript
206
+ import { getSSIDs, getRSSI, getBSSID, getChannelInfo, getNetworkInfo } from 'munim-wifi'
207
+
208
+ // Get all SSIDs
209
+ const ssids = await getSSIDs()
210
+ console.log('Available networks:', ssids)
211
+
212
+ // Get RSSI for a specific network
213
+ const rssi = await getRSSI('MyNetwork')
214
+ console.log('Signal strength:', rssi, 'dBm')
215
+
216
+ // Get BSSID (MAC address) for a network
217
+ const bssid = await getBSSID('MyNetwork')
218
+ console.log('BSSID:', bssid)
219
+
220
+ // Get channel information
221
+ const channelInfo = await getChannelInfo('MyNetwork')
222
+ if (channelInfo) {
223
+ console.log('Channel:', channelInfo.channel)
224
+ console.log('Frequency:', channelInfo.frequency, 'MHz')
225
+ }
226
+
227
+ // Get all information for a network
228
+ const networkInfo = await getNetworkInfo('MyNetwork')
229
+ if (networkInfo) {
230
+ console.log('Full network info:', networkInfo)
231
+ }
232
+ ```
233
+
234
+ ### Wi-Fi Fingerprinting
235
+
236
+ ```typescript
237
+ import { getWifiFingerprint } from 'munim-wifi'
238
+
239
+ // Get Wi-Fi fingerprint (useful for location services)
240
+ const fingerprint = await getWifiFingerprint()
241
+ console.log('Fingerprint timestamp:', fingerprint.timestamp)
242
+ console.log('Networks found:', fingerprint.networks.length)
243
+
244
+ fingerprint.networks.forEach(network => {
245
+ console.log(`${network.ssid}: ${network.rssi} dBm on channel ${network.channel}`)
246
+ })
247
+ ```
248
+
249
+ ### Continuous Scanning
250
+
251
+ ```typescript
252
+ import { startScan, stopScan, addNetworkFoundListener } from 'munim-wifi'
253
+
254
+ // Start continuous scanning
255
+ startScan()
256
+
257
+ // Listen for discovered networks
258
+ const unsubscribe = addNetworkFoundListener((network) => {
259
+ console.log('Network found:', network.ssid, network.rssi, 'dBm')
260
+ })
261
+
262
+ // Stop scanning when done
263
+ // stopScan()
264
+ // unsubscribe()
265
+ ```
266
+
267
+ ## 🔧 API Reference
268
+
269
+ ### Core Functions
270
+
271
+ #### `isWifiEnabled()`
272
+
273
+ Checks if Wi-Fi is enabled on the device.
274
+
275
+ **Returns:** Promise<boolean>
276
+
277
+ #### `requestWifiPermission()`
278
+
279
+ Requests Wi-Fi permissions (Android) or checks authorization status (iOS).
280
+ On Android, this requests location permission which is required for Wi-Fi scanning.
281
+ On iOS, this checks location authorization status.
282
+
283
+ **Returns:** Promise<boolean>
284
+
285
+ #### `scanNetworks(options?)`
286
+
287
+ Scans for nearby Wi-Fi networks.
288
+
289
+ **Parameters:**
290
+
291
+ - `options?` (object):
292
+ - `maxResults?` (number): Maximum number of results to return
293
+ - `timeout?` (number): Timeout in milliseconds (default: 10000)
294
+
295
+ **Returns:** Promise<WifiNetwork[]>
296
+
297
+ #### `startScan(options?)`
298
+
299
+ Starts continuous Wi-Fi scanning. Results will be emitted via events.
300
+
301
+ **Parameters:**
302
+
303
+ - `options?` (object):
304
+ - `maxResults?` (number): Maximum number of results to return
305
+ - `timeout?` (number): Timeout in milliseconds
306
+
307
+ #### `stopScan()`
308
+
309
+ Stops continuous Wi-Fi scanning.
310
+
311
+ #### `getSSIDs()`
312
+
313
+ Gets list of SSIDs (network names) from the last scan.
314
+
315
+ **Returns:** Promise<string[]>
316
+
317
+ #### `getWifiFingerprint()`
318
+
319
+ Gets Wi-Fi fingerprint containing all network information.
320
+ This includes SSIDs, BSSIDs, RSSI, channels, and frequencies.
321
+
322
+ **Returns:** Promise<WifiFingerprint>
323
+
324
+ #### `getRSSI(ssid)`
325
+
326
+ Gets RSSI (signal strength) for a specific network by SSID.
327
+
328
+ **Parameters:**
329
+
330
+ - `ssid` (string): The SSID of the network
331
+
332
+ **Returns:** Promise<number | null>
333
+
334
+ #### `getBSSID(ssid)`
335
+
336
+ Gets BSSID (MAC address) for a specific network by SSID.
337
+
338
+ **Parameters:**
339
+
340
+ - `ssid` (string): The SSID of the network
341
+
342
+ **Returns:** Promise<string | null>
343
+
344
+ #### `getChannelInfo(ssid)`
345
+
346
+ Gets channel and frequency information for a specific network by SSID.
347
+
348
+ **Parameters:**
349
+
350
+ - `ssid` (string): The SSID of the network
351
+
352
+ **Returns:** Promise<{ channel: number; frequency: number } | null>
353
+
354
+ #### `getNetworkInfo(ssid)`
355
+
356
+ Gets all available information for a specific network by SSID.
357
+
358
+ **Parameters:**
359
+
360
+ - `ssid` (string): The SSID of the network
361
+
362
+ **Returns:** Promise<WifiNetwork | null>
363
+
364
+ ### Event Management
365
+
366
+ #### `addNetworkFoundListener(callback)`
367
+
368
+ Adds a network found event listener (for continuous scanning).
369
+
370
+ **Parameters:**
371
+
372
+ - `callback` (function): Function to call when a network is found
373
+
374
+ **Returns:** Function to remove the listener
375
+
376
+ #### `addEventListener(eventName, callback)`
377
+
378
+ Adds an event listener.
379
+
380
+ **Parameters:**
381
+
382
+ - `eventName` (string): The name of the event to listen for
383
+ - `callback` (function): The callback to invoke when the event occurs
384
+
385
+ **Returns:** Function to remove the listener
386
+
387
+ ### Types
388
+
389
+ #### `WifiNetwork`
390
+
391
+ ```typescript
392
+ interface WifiNetwork {
393
+ ssid: string
394
+ bssid: string
395
+ rssi: number
396
+ frequency: number
397
+ channel?: number
398
+ capabilities?: string
399
+ isSecure?: boolean
400
+ timestamp?: number
401
+ }
402
+ ```
403
+
404
+ #### `WifiFingerprint`
405
+
406
+ ```typescript
407
+ interface WifiFingerprint {
408
+ networks: WifiNetwork[]
409
+ timestamp: number
410
+ location?: {
411
+ latitude?: number
412
+ longitude?: number
413
+ }
414
+ }
415
+ ```
416
+
417
+ #### `ScanOptions`
418
+
419
+ ```typescript
420
+ interface ScanOptions {
421
+ maxResults?: number
422
+ timeout?: number
423
+ }
424
+ ```
425
+
426
+ ## 📖 Usage Examples
427
+
428
+ ### Network Scanner Component
429
+
430
+ ```typescript
431
+ import React, { useState, useEffect } from 'react'
432
+ import { View, Text, FlatList, Button } from 'react-native'
433
+ import {
434
+ scanNetworks,
435
+ requestWifiPermission,
436
+ isWifiEnabled,
437
+ type WifiNetwork,
438
+ } from 'munim-wifi'
439
+
440
+ const NetworkScanner = () => {
441
+ const [networks, setNetworks] = useState<WifiNetwork[]>([])
442
+ const [scanning, setScanning] = useState(false)
443
+
444
+ const handleScan = async () => {
445
+ setScanning(true)
446
+
447
+ // Check Wi-Fi status
448
+ const wifiEnabled = await isWifiEnabled()
449
+ if (!wifiEnabled) {
450
+ alert('Please enable Wi-Fi')
451
+ setScanning(false)
452
+ return
453
+ }
454
+
455
+ // Request permissions
456
+ const hasPermission = await requestWifiPermission()
457
+ if (!hasPermission) {
458
+ alert('Location permission is required for Wi-Fi scanning')
459
+ setScanning(false)
460
+ return
461
+ }
462
+
463
+ // Scan networks
464
+ const results = await scanNetworks({ maxResults: 20 })
465
+ setNetworks(results)
466
+ setScanning(false)
467
+ }
468
+
469
+ return (
470
+ <View>
471
+ <Button
472
+ title={scanning ? 'Scanning...' : 'Scan Networks'}
473
+ onPress={handleScan}
474
+ disabled={scanning}
475
+ />
476
+ <FlatList
477
+ data={networks}
478
+ keyExtractor={(item) => item.bssid}
479
+ renderItem={({ item }) => (
480
+ <View>
481
+ <Text>{item.ssid}</Text>
482
+ <Text>Signal: {item.rssi} dBm</Text>
483
+ <Text>Channel: {item.channel}</Text>
484
+ <Text>BSSID: {item.bssid}</Text>
485
+ <Text>Secure: {item.isSecure ? 'Yes' : 'No'}</Text>
486
+ </View>
487
+ )}
488
+ />
489
+ </View>
490
+ )
491
+ }
492
+ ```
493
+
494
+ ### Wi-Fi Fingerprinting for Location
495
+
496
+ ```typescript
497
+ import { getWifiFingerprint } from 'munim-wifi'
498
+
499
+ const collectFingerprint = async () => {
500
+ const fingerprint = await getWifiFingerprint()
501
+
502
+ // Send fingerprint to your backend for location matching
503
+ await fetch('https://your-api.com/location', {
504
+ method: 'POST',
505
+ headers: { 'Content-Type': 'application/json' },
506
+ body: JSON.stringify({
507
+ fingerprint: fingerprint.networks.map(n => ({
508
+ bssid: n.bssid,
509
+ rssi: n.rssi,
510
+ channel: n.channel,
511
+ })),
512
+ timestamp: fingerprint.timestamp,
513
+ }),
514
+ })
515
+ }
516
+ ```
517
+
518
+ ### Signal Strength Monitor
519
+
520
+ ```typescript
521
+ import { startScan, addNetworkFoundListener, stopScan } from 'munim-wifi'
522
+
523
+ const monitorSignalStrength = (targetSSID: string) => {
524
+ const rssiHistory: number[] = []
525
+
526
+ const unsubscribe = addNetworkFoundListener((network) => {
527
+ if (network.ssid === targetSSID) {
528
+ rssiHistory.push(network.rssi)
529
+ console.log(`Current RSSI: ${network.rssi} dBm`)
530
+ console.log(`Average RSSI: ${rssiHistory.reduce((a, b) => a + b, 0) / rssiHistory.length} dBm`)
531
+ }
532
+ })
533
+
534
+ startScan()
535
+
536
+ // Stop after 30 seconds
537
+ setTimeout(() => {
538
+ stopScan()
539
+ unsubscribe()
540
+ }, 30000)
541
+ }
542
+ ```
543
+
544
+ ## 🔍 Troubleshooting
545
+
546
+ ### Common Issues
547
+
548
+ 1. **Permission Denied**: Ensure you have the necessary location permissions in your app. On Android 6.0+, location permission is required for Wi-Fi scanning.
549
+
550
+ 2. **No Networks Found**:
551
+ - Verify Wi-Fi is enabled on the device
552
+ - Check that location permissions are granted
553
+ - On iOS, ensure location services are enabled in Settings
554
+
555
+ 3. **Scan Timeout**: Increase the timeout value in scan options or check network connectivity
556
+
557
+ 4. **Empty Results**: Make sure you've called `scanNetworks()` or `startScan()` before calling `getSSIDs()` or other getter methods
558
+
559
+ ### Expo-Specific Issues
560
+
561
+ 1. **Development Build Required**: This library requires a development build in Expo. Use `npx expo run:ios` or `npx expo run:android`
562
+
563
+ 2. **Permissions Not Working**: Make sure you've added the permissions to your `app.json` as shown in the setup section
564
+
565
+ 3. **Build Errors**: Ensure you're using Expo SDK 50+ and have the latest Expo CLI
566
+
567
+ 4. **Nitro Modules**: Make sure you have `react-native-nitro-modules` installed and configured
568
+
569
+ ### Platform-Specific Notes
570
+
571
+ **Android:**
572
+ - Requires `ACCESS_FINE_LOCATION` or `ACCESS_COARSE_LOCATION` permission
573
+ - Wi-Fi scanning may be limited on some devices
574
+ - Background scanning has restrictions on Android 8.0+
575
+
576
+ **iOS:**
577
+ - Requires location permission for Wi-Fi scanning
578
+ - CoreWLAN framework is used for scanning
579
+ - Some network information may be limited for privacy reasons
580
+
581
+ ## 👏 Contributing
582
+
583
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to submit pull requests, report issues, and contribute to the project.
584
+
585
+ ## 📄 License
586
+
587
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
588
+
589
+ ---
590
+
591
+ <img alt="Star the Munim Technologies repo on GitHub to support the project" src="https://user-images.githubusercontent.com/9664363/185428788-d762fd5d-97b3-4f59-8db7-f72405be9677.gif" width="50%">
@@ -0,0 +1,32 @@
1
+ project(MunimWifi)
2
+ cmake_minimum_required(VERSION 3.9.0)
3
+
4
+ set (PACKAGE_NAME MunimWifi)
5
+ set (CMAKE_VERBOSE_MAKEFILE ON)
6
+ set (CMAKE_CXX_STANDARD 20)
7
+
8
+ # Enable Raw Props parsing in react-native (for Nitro Views)
9
+ add_compile_options(-DRN_SERIALIZABLE_STATE=1)
10
+
11
+ # Define C++ library and add all sources
12
+ add_library(${PACKAGE_NAME} SHARED
13
+ src/main/cpp/cpp-adapter.cpp
14
+ )
15
+
16
+ # Add Nitrogen specs :)
17
+ include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/MunimWifi+autolinking.cmake)
18
+
19
+ # Set up local includes
20
+ include_directories(
21
+ "src/main/cpp"
22
+ "../cpp"
23
+ )
24
+
25
+ find_library(LOG_LIB log)
26
+
27
+ # Link all libraries together
28
+ target_link_libraries(
29
+ ${PACKAGE_NAME}
30
+ ${LOG_LIB}
31
+ android # <-- Android core
32
+ )