Hardware Reference
In-Depth Information
switch ( mState )
{
case ACC_ENABLE:
Log . d ( LOGTAG , "uiFailedWrite: Failed to enable accelerometer" );
break ;
}
}
To enable all of the sensors, you would basically extend the case of enabling one sensor
to all of the sensors. After the write operation to enable the first sensor, you would enable
each of the other sensors in the callback:
@Override
public void uiSuccessfulWrite ( BluetoothGatt gatt ,
BluetoothDevice device ,
BluetoothGattService service ,
BluetoothGattCharacteristic ch ,
String description )
{
BluetoothGattCharacteristic c ;
super . uiSuccessfulWrite ( gatt , device , service , ch , description );
switch ( mState )
{
case ACC_ENABLE:
Log . d ( LOGTAG , "uiSuccessfulWrite: Successfully enabled
accelerometer" );
// enable next sensor
c = gatt . getService ( UUID_IRT_SERV ). getCharacteristic ( UUID_IRT_CONF );
mBleWrapper . writeDataToCharacteristic ( c , new byte [] { 0x01 });
mState = IRT_ENABLE ; // keep state context for callback
break ;
case IRT_ENABLE:
Log . d ( LOGTAG , "uiSuccessfulWrite: Successfully enabled IR temp sensor" );
// enable next sensor
c = gatt . getService ( UUID_HUM_SERV ). getCharacteristic ( UUID_HUM_CONF );
mBleWrapper . writeDataToCharacteristic ( c , new byte [] { 0x01 });
mState = HUM_ENABLE ; // keep state context for callback
break ;
case HUM_ENABLE:
....
mState = MAG_ENABLE ;
break ;
...
}
}
Search WWH ::




Custom Search