PureSwift / GATT

Bluetooth Generic Attribute Profile (GATT) for Swift (Supports Linux)
MIT License
63 stars 18 forks source link

Beacon and Service Advertisement #9

Closed rvsrvs closed 6 years ago

rvsrvs commented 6 years ago

When I start a service as follows, LightBlue sees the device and can scan it, but does not see it advertising a service. ScanBeacon does not see the beacon. Should I be able to see both?

        if let uuid = Foundation.UUID(uuidString: "C870EC7D-4EB9-4549-A355-5663EB99D71D"),                                                                     
           let rssi = RSSI(rawValue: Int8(bitPattern: 0xb3)) {                                                                                                 
            let beacon = Bluetooth.iBeacon(uuid: uuid, major: 787, minor: 0, rssi: rssi, interval: 800)                                                        
            print("Beacon id = \(beacon)")                                                                                                                     
            do {                                                                                                                                               
                let _ = try peripheral.add(service: ConfigurationProfile.Service)       // ConfigurationProfile.Service is a correctly configured service                                                       
                do {                                                                                                                                           
                    try peripheral.start(beacon: beacon)                                                                                               
                    print("Vending ConfigurationService = \n\(ConfigurationProfile.Service)")                                                  
                } catch {                                                                                                                                      
                    print("failed to start service")                                                                                                           
                    print("Exception: \(error.localizedDescription)")                                                                                          
                }                                                                                                                                              
            } catch {                                                                                                                                          
                print("failed to add service")                                                                                                                 
                print("Exception: \(error.localizedDescription)")                                                                                              
            }                                                                                                                                                  
        }                                                                                                                                                      
colemancda commented 6 years ago

It should see the beacon. The service should be available upon discovering services, not advertising. The adverting payload is 31 bytes is only enough for the iBeacon.

colemancda commented 6 years ago

@rvsrvs Can you give me a compilable project or repo to test with? If advertising is not working properly I will fix it ASAP.

colemancda commented 6 years ago

@rvsrvs Is this on Linux, iOS or Mac? macOS cannot advertise iBeacon.

rvsrvs commented 6 years ago

Raspbian. Sorry been gone all day will construct a small example tomorrow.