com.eveningoutpost.dexdrip.Services.G5CollectionService Java Examples

The following examples show how to use com.eveningoutpost.dexdrip.Services.G5CollectionService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StopSensor.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
public void addListenerOnButton() {

        button = (Button)findViewById(R.id.stop_sensor);

        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Sensor.stopSensor();
                AlertPlayer.getPlayer().stopAlert(getApplicationContext(), true, false);

                Toast.makeText(getApplicationContext(), "Sensor stopped", Toast.LENGTH_LONG).show();

                //If Sensor is stopped for G5, we need to prevent further BLE scanning.
                SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
                String collection_method = prefs.getString("dex_collection_method", "BluetoothWixel");
                if(collection_method.compareTo("DexcomG5") == 0) {
                    Intent serviceIntent = new Intent(getApplicationContext(), G5CollectionService.class);
                    startService(serviceIntent);
                }

                Intent intent = new Intent(getApplicationContext(), Home.class);
                startActivity(intent);
                finish();
            }

        });
    }
 
Example #2
Source File: WatchUpdaterService.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private void syncFieldData(DataMap dataMap) {
    String dex_txid = dataMap.getString("dex_txid", "");
    byte[] G5_BATTERY_MARKER = dataMap.getByteArray(G5CollectionService.G5_BATTERY_MARKER);
    byte[] G5_FIRMWARE_MARKER = dataMap.getByteArray(G5CollectionService.G5_FIRMWARE_MARKER);
    if (dex_txid != null && dex_txid.equals(mPrefs.getString("dex_txid", "default"))) {
        if (G5_BATTERY_MARKER != null) {
            long watch_last_battery_query = dataMap.getLong(G5CollectionService.G5_BATTERY_FROM_MARKER);
            long phone_last_battery_query = PersistentStore.getLong(G5CollectionService.G5_BATTERY_FROM_MARKER + dex_txid);
            if (watch_last_battery_query > phone_last_battery_query) {
                G5CollectionService.setStoredBatteryBytes(dex_txid, G5_BATTERY_MARKER);
                PersistentStore.setLong(G5CollectionService.G5_BATTERY_FROM_MARKER + dex_txid, watch_last_battery_query);
                G5CollectionService.getBatteryStatusNow = false;
                Ob1G5CollectionService.getBatteryStatusNow = false;
            }
        }
        if (G5_FIRMWARE_MARKER != null) {
            G5CollectionService.setStoredFirmwareBytes(dex_txid, G5_FIRMWARE_MARKER);
        }
    }
}
 
Example #3
Source File: WatchUpdaterService.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private void syncFieldData(DataMap dataMap) {
    String dex_txid = dataMap.getString("dex_txid", "");
    byte[] G5_BATTERY_MARKER = dataMap.getByteArray(G5CollectionService.G5_BATTERY_MARKER);
    byte[] G5_FIRMWARE_MARKER = dataMap.getByteArray(G5CollectionService.G5_FIRMWARE_MARKER);
    if (dex_txid != null && dex_txid.equals(mPrefs.getString("dex_txid", "default"))) {
        if (G5_BATTERY_MARKER != null) {
            long watch_last_battery_query = dataMap.getLong(G5CollectionService.G5_BATTERY_FROM_MARKER);
            long phone_last_battery_query = PersistentStore.getLong(G5CollectionService.G5_BATTERY_FROM_MARKER + dex_txid);
            if (watch_last_battery_query > phone_last_battery_query) {
                G5CollectionService.setStoredBatteryBytes(dex_txid, G5_BATTERY_MARKER);
                PersistentStore.setLong(G5CollectionService.G5_BATTERY_FROM_MARKER + dex_txid, watch_last_battery_query);
                G5CollectionService.getBatteryStatusNow = false;
                Ob1G5CollectionService.getBatteryStatusNow = false;
            }
        }
        if (G5_FIRMWARE_MARKER != null) {
            G5CollectionService.setStoredFirmwareBytes(dex_txid, G5_FIRMWARE_MARKER);
        }
    }
}
 
Example #4
Source File: CollectionServiceStarter.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public void startBtG5Service() {//private
    Log.d(TAG, "starting G5 service");
    //if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
    PersistentStore.setBoolean(pref_run_wear_collector, true);

    if (!Pref.getBooleanDefaultFalse(Ob1G5CollectionService.OB1G5_PREFS)) {
        G5CollectionService.keep_running = true;
        this.mContext.startService(new Intent(this.mContext, G5CollectionService.class));
    } else {
        Ob1G5CollectionService.keep_running = true;
        this.mContext.startService(new Intent(this.mContext, Ob1G5CollectionService.class));
    }
    //}
}
 
Example #5
Source File: WatchUpdaterService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private void startBtG5Service() {//KS
    Log.d(TAG, "startBtG5Service");
    //is_using_g5 = (getDexCollectionType() == DexCollectionType.DexcomG5);
    is_using_bt = DexCollectionType.hasBluetooth();
    if (is_using_bt) {
        Context myContext = getApplicationContext();
        Log.d(TAG, "startBtG5Service start G5CollectionService");
        myContext.startService(new Intent(myContext, G5CollectionService.class));
        Log.d(TAG, "startBtG5Service AFTER startService G5CollectionService");
    } else {
        Log.d(TAG, "Not starting any G5 service as it is not our data source");
    }
}
 
Example #6
Source File: SystemStatusFragment.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private void requestWearCollectorStatus() {
    final PowerManager.WakeLock wl = JoH.getWakeLock("ACTION_STATUS_COLLECTOR",120000);
    if (Home.get_enable_wear()) {
        if (DexCollectionType.getDexCollectionType().equals(DexcomG5)) {
            startWatchUpdaterService(safeGetContext(), WatchUpdaterService.ACTION_STATUS_COLLECTOR, TAG, "getBatteryStatusNow", G5CollectionService.getBatteryStatusNow);
        }
        else {
            startWatchUpdaterService(safeGetContext(), WatchUpdaterService.ACTION_STATUS_COLLECTOR, TAG);
        }
    }
    JoH.releaseWakeLock(wl);
}
 
Example #7
Source File: MegaStatus.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private void requestWearCollectorStatus() {
    if (Home.get_enable_wear()) {
        if (DexCollectionType.getDexCollectionType().equals(DexcomG5)) {
            startWatchUpdaterService(xdrip.getAppContext(), WatchUpdaterService.ACTION_STATUS_COLLECTOR, TAG, "getBatteryStatusNow", G5CollectionService.getBatteryStatusNow);
        } else {
            startWatchUpdaterService(xdrip.getAppContext(), WatchUpdaterService.ACTION_STATUS_COLLECTOR, TAG);
        }
    }
}
 
Example #8
Source File: CollectionServiceStarter.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private void stopG5Service() {
    Log.d(TAG, "stopping G5  services");
    G5CollectionService.keep_running = false; // ensure zombie stays down
    this.mContext.stopService(new Intent(this.mContext, G5CollectionService.class));
    Ob1G5CollectionService.keep_running = false; // ensure zombie stays down
    this.mContext.stopService(new Intent(this.mContext, Ob1G5CollectionService.class));
    Ob1G5CollectionService.resetSomeInternalState();
}
 
Example #9
Source File: CollectionServiceStarter.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private void startBtG5Service() {
    // Log.d(TAG,"stopping G5 service");
    // stopG5Service(); // TODO diabled due to multiple service restarts but others may suffer same problems - needs rework
    Log.d(TAG, "starting G5 service");
    //if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
    if (!Pref.getBooleanDefaultFalse(Ob1G5CollectionService.OB1G5_PREFS)) {
        G5CollectionService.keep_running = true;
        startServiceCompat(new Intent(this.mContext, G5CollectionService.class));
    } else {
        Ob1G5CollectionService.keep_running = true;
        startServiceCompat(new Intent(this.mContext, Ob1G5CollectionService.class));
    }
    //}
}
 
Example #10
Source File: CollectionServiceStarter.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private void stopG5ShareService() {
    Log.d(TAG, "stopping G5 service");
    G5CollectionService.keep_running = false; // ensure zombie stays down
    this.mContext.stopService(new Intent(this.mContext, G5CollectionService.class));
    Ob1G5CollectionService.keep_running = false; // ensure zombie stays down
    this.mContext.stopService(new Intent(this.mContext, Ob1G5CollectionService.class));
}
 
Example #11
Source File: CollectionServiceStarter.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public void startBtG5Service() {//private
    Log.d(TAG, "starting G5 service");
    //if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
    PersistentStore.setBoolean(pref_run_wear_collector, true);

    if (!Pref.getBooleanDefaultFalse(Ob1G5CollectionService.OB1G5_PREFS)) {
        G5CollectionService.keep_running = true;
        this.mContext.startService(new Intent(this.mContext, G5CollectionService.class));
    } else {
        Ob1G5CollectionService.keep_running = true;
        this.mContext.startService(new Intent(this.mContext, Ob1G5CollectionService.class));
    }
    //}
}
 
Example #12
Source File: WatchUpdaterService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
private void startBtG5Service() {//KS
    Log.d(TAG, "startBtG5Service");
    //is_using_g5 = (getDexCollectionType() == DexCollectionType.DexcomG5);
    is_using_bt = DexCollectionType.hasBluetooth();
    if (is_using_bt) {
        Context myContext = getApplicationContext();
        Log.d(TAG, "startBtG5Service start G5CollectionService");
        myContext.startService(new Intent(myContext, G5CollectionService.class));
        Log.d(TAG, "startBtG5Service AFTER startService G5CollectionService");
    } else {
        Log.d(TAG, "Not starting any G5 service as it is not our data source");
    }
}
 
Example #13
Source File: SystemStatusFragment.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
private void requestWearCollectorStatus() {
    final PowerManager.WakeLock wl = JoH.getWakeLock("ACTION_STATUS_COLLECTOR",120000);
    if (Home.get_enable_wear()) {
        if (DexCollectionType.getDexCollectionType().equals(DexcomG5)) {
            startWatchUpdaterService(safeGetContext(), WatchUpdaterService.ACTION_STATUS_COLLECTOR, TAG, "getBatteryStatusNow", G5CollectionService.getBatteryStatusNow);
        }
        else {
            startWatchUpdaterService(safeGetContext(), WatchUpdaterService.ACTION_STATUS_COLLECTOR, TAG);
        }
    }
    JoH.releaseWakeLock(wl);
}
 
Example #14
Source File: MegaStatus.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
private void requestWearCollectorStatus() {
    if (Home.get_enable_wear()) {
        if (DexCollectionType.getDexCollectionType().equals(DexcomG5)) {
            startWatchUpdaterService(xdrip.getAppContext(), WatchUpdaterService.ACTION_STATUS_COLLECTOR, TAG, "getBatteryStatusNow", G5CollectionService.getBatteryStatusNow);
        } else {
            startWatchUpdaterService(xdrip.getAppContext(), WatchUpdaterService.ACTION_STATUS_COLLECTOR, TAG);
        }
    }
}
 
Example #15
Source File: CollectionServiceStarter.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
private void stopG5ShareService() {
    Log.d(TAG, "stopping G5 service");
    G5CollectionService.keep_running = false; // ensure zombie stays down
    this.mContext.stopService(new Intent(this.mContext, G5CollectionService.class));
    Ob1G5CollectionService.keep_running = false; // ensure zombie stays down
    this.mContext.stopService(new Intent(this.mContext, Ob1G5CollectionService.class));
}
 
Example #16
Source File: CollectionServiceStarter.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
private void startBtG5Service() {
    // Log.d(TAG,"stopping G5 service");
    // stopG5Service(); // TODO diabled due to multiple service restarts but others may suffer same problems - needs rework
    Log.d(TAG, "starting G5 service");
    //if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
    if (!Pref.getBooleanDefaultFalse(Ob1G5CollectionService.OB1G5_PREFS)) {
        G5CollectionService.keep_running = true;
        startServiceCompat(new Intent(this.mContext, G5CollectionService.class));
    } else {
        Ob1G5CollectionService.keep_running = true;
        startServiceCompat(new Intent(this.mContext, Ob1G5CollectionService.class));
    }
    //}
}
 
Example #17
Source File: CollectionServiceStarter.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
private void stopG5Service() {
    Log.d(TAG, "stopping G5  services");
    G5CollectionService.keep_running = false; // ensure zombie stays down
    this.mContext.stopService(new Intent(this.mContext, G5CollectionService.class));
    Ob1G5CollectionService.keep_running = false; // ensure zombie stays down
    this.mContext.stopService(new Intent(this.mContext, Ob1G5CollectionService.class));
    Ob1G5CollectionService.resetSomeInternalState();
}
 
Example #18
Source File: SystemStatus.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
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(getApplicationContext().getString(R.string.connected));
    } else {
        connection_status.setText(getApplicationContext().getString(R.string.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();
        if (mBluetoothAdapter != null) {
            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)) {
                            final String fw = G5CollectionService.getFirmwareVersionString(defaultTransmitter.transmitterId);
                            connection_status.setText(device.getName() + " Authed" + ((fw != null) ? ("\n" + fw) : ""));
                            break;
                        }

                    }
                }
            }
        } else {
            connection_status.setText(getApplicationContext().getString(R.string.no_bluetooth));
        }
    }
}
 
Example #19
Source File: CollectionServiceStarter.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
private void stopG5ShareService() {
    Log.d(TAG, "stopping G5  service");
    mContext.stopService(new Intent(mContext, G5CollectionService.class));
}
 
Example #20
Source File: CollectionServiceStarter.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
private void startBtG5Service() {
    Log.d(TAG, "starting G5 share service");
    //if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
        mContext.startService(new Intent(mContext, G5CollectionService.class));
    //}
}
 
Example #21
Source File: ListenerService.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
private void sendCollectorStatus (Context context, String path) {
    String msg;
    //long last_timestamp = 0;
    DataMap dataMap = new DataMap();
    switch (DexCollectionType.getDexCollectionType()) {
        case DexcomG5:

            if (DexCollectionType.getCollectorServiceClass() == G5CollectionService.class) {
                dataMap = G5CollectionService.getWatchStatus();//msg, last_timestamp
            } else {
                dataMap = Ob1G5CollectionService.getWatchStatus();//msg, last_timestamp
            }
            break;
        case DexcomShare://TODO getLastState() in non-G5 Services
            BluetoothManager mBluetoothManager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
            ActiveBluetoothDevice activeBluetoothDevice = ActiveBluetoothDevice.first();
            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) {
                msg = "Connected on watch";
            } else {
                msg = "Not Connected";
            }
            dataMap.putString("lastState", msg);
            break;
        default:
            dataMap = DexCollectionService.getWatchStatus();
            break;
    }
    if (dataMap != null) {
        dataMap.putString("action_path", path);
    }

    //sendReplyMsg (msg, last_timestamp, path, false);
    sendData(WEARABLE_REPLYMSG_PATH, dataMap.toByteArray());
}
 
Example #22
Source File: WatchUpdaterService.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
private void stopBtG5Service() {//KS
    Log.d(TAG, "stopBtG5Service");
    Context myContext = getApplicationContext();
    myContext.stopService(new Intent(myContext, G5CollectionService.class));
}
 
Example #23
Source File: SystemStatusFragment.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
private void setConnectionStatus() {
    boolean connected = false;
    if (mBluetoothManager != null && activeBluetoothDevice != null && (Build.VERSION.SDK_INT >= 18)) {
        for (BluetoothDevice bluetoothDevice : mBluetoothManager.getConnectedDevices(BluetoothProfile.GATT)) {
            if (bluetoothDevice.getAddress().compareTo(activeBluetoothDevice.address) == 0) {
                connected = true;
            }
        }
    }
    if (connected) {
        connection_status.setText(safeGetContext().getString(R.string.connected));
    } else {
        connection_status.setText(safeGetContext().getString(R.string.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"));
        if (Build.VERSION.SDK_INT >= 18) mBluetoothAdapter = mBluetoothManager.getAdapter();
        if (mBluetoothAdapter != null) {
            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)) {
                            final String fw = G5CollectionService.getFirmwareVersionString(defaultTransmitter.transmitterId);
                            connection_status.setText(device.getName() + " Authed" + ((fw != null) ? ("\n" + fw) : ""));
                            break;
                        }

                    }
                }
            }
        } else {
            connection_status.setText(safeGetContext().getString(R.string.no_bluetooth)); 
        }
    }
}
 
Example #24
Source File: SystemStatusFragment.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    //Injectors.getMicroStatusComponent().inject(this);
    requestWearCollectorStatus();
    serviceDataReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context ctx, Intent intent) {
            final String action = intent.getAction();
            //final String msg = intent.getStringExtra("data");
            Bundle bundle = intent.getBundleExtra("data");
            if (bundle != null) {
                DataMap dataMap = DataMap.fromBundle(bundle);
                String lastState = dataMap.getString("lastState", "");
                long last_timestamp = dataMap.getLong("timestamp", 0);
                UserError.Log.d(TAG, "serviceDataReceiver onReceive:" + action + " :: " + lastState + " last_timestamp :: " + last_timestamp);
                switch (action) {
                    case WatchUpdaterService.ACTION_BLUETOOTH_COLLECTION_SERVICE_UPDATE:
                        switch (DexCollectionType.getDexCollectionType()) {
                            case DexcomG5:
                                G5CollectionService.setWatchStatus(dataMap);//msg, last_timestamp
                                break;
                            case DexcomShare:
                                if (lastState != null && !lastState.isEmpty()) {
                                    setConnectionStatus(lastState);//TODO getLastState() in non-G5 Services
                                }
                                break;
                            default:
                                DexCollectionService.setWatchStatus(dataMap);//msg, last_timestamp
                                if (lastState != null && !lastState.isEmpty()) {
                                    setConnectionStatus(lastState);
                                }
                                break;
                        }
                        break;
                }
            }
        }
    };
    final ActivitySystemStatusBinding binding = DataBindingUtil.inflate(
            inflater, R.layout.activity_system_status, container, false);
    microStatus = new MicroStatusImpl();
    binding.setMs(microStatus);
    return binding.getRoot();
}
 
Example #25
Source File: SystemStatusFragment.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
private void setConnectionStatus() {
    boolean connected = false;
    if (mBluetoothManager != null && activeBluetoothDevice != null && (Build.VERSION.SDK_INT >= 18)) {
        for (BluetoothDevice bluetoothDevice : mBluetoothManager.getConnectedDevices(BluetoothProfile.GATT)) {
            if (bluetoothDevice.getAddress().compareTo(activeBluetoothDevice.address) == 0) {
                connected = true;
            }
        }
    }
    if (connected) {
        connection_status.setText(safeGetContext().getString(R.string.connected));
    } else {
        connection_status.setText(safeGetContext().getString(R.string.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"));
        if (Build.VERSION.SDK_INT >= 18) mBluetoothAdapter = mBluetoothManager.getAdapter();
        if (mBluetoothAdapter != null) {
            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)) {
                            final String fw = G5CollectionService.getFirmwareVersionString(defaultTransmitter.transmitterId);
                            connection_status.setText(device.getName() + " Authed" + ((fw != null) ? ("\n" + fw) : ""));
                            break;
                        }

                    }
                }
            }
        } else {
            connection_status.setText(safeGetContext().getString(R.string.no_bluetooth)); 
        }
    }
}
 
Example #26
Source File: MegaStatus.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
private static void populate(MegaStatusListAdapter la, String section) {
    if ((la == null) || (section == null)) {
        UserError.Log.e(TAG, "Adapter or Section were null in populate()");
        return;
    }

    la.clear(false);
    switch (section) {

        case G4_STATUS:
            la.addRows(DexCollectionService.megaStatus());
            break;
        case G5_STATUS:
            if (Pref.getBooleanDefaultFalse(Ob1G5CollectionService.OB1G5_PREFS)) {
                la.addRows(Ob1G5CollectionService.megaStatus());
            } else {
                la.addRows(G5CollectionService.megaStatus());
            }
            break;
        case MEDTRUM_STATUS:
            la.addRows(MedtrumCollectionService.megaStatus());
            break;
        case IP_COLLECTOR:
            la.addRows(WifiCollectionService.megaStatus(mActivity));
            break;
        case XDRIP_PLUS_SYNC:
            la.addRows(DoNothingService.megaStatus());
            la.addRows(GcmListenerSvc.megaStatus());
            la.addRows(DesertSync.megaStatus());
            la.addRows(RollCall.megaStatus());
            break;
        case UPLOADERS:
            la.addRows(UploaderQueue.megaStatus());
            break;
        case LEFUN_STATUS:
            la.addRows(LeFunService.megaStatus());
            break;
        case MIBAND_STATUS:
            la.addRows(MiBandService.megaStatus());
            break;
        case BLUEJAY_STATUS:
            la.addRows(BlueJayService.megaStatus());
            break;
        case INPEN_STATUS:
            la.addRows(InPenService.megaStatus());
            break;
        case NIGHTSCOUT_FOLLOW:
            la.addRows(NightscoutFollowService.megaStatus());
            break;
        case SHARE_FOLLOW:
            la.addRows(ShareFollowService.megaStatus());
            break;
        case XDRIP_LIBRE2:
            la.addRows(LibreReceiver.megaStatus());
            break;
    }
    la.changed();
}
 
Example #27
Source File: MegaStatus.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
private static void populate(MegaStatusListAdapter la, String section) {
    if ((la == null) || (section == null)) {
        UserError.Log.e(TAG, "Adapter or Section were null in populate()");
        return;
    }

    la.clear(false);
    switch (section) {

        case G4_STATUS:
            la.addRows(DexCollectionService.megaStatus());
            break;
        case G5_STATUS:
            if (Pref.getBooleanDefaultFalse(Ob1G5CollectionService.OB1G5_PREFS)) {
                la.addRows(Ob1G5CollectionService.megaStatus());
            } else {
                la.addRows(G5CollectionService.megaStatus());
            }
            break;
        case MEDTRUM_STATUS:
            la.addRows(MedtrumCollectionService.megaStatus());
            break;
        case IP_COLLECTOR:
            la.addRows(WifiCollectionService.megaStatus(mActivity));
            break;
        case XDRIP_PLUS_SYNC:
            la.addRows(DoNothingService.megaStatus());
            la.addRows(GcmListenerSvc.megaStatus());
            la.addRows(DesertSync.megaStatus());
            la.addRows(RollCall.megaStatus());
            break;
        case UPLOADERS:
            la.addRows(UploaderQueue.megaStatus());
            break;
        case LEFUN_STATUS:
            la.addRows(LeFunService.megaStatus());
            break;
        case MIBAND_STATUS:
            la.addRows(MiBandService.megaStatus());
            break;
        case BLUEJAY_STATUS:
            la.addRows(BlueJayService.megaStatus());
            break;
        case INPEN_STATUS:
            la.addRows(InPenService.megaStatus());
            break;
        case NIGHTSCOUT_FOLLOW:
            la.addRows(NightscoutFollowService.megaStatus());
            break;
        case SHARE_FOLLOW:
            la.addRows(ShareFollowService.megaStatus());
            break;
        case XDRIP_LIBRE2:
            la.addRows(LibreReceiver.megaStatus());
            break;
    }
    la.changed();
}
 
Example #28
Source File: SystemStatus.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
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(getApplicationContext().getString(R.string.connected));
    } else {
        connection_status.setText(getApplicationContext().getString(R.string.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();
        if (mBluetoothAdapter != null) {
            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)) {
                            final String fw = G5CollectionService.getFirmwareVersionString(defaultTransmitter.transmitterId);
                            connection_status.setText(device.getName() + " Authed" + ((fw != null) ? ("\n" + fw) : ""));
                            break;
                        }

                    }
                }
            }
        } else {
            connection_status.setText(getApplicationContext().getString(R.string.no_bluetooth));
        }
    }
}
 
Example #29
Source File: SystemStatusFragment.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    //Injectors.getMicroStatusComponent().inject(this);
    requestWearCollectorStatus();
    serviceDataReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context ctx, Intent intent) {
            final String action = intent.getAction();
            //final String msg = intent.getStringExtra("data");
            Bundle bundle = intent.getBundleExtra("data");
            if (bundle != null) {
                DataMap dataMap = DataMap.fromBundle(bundle);
                String lastState = dataMap.getString("lastState", "");
                long last_timestamp = dataMap.getLong("timestamp", 0);
                UserError.Log.d(TAG, "serviceDataReceiver onReceive:" + action + " :: " + lastState + " last_timestamp :: " + last_timestamp);
                switch (action) {
                    case WatchUpdaterService.ACTION_BLUETOOTH_COLLECTION_SERVICE_UPDATE:
                        switch (DexCollectionType.getDexCollectionType()) {
                            case DexcomG5:
                                G5CollectionService.setWatchStatus(dataMap);//msg, last_timestamp
                                break;
                            case DexcomShare:
                                if (lastState != null && !lastState.isEmpty()) {
                                    setConnectionStatus(lastState);//TODO getLastState() in non-G5 Services
                                }
                                break;
                            default:
                                DexCollectionService.setWatchStatus(dataMap);//msg, last_timestamp
                                if (lastState != null && !lastState.isEmpty()) {
                                    setConnectionStatus(lastState);
                                }
                                break;
                        }
                        break;
                }
            }
        }
    };
    final ActivitySystemStatusBinding binding = DataBindingUtil.inflate(
            inflater, R.layout.activity_system_status, container, false);
    microStatus = new MicroStatusImpl();
    binding.setMs(microStatus);
    return binding.getRoot();
}
 
Example #30
Source File: ListenerService.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
private void sendCollectorStatus (Context context, String path) {
    String msg;
    //long last_timestamp = 0;
    DataMap dataMap = new DataMap();
    switch (DexCollectionType.getDexCollectionType()) {
        case DexcomG5:

            if (DexCollectionType.getCollectorServiceClass() == G5CollectionService.class) {
                dataMap = G5CollectionService.getWatchStatus();//msg, last_timestamp
            } else {
                dataMap = Ob1G5CollectionService.getWatchStatus();//msg, last_timestamp
            }
            break;
        case DexcomShare://TODO getLastState() in non-G5 Services
            BluetoothManager mBluetoothManager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
            ActiveBluetoothDevice activeBluetoothDevice = ActiveBluetoothDevice.first();
            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) {
                msg = "Connected on watch";
            } else {
                msg = "Not Connected";
            }
            dataMap.putString("lastState", msg);
            break;
        default:
            dataMap = DexCollectionService.getWatchStatus();
            break;
    }
    if (dataMap != null) {
        dataMap.putString("action_path", path);
    }

    //sendReplyMsg (msg, last_timestamp, path, false);
    sendData(WEARABLE_REPLYMSG_PATH, dataMap.toByteArray());
}