本文整理汇总了Java中com.eveningoutpost.dexdrip.G5Model.Extensions类的典型用法代码示例。如果您正苦于以下问题:Java Extensions类的具体用法?Java Extensions怎么用?Java Extensions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Extensions类属于com.eveningoutpost.dexdrip.G5Model包,在下文中一共展示了Extensions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupLeScanCallback
import com.eveningoutpost.dexdrip.G5Model.Extensions; //导入依赖的package包/类
private void setupLeScanCallback() {
if (mLeScanCallback == null) {
mLeScanCallback = new BluetoothAdapter.LeScanCallback() {
@Override
public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) {
// Check if the device has a name, the Dexcom transmitter always should. Match it with the transmitter id that was entered.
// We get the last 2 characters to connect to the correct transmitter if there is more than 1 active or in the room.
// If they match, connect to the device.
if (device.getName() != null) {
String transmitterIdLastTwo = Extensions.lastTwoCharactersOfString(defaultTransmitter.transmitterId);
String deviceNameLastTwo = Extensions.lastTwoCharactersOfString(device.getName());
if (transmitterIdLastTwo.toUpperCase().equals(deviceNameLastTwo.toUpperCase())) {
connectToDevice(device);
}
}
}
};
}
}
示例2: getTransmitterDetails
import com.eveningoutpost.dexdrip.G5Model.Extensions; //导入依赖的package包/类
private void getTransmitterDetails() {
prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
Log.d(TAG, "Transmitter: " + prefs.getString("dex_txid", "ABCDEF"));
defaultTransmitter = new Transmitter(prefs.getString("dex_txid", "ABCDEF"));
isBondedOrBonding = false;
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
if (pairedDevices.size() > 0) {
for (BluetoothDevice device : pairedDevices) {
if (device.getName() != null) {
String transmitterIdLastTwo = Extensions.lastTwoCharactersOfString(defaultTransmitter.transmitterId);
String deviceNameLastTwo = Extensions.lastTwoCharactersOfString(device.getName());
if (transmitterIdLastTwo.equals(deviceNameLastTwo)) {
isBondedOrBonding = true;
} else {
isIntialScan = true;
}
}
}
}
Log.d(TAG, "Bonded? " + isBondedOrBonding.toString());
}
示例3: getTransmitterDetails
import com.eveningoutpost.dexdrip.G5Model.Extensions; //导入依赖的package包/类
private synchronized void getTransmitterDetails() {
prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
Log.d(TAG, "Transmitter: " + prefs.getString("dex_txid", "ABCDEF"));
defaultTransmitter = new Transmitter(prefs.getString("dex_txid", "ABCDEF"));
final boolean previousBondedState = isBonded;
isBondedOrBonding = false;
isBonded = false;
if (mBluetoothAdapter == null) {
Log.wtf(TAG, "No bluetooth adapter");
return;
}
final Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
if ((pairedDevices != null) && (pairedDevices.size() > 0)) {
for (BluetoothDevice device : pairedDevices) {
if (device.getName() != null) {
final String transmitterIdLastTwo = Extensions.lastTwoCharactersOfString(defaultTransmitter.transmitterId);
final String deviceNameLastTwo = Extensions.lastTwoCharactersOfString(device.getName());
if (transmitterIdLastTwo.equals(deviceNameLastTwo)) {
isBondedOrBonding = true;
isBonded=true;
if (!previousBondedState) Log.e(TAG,"Device is now detected as bonded!");
// TODO should we break here for performance?
} else {
isIntialScan = true;
}
}
}
}
if (previousBondedState && !isBonded) Log.e(TAG,"Device is no longer detected as bonded!");
Log.d(TAG, "getTransmitterDetails() result: Bonded? " + isBondedOrBonding.toString()+(isBonded ? " localed bonded" : " not locally bonded"));
}
示例4: setupBluetooth
import com.eveningoutpost.dexdrip.G5Model.Extensions; //导入依赖的package包/类
public void setupBluetooth() {
getTransmitterDetails();
if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
//First time using the app or bluetooth was turned off?
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
Timer single_timer = new Timer();
single_timer.schedule(new TimerTask() {
@Override
public void run() {
if (mBluetoothAdapter != null) mBluetoothAdapter.enable();
}
}, 1000);
single_timer.schedule(new TimerTask() {
@Override
public void run() {
setupBluetooth();
}
}, 10000);
} else {
if (Build.VERSION.SDK_INT >= 21) {
mLEScanner = mBluetoothAdapter.getBluetoothLeScanner();
settings = new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
.build();
filters = new ArrayList<>();
//Only look for CGM.
//filters.add(new ScanFilter.Builder().setServiceUuid(new ParcelUuid(BluetoothServices.Advertisement)).build());
String transmitterIdLastTwo = Extensions.lastTwoCharactersOfString(defaultTransmitter.transmitterId);
filters.add(new ScanFilter.Builder().setDeviceName("Dexcom" + transmitterIdLastTwo).build());
}
// unbond here to avoid clashes when we are mid-connection
if (alwaysUnbond()) {
forgetDevice();
}
JoH.ratelimit("G5-timeout",0);//re-init to ensure onStartCommand always executes cycleScan
cycleScan(0);
}
}
示例5: getTransmitterDetails
import com.eveningoutpost.dexdrip.G5Model.Extensions; //导入依赖的package包/类
private synchronized void getTransmitterDetails() {
prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
Log.d(TAG, "Transmitter: " + prefs.getString("dex_txid", "ABCDEF"));
defaultTransmitter = new Transmitter(prefs.getString("dex_txid", "ABCDEF"));
final boolean previousBondedState = isBonded;
isBondedOrBonding = false;
isBonded = false;
static_is_bonded = false;
if (mBluetoothAdapter == null) {
Log.wtf(TAG, "No bluetooth adapter");
return;
}
final Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
if ((pairedDevices != null) && (pairedDevices.size() > 0)) {
for (BluetoothDevice device : pairedDevices) {
if (device.getName() != null) {
final String transmitterIdLastTwo = Extensions.lastTwoCharactersOfString(defaultTransmitter.transmitterId);
final String deviceNameLastTwo = Extensions.lastTwoCharactersOfString(device.getName());
if (transmitterIdLastTwo.equals(deviceNameLastTwo)) {
isBondedOrBonding = true;
isBonded=true;
static_is_bonded = true;
if (!previousBondedState) Log.e(TAG,"Device is now detected as bonded!");
// TODO should we break here for performance?
} else {
isIntialScan = true;
}
}
}
}
if (previousBondedState && !isBonded) Log.e(TAG,"Device is no longer detected as bonded!");
Log.d(TAG, "getTransmitterDetails() result: Bonded? " + isBondedOrBonding.toString()+(isBonded ? " localed bonded" : " not locally bonded"));
}
示例6: setCurrentDevice
import com.eveningoutpost.dexdrip.G5Model.Extensions; //导入依赖的package包/类
public void setCurrentDevice() {
if(activeBluetoothDevice != null) {
current_device.setText(activeBluetoothDevice.name);
} else {
current_device.setText("None Set");
}
String collection_method = prefs.getString("dex_collection_method", "BluetoothWixel");
if (collection_method.compareTo("DexcomG5") == 0) {
Transmitter defaultTransmitter = new Transmitter(prefs.getString("dex_txid", "ABCDEF"));
mBluetoothAdapter = mBluetoothManager.getAdapter();
if (mBluetoothAdapter != null) {
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
if ((pairedDevices != null) && (pairedDevices.size() > 0)) {
for (BluetoothDevice device : pairedDevices) {
if (device.getName() != null) {
String transmitterIdLastTwo = Extensions.lastTwoCharactersOfString(defaultTransmitter.transmitterId);
String deviceNameLastTwo = Extensions.lastTwoCharactersOfString(device.getName());
if (transmitterIdLastTwo.equals(deviceNameLastTwo)) {
current_device.setText(defaultTransmitter.transmitterId);
}
}
}
}
} else {
current_device.setText("No Bluetooth");
}
}
}
示例7: setCurrentDevice
import com.eveningoutpost.dexdrip.G5Model.Extensions; //导入依赖的package包/类
public void setCurrentDevice() {
if (activeBluetoothDevice != null) {
current_device.setText(activeBluetoothDevice.name);
} else {
current_device.setText("None Set");
}
String collection_method = prefs.getString("dex_collection_method", "BluetoothWixel");
if (collection_method.compareTo("DexcomG5") == 0) {
Transmitter defaultTransmitter = new Transmitter(prefs.getString("dex_txid", "ABCDEF"));
if (Build.VERSION.SDK_INT >= 18) {
mBluetoothAdapter = mBluetoothManager.getAdapter();
}
if (mBluetoothAdapter != null) {
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
if ((pairedDevices != null) && (pairedDevices.size() > 0)) {
for (BluetoothDevice device : pairedDevices) {
if (device.getName() != null) {
String transmitterIdLastTwo = Extensions.lastTwoCharactersOfString(defaultTransmitter.transmitterId);
String deviceNameLastTwo = Extensions.lastTwoCharactersOfString(device.getName());
if (transmitterIdLastTwo.equals(deviceNameLastTwo)) {
current_device.setText(defaultTransmitter.transmitterId);
}
}
}
}
} else {
current_device.setText("No Bluetooth");
}
}
}
示例8: setupBluetooth
import com.eveningoutpost.dexdrip.G5Model.Extensions; //导入依赖的package包/类
public void setupBluetooth() {
getTransmitterDetails();
if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
//First time using the app or bluetooth was turned off?
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
Timer single_timer = new Timer();
single_timer.schedule(new TimerTask() {
@Override
public void run() {
mBluetoothAdapter.enable();
}
}, 1000);
single_timer.schedule(new TimerTask() {
@Override
public void run() {
setupBluetooth();
}
}, 10000);
} else {
if (Build.VERSION.SDK_INT >= 21) {
mLEScanner = mBluetoothAdapter.getBluetoothLeScanner();
settings = new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
.build();
filters = new ArrayList<>();
//Only look for CGM.
//filters.add(new ScanFilter.Builder().setServiceUuid(new ParcelUuid(BluetoothServices.Advertisement)).build());
String transmitterIdLastTwo = Extensions.lastTwoCharactersOfString(defaultTransmitter.transmitterId);
filters.add(new ScanFilter.Builder().setDeviceName("Dexcom" + transmitterIdLastTwo).build());
}
cycleScan(0);
}
}
示例9: setCurrentDevice
import com.eveningoutpost.dexdrip.G5Model.Extensions; //导入依赖的package包/类
public void setCurrentDevice() {
if(activeBluetoothDevice != null) {
current_device.setText(activeBluetoothDevice.name);
} else {
current_device.setText("None Set");
}
String collection_method = prefs.getString("dex_collection_method", "BluetoothWixel");
if(collection_method.compareTo("DexcomG5") == 0) {
Transmitter defaultTransmitter = new Transmitter(prefs.getString("dex_txid", "ABCDEF"));
mBluetoothAdapter = mBluetoothManager.getAdapter();
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
if (pairedDevices.size() > 0) {
for (BluetoothDevice device : pairedDevices) {
if (device.getName() != null) {
String transmitterIdLastTwo = Extensions.lastTwoCharactersOfString(defaultTransmitter.transmitterId);
String deviceNameLastTwo = Extensions.lastTwoCharactersOfString(device.getName());
if (transmitterIdLastTwo.equals(deviceNameLastTwo)) {
current_device.setText(defaultTransmitter.transmitterId);
}
}
}
}
}
}
示例10: setConnectionStatus
import com.eveningoutpost.dexdrip.G5Model.Extensions; //导入依赖的package包/类
private void setConnectionStatus() {
boolean connected = false;
if (mBluetoothManager != null && activeBluetoothDevice != null) {
for (BluetoothDevice bluetoothDevice : mBluetoothManager.getConnectedDevices(BluetoothProfile.GATT)) {
if (bluetoothDevice.getAddress().compareTo(activeBluetoothDevice.address) == 0) {
connected = true;
}
}
}
if(connected) {
connection_status.setText("Connected");
} else {
connection_status.setText("Not Connected");
}
String collection_method = prefs.getString("dex_collection_method", "BluetoothWixel");
if(collection_method.compareTo("DexcomG5") == 0) {
Transmitter defaultTransmitter = new Transmitter(prefs.getString("dex_txid", "ABCDEF"));
mBluetoothAdapter = mBluetoothManager.getAdapter();
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
if (pairedDevices.size() > 0) {
for (BluetoothDevice device : pairedDevices) {
if (device.getName() != null) {
String transmitterIdLastTwo = Extensions.lastTwoCharactersOfString(defaultTransmitter.transmitterId);
String deviceNameLastTwo = Extensions.lastTwoCharactersOfString(device.getName());
if (transmitterIdLastTwo.equals(deviceNameLastTwo)) {
connection_status.setText(device.getName() + "\nAuthenticated");
}
}
}
}
}
}
示例11: getTransmitterBluetoothName
import com.eveningoutpost.dexdrip.G5Model.Extensions; //导入依赖的package包/类
private String getTransmitterBluetoothName() {
final String transmitterIdLastTwo = Extensions.lastTwoCharactersOfString(transmitterID);
// todo check for bad config
return "Dexcom" + transmitterIdLastTwo;
}
示例12: initScanCallback
import com.eveningoutpost.dexdrip.G5Model.Extensions; //导入依赖的package包/类
private void initScanCallback(){
mScanCallback = new ScanCallback() {
@Override
public void onScanResult(int callbackType, ScanResult result) {
UserError.Log.i(TAG, "result: " + result.toString());
BluetoothDevice btDevice = result.getDevice();
// // Check if the device has a name, the Dexcom transmitter always should. Match it with the transmitter id that was entered.
// // We get the last 2 characters to connect to the correct transmitter if there is more than 1 active or in the room.
// // If they match, connect to the device.
if (btDevice.getName() != null) {
String transmitterIdLastTwo = Extensions.lastTwoCharactersOfString(defaultTransmitter.transmitterId);
String deviceNameLastTwo = Extensions.lastTwoCharactersOfString(btDevice.getName());
if (transmitterIdLastTwo.equals(deviceNameLastTwo)) {
if (advertiseTimeMS.size() > 0)
if ((new Date().getTime() - advertiseTimeMS.get(advertiseTimeMS.size()-1)) > 2.5*60*1000)
advertiseTimeMS.clear();
advertiseTimeMS.add(new Date().getTime());
isIntialScan = false;
//device = btDevice;
device = mBluetoothAdapter.getRemoteDevice(btDevice.getAddress());
if (fullWake != null) JoH.releaseWakeLock(fullWake);
stopScan();
connectToDevice(btDevice);
} else {
//stopScan(10000);
}
}
}
@Override
public void onScanFailed(int errorCode) {
Log.e(TAG, "Scan Failed Error Code: " + errorCode);
if (fullWake != null) JoH.releaseWakeLock(fullWake);
if (errorCode == 1) {
UserError.Log.e(TAG, "Already Scanning: " + isScanning);
//isScanning = true;
} else if (errorCode == 2){
cycleBT();
}
}
};
}
示例13: processRxCharacteristic
import com.eveningoutpost.dexdrip.G5Model.Extensions; //导入依赖的package包/类
private synchronized void processRxCharacteristic(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
Log.i(TAG, "onCharacteristicChanged On Main Thread? " + isOnMainThread());
Log.e(TAG, "CharBytes-nfy" + Arrays.toString(characteristic.getValue()));
Log.i(TAG, "CharHex-nfy" + Extensions.bytesToHex(characteristic.getValue()));
byte[] buffer = characteristic.getValue();
byte firstByte = buffer[0];
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && gatt != null) {
gatt.requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_HIGH);
}
Log.d(TAG, "Received opcode reply: " + JoH.bytesToHex(new byte[] { firstByte }));
if (firstByte == 0x2f) {
SensorRxMessage sensorRx = new SensorRxMessage(characteristic.getValue());
ByteBuffer sensorData = ByteBuffer.allocate(buffer.length);
sensorData.order(ByteOrder.LITTLE_ENDIAN);
sensorData.put(buffer, 0, buffer.length);
int sensor_battery_level = 0;
if (sensorRx.status == TransmitterStatus.BRICKED) {
//TODO Handle this in UI/Notification
sensor_battery_level = 206; //will give message "EMPTY"
} else if (sensorRx.status == TransmitterStatus.LOW) {
sensor_battery_level = 209; //will give message "LOW"
} else {
sensor_battery_level = 216; //no message, just system status "OK"
}
//Log.e(TAG, "filtered: " + sensorRx.filtered);
disconnected133 = 0; // reset as we got a reading
disconnected59 = 0;
lastState = "Got data OK: " + JoH.hourMinuteString();
successes++;
failures=0;
Log.e(TAG, "SUCCESS!! unfiltered: " + sensorRx.unfiltered + " timestamp: " + sensorRx.timestamp + " " + JoH.qs((double)sensorRx.timestamp / 86400, 1) + " days");
if (sensorRx.unfiltered == 0) {
lastState = "Transmitter sent raw sensor value of 0 !! This isn't good. " + JoH.hourMinuteString();
}
last_transmitter_timestamp = sensorRx.timestamp;
if ((getVersionDetails) && (!haveFirmwareDetails())) {
doVersionRequestMessage(gatt, characteristic);
} else if ((getBatteryDetails) && (getBatteryStatusNow || !haveCurrentBatteryStatus())) {
doBatteryInfoRequestMessage(gatt, characteristic);
} else {
doDisconnectMessage(gatt, characteristic);
}
processNewTransmitterData(sensorRx.unfiltered, sensorRx.filtered, sensor_battery_level, new Date().getTime());
// was this the first success after we force enabled always_authenticate?
if (force_always_authenticate && (successes == 1)) {
Log.wtf(TAG, "We apparently only got a reading after forcing the Always Authenticate option");
Home.toaststaticnext("Please Enable G5 Always Authenticate debug option!");
// TODO should we actually change the settings here?
}
} else if (firstByte == GlucoseRxMessage.opcode) {
disconnected133 = 0; // reset as we got a reading
disconnected59 = 0;
GlucoseRxMessage glucoseRx = new GlucoseRxMessage(characteristic.getValue());
Log.e(TAG, "SUCCESS!! glucose unfiltered: " + glucoseRx.unfiltered);
successes++;
failures=0;
doDisconnectMessage(gatt, characteristic);
processNewTransmitterData(glucoseRx.unfiltered, glucoseRx.filtered, 216, new Date().getTime());
} else if (firstByte == VersionRequestRxMessage.opcode) {
if (!setStoredFirmwareBytes(defaultTransmitter.transmitterId, characteristic.getValue(), true)) {
Log.wtf(TAG, "Could not save out firmware version!");
}
doDisconnectMessage(gatt, characteristic);
} else if (firstByte == BatteryInfoRxMessage.opcode) {
if (!setStoredBatteryBytes(defaultTransmitter.transmitterId, characteristic.getValue())) {
Log.wtf(TAG, "Could not save out battery data!");
}
getBatteryStatusNow = false;
doDisconnectMessage(gatt, characteristic);
} else {
Log.e(TAG, "onCharacteristic CHANGED unexpected opcode: " + firstByte + " (have not disconnected!)");
}
Log.e(TAG, "OnCharacteristic CHANGED finished: ");
}
示例14: setupBluetooth
import com.eveningoutpost.dexdrip.G5Model.Extensions; //导入依赖的package包/类
public void setupBluetooth() {
getTransmitterDetails();
if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
//First time using the app or bluetooth was turned off?
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
Timer single_timer = new Timer();
single_timer.schedule(new TimerTask() {
@Override
public void run() {
try {
if (mBluetoothAdapter != null) mBluetoothAdapter.enable();
} catch (SecurityException e) {
JoH.static_toast_short("Please enable Bluetooth!");
}
}
}, 1000);
single_timer.schedule(new TimerTask() {
@Override
public void run() {
setupBluetooth();
}
}, 10000);
} else {
if (Build.VERSION.SDK_INT >= 21) {
mLEScanner = mBluetoothAdapter.getBluetoothLeScanner();
settings = new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
.build();
filters = new ArrayList<>();
//Only look for CGM.
//filters.add(new ScanFilter.Builder().setServiceUuid(new ParcelUuid(BluetoothServices.Advertisement)).build());
String transmitterIdLastTwo = Extensions.lastTwoCharactersOfString(defaultTransmitter.transmitterId);
filters.add(new ScanFilter.Builder().setDeviceName("Dexcom" + transmitterIdLastTwo).build());
}
// unbond here to avoid clashes when we are mid-connection
if (alwaysUnbond()) {
forgetDevice();
}
JoH.ratelimit("G5-timeout",0);//re-init to ensure onStartCommand always executes cycleScan
cycleScan(0);
}
}
示例15: initScanCallback
import com.eveningoutpost.dexdrip.G5Model.Extensions; //导入依赖的package包/类
private void initScanCallback(){
mScanCallback = new ScanCallback() {
@Override
public void onScanResult(int callbackType, ScanResult result) {
UserError.Log.i(TAG, "result: " + result.toString());
BluetoothDevice btDevice = result.getDevice();
// // Check if the device has a name, the Dexcom transmitter always should. Match it with the transmitter id that was entered.
// // We get the last 2 characters to connect to the correct transmitter if there is more than 1 active or in the room.
// // If they match, connect to the device.
if (btDevice.getName() != null) {
String transmitterIdLastTwo = Extensions.lastTwoCharactersOfString(defaultTransmitter.transmitterId);
String deviceNameLastTwo = Extensions.lastTwoCharactersOfString(btDevice.getName());
if (transmitterIdLastTwo.equals(deviceNameLastTwo)) {
if (advertiseTimeMS.size() > 0)
if ((new Date().getTime() - advertiseTimeMS.get(advertiseTimeMS.size()-1)) > 2.5*60*1000)
advertiseTimeMS.clear();
advertiseTimeMS.add(new Date().getTime());
isIntialScan = false;
//device = btDevice;
device = mBluetoothAdapter.getRemoteDevice(btDevice.getAddress());
static_device_address = btDevice.getAddress();
stopScan();
connectToDevice(btDevice);
} else {
//stopScan(10000);
}
}
}
@Override
public void onScanFailed(int errorCode) {
Log.e(TAG, "Scan Failed Error Code: " + errorCode);
if (errorCode == 1) {
UserError.Log.e(TAG, "Already Scanning: " + isScanning);
//isScanning = true;
} else if (errorCode == 2){
cycleBT();
}
}
};
}