|
Bogdan Timofte
authored
2 weeks ago
|
1
|
//
|
|
|
2
|
// BluetoothRadio.swift
|
|
|
3
|
// USB Meter
|
|
|
4
|
//
|
|
|
5
|
// Created by Bogdan Timofte on 19/03/2020.
|
|
|
6
|
// Copyright © 2020 Bogdan Timofte. All rights reserved.
|
|
|
7
|
//
|
|
|
8
|
|
|
|
9
|
import CoreBluetooth
|
|
|
10
|
|
|
|
11
|
/**
|
|
|
12
|
Bluetooth Radio Modules
|
|
|
13
|
# DX-BT18 (HM-10)
|
|
|
14
|
- Documentation [DX-BT18 User Manual](https:fccid.io/2AKS8DX-BT18/User-Manual/Users-Manual-4216091)
|
|
|
15
|
- Code [HM10 Bluetooth Serial iOS](https://github.com/hoiberg/HM10-BluetoothSerial-iOS)
|
|
|
16
|
# PW0316
|
|
|
17
|
- Documentation [PW0316 BLE4.0 User Manual](http://www.phangwei.com/o/PW0316_User_Manual_V2.9.pdf)
|
|
|
18
|
*/
|
|
|
19
|
enum BluetoothRadio : CaseIterable {
|
|
|
20
|
case BT18
|
|
|
21
|
case PW0316
|
|
|
22
|
case UNKNOWN
|
|
|
23
|
}
|
|
|
24
|
|
|
|
25
|
/**
|
|
|
26
|
Dictionary containing services used in our communication for each radio
|
|
|
27
|
*/
|
|
|
28
|
var BluetoothRadioServicesUUIDS: [BluetoothRadio:[CBUUID]] = [
|
|
|
29
|
.BT18 : [CBUUID(string: "FFE0")],
|
|
|
30
|
.PW0316 : [CBUUID(string: "FFE0"), CBUUID(string: "FFE5")]
|
|
|
31
|
]
|
|
|
32
|
|
|
|
33
|
/**
|
|
|
34
|
Returns an array containing all service UUIDs used by radios
|
|
|
35
|
*/
|
|
|
36
|
func allBluetoothRadioServices () -> [CBUUID] {
|
|
|
37
|
var retval: [CBUUID] = []
|
|
|
38
|
for radio in BluetoothRadio.allCases {
|
|
|
39
|
for serviceUUID in BluetoothRadioServicesUUIDS[radio] ?? [] {
|
|
|
40
|
if !retval.contains(serviceUUID) {
|
|
|
41
|
retval.append(serviceUUID)
|
|
|
42
|
}
|
|
|
43
|
}
|
|
|
44
|
}
|
|
|
45
|
return retval
|
|
|
46
|
}
|