Page 1 of 1

Notifications/what is significant

Posted: 00:10, 03 Jan 2015
by zook
Hi

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;
}

Re: Notifications/what is significant

Posted: 16:38, 05 Jan 2015
by micke
Hi Zook,

Have you looked at the "TI SensorTag Sensors" example that comes with Evothings Studio?

http://evothings.com/doc/examples/ble-t ... nsors.html

This example shows how to read all sensors. You could strip it down to use only the sensors you need. Then build a native Cordova app for the final version to publish.

If you use Nexus 7, be aware of this issue:

https://github.com/evothings/evothings- ... issues/106

Let me know how it goes.

Best, Mikael