本文整理汇总了Java中com.samsung.android.sdk.bt.gatt.BluetoothGatt.GATT_SUCCESS属性的典型用法代码示例。如果您正苦于以下问题:Java BluetoothGatt.GATT_SUCCESS属性的具体用法?Java BluetoothGatt.GATT_SUCCESS怎么用?Java BluetoothGatt.GATT_SUCCESS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.samsung.android.sdk.bt.gatt.BluetoothGatt
的用法示例。
在下文中一共展示了BluetoothGatt.GATT_SUCCESS属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onConnectionStateChange
@Override
public void onConnectionStateChange(BluetoothDevice device, int status,
int newState) {
if (mBluetoothGatt == null) {
return;
}
if (status != BluetoothGatt.GATT_SUCCESS) {
disconnect(device.getAddress());
mService.bleGattDisConnected(device.getAddress());
return;
}
if (newState == BluetoothProfile.STATE_CONNECTED) {
mService.bleGattConnected(device);
mService.addBleRequest(new BleRequest(
RequestType.DISCOVER_SERVICE, device.getAddress()));
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
mService.bleGattDisConnected(device.getAddress());
disconnect(device.getAddress());
}
}
示例2: onCharacteristicRead
@Override
public void onCharacteristicRead(BluetoothGattCharacteristic characteristic, int status) {
Log.i(TAG, "onCharacteristicRead");
super.onCharacteristicRead(characteristic, status);
String deviceID = getDeviceID(characteristic.getService());
CallbackContext callbackContext = null;
if (mapReadValueCallBack != null) {
callbackContext = mapReadValueCallBack.get(characteristic);
}
if (callbackContext != null) {
if (status == BluetoothGatt.GATT_SUCCESS) {
JSONObject jsonObject = new JSONObject();
Tools.addProperty(jsonObject, Tools.DEVICE_ID, deviceID);
Tools.addProperty(jsonObject, Tools.VALUE, Tools.encodeBase64(characteristic.getValue()));
Tools.addProperty(jsonObject, Tools.DATE, Tools.getDateString());
callbackContext.success(jsonObject);
} else {
Tools.sendErrorMsg(callbackContext);
}
mapReadValueCallBack.remove(deviceID);
}
}
示例3: onReadRemoteRssi
@Override
public void onReadRemoteRssi(BluetoothDevice device, int rssi, int status) {
super.onReadRemoteRssi(device, rssi, status);
Log.i(TAG, "onReadRemoteRssi");
String deviceID = device.getAddress();
CallbackContext callbackContext = null;
if (mapGetRSSICallBack != null) {
callbackContext = mapGetRSSICallBack.get(deviceID);
}
if (callbackContext != null) {
if (status == BluetoothGatt.GATT_SUCCESS) {
JSONObject jsonObject = new JSONObject();
Tools.addProperty(jsonObject, Tools.DEVICE_ID, deviceID);
Tools.addProperty(jsonObject, Tools.RSSI, Integer.toString(rssi));
callbackContext.success(jsonObject);
} else {
Tools.sendErrorMsg(callbackContext);
}
mapGetRSSICallBack.remove(deviceID);
}
}
示例4: onDescriptorRead
@Override
public void onDescriptorRead(BluetoothGattDescriptor descriptor, int status) {
super.onDescriptorRead(descriptor, status);
Log.i(TAG, "onDescriptorRead");
String deviceID = getDeviceID(descriptor.getCharacteristic().getService());
CallbackContext callbackContext = mapReadValueCallBack.get(deviceID);
if (callbackContext != null) {
if (status == BluetoothGatt.GATT_SUCCESS) {
JSONObject jsonObject = new JSONObject();
Tools.addProperty(jsonObject, Tools.DEVICE_ID, deviceID);
Tools.addProperty(jsonObject, Tools.VALUE, Tools.encodeBase64(descriptor.getValue()));
Tools.addProperty(jsonObject, Tools.DATE, Tools.getDateString());
callbackContext.success(jsonObject);
} else {
Tools.sendErrorMsg(callbackContext);
}
mapReadValueCallBack.remove(deviceID);
}
}
示例5: onDescriptorWrite
@Override
public void onDescriptorWrite(BluetoothGattDescriptor descriptor, int status) {
super.onDescriptorWrite(descriptor, status);
Log.i(TAG, "onDescriptorWrite");
String deviceID = getDeviceID(descriptor.getCharacteristic().getService());
CallbackContext writeValueCallbackContext = null;
if (mapWriteValueCallBack != null) {
writeValueCallbackContext = mapWriteValueCallBack.get(descriptor);
}
if (writeValueCallbackContext != null) {
if (status == BluetoothGatt.GATT_SUCCESS) {
Tools.sendSuccessMsg(writeValueCallbackContext);
} else {
Tools.sendErrorMsg(writeValueCallbackContext);
}
mapWriteValueCallBack.remove(deviceID);
}
}
示例6: resultCodeToString
private String resultCodeToString(int paramInt) {
switch (paramInt) {
case BluetoothGatt.GATT_SUCCESS:
return "SUCCESS";
case BluetoothGatt.GATT_INVALID_ATTRIBUTE_LENGTH:
return "GATT_INVALID_ATTRIBUTE_LENGTH";
case BluetoothGatt.GATT_WRITE_NOT_PERMITTED:
return "GATT_WRITE_NOT_PERMITTED";
case BluetoothGatt.GATT_ALREADY_OPEN:
return "GATT_ALREADY_OPEN";
case BluetoothGatt.GATT_ERROR:
return "GATT_ERROR";
case BluetoothGatt.GATT_INVALID_OFFSET:
return "GATT_INVALID_OFFSET";
case BluetoothGatt.GATT_INTERNAL_ERROR:
return "GATT_INTERNAL_ERROR";
default:
return "UNKNOWN";
}
}
示例7: onServicesDiscovered
@Override
public void onServicesDiscovered(BluetoothDevice device, int status) {
String address = device.getAddress();
if (status != BluetoothGatt.GATT_SUCCESS) {
disconnect(address);
mService.bleGattDisConnected(address);
mService.requestProcessed(address,
RequestType.DISCOVER_SERVICE, false);
return;
}
mService.bleServiceDiscovered(device.getAddress());
}
示例8: onCharacteristicRead
@Override
public void onCharacteristicRead(
BluetoothGattCharacteristic characteristic, int status) {
BleRequest request = mService.getCurrentRequest();
String address = request.address;
if (status != BluetoothGatt.GATT_SUCCESS) {
mService.requestProcessed(address,
RequestType.READ_CHARACTERISTIC, false);
return;
}
mService.bleCharacteristicRead(address, characteristic.getUuid()
.toString(), status, characteristic.getValue());
}
示例9: onCharacteristicWrite
@Override
public void onCharacteristicWrite(
BluetoothGattCharacteristic characteristic, int status) {
BleRequest request = mService.getCurrentRequest();
String address = request.address;
if (status != BluetoothGatt.GATT_SUCCESS) {
mService.requestProcessed(address,
RequestType.WRITE_CHARACTERISTIC, false);
return;
}
mService.bleCharacteristicWrite(address, characteristic.getUuid()
.toString(), status);
}
示例10: onDescriptorWrite
@Override
public void onDescriptorWrite(BluetoothGattDescriptor descriptor,
int status) {
BleRequest request = mService.getCurrentRequest();
String address = request.address;
if (request.type == RequestType.CHARACTERISTIC_NOTIFICATION
|| request.type == RequestType.CHARACTERISTIC_INDICATION
|| request.type == RequestType.CHARACTERISTIC_STOP_NOTIFICATION) {
if (status != BluetoothGatt.GATT_SUCCESS) {
mService.requestProcessed(address, request.type, false);
return;
}
if (request.type == RequestType.CHARACTERISTIC_NOTIFICATION) {
mService.bleCharacteristicNotification(address, descriptor
.getCharacteristic().getUuid().toString(), true,
status);
} else if (request.type == RequestType.CHARACTERISTIC_INDICATION) {
mService.bleCharacteristicIndication(address, descriptor
.getCharacteristic().getUuid().toString(), status);
} else {
mService.bleCharacteristicNotification(address, descriptor
.getCharacteristic().getUuid().toString(), false,
status);
}
return;
}
}
示例11: onCharacteristicWrite
@Override
public void onCharacteristicWrite(BluetoothGattCharacteristic characteristic, int status) {
super.onCharacteristicWrite(characteristic, status);
Log.i(TAG, "onCharacteristicWrite");
String deviceID = getDeviceID(characteristic.getService());
CallbackContext callbackContext = mapWriteValueCallBack.get(characteristic);
if (callbackContext != null) {
if (status == BluetoothGatt.GATT_SUCCESS) {
Tools.sendSuccessMsg(callbackContext);
} else {
Tools.sendErrorMsg(callbackContext);
}
mapWriteValueCallBack.remove(deviceID);
}
}
示例12: onServiceAdded
@Override
public void onServiceAdded(int status, BluetoothGattService bluetoothGattService) {
super.onServiceAdded(status, bluetoothGattService);
Log.i(TAG, "onServiceAdded");
if (status == BluetoothGatt.GATT_SUCCESS) {
addedServiceNumber++;
if (addedServiceNumber == serviceNumber) {
if (addServiceCallBack != null) {
Tools.sendSuccessMsg(addServiceCallBack);
}
addedServiceNumber = 0;
}
}
}
示例13: onConnectionStateChange
@Override
public void onConnectionStateChange(BluetoothDevice device, int status, int newState) {
super.onConnectionStateChange(device, status, newState);
Log.i(TAG, "onConnectionStateChange");
String deviceID = device.getAddress();
CallbackContext connectCallbackContext = null;
CallbackContext disConnectCallbackContext = null;
JSONObject jsonObject = new JSONObject();
if (mapConnectCallBack != null) {
connectCallbackContext = mapConnectCallBack.get(deviceID);
}
if (mapDisconnectCallBack != null) {
disConnectCallbackContext = mapDisconnectCallBack.get(deviceID);
}
if (disConnectCallbackContext == null && mapAddListenerCallBack != null) {
disConnectCallbackContext = mapAddListenerCallBack.get(Tools.DISCONNECT);
}
if (connectCallbackContext != null) {
if (status == BluetoothGatt.GATT_SUCCESS && newState == BluetoothProfile.STATE_CONNECTED) {
Tools.addProperty(jsonObject, Tools.DEVICE_ID, deviceID);
Tools.addProperty(jsonObject, Tools.MES, Tools.SUCCESS);
connectCallbackContext.success(jsonObject);
} else {
Tools.sendErrorMsg(connectCallbackContext);
}
mapConnectCallBack.remove(deviceID);
return;
}
if (disConnectCallbackContext != null) {
Log.i(TAG, "device: "+deviceID+" disconnect!");
if (newState == BluetoothProfile.STATE_DISCONNECTED && status == BluetoothGatt.GATT_SUCCESS) {
Tools.addProperty(jsonObject, Tools.DEVICE_ID, deviceID);
Tools.addProperty(jsonObject, Tools.MES, Tools.SUCCESS);
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, jsonObject);
pluginResult.setKeepCallback(true);
disConnectCallbackContext.sendPluginResult(pluginResult);
} else {
Tools.sendErrorMsg(disConnectCallbackContext);
}
mapDisconnectCallBack.remove(deviceID);
}
}