WIBLELib 0.0.10

WIBLELib 0.0.10

CS KIM 维护。



WIBLELib 0.0.10

  • 作者:
  • cskim

Walinsights - 线下客户分析

Walinsights 通过自动化解决方案分析通过外部流量、商店访问和退货的客户行为。

Platform Languages Commercial License

概览

这个 BLE SDK 提供一组简单的 API,使第三方应用能够从注册的 ZOYI Squares (ZOYI 路由器设备) 接收通知。

先决条件

  • iOS 8.0 或更高版本

如何使用

简单流程图

     +-------------------------------+      
     |                               |      
     |  Get squares' MAC addresses.  |      
     |                               |      
     +---------------+---------------+      
                     |                      
                     |                      
                     |                      
    +----------------v----------------+     
    |                                 |     
    | BleManager start scan with      |     
    | these mac addresses.            |     
    |                                 |     
    +----------------+----------------+     
                     |                      
                     |                      
                     |                      
  +------------------v-------------------+  
  |                                      |  
  | Get notified from BleManager when one|  
  | of the MAC address are discovered.   |  
  |                                      |  
  +------------------+-------------------+  
                     |                      
                     |                      
                     |                      
     +---------------v--------------+       
     |                              |       
     | Stop Scan when you are done. |       
     |                              |       
     +------------------------------+       

从CocoaPods中安装WI BLE库框架(iOS 8.0+)

将以下内容添加到Xcode的Podfile中。

target YOUR_PROJECT_TARGET do
  pod 'WIBLELib'
end

通过CocoaPods安装WIBLELib框架。

pod repo update
pod install

现在您可以通过检查YOUR_PROJECT.xcworkspace来查看WI BLE框架。

创建一个BleManager来管理扫描过程,将BleManagerDeleagate分配给BleManager以触发调用。

class ViewController: UIViewController, BleManagerDeleagate{
  func didDiscoverMac(with mac: String, rssi: Int, timestamp: TimeInterval) {
    // example
    if (rssi > rssiThreashHold) {
      self.stopScanning()
    }
  }

  var manager:BleManager!
  override func viewDidLoad() {
    // on Debug mode
    BleManager.debugMode = true

    // Create BleManager
    manager = BleManager(initWithDelegate: self)
  }

  ...
}

通过滤波特定MAC地址来启动扫描

  // startScanWithmacs
  if (manager.isPowerOn &&    // Support Bluetooth hardware
      !manager.isScanning &&  // Check Already scanning
      manager.startScanWithMacs(targetMacs: targetMacs)) {  // Start Scaning with specific MAC addresses
    // Success
  } else {
    // Failed
  }

从BleManager接收发现回调

  func didDiscoverMac(with mac: String, rssi: Int, timestamp: TimeInterval) {
    // example
    if (rssi > rssiThreashHold) {
      print("Find!! \(mac)")
      // stop Scanning
      self.stopScanning()
    }
  }

完成任务后,请记住停止扫描。

  self.stopScanning()