Java 类android.bluetooth.BluetoothGattServer 实例源码

项目:AsteroidOSSync    文件:P_NativeServerWrapper.java   
private void assertThatAllClientsAreDisconnected()
{
    if( m_nativeConnectionStates.size() == 0 )  return;

    for( String macAddress : m_nativeConnectionStates.keySet() )
    {
        final Integer state = m_nativeConnectionStates.get(macAddress);

        if( state != null && state != BluetoothGattServer.STATE_DISCONNECTED )
        {
            m_mngr.ASSERT(false, "Found a server connection state that is not disconnected when it should be.");

            return;
        }
    }
}
项目:SweetBlue    文件:P_NativeServerWrapper.java   
private void assertThatAllClientsAreDisconnected()
{
    if( m_nativeConnectionStates.size() == 0 )  return;

    for( String macAddress : m_nativeConnectionStates.keySet() )
    {
        final Integer state = m_nativeConnectionStates.get(macAddress);

        if( state != null && state != BluetoothGattServer.STATE_DISCONNECTED )
        {
            m_mngr.ASSERT(false, "Found a server connection state that is not disconnected when it should be.");

            return;
        }
    }
}
项目:mesh-core-on-android    文件:JniCallbacks.java   
PeerDevice(BluetoothGattServer server) {
    mConnectionState = STATE_DISCONNECTED;
    mPeerRole = ROLE_CLIENT;
    mGattServer = server;
    mSending = false;
    mSendList = null;
}
项目:AsteroidOSSync    文件:P_NativeServerWrapper.java   
public final int getNativeState(final String macAddress)
{
    if( m_nativeConnectionStates.containsKey(macAddress) )
    {
        return m_nativeConnectionStates.get(macAddress);
    }
    else
    {
        return BluetoothGattServer.STATE_DISCONNECTED;
    }
}
项目:AsteroidOSSync    文件:PA_Task_RequiresServerConnection.java   
@Override protected boolean isExecutable()
{
    boolean shouldBeExecutable = super.isExecutable() && getServer().m_nativeWrapper.getNativeState(m_macAddress) == BluetoothGattServer.STATE_CONNECTED;

    if( shouldBeExecutable )
    {
        return true;
    }

    return false;
}
项目:ble-test-peripheral-android    文件:Peripheral.java   
private void updateConnectedDevicesStatus() {
  final String message = getString(R.string.status_devicesConnected) + " "
      + mBluetoothManager.getConnectedDevices(BluetoothGattServer.GATT).size();
  runOnUiThread(new Runnable() {
    @Override
    public void run() {
      mConnectionStatus.setText(message);
    }
  });
}
项目:ble-test-peripheral-android    文件:Peripheral.java   
private void disconnectFromDevices() {
  Log.d(TAG, "Disconnecting devices...");
  for (BluetoothDevice device : mBluetoothManager.getConnectedDevices(
      BluetoothGattServer.GATT)) {
    Log.d(TAG, "Devices: " + device.getAddress() + " " + device.getName());
    mGattServer.cancelConnection(device);
  }
}
项目:SweetBlue    文件:P_NativeServerWrapper.java   
public final int getNativeState(final String macAddress)
{
    if( m_nativeConnectionStates.containsKey(macAddress) )
    {
        return m_nativeConnectionStates.get(macAddress);
    }
    else
    {
        return BluetoothGattServer.STATE_DISCONNECTED;
    }
}
项目:SweetBlue    文件:PA_Task_RequiresServerConnection.java   
@Override protected boolean isExecutable()
{
    boolean shouldBeExecutable = super.isExecutable() && getServer().m_nativeWrapper.getNativeState(m_macAddress) == BluetoothGattServer.STATE_CONNECTED;

    if( shouldBeExecutable )
    {
        return true;
    }

    return false;
}
项目:BGSEP    文件:HIDoverGattProfile.java   
public boolean addProfileToGATTServer(BluetoothGattServer server) {
    boolean fail = false;
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e2) {
        e2.printStackTrace();
    }
    if (!server.addService(batteryService)) {
        fail = true;
        Log.d(TAG, "fail adding BatteryService");
    } else {
        Log.d(TAG, "added BatteryService");
    }
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }
    if (!server.addService(HIDService)) {
        fail = true;
        Log.d(TAG, "fail adding HIDService");
    } else {
        Log.d(TAG, "added HIDService");
    }
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    if (!server.addService(deviceInfoService)) {
        fail = true;
        Log.d(TAG, "fail adding DeviceInfoService");
    } else {
        Log.d(TAG, "added DeviceInfoService");
    }
    return !fail;
}
项目:mesh-core-on-android    文件:JniCallbacks.java   
public BluetoothGattServer getGattServer() {
        return mGattServer;
}
项目:android-bluetooth-current-time-service    文件:CurrentTimeService.java   
void setGattServer(BluetoothGattServer gattServer) {
    mGattServer = gattServer;
}
项目:AsteroidOSSync    文件:UnitTestServerLayer.java   
@Override
public BluetoothGattServer getNativeServer()
{
    return null;
}
项目:AsteroidOSSync    文件:P_NativeServerWrapper.java   
public final boolean isDisconnecting(final String macAddress)
{
    return getNativeState(macAddress) == BluetoothGattServer.STATE_DISCONNECTING;
}
项目:AsteroidOSSync    文件:P_NativeServerWrapper.java   
public final boolean isDisconnected(final String macAddress)
{
    return getNativeState(macAddress) == BluetoothGattServer.STATE_DISCONNECTED;
}
项目:AsteroidOSSync    文件:P_NativeServerWrapper.java   
public final boolean isConnected(final String macAddress)
{
    return getNativeState(macAddress) == BluetoothGattServer.STATE_CONNECTED;
}
项目:AsteroidOSSync    文件:P_NativeServerWrapper.java   
public final boolean isConnecting(final String macAddress)
{
    return getNativeState(macAddress) == BluetoothGattServer.STATE_CONNECTING;
}
项目:AsteroidOSSync    文件:P_NativeServerWrapper.java   
public final boolean isConnectingOrConnected(final String macAddress)
{
    final int  nativeState = getNativeState(macAddress);

    return nativeState == BluetoothGattServer.STATE_CONNECTING || nativeState == BluetoothGattServer.STATE_CONNECTED;
}
项目:AsteroidOSSync    文件:P_NativeServerWrapper.java   
public final boolean isDisconnectingOrDisconnected(final String macAddress)
{
    final int  nativeState = getNativeState(macAddress);

    return nativeState == BluetoothGattServer.STATE_DISCONNECTING || nativeState == BluetoothGattServer.STATE_DISCONNECTED;
}
项目:AsteroidOSSync    文件:BleServer.java   
/**
 * Provides just-in-case lower-level access to the native server instance.
 * See similar warning for {@link BleDevice#getNative()}.
 */
@Advanced
public final @Nullable(Nullable.Prevalence.RARE) BluetoothGattServer getNative()
{
    return m_nativeWrapper.getNative().getNativeServer();
}
项目:AsteroidOSSync    文件:P_AndroidBleServer.java   
P_AndroidBleServer(BluetoothGattServer server)
{
    m_server = server;
}
项目:AsteroidOSSync    文件:P_AndroidBleServer.java   
@Override
public final BluetoothGattServer getNativeServer()
{
    return m_server;
}
项目:BLE-Mesh    文件:BLEGattServer.java   
public BluetoothGattServer getGattServer() {
    return gattServer;
}
项目:beacons-android    文件:EddystoneGattService.java   
public void readCharacteristic(BluetoothGattServer gattServer, BluetoothDevice device,
                                   int requestId, int offset,
                                   BluetoothGattCharacteristic characteristic) {
//        UUID uuid = characteristic.getUuid();
        int status =  BluetoothGatt.GATT_SUCCESS;

        if (isLocked()) {
            if (characteristic == mUnlockCharacteristic) {
                log("Generating secure unlock challenge");
                characteristic.setValue(new byte[16]);
                new SecureRandom().nextBytes(characteristic.getValue());
            } else {
                if (characteristic != mLockStateCharacteristic) {
                    status = BluetoothGatt.GATT_READ_NOT_PERMITTED;
                }
            }
        }
        else if (characteristic == mUnlockCharacteristic) {
            status = BluetoothGatt.GATT_READ_NOT_PERMITTED;
        } else if (characteristic == mPublicEcdhKeyCharacteristic) {
            log("ECDH Public Key was requested");
            if (0 == offset) {
                characteristic.setValue(null == mEidKeyPair ? new byte[0] : mEidKeyPair.getPublicKey());
            }
        } else if (characteristic == mAdvSlotDataCharacteristic) {
            log("Advertisement slot data requested");
            characteristic.setValue(mConfigCallback.getAdvertisedData());
        } else if (characteristic  == mEidIdentityKeyCharacteristic) {
            log("Identity Key was requested");
            byte[] identityKey = mConfigCallback.getEidIdentityKey();
            if (null == identityKey) {
                status = BluetoothGatt.GATT_FAILURE;
            }
            else {
                characteristic.setValue(aes_transform(true, identityKey, 0, 16));
            }
        }

        gattServer.sendResponse(device, requestId, status, offset,
                status == BluetoothGatt.GATT_SUCCESS ? Arrays.copyOfRange(characteristic.getValue(), offset, characteristic.getValue().length) : null);
    }
项目:swan-sense-studio    文件:BLEManager.java   
public ExecAddService(BluetoothGattServer bleServer, BluetoothGattService service) {
    this.bleServer = bleServer;
    this.service = service;
}
项目:swan-sense-studio    文件:BLEManager.java   
protected BluetoothGattServer getBleServer() {
    return bleServer;
}
项目:swan-sense-studio    文件:BLEClientWorker.java   
public ExecAddService(BluetoothGattServer bleServer, BluetoothGattService service) {
    this.bleServer = bleServer;
    this.service = service;
}
项目:SweetBlue    文件:UnitTestServerLayer.java   
@Override
public BluetoothGattServer getNativeServer()
{
    return null;
}
项目:SweetBlue    文件:P_NativeServerWrapper.java   
public final boolean isDisconnecting(final String macAddress)
{
    return getNativeState(macAddress) == BluetoothGattServer.STATE_DISCONNECTING;
}
项目:SweetBlue    文件:P_NativeServerWrapper.java   
public final boolean isDisconnected(final String macAddress)
{
    return getNativeState(macAddress) == BluetoothGattServer.STATE_DISCONNECTED;
}
项目:SweetBlue    文件:P_NativeServerWrapper.java   
public final boolean isConnected(final String macAddress)
{
    return getNativeState(macAddress) == BluetoothGattServer.STATE_CONNECTED;
}
项目:SweetBlue    文件:P_NativeServerWrapper.java   
public final boolean isConnecting(final String macAddress)
{
    return getNativeState(macAddress) == BluetoothGattServer.STATE_CONNECTING;
}
项目:SweetBlue    文件:P_NativeServerWrapper.java   
public final boolean isConnectingOrConnected(final String macAddress)
{
    final int  nativeState = getNativeState(macAddress);

    return nativeState == BluetoothGattServer.STATE_CONNECTING || nativeState == BluetoothGattServer.STATE_CONNECTED;
}
项目:SweetBlue    文件:P_NativeServerWrapper.java   
public final boolean isDisconnectingOrDisconnected(final String macAddress)
{
    final int  nativeState = getNativeState(macAddress);

    return nativeState == BluetoothGattServer.STATE_DISCONNECTING || nativeState == BluetoothGattServer.STATE_DISCONNECTED;
}
项目:SweetBlue    文件:BleServer.java   
/**
 * Provides just-in-case lower-level access to the native server instance.
 * See similar warning for {@link BleDevice#getNative()}.
 */
@Advanced
public final @Nullable(Nullable.Prevalence.RARE) BluetoothGattServer getNative()
{
    return m_nativeWrapper.getNative().getNativeServer();
}
项目:SweetBlue    文件:P_AndroidBleServer.java   
P_AndroidBleServer(BluetoothGattServer server)
{
    m_server = server;
}
项目:SweetBlue    文件:P_AndroidBleServer.java   
@Override
public final BluetoothGattServer getNativeServer()
{
    return m_server;
}
项目:Bluebit    文件:AospGattServer.java   
public AospGattServer(BluetoothGattServer srv) {
    mGattSrv = srv;
}
项目:BLEServerSimple    文件:AdvertiseAdaptor.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private BluetoothGattServer getGattServer(Context context, BluetoothManager manager) {
    return manager.openGattServer(context, mBLEServerAdaptor);
}
项目:AsteroidOSSync    文件:P_NativeServerLayer.java   
BluetoothGattServer getNativeServer();