Last active
April 26, 2017 15:18
-
-
Save SherlockJiang/4924476e6f9d4281c275a780cad2a749 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void) bleAction1 | |
{ | |
self.bleAction([[BleAction alloc] initWithServiceUUID: @"07CD3295-E29F-4EEA-A0EC-617DA6921626" | |
andCharacteristicUUID: @"98EE2679-917C-4E39-A587-20E31E0BA519"]); | |
} | |
-(void) bleAction2 | |
{ | |
self.bleAction([[BleAction alloc] initWithServiceUUID: @"2FD8921C-9F28-4257-A1EB-61E6476FD2FF" | |
andCharacteristicUUID: @"C9D1BE56-9027-4AE3-BE66-9E8BED3A1FC3"]); | |
} | |
-(void) bleAction(BleAction *action) | |
{ | |
CBCharacteristic *characteristic = self.characteristicByAction(peripheral, action); | |
[peripheral readValueForCharacteristic: characteristic]; | |
} | |
-(CBCharacteristic *) characteristicByAction(CBPeripheral *peripheral, BleAction *action) | |
{ | |
CBCharacteristic *result = nil; | |
for(CBService *service in peripheral.services) | |
{ | |
if([service.UUID isEqual:[CBUUID UUIDWithString:action.serviceUUID]]) | |
{ | |
for(CBCharacteristic *characteristic in service.characteristics) | |
{ | |
if([characteristic.UUID isEqual:[CBUUID UUIDWithString:action.characteristicUUID]]) | |
{ | |
result = characteristic; | |
} | |
} | |
} | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment