Bluetooth+Types.swift 3.53 KB
//
//  Bluetooth+Types.swift
//  Twear
//
//  Created by yangbin on 2021/12/6.
//

import CoreFoundation



struct ScanDevice {
    var peripheral: CBPeripheral
    var mac: String
    
    init(_ peripheral: CBPeripheral, mac: String) {
        self.peripheral = peripheral
        self.mac = mac
    }
}





public struct BLEConfig {
    
    static let ServerUUID = "C3E6FEA0-E966-1000-8000-BE99C223DF6A" //主服务UUID
    static let ReadUUID = "C3E6FEA2-E966-1000-8000-BE99C223DF6A"   //读取数据特征值
    static let WriteUUID = "C3E6FEA1-E966-1000-8000-BE99C223DF6A"  //写入数据特征值
    
    
    static let MTKBasServerUUID = "0000180F-0000-1000-8000-00805F9B34FB"  //mtk2502 Bas主服务UUID
    static let MTKBasReadUUID = "00002A19-0000-1000-8000-00805F9B34FB"   //mtk2502 Bas读取数据特征值
    static let MTKBasWriteUUID = "00002A19-0000-1000-8000-00805F9B34FB"  //mtk2502 Bas写入数据特征值
    
    static let MTKServerUUID = "000018AA-0000-1000-8000-00805F9B34FB"  //mtk2502主服务UUID
    static let MTKReadUUID = "00002AAA-0000-1000-8000-00805F9B34FB"   //mtk2502读取数据特征值
    static let MTKWriteUUID = "00002AAA-0000-1000-8000-00805F9B34FB"  //mtk2502写入数据特征值
    
    static let MTKDialServerUUID = "0000180D-0000-1000-8000-00805F9B34FB"  //mtk2502 Dial主服务UUID
    static let MTKDialReadUUID = "00002A37-0000-1000-8000-00805F9B34FB"   //mtk2502 Dial读取数据特征值
    static let MTKDialWriteUUID = "00002A37-0000-1000-8000-00805F9B34FB"  //mtk2502 Dial写入数据特征值
    static let SyncHealthTimer = "SyncHealthDataTimer"
    
}



enum DistanceUnit: UInt8 {
    case foot = 1
    case meter = 0
}
enum TemperatureUnit: UInt8 {
    case celsius = 0
    case fahrenheit = 1
}
enum TimeFormat: UInt8 {
    case hour_24 = 0
    case hour_12 = 1
}

enum BleCmd: UInt8 {
    case firmware = 0x01
    case set = 0x02
    case device = 0x04
    case weather = 0x03
    case find = 0x05
    case remind = 0x06
    case sync = 0x0A
}

enum SetCmd: UInt8 {
    case unit = 0x01
    case firmware = 0x12
    case firmware_return = 0x13
    case time = 0x20
    case alarmClock = 0x21
    case user = 0x23
    case sedentary = 0x25
    case menstrual = 0x26
    case language = 0x27
    case drink = 0x28
    case push = 0x29
    case dial = 0x2B
    case setting = 0x2E
    case weather = 0x30
    case contact = 0x32
    case card = 0x33
    case contact1 = 0x34
    case contact2 = 0x35
    case contact3 = 0x36
    case custom = 0x37
    case pay = 0x38
    case battery = 0x40  // device-battery   set-contact4
    case battery_return = 0x41
    case openCamera = 0x46
    case takePicture = 0x47
    case exitCamera = 0x48
    case wrist = 0x4A
    case autoMeasure = 0x4B
    case find_device = 0x50
    case find_phone_start = 0x51
    case find_phone_stop = 0x52
    case disturb = 0x64
    case sync = 0xA0
    case set_return = 0x2F
}

enum SyncCmd: UInt8 {
    case sleep = 0xA2
    case step = 0xA3
    case hr = 0xA4
    case train = 0xA5
    case bp = 0xAD
    case bo = 0xAE
    case pressure = 0xB8
    case mett = 0xB9
    case hr_rt = 0xAB
    case bp_rt = 0xB1
    case bo_rt = 0xB2
    case step_rt = 0xAC
    case other = 0x00
}

enum SyncType: UInt8 {
    case sleep = 0x01
    case hr = 0x02
    case step = 0x03
    case train = 0x04
    case bo = 0x05
    case bp = 0x07
    case pressure = 0x08
    case mett = 0x09
}

enum SyncDay: Int {
    case today = 0
    case yesterday = -1
    case dayBeforYesterday = -2
}

//enum DeviceCmd: UInt8 {
//    case openCamera = 0x46
//    case exitCamera = 0x48
//}