ios - Bluetooth characteristic being set to nil -


i running app communicates mac iphone via bluetooth , vice versa. working (with 2 generated characteristics 1 mac iphone , 1 iphone mac) apart from, characteristic mac iphone not being updated , think due charachteristic on mac being set nil no apparent reason.

so update char on mac do:

- (void)updatevalueforcharacteristic:(int)sendid {     nslog(@"sent %d", sendid);      if (self.characteristic != nil) {         dispatch_block_t block = ^(void) {             nsdata *value = [nsdata datawithbytes:&sendid length:sizeof(sendid)];             [_managerout updatevalue:value forcharacteristic:self.characteristic onsubscribedcentrals:nil];         };          dispatch_queue_t queue = dispatch_get_global_queue(dispatch_queue_priority_default, 0);         dispatch_async(queue, block);     }else{         //why being called?!     } } 

and receive on iphone do:

- (void)peripheral:(cbperipheral *)peripheral didupdatevalueforcharacteristic:(cbcharacteristic *)characteristic error:(nserror *)error {     if (error != nil) {         nslog(@"error updating value: %@", error.localizeddescription);          return;     }      cbuuid *characteristicuuid = [cbuuid uuidwithstring:_kcharacteristicuuidin];     nsinteger rec = 0;     [characteristic.value getbytes:&rec length:sizeof(rec)];     nslog(@"recieved %ld", (long)rec);      if ([characteristic.uuid isequal:characteristicuuid]) {         nslog(@"officially recieved %ld", (long)rec);         //handle char (sometimes not noticing)     } } 

is there anyway can verify iphone has received char. should scrap technique , try writing (rather updating) char or maybe try multiple chars rather one?

i need make sure iphone gets or else program useless.

update

i have added else block if (self.characteristic != nil) { , else block being called when char isn't being updated!!! can't find life of why self.characteristic being set nil?! , how should go re-creating characteristic after?

project


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -