0

How to read 0x1801 gerneric attribute service in iOS ?

strenger gravatar image

asked 2017-04-21 09:05:06 +0200

updated 2017-04-21 14:57:18 +0200

Hi,

I have changed in my services so I have added 0x2A05 (service changed) characteristic in my 0x1801 service. But I am not able to read the service.

In didDiscoverServices I have below code.

- (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error {


    for (CBService *service in peripheral.services) {

        DebugLog(@"Discovered service: %@", service);

        [peripheral discoverCharacteristics:nil forService:service];

        }
}

Also In didDiscoverCharacteristicsForService have below code.

- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error {

    self.connectedPeripheral = peripheral;

    for (CBCharacteristic *characteristic in service.characteristics) {
        if (characteristic.isNotifying) {
            [self.connectedPeripheral setNotifyValue:YES forCharacteristic:characteristic];
        }
    }
}

Still I am not able to read the generic attribute service i.e 0x1801

here are the logs:

discovered services

2017-04-21 12:19:55.151 Beam[1876:823627] -[BLECentral peripheral:didDiscoverServices:] [Line 310] Discovered service: <CBService: 0x153af8830, isPrimary = YES, UUID = 524D1856-763D-43EB-A001-0594B37AC495>
2017-04-21 12:19:58.532 Beam[1876:823627] -[BLECentral peripheral:didDiscoverServices:] [Line 310] Discovered service: <CBService: 0x153af8710, isPrimary = YES, UUID = Battery>
2017-04-21 12:20:02.048 Beam[1876:823627] -[BLECentral peripheral:didDiscoverServices:] [Line 310] Discovered service: <CBService: 0x153af9fc0, isPrimary = YES, UUID = Device Information>
2017-04-21 12:20:05.042 Beam[1876:823627] -[BLECentral peripheral:didDiscoverServices:] [Line 310] Discovered service: <CBService: 0x153afa370, isPrimary = YES, UUID = 00001530-1212-EFDE-1523-785FEABCD123>


discovered characteristics

2017-04-21 12:20:37.554 Beam[1876:823627] -[BLECentral setNotifyValue:peripheral:] [Line 501] discovered Characteristics:<CBCharacteristic: 0x153b06ce0, UUID = 524D1857-763D-43EB-A001-0594B37AC495, properties = 0x12, value = (null), notifying = NO>
2017-04-21 12:20:56.464 Beam[1876:823627] -[BLECentral setNotifyValue:peripheral:] [Line 501] discovered Characteristics:<CBCharacteristic: 0x153b070d0, UUID = 524D1858-763D-43EB-A001-0594B37AC495, properties = 0xA, value = (null), notifying = NO>
2017-04-21 12:21:13.667 Beam[1876:823627] -[BLECentral setNotifyValue:peripheral:] [Line 501] discovered Characteristics:<CBCharacteristic: 0x153b07210, UUID = 524D1859-763D-43EB-A001-0594B37AC495, properties = 0x8, value = (null), notifying = NO>
2017-04-21 12:21:29.226 Beam[1876:823627] -[BLECentral setNotifyValue:peripheral:] [Line 501] discovered Characteristics:<CBCharacteristic: 0x153b07270, UUID = 524D1861-763D-43EB-A001-0594B37AC495, properties = 0x2, value = <0000>, notifying = NO>
2017-04-21 12:21:37.770 Beam[1876:823627] -[BLECentral setNotifyValue:peripheral:] [Line 501] discovered Characteristics:<CBCharacteristic: 0x153b07130, UUID = 524D1860-763D-43EB-A001-0594B37AC495, properties = 0x1A, value = <03>, notifying = NO>
2017-04-21 12:21:37.775 Beam[1876:823627] -[BLECentral setNotifyValue:peripheral:] [Line 501] discovered Characteristics:<CBCharacteristic: 0x153b0f170, UUID = Battery Level, properties = 0x12, value = <09>, notifying = NO>
2017-04-21 12:21:37.780 Beam[1876:823627] -[BLECentral setNotifyValue:peripheral:] [Line 501] discovered Characteristics:<CBCharacteristic: 0x153b0ffc0, UUID = Manufacturer Name String, properties = 0x2, value = <64>, notifying = NO>
2017-04-21 12:21:37.782 Beam[1876:823627] -[BLECentral setNotifyValue:peripheral:] [Line 501] discovered Characteristics:<CBCharacteristic: 0x153b01680, UUID = Hardware Revision String, properties = 0x2, value = <0a18>, notifying = NO>
2017-04-21 12:21:37.783 Beam[1876:823627] -[BLECentral setNotifyValue:peripheral:] [Line 501] discovered Characteristics:<CBCharacteristic: 0x153b007b0, UUID = Firmware Revision String, properties = 0x2, value = <52616e64 204d634e 616c6c79>, notifying = NO>
2017-04-21 12:21:37.805 Beam[1876:823627] -[BLECentral setNotifyValue:peripheral:] [Line 501] discovered Characteristics:<CBCharacteristic: 0x153b05560, UUID = Firmware Revision String, properties = 0x2, value = <76312e30 325f3034 3139>, notifying = NO>
2017-04-21 12:21:37.806 Beam[1876:823627] -[BLECentral setNotifyValue:peripheral:] [Line 501] discovered Characteristics:<CBCharacteristic: 0x153b06400, UUID = 00001532-1212-EFDE-1523-785FEABCD123, properties = 0x4, value = (null), notifying = NO>
2017-04-21 12:21:37.806 Beam[1876:823627] -[BLECentral setNotifyValue:peripheral:] [Line 501] discovered Characteristics:<CBCharacteristic: 0x153b06460, UUID = 00001531-1212-EFDE-1523-785FEABCD123, properties = 0x18, value = (null), notifying = NO>
2017-04-21 12:21:37.806 Beam[1876:823627] -[BLECentral setNotifyValue:peripheral:] [Line 501] discovered Characteristics:<CBCharacteristic: 0x153af9a70, UUID = 00001534-1212-EFDE-1523-785FEABCD123, properties = 0x2, value = (null), notifying = NO>

As per Apples documentation here :https://developer.apple.com/hardwaredrivers/BluetoothDesignGuidelines.pdf

service Generic attribute i.e 0x1801 Is handled by iOS internally.

So, I don't know how to clear the BLE cache using IS_Service_Changed ? Do I need to read (0x2A05 ) characteristics i.e service Changed Characteristic ? How my BLE cache will get cleared ?

Suggest a way to read the 0x2A05 characteristics. How to enable notification for it ?

edit retag flag offensive close delete report spam

1 answer

Sort by » oldest newest most voted
0
run_ar gravatar image

answered 2017-04-21 16:30:15 +0200

If I remember correctly this characteristic is not exposed to the application on iOS. Instead this is handled by corebluetooth. Can you please check whether or not iOS enable this? Note that you need to bond for iOS to utilize this, and that you might have to toggle bluetooth off/on to flush the attribute cash on iOS, if you just added the characteristic.

edit flag offensive delete publish link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer. Do not ask a new question or reply to an answer here.

[hide preview]

User menu

    or sign up

Recent questions

Question Tools

1 follower

Stats

Asked: 2017-04-21 09:05:06 +0200

Seen: 18 times

Last updated: Apr 21