Search code examples
iosobjective-crssicbperipheral

readRSSI not calling didReadRSSI


I can't get didReadRSSI to call back on my peripheral!!

I'm developing on an iPad mini - iOS 8.1.2

I set the peripheral to an NSMutable array and I can call connect, disconnect etc. fine from that array so the peripheral object attached to that array is valid.

My code is below, what is wrong? Why don't I get a didReadRSSI callback on my peripheral??

- (void)updateConnectedRSSITimerFunc {
    for(TheCustomPeripheral *arrayItem in self.peripherals) {
      if(arrayItem.connected) {
          //This is called every 4 seconds from an NSTimer succesfully
          [arrayItem.peripheral readRSSI];
          NSLog(@"RSSI request");
      }
    }
}

-(void) peripheral:(CBPeripheral *)peripheral didReadRSSI:(NSNumber *)RSSI error:(NSError *)error {
//This never get's called!!!!!
   NSLog(@"RSSI returned %@", [RSSI stringValue]);
}

Solution

  • Solved!!! In the timer I added this... I'm still new to iOS so I missed the delegate bit to get callbacks...

                arrayItem.peripheral.delegate = self;
    

    As a supplementary question, why do I get this warning? I'm ignoring it because the app runs fine.

    Assigning to 'id' from incompatible type 'xxxListTableViewController *const __strong'

    Answer: My class had to be a CBPeripheralDelegate, e.g. @interface myInterface ,CBPeripheralDelegate>