I have a CBPeripheral
which accepting different commands for communications.
For example:
If I need to fetch current rate from the device, the command is "get-rate".
If I need to fetch current battery level of the device, the command is "battery".
So If I execute individual command, it works fine. Giving me proper response. But after each commands execution, I need to reconnect (disconnect & then connect again) before executing another command. If I will not do that then, it will always returning the value of lastly executed command.
I am NOT sure if this is the right way to do?
Let me know if you need more information from me.
This doesn't help:
@property (nonatomic, strong) CBPeripheral *currentPeripheral;
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:k_UUID];
NSArray *peripherals = [self.btManager retrievePeripheralsWithIdentifiers:@[uuid]];
if(peripherals.count) {
self.currentPeripheral = [peripherals firstObject];
[self.btManager connectPeripheral:self.currentPeripheral options:nil];
}