lundi 2 février 2015

iOS CoreBluetooth:Call the connected Ble class from one class to other class

I am doing core bluetooth application .Having coreBLE.h and coreBLE.m as a library classes.And first view controller class cointains scan button when i click the scan button the screen moves to the second view controller and in that tableview is present so all the scanned devices are present in that view controller as i have written code for the second view controller as below



coreBle = [[CoreBLE alloc] init]; // Init CoreBLE class.
coreBle.delegate = self;


After appearing the scan devices i will select the one of the scanned devices and click button so that the scanned device will connect and i have written code as below.



- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
deviceselected= [NSString stringWithFormat:@"Table cell pressed. (%d)", indexPath.row];
periperal=[NSString stringWithFormat:@"%d",indexPath.row];


[[self.tableView cellForRowAtIndexPath:indexPath]
setAccessoryType:UITableViewCellAccessoryCheckmark];
}

- (IBAction)Go:(id)sender
{
if (periperal==nil) {
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:nil
message:@"Select watch to connect"
delegate:self
cancelButtonTitle:@"Ok" otherButtonTitles: nil];
[alert show];
}
else{

[coreBle connectToPeripheralAt:[periperal integerValue]];
NSLog(@"peripheral connected is %@",periperal);
HUD.labelText = @"Connecting...";


[HUD showWhileExecuting:@selector(connectingtask) onTarget:self
withObject:nil animated:YES];


}

}


suppose to retrieve battery information in the second view controller i am doing like this



-(IBAction)checkbattery
{
[coreBle checkbatterystatus];
}


upto here it s fine connections is establishing and My problem is i need to get the same connected peripheral value to the first view controller . i am doing every thing in the second view controller like scanning and connecting and writing and reading values from the peripheral .Now i need to read the same connected peripheral value in the first view controller by clicking a button how its possible .Please help me




Aucun commentaire:

Enregistrer un commentaire