All Projects → Kuniwak → WiFiQRCodeKit

Kuniwak / WiFiQRCodeKit

Licence: other
Library helping Wi-Fi configurations over QR codes

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to WiFiQRCodeKit

Wifi Password
Quickly fetch your WiFi password and if needed, generate a QR code of your WiFi to allow phones to easily connect
Stars: ✭ 2,325 (+6542.86%)
Mutual labels:  qrcode, wifi
Qr Filetransfer
Transfer files over WiFi between your computer and your smartphone from the terminal
Stars: ✭ 738 (+2008.57%)
Mutual labels:  qrcode, wifi
wifiqr
Create a QR code with your Wi-Fi login details
Stars: ✭ 207 (+491.43%)
Mutual labels:  qrcode, wifi
makeqr
WiFi QR Code Generator
Stars: ✭ 21 (-40%)
Mutual labels:  qrcode, wifi
WifiBarcodeSample
Sample code for my article in DotNetCurry magazine on scanning barcodes. In this sample you can generate and scan QR codes that contain a Wi-Fi connection string
Stars: ✭ 13 (-62.86%)
Mutual labels:  wifi
ProxySwitcher
Easily enable / disable WiFi proxy on a jailbroken iOS device
Stars: ✭ 55 (+57.14%)
Mutual labels:  wifi
ionic3-awesome
😃 ionic3自定义组件及常用例子 演示地址
Stars: ✭ 95 (+171.43%)
Mutual labels:  qrcode
wifi-sploit
Wi-Fi sploit is a password cracker for an admin page of a Wi-Fi Router.
Stars: ✭ 29 (-17.14%)
Mutual labels:  wifi
ggtrack
restlessdata.com.au/ggtrack
Stars: ✭ 39 (+11.43%)
Mutual labels:  qrcode
qrcode
A simple library for generating QR codes in C.
Stars: ✭ 23 (-34.29%)
Mutual labels:  qrcode
openwrt-useful-tools
A repo containing different tools compiled specifically for the Hak5 WiFi Pineapple MK6 and MK7.
Stars: ✭ 155 (+342.86%)
Mutual labels:  wifi
anon-hotspot
On demand Debian Linux (Tor) Hotspot setup tool
Stars: ✭ 34 (-2.86%)
Mutual labels:  wifi
ips-qr-code
IPS QR Code Generator
Stars: ✭ 30 (-14.29%)
Mutual labels:  qrcode
torbox
Container-based Tor access point (Anonymizing Middlebox).
Stars: ✭ 52 (+48.57%)
Mutual labels:  wifi
Eduponics-Mini
MicroPython MQTT & code example for Eduponics mini ESP32 learning kit
Stars: ✭ 41 (+17.14%)
Mutual labels:  wifi
Zxing
🎫 Nepxion Zxing is a general code picture generator based on google zxing framework, support QR code and EAN code for file and byte array formats 基于Google Zxing的二维码/条形码创建和扫描组件
Stars: ✭ 26 (-25.71%)
Mutual labels:  qrcode
RaspberryPi-Packet-Sniffer
An HTTP and HTTPS sniffing tool created using a Raspberry Pi
Stars: ✭ 79 (+125.71%)
Mutual labels:  wifi
python
Build Python extension with Dynamsoft Barcode Reader.
Stars: ✭ 35 (+0%)
Mutual labels:  qrcode
libwifi
An 802.11 Frame Generation and Parsing Library in C
Stars: ✭ 27 (-22.86%)
Mutual labels:  wifi
art-qr
JavaScript library to generate beautiful QR code in browser 艺术二维码
Stars: ✭ 19 (-45.71%)
Mutual labels:  qrcode

WiFiQRCodeKit

Swift Compatible CocoaPods Status Carhthage Compatible Build Status

In iOS 11, we can easily configure Wi-Fi networks by reading QR code for Wi-Fi. But some reasonable situations that is keeping iOS version lower than iOS 11 can exist.

WiFiQRCodeKit provides the Wi-Fi configuration feature via QR code for the situations. It can work with iOS 8.0+.

Install

Carthage

github "Kuniwak/WiFiQRCodeKit" >= 1.0

CocoaPods

pod 'WiFiQRCodeKit', '~> 1.0'

Requirements

  • iOS 8.0+

And WiFiQRCodeKit requires 2 other libraries:

  • A QR code reader library
  • A local HTTP server library

It means that you can use any libraries you want.

Usage

Simple Example

This is an simple example for using with yannickl/QRCodeReader.swift and httpswift/swifter:

// AppDelegate.swift
import QRCodeReader
import WiFiQRCodeKit


class AppDelegate: UIResponder, UIApplicationDelegate {

    // ...

    private let installer = WiFIQRCodeKit.MobileConfig.Installer(
        distributingBy: SwifterMobileConfigDistributionServer(listeningOn: 8989)
    )

    private var qrCodeReaderWindow: UIWindow?
    private var originalWindow: UIWindow?

    // ...

    func applicationDidEnterBackground(_ application: UIApplication) {
        // This method MUST be called in the method.
        self.installer.keepDistributionServerForBackground(for: application)
    }


    // Open a QR code reader.
    func readQRCode() {
        let qrCodeReaderBuilder = QRCodeReaderViewControllerBuilder()
        qrCodeReaderBuilder.reader = QRCodeReader(
            metadataObjectTypes: [.qr],
            captureDevicePosition: .back
        )

        let qrCodeReaderViewController = QRCodeReaderViewController(builder: qrCodeReaderBuilder)
        qrCodeReaderViewController.completionBlock = { [weak self] result in
            guard let `self` = self else { return }

            if let result = result {
                self.install(qrCodeContent: result.value)
            }

            self.qrCodeReaderWindow = nil
            self.originalWindow.makeKeyAndVisible()
        }

        self.originalWindow = UIApplication.shared.keyWindow

        let qrCodeReaderWindow = UIWindow()
        qrCodeReaderWindow.rootViewController = qrCodeReaderViewController
        qrCodeReaderWindow.makeKeyAndVisible()

        self.qrCodeReaderWindow = window
    }


    // Install the Wi-Fi settings.
    private func install(qrCodeContent: String) {
        switch WiFiQRCodeKit.parse(text: qrCodeContent) {
        case .success(let wiFiQRCode):
            var mobileConfig = WiFiQRCodeKit.MobileConfig.from(
                wiFiQRCode: wiFiQRCode,
                organization: .init(organizationName: "Example, Inc.")

                // Also you can specify the following optional items:
                //
                //   identifier: .init(identifier: "com.example.WiFiSettings"),
                //   description: "Joining the Wi-Fi network that managed by Example, Inc.",
                //   displayName: .init(displayName: "Wi-Fi settings for Example, Inc."),
                //   consentText: .init(consentTextsForEachLanguages: [
                //       .default: "Would you join the Wi-Fi network that manged by Example, Inc.?",
                //       .en: "Would you join the Wi-Fi network that manged by Example, Inc.?",
                //       .jp: "Example, Inc. の Wi-Fi ネットワークへ接続しますか?",
                //   ])
            )

            // You can modify other items such as the expiration option of the configuration profile.
            // Configurable items are listed on "Configuration Profile Reference".
            // See https://developer.apple.com/library/content/featuredarticles/iPhoneConfigurationProfileRef/

            // It open the configuration profile on Safari.
            self.installer.install(mobileConfig: mobileConfig)

        case .failed(because: let reason):
            dump(reason)
        }
    }
}
// SwifterMobileConfigDistributionServer.swift
import Swifter
import WiFiQRCodeKit


class SwifterMobileConfigDistributionServer: WiFiQRCodeKit.MobileConfig.DistributionServer {
    let distributionURL: URL
    private let server: Swifter.HttpServer
    private let port: UInt16
    private var mobileConfig: (data: Data, mimeType: String)?


    init(listeningOn port: UInt16) {
        let mobileConfigPath = "/WiFi.mobileConfig"

        self.distributionURL = URL(string: "http://127.0.0.1:\(port)\(mobileConfigPath)")!
        self.port = port
        self.server = Swifter.HttpServer()

        self.server[mobileConfigPath] = { [weak self] (_: Swifter.HttpRequest) -> Swifter.HttpResponse in
            guard let `self` = self, let mobileConfig = self.mobileConfig else {
                return .notFound
            }

            let statusCode = 20
            let statusText = "OK"
            let headers = ["Content-Type": mobileConfig.mimeType]

            return .raw(
                statusCode,
                statusText,
                headers,
                { (writer: Swifter.HttpResponseBodyWriter) throws in
                    try writer.write(mobileConfig.data)
                }
            )
        }
    }


    func start() -> WiFiQRCodeKit.MobileConfig.DistributionServerState {
        do {
            try self.server.start(self.port)
            return .successfullyStarted
        }
        catch {
            return .failed(because: "\(error)")
        }
    }


    func update(mobileConfigData: Data, mimeType: String) {
        self.mobileConfig = (data: mobileConfigData, mimeType: mimeType)
    }
}

Full Example

See Kuniwak/WiFiQRCodeKitExampleApp.

Implementation Defail

The procedure of WiFiQRCodeKit is the following:

  1. Get a Wi-Fi QR code content by a QR code reader library
  2. WiFiQRCodeKit create the provisioing profile for Wi-Fi settings
  3. WiFiQRCodeKit start a local HTTP server that will deliver the provisoning profile
  4. WiFiQRCodeKit open Safari with an URL of the local HTTP server
  5. Safari confirm the provisioning profile to the user
  6. Connect to the Wi-Fi

References

License

The MIT License (MIT)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].