当前位置: 首页>>代码示例>>Java>>正文


Java BluetoothGatt.GATT_SUCCESS属性代码示例

本文整理汇总了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());
	}
}
 
开发者ID:xpg,项目名称:GizwitsBLE,代码行数:22,代码来源:SamsungBle.java

示例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);
    }
}
 
开发者ID:hfeeki,项目名称:bluetooth,代码行数:22,代码来源:BluetoothSam42.java

示例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);
    }
}
 
开发者ID:hfeeki,项目名称:bluetooth,代码行数:21,代码来源:BluetoothSam42.java

示例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);
    }
}
 
开发者ID:hfeeki,项目名称:bluetooth,代码行数:19,代码来源:BluetoothSam42.java

示例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);
    }
    
}
 
开发者ID:hfeeki,项目名称:bluetooth,代码行数:19,代码来源:BluetoothSam42.java

示例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";
	}
}
 
开发者ID:TheGenuine,项目名称:BeaconScanner,代码行数:20,代码来源:HRPService.java

示例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());
}
 
开发者ID:xpg,项目名称:GizwitsBLE,代码行数:12,代码来源:SamsungBle.java

示例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());
}
 
开发者ID:xpg,项目名称:GizwitsBLE,代码行数:13,代码来源:SamsungBle.java

示例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);
}
 
开发者ID:xpg,项目名称:GizwitsBLE,代码行数:13,代码来源:SamsungBle.java

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

}
 
开发者ID:xpg,项目名称:GizwitsBLE,代码行数:29,代码来源:SamsungBle.java

示例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);
    }
}
 
开发者ID:hfeeki,项目名称:bluetooth,代码行数:15,代码来源:BluetoothSam42.java

示例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;
        }
    }
}
 
开发者ID:hfeeki,项目名称:bluetooth,代码行数:14,代码来源:BluetoothSam42.java

示例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);
    }
}
 
开发者ID:hfeeki,项目名称:bluetooth,代码行数:42,代码来源:BluetoothSam42.java


注:本文中的com.samsung.android.sdk.bt.gatt.BluetoothGatt.GATT_SUCCESS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。