Notifications/what is significant

Discuss mobile apps for Texas Instruments products.
zook
Posts: 1
Joined: 06:14, 28 Dec 2014

Notifications/what is significant

Postby zook » 00:10, 03 Jan 2015

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

User avatar
micke
Posts: 256
Joined: 20:49, 18 Nov 2013

Re: Notifications/what is significant

Postby micke » 16:38, 05 Jan 2015

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


Return to “Texas Instruments”

Who is online

Users browsing this forum: No registered users and 5 guests