XYOracleNetwork/sdk-xyo-swift

View on GitHub
Carthage/Checkouts/sdk-ble-swift/Source/Gatt/Standard/CurrentTimeService.swift

Summary

Maintainability
A
3 hrs
Test Coverage
//
//  CurrentTimeService.swift
//  XYBleSdk
//
//  Created by Darren Sutherland on 9/25/18.
//  Copyright © 2018 XY - The Findables Company. All rights reserved.
//

import CoreBluetooth

public enum CurrentTimeService: String, XYServiceCharacteristic {

    public var serviceDisplayName: String { return "Current Time" }
    public var serviceUuid: CBUUID { return CurrentTimeService.serviceUuid }

    case currentTime
    case localTimeInformation
    case referenceTimeInformation

    public var characteristicUuid: CBUUID {
        return CurrentTimeService.uuids[self]!
    }

    public var characteristicType: XYServiceCharacteristicType {
        return .integer
    }

    public var displayName: String {
        switch self {
        case.currentTime: return "Current Time"
        case .localTimeInformation: return "Local Time Information"
        case .referenceTimeInformation: return "Reference Time Information"
        }
    }

    private static let serviceUuid = CBUUID(string: "00001805-0000-1000-8000-00805F9B34FB")

    private static let uuids: [CurrentTimeService: CBUUID] = [
        .currentTime : CBUUID(string: "00002a2b-0000-1000-8000-00805f9b34fb"),
        .localTimeInformation : CBUUID(string: "00002a0f-0000-1000-8000-00805f9b34fb"),
        .referenceTimeInformation : CBUUID(string: "00002a14-0000-1000-8000-00805f9b34fb")
    ]

    public static var values: [XYServiceCharacteristic] = [
        currentTime, localTimeInformation, referenceTimeInformation
    ]
}