Firstly, my thanks to the developers at evothings - I think it's awesome!
I'm having some difficulty trying to set the change of characteristics I need to be notified for.
In particular I need ios and android phones to be notified when gyroscopes and accelerometers in the sensor tag pass set limits.
I'm having trouble setting said limits.
I've been playing with java, obj-c/swift and javascript (which is probably just adding to the confusion!)
Any pointers as to where to look next would be great.
Code: Select all
/* java */
@Override
public void onCharacteristicChanged(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic) //todo
{
broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
}
};
private void broadcastUpdate(final String action)
{
final Intent intent = new Intent(action);
sendBroadcast(intent);
}
private void broadcastUpdate(final String action,
final BluetoothGattCharacteristic characteristic) //todo
{
final Intent intent = new Intent(action);
final byte[] data = characteristic.getValue();
if (data != null && data.length > 0) //todo
{
final StringBuilder stringBuilder = new StringBuilder(data.length);
for (byte byteChar : data)
stringBuilder.append(String.format("%02X ", byteChar));
intent.putExtra(EXTRA_DATA, new String(data) + "\n" + stringBuilder.toString());
}
sendBroadcast(intent);
}
/* js */
instance.accelerometerCallback = function(fun, interval)
{
instance.accelerometerFun = fun
instance.accelerometerConfig = 1 // on
instance.accelerometerInterval = interval
instance.requiredServices.push(sensortag.ACCELEROMETER_SERVICE)
return instance
}
/* ios */
+(bool) isCharacteristicNotifiable:(CBPeripheral *)peripheral sCBUUID:(CBUUID *)sCBUUID cCBUUID:(CBUUID *) cCBUUID {
for ( CBService *service in peripheral.services ) {
if ([service.UUID isEqual:sCBUUID]) {
for (CBCharacteristic *characteristic in service.characteristics ) {
if ([characteristic.UUID isEqual:cCBUUID])
{
if (characteristic.properties & CBCharacteristicPropertyNotify) return YES;
else return NO;
}
}
}
}
return NO;
}