how can I check for Bluetooth's Serial Number on Xcode

196 Views Asked by At

I am using SwiftifyBluetooth on Cocoapods but... I did use discoverServices but it only showed as its CBService's value... but I can't seem to know how to convert from its value to string... I checked on how SwiftifyBluetooth and Core Bluetooth work and hit a dead end from myself...

here is the code:

peri[0].discoverServices(withUUIDs: nil, completion: {
                result in
                switch result{
                    
                case .success(let services):
                    print(services)
                    break
                case .failure(let error):
                    print(error)
                    break
                }
            })

and this was the outputted printed in the services EDIT: [<CBService: 0x283f14ac0, isPrimary = YES, UUID = 1804>, <CBService: 0x283f14700, isPrimary = YES, UUID = Battery>, <CBService: 0x283f15480, isPrimary = YES, UUID = Device Information>, <CBService: 0x283f15840, isPrimary = YES, UUID = 49535343-FE7D-4AE5-8FA9-9FAFD205E455>]

I was just checking if this is possible to convert the the CBServices value from that datatype to string

1

There are 1 best solutions below

0
Brinkster129 On

So I did found a way after I to discover the characteristics put the "180A" in the service UUID to get the Device info as said to the cheat sheet I found about Bluetooth BLE but now my concern why is it showing values as "(null)"

Code after Discovering Services and the Characteristics

periphers[indexing].discoverServices(completion: {
            result in
            switch result{
            case .success(let service):
                print(service)
                break
            case .failure(_):
                break
                }
        })
        
        periphers[indexing].discoverCharacteristics(ofServiceWithUUID: "180A", completion: {
            result in
            switch result{
                case .success(let service):
                    print(service)
                case .failure(let error):
                    print(error)
                    break
            }
        })

output: Output of Characteristics value being null