Java源码示例:com.eveningoutpost.dexdrip.UtilityModels.DexShareAttributes

示例1
public void assignCharacteristics() {
    if(!share2) {
        Log.d(TAG, "Setting #1 characteristics");
        mSendDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageReceiver);
        mReceiveDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageResponse);
        mCommandCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Command);
        mResponseCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Response);
        mHeartBeatCharacteristic = mShareService.getCharacteristic(DexShareAttributes.HeartBeat);
    } else {
        Log.d(TAG, "Setting #1 characteristics");
        mSendDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageReceiver2);
        mReceiveDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageResponse2);
        mCommandCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Command2);
        mResponseCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Response2);
        mHeartBeatCharacteristic = mShareService.getCharacteristic(DexShareAttributes.HeartBeat2);
    }
}
 
示例2
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
    Log.d(TAG, "services discovered " + status);
   if (status == BluetoothGatt.GATT_SUCCESS && mBluetoothGatt != null) {
       mShareService = mBluetoothGatt.getService(DexShareAttributes.CradleService);
       if(mShareService == null) {
           mShareService = mBluetoothGatt.getService(DexShareAttributes.CradleService2);
           share2 = true;
       } else {
           share2 = false;
       }
        assignCharacteristics();
        authenticateConnection();
        gattSetupStep();
    } else {
        Log.w(TAG, "No Services Discovered!");
    }
}
 
示例3
public void assignCharacteristics() {
    if(!share2) {
        Log.d(TAG, "Setting #1 characteristics");
        mSendDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageReceiver);
        mReceiveDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageResponse);
        mCommandCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Command);
        mResponseCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Response);
        mHeartBeatCharacteristic = mShareService.getCharacteristic(DexShareAttributes.HeartBeat);
    } else {
        Log.d(TAG, "Setting #1 characteristics");
        mSendDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageReceiver2);
        mReceiveDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageResponse2);
        mCommandCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Command2);
        mResponseCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Response2);
        mHeartBeatCharacteristic = mShareService.getCharacteristic(DexShareAttributes.HeartBeat2);
    }
}
 
示例4
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
    Log.d(TAG, "services discovered " + status);
   if (status == BluetoothGatt.GATT_SUCCESS && mBluetoothGatt != null) {
       mShareService = mBluetoothGatt.getService(DexShareAttributes.CradleService);
       if(mShareService == null) {
           mShareService = mBluetoothGatt.getService(DexShareAttributes.CradleService2);
           share2 = true;
       } else {
           share2 = false;
       }
        assignCharacteristics();
        authenticateConnection();
        gattSetupStep();
    } else {
        Log.w(TAG, "No Services Discovered!");
    }
}
 
示例5
public void authenticateConnection(BluetoothGatt bluetoothGatt) {
    Log.i(TAG, "Trying to auth");
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    String receiverSn = prefs.getString("share_key", "SM00000000").toUpperCase();
    if(bluetoothGatt != null) {
        mBluetoothGatt = bluetoothGatt;
        mShareService = mBluetoothGatt.getService(DexShareAttributes.CradleService);
        if (mShareService != null) {
            mAuthenticationCharacteristic = mShareService.getCharacteristic(DexShareAttributes.AuthenticationCode);
            if(mAuthenticationCharacteristic != null) {
                Log.i(TAG, "Auth Characteristic found: " + mAuthenticationCharacteristic.toString());
                mAuthenticationCharacteristic.setValue((receiverSn + "000000").getBytes(StandardCharsets.US_ASCII));
                currentGattTask = GATT_SETUP;
                step = 1;
                bluetoothGatt.writeCharacteristic(mAuthenticationCharacteristic);
            } else {
                Log.w(TAG, "Authentication Characteristic IS NULL");
            }
        } else {
            Log.w(TAG, "CRADLE SERVICE IS NULL");
        }
    }
}
 
示例6
public void assignCharacteristics() {
    if(!share2) {
        Log.d(TAG, "Setting #1 characteristics");
        mSendDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageReceiver);
        mReceiveDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageResponse);
        mCommandCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Command);
        mResponseCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Response);
        mHeartBeatCharacteristic = mShareService.getCharacteristic(DexShareAttributes.HeartBeat);
    } else {
        Log.d(TAG, "Setting #1 characteristics");
        mSendDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageReceiver2);
        mReceiveDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageResponse2);
        mCommandCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Command2);
        mResponseCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Response2);
        mHeartBeatCharacteristic = mShareService.getCharacteristic(DexShareAttributes.HeartBeat2);
    }
}
 
示例7
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
    Log.d(TAG, "services discovered " + status);
   if (status == BluetoothGatt.GATT_SUCCESS && mBluetoothGatt != null) {
       mShareService = mBluetoothGatt.getService(DexShareAttributes.CradleService);
       if(mShareService == null) {
           mShareService = mBluetoothGatt.getService(DexShareAttributes.CradleService2);
           share2 = true;
       } else {
           share2 = false;
       }
        assignCharacteristics();
        authenticateConnection();
        gattSetupStep();
    } else {
        Log.w(TAG, "No Services Discovered!");
    }
}
 
示例8
public void assignCharacteristics() {
    if(!share2) {
        Log.d(TAG, "Setting #1 characteristics");
        mSendDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageReceiver);
        mReceiveDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageResponse);
        mCommandCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Command);
        mResponseCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Response);
        mHeartBeatCharacteristic = mShareService.getCharacteristic(DexShareAttributes.HeartBeat);
    } else {
        Log.d(TAG, "Setting #1 characteristics");
        mSendDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageReceiver2);
        mReceiveDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageResponse2);
        mCommandCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Command2);
        mResponseCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Response2);
        mHeartBeatCharacteristic = mShareService.getCharacteristic(DexShareAttributes.HeartBeat2);
    }
}
 
示例9
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
    Log.d(TAG, "services discovered " + status);
   if (status == BluetoothGatt.GATT_SUCCESS && mBluetoothGatt != null) {
       mShareService = mBluetoothGatt.getService(DexShareAttributes.CradleService);
       if(mShareService == null) {
           mShareService = mBluetoothGatt.getService(DexShareAttributes.CradleService2);
           share2 = true;
       } else {
           share2 = false;
       }
        assignCharacteristics();
        authenticateConnection();
        gattSetupStep();
    } else {
        Log.w(TAG, "No Services Discovered!");
    }
}
 
示例10
public void authenticateConnection(BluetoothGatt bluetoothGatt) {
    Log.i(TAG, "Trying to auth");
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    String receiverSn = prefs.getString("share_key", "SM00000000").toUpperCase();
    if(bluetoothGatt != null) {
        mBluetoothGatt = bluetoothGatt;
        mShareService = mBluetoothGatt.getService(DexShareAttributes.CradleService);
        if (mShareService != null) {
            mAuthenticationCharacteristic = mShareService.getCharacteristic(DexShareAttributes.AuthenticationCode);
            if(mAuthenticationCharacteristic != null) {
                Log.i(TAG, "Auth Characteristic found: " + mAuthenticationCharacteristic.toString());
                mAuthenticationCharacteristic.setValue((receiverSn + "000000").getBytes(StandardCharsets.US_ASCII));
                currentGattTask = GATT_SETUP;
                step = 1;
                bluetoothGatt.writeCharacteristic(mAuthenticationCharacteristic);
            } else {
                Log.w(TAG, "Authentication Characteristic IS NULL");
            }
        } else {
            Log.w(TAG, "CRADLE SERVICE IS NULL");
        }
    }
}
 
示例11
public void assignCharacteristics() {
    if(!share2) {
        Log.d(TAG, "Setting #1 characteristics");
        mSendDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageReceiver);
        mReceiveDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageResponse);
        mCommandCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Command);
        mResponseCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Response);
        mHeartBeatCharacteristic = mShareService.getCharacteristic(DexShareAttributes.HeartBeat);
    } else {
        Log.d(TAG, "Setting #1 characteristics");
        mSendDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageReceiver2);
        mReceiveDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageResponse2);
        mCommandCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Command2);
        mResponseCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Response2);
        mHeartBeatCharacteristic = mShareService.getCharacteristic(DexShareAttributes.HeartBeat2);
    }
}
 
示例12
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
    Log.d(TAG, "services discovered " + status);
   if (status == BluetoothGatt.GATT_SUCCESS && mBluetoothGatt != null) {
       mShareService = mBluetoothGatt.getService(DexShareAttributes.CradleService);
       if(mShareService == null) {
           mShareService = mBluetoothGatt.getService(DexShareAttributes.CradleService2);
           share2 = true;
       } else {
           share2 = false;
       }
        assignCharacteristics();
        authenticateConnection();
        gattSetupStep();
    } else {
        Log.w(TAG, "No Services Discovered!");
    }
}
 
示例13
public void authenticateConnection(BluetoothGatt bluetoothGatt) {
    Log.i(TAG, "Trying to auth");
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    String receiverSn = prefs.getString("share_key", "SM00000000").toUpperCase();
    if(bluetoothGatt != null) {
        mBluetoothGatt = bluetoothGatt;
        mShareService = mBluetoothGatt.getService(DexShareAttributes.CradleService);
        if (mShareService != null) {
            mAuthenticationCharacteristic = mShareService.getCharacteristic(DexShareAttributes.AuthenticationCode);
            if(mAuthenticationCharacteristic != null) {
                Log.i(TAG, "Auth Characteristic found: " + mAuthenticationCharacteristic.toString());
                mAuthenticationCharacteristic.setValue((receiverSn + "000000").getBytes(StandardCharsets.US_ASCII));
                currentGattTask = GATT_SETUP;
                step = 1;
                bluetoothGatt.writeCharacteristic(mAuthenticationCharacteristic);
            } else {
                Log.w(TAG, "Authentication Characteristic IS NULL");
            }
        } else {
            Log.w(TAG, "CRADLE SERVICE IS NULL");
        }
    }
}
 
示例14
public void assignCharacteristics() {
    if(!share2) {
        Log.d(TAG, "Setting #1 characteristics");
        mSendDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageReceiver);
        mReceiveDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageResponse);
        mCommandCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Command);
        mResponseCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Response);
        mHeartBeatCharacteristic = mShareService.getCharacteristic(DexShareAttributes.HeartBeat);
    } else {
        Log.d(TAG, "Setting #1 characteristics");
        mSendDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageReceiver2);
        mReceiveDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageResponse2);
        mCommandCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Command2);
        mResponseCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Response2);
        mHeartBeatCharacteristic = mShareService.getCharacteristic(DexShareAttributes.HeartBeat2);
    }
}
 
示例15
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
    Log.d(TAG, "services discovered " + status);
   if (status == BluetoothGatt.GATT_SUCCESS) {
       mShareService = mBluetoothGatt.getService(DexShareAttributes.CradleService);
       if(mShareService == null) {
           mShareService = mBluetoothGatt.getService(DexShareAttributes.CradleService2);
           share2 = true;
       } else {
           share2 = false;
       }
        assignCharacteristics();
        authenticateConnection();
        gattSetupStep();
    } else {
        Log.w(TAG, "No Services Discovered!");
    }
}
 
示例16
public void authenticateConnection(BluetoothGatt bluetoothGatt) {
    Log.w(TAG, "Trying to auth");
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    String receiverSn = prefs.getString("share_key", "SM00000000").toUpperCase();
    if(bluetoothGatt != null) {
        mBluetoothGatt = bluetoothGatt;
        mShareService = mBluetoothGatt.getService(DexShareAttributes.CradleService);
        if (mShareService != null) {
            mAuthenticationCharacteristic = mShareService.getCharacteristic(DexShareAttributes.AuthenticationCode);
            if(mAuthenticationCharacteristic != null) {
                Log.w(TAG, "Auth Characteristic found: " + mAuthenticationCharacteristic.toString());
                mAuthenticationCharacteristic.setValue((receiverSn + "000000").getBytes(StandardCharsets.US_ASCII));
                currentGattTask = GATT_SETUP;
                step = 1;
                bluetoothGatt.writeCharacteristic(mAuthenticationCharacteristic);
            } else {
                Log.w(TAG, "Authentication Characteristic IS NULL");
            }
        } else {
            Log.w(TAG, "CRADLE SERVICE IS NULL");
        }
    }
}
 
示例17
public void authenticateConnection() {
    Log.i(TAG, "Trying to auth");
    String receiverSn = prefs.getString("share_key", "SM00000000").toUpperCase() + "000000";
    if(receiverSn.compareTo("SM00000000000000") == 0) { // They havnt set their serial number, dont bond!
        setRetryTimer();
        return;
    }
    byte[] bondkey = (receiverSn).getBytes(StandardCharsets.US_ASCII);
    if (mBluetoothGatt != null) {
        if (mShareService != null) {
            if(!share2) {
                mAuthenticationCharacteristic = mShareService.getCharacteristic(DexShareAttributes.AuthenticationCode);
            } else {
                mAuthenticationCharacteristic = mShareService.getCharacteristic(DexShareAttributes.AuthenticationCode2);
            }
            if (mAuthenticationCharacteristic != null) {
                Log.v(TAG, "Auth Characteristic found: " + mAuthenticationCharacteristic.toString());
                if (mAuthenticationCharacteristic.setValue(bondkey)) {
                    mBluetoothGatt.writeCharacteristic(mAuthenticationCharacteristic);
                } else {
                    setRetryTimer();
                }
            } else {
                Log.w(TAG, "Authentication Characteristic IS NULL");
                setRetryTimer();
            }
        } else {
            Log.w(TAG, "CRADLE SERVICE IS NULL");
        }
    } else {
        setRetryTimer();
    }
}
 
示例18
public void authenticateConnection() {
    Log.i(TAG, "Trying to auth");
    String receiverSn = prefs.getString("share_key", "SM00000000").toUpperCase() + "000000";
    if(receiverSn.compareTo("SM00000000000000") == 0) { // They havnt set their serial number, dont bond!
        setRetryTimer();
        return;
    }
    byte[] bondkey = (receiverSn).getBytes(StandardCharsets.US_ASCII);
    if (mBluetoothGatt != null) {
        if (mShareService != null) {
            if(!share2) {
                mAuthenticationCharacteristic = mShareService.getCharacteristic(DexShareAttributes.AuthenticationCode);
            } else {
                mAuthenticationCharacteristic = mShareService.getCharacteristic(DexShareAttributes.AuthenticationCode2);
            }
            if (mAuthenticationCharacteristic != null) {
                Log.v(TAG, "Auth Characteristic found: " + mAuthenticationCharacteristic.toString());
                if (mAuthenticationCharacteristic.setValue(bondkey)) {
                    mBluetoothGatt.writeCharacteristic(mAuthenticationCharacteristic);
                } else {
                    setRetryTimer();
                }
            } else {
                Log.w(TAG, "Authentication Characteristic IS NULL");
                setRetryTimer();
            }
        } else {
            Log.w(TAG, "CRADLE SERVICE IS NULL");
        }
    } else {
        setRetryTimer();
    }
}
 
示例19
public void assignCharacteristics() {
    mSendDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageReceiver);
    mReceiveDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageResponse);
    mHeartBeatCharacteristic = mShareService.getCharacteristic(DexShareAttributes.HeartBeat);
    mCommandCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Command);
    mResponseCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Response);
}
 
示例20
public void authenticateConnection() {
    Log.i(TAG, "Trying to auth");
    String receiverSn = prefs.getString("share_key", "SM00000000").toUpperCase() + "000000";
    if(receiverSn.compareTo("SM00000000000000") == 0) { // They havnt set their serial number, dont bond!
        setRetryTimer();
        return;
    }
    byte[] bondkey = (receiverSn).getBytes(StandardCharsets.US_ASCII);
    if (mBluetoothGatt != null) {
        if (mShareService != null) {
            if(!share2) {
                mAuthenticationCharacteristic = mShareService.getCharacteristic(DexShareAttributes.AuthenticationCode);
            } else {
                mAuthenticationCharacteristic = mShareService.getCharacteristic(DexShareAttributes.AuthenticationCode2);
            }
            if (mAuthenticationCharacteristic != null) {
                Log.v(TAG, "Auth Characteristic found: " + mAuthenticationCharacteristic.toString());
                if (mAuthenticationCharacteristic.setValue(bondkey)) {
                    mBluetoothGatt.writeCharacteristic(mAuthenticationCharacteristic);
                } else {
                    setRetryTimer();
                }
            } else {
                Log.w(TAG, "Authentication Characteristic IS NULL");
                setRetryTimer();
            }
        } else {
            Log.w(TAG, "CRADLE SERVICE IS NULL");
        }
    } else {
        setRetryTimer();
    }
}
 
示例21
public void authenticateConnection() {
    Log.i(TAG, "Trying to auth");
    String receiverSn = prefs.getString("share_key", "SM00000000").toUpperCase() + "000000";
    if(receiverSn.compareTo("SM00000000000000") == 0) { // They havnt set their serial number, dont bond!
        setRetryTimer();
        return;
    }
    byte[] bondkey = (receiverSn).getBytes(StandardCharsets.US_ASCII);
    if (mBluetoothGatt != null) {
        if (mShareService != null) {
            if(!share2) {
                mAuthenticationCharacteristic = mShareService.getCharacteristic(DexShareAttributes.AuthenticationCode);
            } else {
                mAuthenticationCharacteristic = mShareService.getCharacteristic(DexShareAttributes.AuthenticationCode2);
            }
            if (mAuthenticationCharacteristic != null) {
                Log.v(TAG, "Auth Characteristic found: " + mAuthenticationCharacteristic.toString());
                if (mAuthenticationCharacteristic.setValue(bondkey)) {
                    mBluetoothGatt.writeCharacteristic(mAuthenticationCharacteristic);
                } else {
                    setRetryTimer();
                }
            } else {
                Log.w(TAG, "Authentication Characteristic IS NULL");
                setRetryTimer();
            }
        } else {
            Log.w(TAG, "CRADLE SERVICE IS NULL");
        }
    } else {
        setRetryTimer();
    }
}
 
示例22
public void assignCharacteristics() {
    mSendDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageReceiver);
    mReceiveDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageResponse);
    mHeartBeatCharacteristic = mShareService.getCharacteristic(DexShareAttributes.HeartBeat);
    mCommandCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Command);
    mResponseCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Response);
}
 
示例23
public void authenticateConnection() {
    Log.i(TAG, "Trying to auth");
    String receiverSn = prefs.getString("share_key", "SM00000000").toUpperCase() + "000000";
    if(receiverSn.compareTo("SM00000000000000") == 0) { // They havnt set their serial number, dont bond!
        setRetryTimer();
        return;
    }
    byte[] bondkey = (receiverSn).getBytes(StandardCharsets.US_ASCII);
    if (mBluetoothGatt != null) {
        if (mShareService != null) {
            if(!share2) {
                mAuthenticationCharacteristic = mShareService.getCharacteristic(DexShareAttributes.AuthenticationCode);
            } else {
                mAuthenticationCharacteristic = mShareService.getCharacteristic(DexShareAttributes.AuthenticationCode2);
            }
            if (mAuthenticationCharacteristic != null) {
                Log.v(TAG, "Auth Characteristic found: " + mAuthenticationCharacteristic.toString());
                if (mAuthenticationCharacteristic.setValue(bondkey)) {
                    mBluetoothGatt.writeCharacteristic(mAuthenticationCharacteristic);
                } else {
                    setRetryTimer();
                }
            } else {
                Log.w(TAG, "Authentication Characteristic IS NULL");
                setRetryTimer();
            }
        } else {
            Log.w(TAG, "CRADLE SERVICE IS NULL");
        }
    } else {
        setRetryTimer();
    }
}
 
示例24
public void assignCharacteristics() {
    mSendDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageReceiver);
    mReceiveDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageResponse);
    mHeartBeatCharacteristic = mShareService.getCharacteristic(DexShareAttributes.HeartBeat);
    mCommandCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Command);
    mResponseCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Response);
}
 
示例25
public void authenticateConnection() {
    Log.w(TAG, "Trying to auth");
    String receiverSn = prefs.getString("share_key", "SM00000000").toUpperCase() + "000000";
    if(receiverSn.compareTo("SM00000000000000") == 0) { // They havnt set their serial number, dont bond!
        setRetryTimer();
        return;
    }
    byte[] bondkey = (receiverSn).getBytes(StandardCharsets.US_ASCII);
    if (mBluetoothGatt != null) {
        if (mShareService != null) {
            if(!share2) {
                mAuthenticationCharacteristic = mShareService.getCharacteristic(DexShareAttributes.AuthenticationCode);
            } else {
                mAuthenticationCharacteristic = mShareService.getCharacteristic(DexShareAttributes.AuthenticationCode2);
            }
            if (mAuthenticationCharacteristic != null) {
                Log.v(TAG, "Auth Characteristic found: " + mAuthenticationCharacteristic.toString());
                if (mAuthenticationCharacteristic.setValue(bondkey)) {
                    mBluetoothGatt.writeCharacteristic(mAuthenticationCharacteristic);
                } else {
                    setRetryTimer();
                }
            } else {
                Log.w(TAG, "Authentication Characteristic IS NULL");
                setRetryTimer();
            }
        } else {
            Log.w(TAG, "CRADLE SERVICE IS NULL");
        }
    } else {
        setRetryTimer();
    }
}
 
示例26
public void assignCharacteristics() {
    mSendDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageReceiver);
    mReceiveDataCharacteristic = mShareService.getCharacteristic(DexShareAttributes.ShareMessageResponse);
    mHeartBeatCharacteristic = mShareService.getCharacteristic(DexShareAttributes.HeartBeat);
    mCommandCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Command);
    mResponseCharacteristic = mShareService.getCharacteristic(DexShareAttributes.Response);
}