To run the example project, clone the repo, and run pod install
from the Example directory first.
BPTrackerPod is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'BPTrackerPod'
Alternatively you can directly add the BPTrackerPod
folder to your project.
- Download the latest code version or add the repository as a git submodule to your git-tracked project.
- Open your project in Xcode, then drag and drop
BPTrackerPod
folder onto your project (use the "Product Navigator view"). Make sure to select Copy items when asked if you extracted the code archive outside of your project.
import BPTrackerPod
let bluetoothManager = BPMDataManager.sharedInstance
override func viewDidLoad() { super.viewDidLoad() . . bluetoothManager.delegate = self bluetoothManager.didUpdateManager() }
extension ViewController: BPMDataManagerDelegate{ func medcheckBLEDetected(_ peripheral: CBPeripheral, advertisementData: [String : Any], RSSI: NSNumber) { print(bluetoothManager.arrBLEList) } }
BPMDataManager.sharedInstance.connectPeripheral(peripheral: connectedPeripheral!)
BPMDataManager.sharedInstance.didDisconnectPeripheral(connectedPeripheral!)
BPMDataManager.sharedInstance.clearBPMDataCommand()
BPMDataManager.sharedInstance.timeSyncOfBPM()
BPMDataManager.sharedInstance.timeSyncOfBPM()
extension ViewController: BPMDataManagerDelegate{ func medcheckBLEDetected(_ peripheral: CBPeripheral, advertisementData: [String : Any], RSSI: NSNumber) { if bpmDataManager.bluetoothManager.connected { bpmDataManager.connectPeripheral(peripheral: bpmDataManager.connectedPeripheral!) } } func didMedCheckConnected(_ connectedPeripheral: CBPeripheral) { print("didMedCheckConnected \(connectedPeripheral)") } func connectedUserData(_ connectedUser: [String : Any]) { print("connectedUserData \(connectedUser)") } func willTakeNewReading(_ BLEName: CBPeripheral) { print("willStartDataReading \(BLEName)") } func didSyncTime() { print("didSyncTime") } func didTakeNewReading(_ readingData: [String : Any]) { print("didTakeNewReading \(jsonStringConvert(readingData))") } func showAlertMessage(_ title : String, message : String) { let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert) alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.cancel, handler: nil)) present(alert, animated: true, completion: nil) } func fetchAllDataFromMedCheck(_ readingData: [Any]) { print("fetchAllDataFromMedCheck \(jsonStringConvert(readingData))") } func didClearedData() { print("didClearedData") } func willStartDataReading() { print("willStartDataReading") } func didEndDataReading() { print("didEndDataReading") } func jsonStringConvert(_ obj : Any) -> String { do { let jsonData = try JSONSerialization.data(withJSONObject: obj, options: JSONSerialization.WritingOptions.prettyPrinted) return String(data: jsonData, encoding: String.Encoding.utf8)! as String } catch { return "" } } }
LNAndroid, pratik.patel@letsnurture.com
BPTrackerPod is available under the MIT license. See the LICENSE file for more info.