Skip to content

New iOS5 framework to connect with Low-Energy devices. Actually this framework cannot connect with "traditional" bluetooth devices, iPhone4S will have a "switcher" that will allow to connect LE-devices and "tradicional" bluetooth devices.

Notifications You must be signed in to change notification settings

mneuwert/CoreBluetooth-Demo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CoreBluetooth Demo

This a blocks-delegation code wrapper for CoreBluetooth framework. It simplifies the way you connect with Low-Energy devices. This framework is available on iOS5 an higher OS versions.

Instance the simpleton object and set UIDs from your LE devices, you can set characteristics from a device (or several devices). Also you must set an UIDs array to perform data savings.

On hardware response block, you will be notified about divide status (connected/disconnect/fail to connect).

    BlueToothMe *instance = [BlueToothMe shared];
    [instance setDelegate:self];
    
    NSArray *characteristics = [NSArray arrayWithObjects:[CBUUID UUIDWithString:@"2A1E"], 
                                                         [CBUUID UUIDWithString:@"2A1C"],
                                                         [CBUUID UUIDWithString:@"2A21"], nil];
    
    [instance setCharacteristics:characteristics forServiceCBUUID:@"1809"];
    [instance setLetWriteDataCBUUID:[NSArray arrayWithObject:@"1809"]];
    
    characteristics = [NSArray arrayWithObject:[CBUUID UUIDWithString:@"2A29"]];
                       
    [instance setCharacteristics:characteristics forServiceCBUUID:@"180A"];
    
    [instance hardwareResponse:^(CBPeripheral *peripheral, BLUETOOTH_STATUS status, NSError *error) {
        
        if (status == BLUETOOTH_STATUS_CONNECTED)
        {
            NSLog(@"connected!");
        }
        else if (status == BLUETOOTH_STATUS_FAIL_TO_CONNECT)
        {
            NSLog(@"fail to connect!");
        }
        else
        {
            NSLog(@"disconnected!");
        }
        
        NSLog(@"CBUUID: %@, ERROR: %@", (NSString *)peripheral.UUID, error.localizedDescription);
    }];
    
    [instance startScan];

Delegate methods:

- (void)peripheralDidWriteChracteristic:(CBCharacteristic *)characteristic 
                         withPeripheral:(CBPeripheral *)peripheral 
                              withError:(NSError *)error;

- (void)peripheralDidReadChracteristic:(CBCharacteristic *)characteristic 
                        withPeripheral:(CBPeripheral *)peripheral 
                             withError:(NSError *)error;

- (void)hardwareDidNotifyBehaviourOnCharacteristic:(CBCharacteristic *)characteristic
                                    withPeripheral:(CBPeripheral *)peripheral
                                             error:(NSError *)error;

These delegate methods retrieve the result from write/read/notify a value from one or more devices.

About

New iOS5 framework to connect with Low-Energy devices. Actually this framework cannot connect with "traditional" bluetooth devices, iPhone4S will have a "switcher" that will allow to connect LE-devices and "tradicional" bluetooth devices.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published