Skip to content

Repository files navigation

AWARE: WiFi

Swift Package Manager compatible

This sensor allows us to handle WiFi conditions and events.

Requirements

iOS 13 or later

Installation

You can integrate this framework into your project via Swift Package Manager (SwiftPM).

SwiftPM

  1. Open Package Manager Windows

    • Open Xcode -> Select Menu Bar -> File -> App Package Dependencies...
  2. Find the package using the manager

    • Select Search Package URL and type git@github.com:awareframework/com.awareframework.ios.sensor.wifi.git
  3. Import the package into your target.

  4. Turn ON Access WiFi Information capability on the Xcode project

Public Functions

WifiSensor

  • init(config:WiFiSensor.Config?): Initializes the WiFi sensor with the optional configuration.
  • start(): Starts the WiFi sensor with the optional configuration.
  • stop(): Stops the service.

WifiSensor.Config

Class to hold the configuration of the sensor.

Fields

  • sensorObserver: WiFiObserver: Callback for live data updates.
  • scanIntervalSeconds: Double: Wi-Fi scan interval in seconds. (default = 60)
  • enabled: Bool: Sensor is enabled or not. (default = false)
  • debug: Bool: Enable/disable logging. (default = false)
  • label: String: Label for the data. (default = "")
  • deviceId: String: Id of the device that will be associated with the events and the sensor. (default = "")
  • dbEncryptionKey: String?: Encryption key for the database. (default = nil)
  • dbType: DatabaseType: Which db engine to use for saving data. (default = .none)
  • dbPath: String: Path of the database. (default = "aware_wifi")
  • dbHost: String?: Host for syncing the database. (default = nil)

Broadcasts

  • WiFiSensor.ACTION_AWARE_WIFI_CURRENT_AP: currently connected to this AP. In the extras, WiFiSensor.EXTRA_DATA includes the WiFiData in json string format.
  • WiFiSensor.ACTION_AWARE_WIFI_NEW_DEVICE: new WiFi AP device detected. In the extras, WiFiSensor.EXTRA_DATA includes the WiFiData in json string format.
  • WiFiSensor.ACTION_AWARE_WIFI_SCAN_STARTED: WiFi scan started
  • WiFiSensor.ACTION_AWARE_WIFI_SCAN_ENDED: WiFi scan ended.

Data Representations

WiFi Scan Data

FieldTypeDescription
bssidStringaccess point BSSID (MAC address)
ssidStringaccess point network name
securityStringsecurity mode of the access point
frequencyIntfrequency of the access point (MHz)
rssiIntreceived signal strength in dBm
deviceIdStringAWARE device UUID
labelStringCustomizable label. Useful for data calibration or traceability
timestampInt64Unixtime milliseconds since 1970
timezoneIntTimezone of the device
osStringOperating system of the device (ex. ios)
jsonVersionIntJSON schema version

WiFi Device Data

Contains the current device's own WiFi connection info.

FieldTypeDescription
macAddressStringMAC address of the device's WiFi interface
bssidStringBSSID of the connected access point
ssidStringSSID of the connected access point
deviceIdStringAWARE device UUID
labelStringCustomizable label. Useful for data calibration or traceability
timestampInt64Unixtime milliseconds since 1970
timezoneIntTimezone of the device
osStringOperating system of the device (ex. ios)
jsonVersionIntJSON schema version

Example Usage

letwifiSensor=WiFiSensor.init(WifiSensor.Config().apply{ config in
config.sensorObserver =Observer()
config.scanIntervalSeconds =60
config.debug =true
// more configuration ...
})
// To start the sensor
wifiSensor.start()
// To stop the sensor
wifiSensor.stop()
// Implement an interface of WifiObserver
classObserver:WiFiObserver{func onWiFiAPDetected(data:WiFiScanData){
// Your code here ..
}func onWiFiDisabled(){
// Your code here ..
}func onWiFiScanStarted(){
// Your code here ..
}func onWiFiScanEnded(){
// Your code here ..
}}

Related Links

Author

Yuuki Nishiyama (The University of Tokyo), nishiyama@csis.u-tokyo.ac.jp

License

Copyright (c) 2025 AWARE Mobile Context Instrumentation Middleware/Framework (http://www.awareframework.com)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

Aware WiFi : A WiFi Plugin for AWARE Framework iOS

Resources

Stars

1 star

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages