2012-10-25 1 views
2

Je développe l'application Bluetooth.J'ai un nom de périphérique Bluetooth disponible dans Table View..Si appuyer sur un périphérique signifie que je veux connaître tous les services UUID pris en charge dans un autre contrôleur de vue avec vue Table.Give moi une idée.Comment afficher les services pris en charge de Bluetooth dans tableview à partir du nom de périphérique (UITableViewCell)?

1) Peripheralmanager (NSObject)

2) FirstViewController (Dans ce que j'ai un nom de périphérique)

3) SecondViewController (Dans ce que je veux Services pris en charge)

Peripheralmanager.m

- (void)centralManager:(CBCentralManager *)central 
didDiscoverPeripheral:(CBPeripheral *)peripheral 
advertisementData:(NSDictionary *)advertisementData 
       RSSI:(NSNumber *)RSSI 
{ 

    NSLog(@"didDiscoverPeriphera.peripheral: %@ rssi: %@, UUID:%@ advertisementData:%@", peripheral,RSSI,peripheral.UUID, [advertisementData description]); 

    targetPeripheral = peripheral; 
    peripheral.delegate = self; 
if (!peripheral.isConnected) 
{ 
    [centralManager connectPeripheral:peripheral options:nil]; 
} 

}

FirstViewCo ntroller.m

- (void)peripheralManagerDidConnectPeripheral:(PeripheralManager *)peripheral 
{ 
    NSLog(@"%@",peripheral.deviceName); 
    NSLog(@"%@",peripheral.rssi); 
    [device addObject:[NSString stringWithFormat:@"%@",peripheral.deviceName]]; 
    [self.deviceTable reloadData]; 
} 

Tableview

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *[email protected]"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; 
    if(cell==nil) 
{ 
    cell =[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier]; 
} 
    cell.textLabel.text=[device objectAtIndex:indexPath.row]; 
    return cell; 
} 

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 


} 

Si vous voulez plus d'informations S'il vous plaît Demandez-moi.

S'il vous plaît Vérifiez ce lien sample Itunes app

l'image enter image description here

enter image description here

+0

avez-vous trouvé la réponse que j'essaie de faire la même chose –

Répondre

2

Eh bien ... Tout d'abord, vous voulez Bluetooth Low Energy, ce qui est tout à fait différent du bluetooth. Même si le framework s'appelle Bluetooth et que le "normal" s'appelle ExternalAccessory. Pas vrai?

Je ne suis pas sûr de ce qui est vraiment votre question. Avez-vous essayé l'exemple de Apple: CoreBluetooth Temperature Sensor? Ou même les deux échantillons (température et moniteur cardiaque) fonctionnent aussi puisqu'ils utilisent le même cadre. Il vous expliquera tout cela fonctionne: Périphérique> Service> Caractéristique.

+0

Merci beaucoup pour votre réponse j'ai eu la réponse. – prem

Questions connexes