Skip to content

smartfuturesg/MedCheckSDK_source_iOS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MedCheckPod

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

MedCheckPod is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'MedCheckPod'

Usage

Pod Import

    import MedCheckPod

Get Shared Instance of BPMDataManager

    let bluetoothManager = BPMDataManager.sharedInstance

Set delegate from ViewDidLoad()

override func viewDidLoad() {
    super.viewDidLoad()
    .
    .
    bluetoothManager.delegate = self
    bluetoothManager.didUpdateManager()
}

Get BPMDataManager delegate method for scanned MedCheck devices

extension ViewController: BPMDataManagerDelegate{
    func medcheckBLEDetected(_ peripheral: CBPeripheral, advertisementData: [String : Any], RSSI: NSNumber) {
        print(bluetoothManager.arrBLEList)
    }
}

Connect to MedCheck BLE device

    BPMDataManager.sharedInstance.connectPeripheral(peripheral: connectedPeripheral!)

Disconnect to MedCheck BLE device

    BPMDataManager.sharedInstance.didDisconnectPeripheral(connectedPeripheral!)

Clear Blood Pressure data from MedCheck BLE device

    BPMDataManager.sharedInstance.clearBPMDataCommand()

Synch current time with Blood Pressure data from MedCheck BLE device

    BPMDataManager.sharedInstance.timeSyncOfBPM()

Synch current time with Blood Pressure data from MedCheck BLE device

    BPMDataManager.sharedInstance.timeSyncOfBPM()

BPMDataManagerDelegate methods combined with CoreBluetoothManagerDelegate methods.

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 ""
        }
    }
}

Author

smartfuturesg, sumit@oursmartfuture.com

License

MedCheckPod is available under the MIT license. See the LICENSE file for more info.