Bluetooth+Types.swift 6.47 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 = "0000FFF0-0000-1000-8000-00805F9B34FB" //主服务UUID
    static let ReadUUID = "0000FFF3-0000-1000-8000-00805F9B34FB"   //读取数据特征值
    static let WriteUUID = "0000FFF2-0000-1000-8000-00805F9B34FB"  //写入数据特征值
    
    static let NotificationUUID = "0000FFD2-0000-1000-8000-00805F9B34FB"  //写入数据特征值
    
//    0000FFF4-0000-1000-8000-00805F9B34FB    //  转换特征值
    
    // 旧
//    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 meter = 1
    case foot = 0
}
enum TemperatureUnit: UInt8 {
    case celsius = 0
    case fahrenheit = 1
}
enum TimeFormat: UInt8 {
    case hour_12 = 0
    case hour_24 = 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 NewCmd: UInt8 {
    case response = 0x01
    case queryDeviceInfo = 0x02
//    case ota = 0x07
    case setTime = 0x09
    case setTimeFormat = 0x10
    case setTemperatureUnit = 0x11
    case setDistanceUnit = 0x12
    case setWristSense = 0x13
    case setTouchSense = 0x14
    case setLowPowerRemind = 0x15
    case setLanguage = 0x16
    case setRestore = 0x17
    case setHeartRateHighRemind = 0x90// deprecated
    case setHeartRateLowRemind = 0x91// deprecated
    case setRestHeartRateRemind = 0x18//安静心率预警
    case setExerciseHeartRateRemind = 0x19//运动心率预警
    case setFindWatch = 0x0020
//    case setMessage = 0x0021
//    case setPhoneCall = 0x0022
//                      0x0023
    case setPressureAutoDetect = 0x0024
    case setBloodOxygenAutoDetect = 0x0025
    case setUserInfo = 0x0026
    case setNoDisturb = 0x0027
    case setSynWatch = 0x0028
    case setBeiDouContact = 0x0029
    case setBeiDouQuickAnswer = 0x0030
    case setWeather = 0x0031
    case setHeartRateDetectInterval = 0x0032
    case setBloodOxygenLowRemind = 0x0034
    case setMessageRemind = 0x0035
    case setExerciseStatus = 0x0038
}

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 all = 0x00
    case heartRate = 0x01
    case bloodOxygen = 0x02
//    case step = 0x03
    case temperature = 0x04
    case pressure = 0x05
    case sleep = 0x06
    case train = 0x07
    case step = 0x08
    case battery = 0x09
    case gps = 0x0A
    case intensiveTime = 0x0B
    case beidouCard = 0x0C
    case noDisturb = 0x0D
    case boAutoDetect = 0x0E
    case boLowRemind = 0x0F
//    case hrAutoDetect = 0x10
//    case exerciseHrRemind = 0x12
    case firmwareVersion = 0x14
    case wristSense = 0x15
    case messageRemind = 0x0017
    case beiDouContact = 0x0018
    case pressureAutoDetect = 0x19
    case lowPowerRemind = 0x1A
    case beiDouQuickAnswer = 0x001B
    case exerciseHrRemind = 0x1C//运动心率预警
    case hrAutoDetect = 0x1D//心率测量间隔设置
    case restHrRemind = 0x1E//安静心率预警
    case other = 0xff
}

enum SyncOption: UInt8 {
    case now = 0x01
    case history = 0x02
}

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

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

// 0x01 设备ID
// 0x02 设备名称
// 0x03 设备mac地址
// 0x04 MCU版本号
// 0x05 电量
enum deviceInfoType: UInt8 {
    case deviceId = 0x01
    case deviceName = 0x02
    case deviceMac = 0x03
    case mcuVersion = 0x04
    case battery = 0x05
}

enum WeekFlag: UInt8 {
    case sunday = 0
    case monday = 1
    case tuesday = 2
    case wednesday = 3
    case thursday = 4
    case friday = 5
    case saturday = 6
}

enum ExerciseStatus: UInt8 {
    case sunday = 0
    case monday = 1
    case tuesday = 2
    case wednesday = 3
    case thursday = 4
    case friday = 5
    case saturday = 6
}