Hot to read and write data to a bluetooth low energy device.
- intel CPU usually use little endian.
- The ARM architecture was little-endian before version 3 when it became big-endian.
func SearchBLE(){
cb_manager.scanForPeripherals(withServices:[service_uuid], options: nil)
StopSearchBLE()
}
func centralManager(_ central: CBCentralManager, didConnect peripheral:
CBPeripheral) {
peripheral.delegate = self
peripheral.discoverServices(nil)
}
func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {
for service in peripheral.services! {
print("Service: \\(service)\\n error: \\(error)")
}
}
discoverServices(nil) - NIL means that all services will be returned, which is not a good option.( READ Remarks 3)
If you haven’t found the SERVICE UUID run your code and looking for in console
I found have 3 services: Battery, Device information (Firmware) and FFF0
This uuid service isn’t a standard one, a list with standards can find here
FFF0 is the SERVICE UUID in this case