Hi All, i'm working on a small app which connects to a Nordic Thingy Device via BLE, the sensor mainly just measures Temperature and notifies the app every 30 seconds the temperature Value, this is all working good, but I also need to get the RSSI value periodically, i found the following code in the forum to get the RSSI value and it seems to work, except that when the RSSI value the first time for some reason the temperature value stops being sent to the app.
And then the following function is used to call the objective C code:
As I mentioned, the code seems to work, except that the RSSI value is only returned once and everything else stops working as well, the app continues to run but the the Temperature Value from the Nordic sensor stops being transmitted.
Does anyone have any input on this, why would the temperature value stop being transmitted when the GetRSSIVal function is called, if I comment out the GetRSSIVal line then everything goes back to normal, the temperature value is sent every 30 seconds.
Thanks all in advance for your help.
Walter
ReadRSSI Function:
#IF OBJC
#import <CoreBluetooth/CoreBluetooth.h>
#import <CoreBluetooth/CBPeripheral.h>
- (void)GetRSSIVal:(CBPeripheral*)peripheral {
peripheral.delegate = self; //IMPORTANT or the event wont fire!
[peripheral readRSSI];
}
- (void)peripheral:(CBPeripheral *)peripheral
didReadRSSI:(NSNumber *)RSSI
error:(NSError *)error {
[self.bi raiseEvent:nil event:@"peripheral_rssiavailable:" params:@[RSSI]];
}
#End If
And then the following function is used to call the objective C code:
B4X:
Sub GetRSSI
''If connected = False Then Return 'No RSSI Available.
Dim per As NativeObject = manager.GetPeripheralObject
Dim NativeMe As NativeObject = Me
NativeMe.RunMethod("GetRSSIVal:", Array(per))
End Sub
Sub Peripheral_RssiAvailable(RSSI As Double)
Log("RSSI: " & RSSI)
End Sub
As I mentioned, the code seems to work, except that the RSSI value is only returned once and everything else stops working as well, the app continues to run but the the Temperature Value from the Nordic sensor stops being transmitted.
Does anyone have any input on this, why would the temperature value stop being transmitted when the GetRSSIVal function is called, if I comment out the GetRSSIVal line then everything goes back to normal, the temperature value is sent every 30 seconds.
Thanks all in advance for your help.
Walter