• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java TransmitterData类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中com.eveningoutpost.dexdrip.Models.TransmitterData的典型用法代码示例。如果您正苦于以下问题:Java TransmitterData类的具体用法?Java TransmitterData怎么用?Java TransmitterData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

TransmitterData类属于com.eveningoutpost.dexdrip.Models包,在下文中一共展示了TransmitterData类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: isSafeToDeleteDB

点赞 3

import com.eveningoutpost.dexdrip.Models.TransmitterData; //导入依赖的package包/类
private boolean isSafeToDeleteDB() {//TODO remove once confirm not needed
    TransmitterData last_bg = TransmitterData.last();
    if (last_bg != null && last_send_previous <= last_bg.timestamp) {
        Log.d(TAG, "onDataChanged SYNC_DB_PATH requestData for last_send_previous < last_bg.timestamp:" + JoH.dateTimeText(last_send_previous) + "<="+ JoH.dateTimeText(last_bg.timestamp));
        requestData();
        return false;
    }
    if (mPrefs.getBoolean("sync_wear_logs", false)) {
        UserError last_log = UserError.last();
        if (last_log != null && last_send_previous_log <= last_log.timestamp) {
            Log.d(TAG, "onDataChanged SYNC_DB_PATH requestData for last_send_previous_log < last_log.timestamp:" + JoH.dateTimeText(last_send_previous_log) + "<=" + JoH.dateTimeText((long) last_log.timestamp));
            return false;
        }
    }
    return true;
}
 

开发者ID:NightscoutFoundation,
项目名称:xDrip,
代码行数:17,
代码来源:ListenerService.java

示例2: processNewTransmitterData

点赞 3

import com.eveningoutpost.dexdrip.Models.TransmitterData; //导入依赖的package包/类
private synchronized void processNewTransmitterData(TransmitterData transmitterData, long timestamp) {
    if (transmitterData == null) {
        return;
    }

    final Sensor sensor = Sensor.currentSensor();
    if (sensor == null) {
        Log.i(TAG, "setSerialDataToTransmitterRawData: No Active Sensor, Data only stored in Transmitter Data");
        return;
    }

    if (use_transmiter_pl_bluetooth && (transmitterData.raw_data == 100000)) {
        Log.wtf(TAG, "Ignoring probably erroneous Transmiter_PL data: " + transmitterData.raw_data);
        return;
    }



    //sensor.latest_battery_level = (sensor.latest_battery_level != 0) ? Math.min(sensor.latest_battery_level, transmitterData.sensor_battery_level) : transmitterData.sensor_battery_level;
    sensor.latest_battery_level = transmitterData.sensor_battery_level; // allow level to go up and down
    sensor.save();

    last_transmitter_Data = transmitterData;
    Log.d(TAG, "BgReading.create: new BG reading at " + timestamp + " with a timestamp of " + transmitterData.timestamp);
    BgReading.create(transmitterData.raw_data, transmitterData.filtered_data, this, transmitterData.timestamp);
}
 

开发者ID:NightscoutFoundation,
项目名称:xDrip,
代码行数:27,
代码来源:DexCollectionService.java

示例3: processNewTransmitterData

点赞 3

import com.eveningoutpost.dexdrip.Models.TransmitterData; //导入依赖的package包/类
private static synchronized void processNewTransmitterData(TransmitterData transmitterData) {
    if (transmitterData == null) {
        Log.e(TAG, "Got duplicated data! Last BG at " + JoH.dateTimeText(m_timeLastBg));
        return;
    }

    final Sensor sensor = Sensor.currentSensor();
    if (sensor == null) {
        Log.i(TAG, "processNewTransmitterData: No Active Sensor, Data only stored in Transmitter Data");
        return;
    }

    DexCollectionService.last_transmitter_Data = transmitterData;
    Log.d(TAG, "BgReading.create: new BG reading at " + transmitterData.timestamp);
    BgReading.create(transmitterData.raw_data, transmitterData.filtered_data, xdrip.getAppContext(), transmitterData.timestamp);
}
 

开发者ID:NightscoutFoundation,
项目名称:xDrip,
代码行数:17,
代码来源:Blukon.java

示例4: setSerialDataToTransmitterRawData

点赞 3

import com.eveningoutpost.dexdrip.Models.TransmitterData; //导入依赖的package包/类
private void setSerialDataToTransmitterRawData(int raw_data, int filtered_data, int sensor_battery_leve, Long CaptureTime) {

        final TransmitterData transmitterData = TransmitterData.create(raw_data, filtered_data, sensor_battery_leve, CaptureTime);
        if (transmitterData != null) {
            final Sensor sensor = Sensor.currentSensor();
            if (sensor != null) {
                BgReading bgReading = BgReading.create(transmitterData.raw_data, filtered_data, mContext, CaptureTime);

                //sensor.latest_battery_level = (sensor.latest_battery_level!=0)?Math.min(sensor.latest_battery_level, transmitterData.sensor_battery_level):transmitterData.sensor_battery_level;
                sensor.latest_battery_level = transmitterData.sensor_battery_level; // don't lock it only going downwards
                sensor.save();
            } else {
                Log.d(TAG, "No Active Sensor, Data only stored in Transmitter Data");
            }
        }
    }
 

开发者ID:NightscoutFoundation,
项目名称:xDrip,
代码行数:17,
代码来源:WixelReader.java

示例5: processNewTransmitterData

点赞 3

import com.eveningoutpost.dexdrip.Models.TransmitterData; //导入依赖的package包/类
private void processNewTransmitterData(int raw_data , int filtered_data,int sensor_battery_level, long captureTime) {

        TransmitterData transmitterData = TransmitterData.create(raw_data, sensor_battery_level, captureTime);
        if (transmitterData == null) {
            Log.e(TAG, "TransmitterData.create failed: Duplicate packet");
            return;
        } else {
            timeInMillisecondsOfLastSuccessfulSensorRead = captureTime;
        }
        Sensor sensor = Sensor.currentSensor();
        if (sensor == null) {
            Log.e(TAG, "setSerialDataToTransmitterRawData: No Active Sensor, Data only stored in Transmitter Data");
            return;
        }

        //TODO : LOG if unfiltered or filtered values are zero

        Sensor.updateBatteryLevel(sensor, transmitterData.sensor_battery_level);
        android.util.Log.i("timestamp create", Long.toString(transmitterData.timestamp));

        BgReading.create(transmitterData.raw_data, filtered_data, this, transmitterData.timestamp);
    }
 

开发者ID:StephenBlackWasAlreadyTaken,
项目名称:xDrip-Experimental,
代码行数:23,
代码来源:G5CollectionService.java

示例6: processNewTransmitterData

点赞 2

import com.eveningoutpost.dexdrip.Models.TransmitterData; //导入依赖的package包/类
private void processNewTransmitterData(TransmitterData transmitterData, long timestamp) {
    if (transmitterData == null) {
        return;
    }

    Sensor sensor = Sensor.currentSensor();
    if (sensor == null) {
        Log.i(TAG, "setSerialDataToTransmitterRawData: No Active Sensor, Data only stored in Transmitter Data");
        return;
    }

    Sensor.updateBatteryLevel(sensor, transmitterData.sensor_battery_level);

    BgReading.create(transmitterData.raw_data, transmitterData.filtered_data, this, timestamp);
}
 

开发者ID:LadyViktoria,
项目名称:wearDrip,
代码行数:16,
代码来源:DexCollectionService.java

示例7: getWearTransmitterData

点赞 2

import com.eveningoutpost.dexdrip.Models.TransmitterData; //导入依赖的package包/类
private synchronized DataMap getWearTransmitterData(int count, long last_send_time, int min_count) {//KS
    forceGoogleApiConnect();

    Log.d(TAG, "getWearTransmitterData last_send_time:" + JoH.dateTimeText(last_send_time));

    TransmitterData last_bg = TransmitterData.last();
    if (last_bg != null) {
        Log.d(TAG, "getWearTransmitterData last_bg.timestamp:" + JoH.dateTimeText(last_bg.timestamp));
    }

    if (last_bg != null && last_send_time <= last_bg.timestamp) {//startTime
        long last_send_success = last_send_time;
        Log.d(TAG, "getWearTransmitterData last_send_time < last_bg.timestamp:" + JoH.dateTimeText(last_bg.timestamp));
        List<TransmitterData> graph_bgs = TransmitterData.latestForGraphAsc(count, last_send_time);
        if (!graph_bgs.isEmpty() && graph_bgs.size() > min_count) {
            //Log.d(TAG, "getWearTransmitterData count = " + graph_bgs.size());
            DataMap entries = dataMap(last_bg);
            final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size());
            for (TransmitterData bg : graph_bgs) {
                dataMaps.add(dataMap(bg));
                last_send_success = bg.timestamp;
                //Log.d(TAG, "getWearTransmitterData bg getId:" + bg.getId() + " raw_data:" + bg.raw_data + " filtered_data:" + bg.filtered_data + " timestamp:" + bg.timestamp + " uuid:" + bg.uuid);
            }
            entries.putLong("time", new Date().getTime()); // MOST IMPORTANT LINE FOR TIMESTAMP
            entries.putDataMapArrayList("entries", dataMaps);
            Log.i(TAG, "getWearTransmitterData SYNCED BGs up to " + JoH.dateTimeText(last_send_success) + " count = " + graph_bgs.size());
            return entries;
        } else
            Log.i(TAG, "getWearTransmitterData SYNCED BGs up to " + JoH.dateTimeText(last_send_success) + " count = 0");
    }
    return null;
}
 

开发者ID:NightscoutFoundation,
项目名称:xDrip,
代码行数:33,
代码来源:ListenerService.java

示例8: processNewTransmitterData

点赞 2

import com.eveningoutpost.dexdrip.Models.TransmitterData; //导入依赖的package包/类
private synchronized void processNewTransmitterData(int raw_data , int filtered_data,int sensor_battery_level, long captureTime) {

        final TransmitterData transmitterData = TransmitterData.create(raw_data, filtered_data, sensor_battery_level, captureTime);
        if (transmitterData == null) {
            Log.e(TAG, "TransmitterData.create failed: Duplicate packet");
            return;
        } else {
            timeInMillisecondsOfLastSuccessfulSensorRead = captureTime;
        }
        Sensor sensor = Sensor.currentSensor();
        if (sensor == null) {
            Log.e(TAG, "setSerialDataToTransmitterRawData: No Active Sensor, Data only stored in Transmitter Data");
            return;
        }

        //TODO : LOG if unfiltered or filtered values are zero

        Sensor.updateBatteryLevel(sensor, transmitterData.sensor_battery_level);
        Log.i(TAG,"timestamp create: "+ Long.toString(transmitterData.timestamp));

        BgReading.create(transmitterData.raw_data, transmitterData.filtered_data, this, transmitterData.timestamp);

        Log.d(TAG,"Dex raw_data "+ Double.toString(transmitterData.raw_data));//KS
        Log.d(TAG,"Dex filtered_data "+ Double.toString(transmitterData.filtered_data));//KS
        Log.d(TAG,"Dex sensor_battery_level "+ Double.toString(transmitterData.sensor_battery_level));//KS
        Log.d(TAG,"Dex timestamp "+ JoH.dateTimeText(transmitterData.timestamp));//KS

        static_last_timestamp =  transmitterData.timestamp;

    }
 

开发者ID:NightscoutFoundation,
项目名称:xDrip,
代码行数:31,
代码来源:G5CollectionService.java

示例9: setWatchStatus

点赞 2

import com.eveningoutpost.dexdrip.Models.TransmitterData; //导入依赖的package包/类
public static void setWatchStatus(DataMap dataMap) {
    lastStateWatch = dataMap.getString("lastState", "");
    last_transmitter_DataWatch = new TransmitterData();
    last_transmitter_DataWatch.timestamp = dataMap.getLong("timestamp", 0);
    mStaticStateWatch = dataMap.getInt("mStaticState", 0);
    last_battery_level_watch = dataMap.getInt("last_battery_level", -1);
    retry_time_watch = dataMap.getLong("retry_time", 0);
    failover_time_watch = dataMap.getLong("failover_time", 0);
    static_last_hexdump_watch = dataMap.getString("static_last_hexdump", "");
    static_last_sent_hexdump_watch = dataMap.getString("static_last_sent_hexdump", "");
}
 

开发者ID:NightscoutFoundation,
项目名称:xDrip,
代码行数:12,
代码来源:DexCollectionService.java

示例10: processNewTransmitterData

点赞 2

import com.eveningoutpost.dexdrip.Models.TransmitterData; //导入依赖的package包/类
private static synchronized void processNewTransmitterData(int raw_data, int filtered_data, int sensor_battery_level, long captureTime) {

        final TransmitterData transmitterData = TransmitterData.create(raw_data, filtered_data, sensor_battery_level, captureTime);
        if (transmitterData == null) {
            UserError.Log.e(TAG, "TransmitterData.create failed: Duplicate packet");
            return;
        } else {
            UserError.Log.d(TAG, "Created transmitter data " + transmitterData.uuid + " " + JoH.dateTimeText(transmitterData.timestamp));
            // TODO timeInMillisecondsOfLastSuccessfulSensorRead = captureTime;
        }
        Sensor sensor = Sensor.currentSensor();
        if (sensor == null) {
            UserError.Log.e(TAG, "setSerialDataToTransmitterRawData: No Active Sensor, Data only stored in Transmitter Data");
            return;
        }

        //TODO : LOG if unfiltered or filtered values are zero

        Sensor.updateBatteryLevel(sensor, transmitterData.sensor_battery_level);
        if (d)
            UserError.Log.i(TAG, "timestamp create: " + Long.toString(transmitterData.timestamp));

        BgReading bgreading = BgReading.create(transmitterData.raw_data, transmitterData.filtered_data, xdrip.getAppContext(), transmitterData.timestamp);

        UserError.Log.d(TAG, "Dex raw_data " + Double.toString(transmitterData.raw_data));//KS
        UserError.Log.d(TAG, "Dex filtered_data " + Double.toString(transmitterData.filtered_data));//KS
        UserError.Log.d(TAG, "Dex sensor_battery_level " + Double.toString(transmitterData.sensor_battery_level));//KS
        UserError.Log.d(TAG, "Dex timestamp " + JoH.dateTimeText(transmitterData.timestamp));//KS

        UserError.Log.d(TAG, "BgReading created: " + bgreading.uuid + " " + JoH.dateTimeText(bgreading.timestamp));

        // TODO static_last_timestamp =  transmitterData.timestamp;

    }
 

开发者ID:NightscoutFoundation,
项目名称:xDrip,
代码行数:35,
代码来源:Ob1G5StateMachine.java

示例11: timeForNextRead

点赞 2

import com.eveningoutpost.dexdrip.Models.TransmitterData; //导入依赖的package包/类
static Long timeForNextRead() {

        TransmitterData lastTransmitterData = TransmitterData.last();
        if (lastTransmitterData == null) {
            // We did not receive a packet, well someone hopefully is looking at data, return relatively fast
            Log.e(TAG, "lastTransmitterData == null returning 60000");
            return 60 * 1000L;
        }
        Long gapTime = new Date().getTime() - lastTransmitterData.timestamp;
        Log.d(TAG, "gapTime = " + gapTime);
        if (gapTime < 0) {
            // There is some confusion here (clock was readjusted?)
            Log.e(TAG, "gapTime <= null returning 60000");
            return 60 * 1000L;
        }

        if (gapTime < DEXCOM_PERIOD) {
            // We have received the last packet...
            // 300000 - gaptime is when we expect to have the next packet.
            return (DEXCOM_PERIOD - gapTime) + 2000;
        }

        gapTime = gapTime % DEXCOM_PERIOD;
        Log.d(TAG, "modulus gapTime = " + gapTime);
        if (gapTime < 10000) {
            // A new packet should arrive any second now
            return 10000L;
        }
        if (gapTime < 60000) {
            // A new packet should arrive but chance is we have missed it...
            return 30000L;
        }

        if (httpClient == null) {
            return (DEXCOM_PERIOD - gapTime) + 2000;
        } else {
            // compensate for parakeet gprs lag
            return (DEXCOM_PERIOD - gapTime) + 12000;
        }
    }
 

开发者ID:NightscoutFoundation,
项目名称:xDrip,
代码行数:41,
代码来源:WixelReader.java

示例12: setTransmitterStatus

点赞 2

import com.eveningoutpost.dexdrip.Models.TransmitterData; //导入依赖的package包/类
private void setTransmitterStatus() {

        if(prefs.getString("dex_collection_method", "BluetoothWixel").equals("DexcomShare")){
            transmitter_status_view.setText("See Share Receiver");
            return;
        }

        TransmitterData td = TransmitterData.last();

        if (td== null || td.sensor_battery_level == 0){
            transmitter_status_view.setText("not available");
            GcmActivity.requestSensorBatteryUpdate();
        } else if((System.currentTimeMillis() - td.timestamp) > 1000*60*60*24){
            transmitter_status_view.setText("no data in 24 hours");
            GcmActivity.requestSensorBatteryUpdate();
        } else {
            transmitter_status_view.setText("" + td.sensor_battery_level);
            GcmActivity.requestSensorBatteryUpdate(); // always ask
            if (td.sensor_battery_level <= Dex_Constants.TRANSMITTER_BATTERY_EMPTY) {
                transmitter_status_view.append(" - very low");
            } else if (td.sensor_battery_level <= Dex_Constants.TRANSMITTER_BATTERY_LOW) {
                transmitter_status_view.append(" - low");
                transmitter_status_view.append("\n(experimental interpretation)");
            } else {
                transmitter_status_view.append(" - ok");
            }
        }

    }
 

开发者ID:NightscoutFoundation,
项目名称:xDrip,
代码行数:30,
代码来源:SystemStatus.java

示例13: setTransmitterStatus

点赞 2

import com.eveningoutpost.dexdrip.Models.TransmitterData; //导入依赖的package包/类
private void setTransmitterStatus() {

        if (prefs.getString("dex_collection_method", "BluetoothWixel").equals("DexcomShare")) {
            transmitter_status_view.setText("See Share Receiver");
            return;
        }

        TransmitterData td = TransmitterData.last();

        if (td == null || td.sensor_battery_level == 0) {
            transmitter_status_view.setText("not available");
            GcmActivity.requestSensorBatteryUpdate();
        } else if ((System.currentTimeMillis() - td.timestamp) > 1000 * 60 * 60 * 24) {
            transmitter_status_view.setText("no data in 24 hours");
            GcmActivity.requestSensorBatteryUpdate();
        } else {
            transmitter_status_view.setText("" + td.sensor_battery_level);
            GcmActivity.requestSensorBatteryUpdate(); // always ask
            if (td.sensor_battery_level <= Dex_Constants.TRANSMITTER_BATTERY_EMPTY) {
                transmitter_status_view.append(" - very low");
            } else if (td.sensor_battery_level <= Dex_Constants.TRANSMITTER_BATTERY_LOW) {
                transmitter_status_view.append(" - low");
                transmitter_status_view.append("\n(experimental interpretation)");
            } else {
                transmitter_status_view.append(" - ok");
            }
        }

    }
 

开发者ID:NightscoutFoundation,
项目名称:xDrip,
代码行数:30,
代码来源:SystemStatusFragment.java

示例14: timeForNextRead

点赞 2

import com.eveningoutpost.dexdrip.Models.TransmitterData; //导入依赖的package包/类
static Long timeForNextRead() {

        TransmitterData lastTransmitterData = TransmitterData.last();
        if(lastTransmitterData == null) {
            // We did not receive a packet, well someone hopefully is looking at data, return relatively fast
            Log.e(TAG, "lastTransmitterData == null returning 60000");
            return 60*1000L;
        }
        Long gapTime = new Date().getTime() - lastTransmitterData.timestamp;
        Log.e(TAG, "gapTime = " + gapTime);
        if(gapTime < 0) {
            // There is some confusion here (clock was readjusted?)
            Log.e(TAG, "gapTime <= null returning 60000");
            return 60*1000L;
        }

        if(gapTime < DEXCOM_PERIOD) {
            // We have received the last packet...
            // 300000 - gaptime is when we expect to have the next packet.
            return (DEXCOM_PERIOD - gapTime) + 2000;
        }

        gapTime = gapTime % DEXCOM_PERIOD;
        Log.e(TAG, "gapTime = " + gapTime);
        if(gapTime < 10000) {
            // A new packet should arrive any second now
            return 10000L;
        }
        if(gapTime < 60000) {
            // A new packet should arrive but chance is we have missed it...
            return 30000L;
        }

        if (httpClient == null) {
            return (DEXCOM_PERIOD - gapTime) + 2000;
        } else {
            // compensate for parakeet gprs lag
            return (DEXCOM_PERIOD - gapTime) + 12000;
        }
    }
 

开发者ID:StephenBlackWasAlreadyTaken,
项目名称:xDrip-Experimental,
代码行数:41,
代码来源:WixelReader.java

示例15: setSerialDataToTransmitterRawData

点赞 2

import com.eveningoutpost.dexdrip.Models.TransmitterData; //导入依赖的package包/类
public void setSerialDataToTransmitterRawData(int raw_data, int filtered_data ,int sensor_battery_leve, Long CaptureTime) {

        TransmitterData transmitterData = TransmitterData.create(raw_data, sensor_battery_leve, CaptureTime);
        if (transmitterData != null) {
            Sensor sensor = Sensor.currentSensor();
            if (sensor != null) {
                Sensor.updateBatteryLevel(sensor, transmitterData.sensor_battery_level);
                BgReading bgReading = BgReading.create(transmitterData.raw_data, filtered_data, mContext, CaptureTime);
            } else {
                Log.d(TAG, "No Active Sensor, Data only stored in Transmitter Data");
            }
        }
    }
 

开发者ID:StephenBlackWasAlreadyTaken,
项目名称:xDrip-Experimental,
代码行数:14,
代码来源:WixelReader.java

示例16: processNewTransmitterData

点赞 2

import com.eveningoutpost.dexdrip.Models.TransmitterData; //导入依赖的package包/类
private void processNewTransmitterData(TransmitterData transmitterData, long timestamp) {
    if (transmitterData == null) {
        return;
    }

    Sensor sensor = Sensor.currentSensor();
    if (sensor == null) {
        Log.i(TAG, "setSerialDataToTransmitterRawData: No Active Sensor, Data only stored in Transmitter Data");
        return;
    }

    Sensor.updateBatteryLevel(sensor, transmitterData.sensor_battery_level);
    BgReading.create(transmitterData.raw_data, transmitterData.filtered_data, this, timestamp);
}
 

开发者ID:StephenBlackWasAlreadyTaken,
项目名称:xDrip-Experimental,
代码行数:15,
代码来源:DexCollectionService.java

示例17: setTransmitterStatus

点赞 2

import com.eveningoutpost.dexdrip.Models.TransmitterData; //导入依赖的package包/类
private void setTransmitterStatus() {

        if(prefs.getString("dex_collection_method", "BluetoothWixel").equals("DexcomShare")){
            transmitter_status_view.setText("See Share Receiver");
            return;
        }

        TransmitterData td = TransmitterData.last();

        if (td== null || td.sensor_battery_level == 0){
            transmitter_status_view.setText("not available");
        } else if((System.currentTimeMillis() - td.timestamp) > 1000*60*60*24){
            transmitter_status_view.setText("no data in 24 hours");
        } else {
            transmitter_status_view.setText("" + td.sensor_battery_level);

            if (td.sensor_battery_level <= Constants.TRANSMITTER_BATTERY_EMPTY) {
                transmitter_status_view.append(" - very low");
            } else if (td.sensor_battery_level <= Constants.TRANSMITTER_BATTERY_LOW) {
                transmitter_status_view.append(" - low");
                transmitter_status_view.append("\n(experimental interpretation)");
            } else {
                transmitter_status_view.append(" - ok");
            }
        }

    }
 

开发者ID:StephenBlackWasAlreadyTaken,
项目名称:xDrip-Experimental,
代码行数:28,
代码来源:SystemStatus.java

示例18: setSerialDataToTransmitterRawData

点赞 2

import com.eveningoutpost.dexdrip.Models.TransmitterData; //导入依赖的package包/类
public void setSerialDataToTransmitterRawData(byte[] buffer, int len) {
    long timestamp = new Date().getTime();
    if (CollectionServiceStarter.isDexbridgeWixel(getApplicationContext())) {
        Log.i(TAG, "setSerialDataToTransmitterRawData: Dealing with Dexbridge packet!");
        int DexSrc;
        int TransmitterID;
        String TxId;
        Calendar c = Calendar.getInstance();
        long secondsNow = c.getTimeInMillis();
        ByteBuffer tmpBuffer = ByteBuffer.allocate(len);
        tmpBuffer.order(ByteOrder.LITTLE_ENDIAN);
        tmpBuffer.put(buffer, 0, len);
        ByteBuffer txidMessage = ByteBuffer.allocate(6);
        txidMessage.order(ByteOrder.LITTLE_ENDIAN);
        if (buffer[0] == 0x07 && buffer[1] == -15) {
            //We have a Beacon packet.  Get the TXID value and compare with dex_txid
            Log.i(TAG, "setSerialDataToTransmitterRawData: Received Beacon packet.");
            //DexSrc starts at Byte 2 of a Beacon packet.
            DexSrc = tmpBuffer.getInt(2);
            TxId = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("dex_txid", "00000");
            TransmitterID = convertSrc(TxId);
            if (TxId.compareTo("00000") != 0 && Integer.compare(DexSrc, TransmitterID) != 0) {
                Log.w(TAG, "setSerialDataToTransmitterRawData: TXID wrong.  Expected " + TransmitterID + " but got " + DexSrc);
                txidMessage.put(0, (byte) 0x06);
                txidMessage.put(1, (byte) 0x01);
                txidMessage.putInt(2, TransmitterID);
                sendBtMessage(txidMessage);
            }
            return;
        }
        if (buffer[0] == 0x11 && buffer[1] == 0x00) {
            //we have a data packet.  Check to see if the TXID is what we are expecting.
            Log.i(TAG, "setSerialDataToTransmitterRawData: Received Data packet");
            if (len >= 0x11) {
                //DexSrc starts at Byte 12 of a data packet.
                DexSrc = tmpBuffer.getInt(12);
                TxId = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("dex_txid", "00000");
                TransmitterID = convertSrc(TxId);
                if (Integer.compare(DexSrc, TransmitterID) != 0) {
                    Log.w(TAG, "TXID wrong.  Expected " + TransmitterID + " but got " + DexSrc);
                    txidMessage.put(0, (byte) 0x06);
                    txidMessage.put(1, (byte) 0x01);
                    txidMessage.putInt(2, TransmitterID);
                    sendBtMessage(txidMessage);
                }
                PreferenceManager.getDefaultSharedPreferences(mContext).edit().putInt("bridge_battery", ByteBuffer.wrap(buffer).get(11)).apply();
                //All is OK, so process it.
                //first, tell the wixel it is OK to sleep.
                Log.d(TAG, "setSerialDataToTransmitterRawData: Sending Data packet Ack, to put wixel to sleep");
                ByteBuffer ackMessage = ByteBuffer.allocate(2);
                ackMessage.put(0, (byte) 0x02);
                ackMessage.put(1, (byte) 0xF0);
                sendBtMessage(ackMessage);
                //make sure we are not processing a packet we already have
                if (secondsNow - lastPacketTime < 60000) {
                    Log.v(TAG, "setSerialDataToTransmitterRawData: Received Duplicate Packet.  Exiting.");
                    return;
                } else {
                    lastPacketTime = secondsNow;
                }
                Log.v(TAG, "setSerialDataToTransmitterRawData: Creating TransmitterData at " + timestamp);
                processNewTransmitterData(TransmitterData.create(buffer, len, timestamp), timestamp);
            }
        }
    } else {
        processNewTransmitterData(TransmitterData.create(buffer, len, timestamp), timestamp);
    }
}
 

开发者ID:LadyViktoria,
项目名称:wearDrip,
代码行数:69,
代码来源:DexCollectionService.java

示例19: syncTransmitterData

点赞 2

import com.eveningoutpost.dexdrip.Models.TransmitterData; //导入依赖的package包/类
private synchronized void syncTransmitterData(DataMap dataMap, boolean bBenchmark) {//KS
    Log.d(TAG, "syncTransmitterData");

    ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
    long timeOfLastBG = 0;
    Log.d(TAG, "syncTransmitterData add BgReading Table" );
    if (entries != null) {

        Gson gson = new GsonBuilder()
                .excludeFieldsWithoutExposeAnnotation()
                .registerTypeAdapter(Date.class, new DateTypeAdapter())
                .serializeSpecialFloatingPointValues()
                .create();

        int idx = 0;
        int count = entries.size();
        Log.d(TAG, "syncTransmitterData add BgReading Table entries count=" + count);
        for (DataMap entry : entries) {
            if (entry != null) {
                //Log.d(TAG, "syncTransmitterData add BgReading Table entry=" + entry);
                idx++;
                String bgrecord = entry.getString("bgs");
                if (bgrecord != null) {//for (TransmitterData bgData : bgs) {
                    //Log.d(TAG, "syncTransmitterData add TransmitterData Table bgrecord=" + bgrecord);
                    TransmitterData bgData = gson.fromJson(bgrecord, TransmitterData.class);
                    //TransmitterData bgData = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().fromJson(bgrecord, TransmitterData.class);
                    TransmitterData exists = TransmitterData.getForTimestamp(bgData.timestamp);
                    TransmitterData uuidexists = TransmitterData.findByUuid(bgData.uuid);
                    timeOfLastBG = bgData.timestamp + 1;
                    if (exists != null || uuidexists != null) {
                        Log.d(TAG, "syncTransmitterData BG already exists for uuid=" + bgData.uuid + " timestamp=" + bgData.timestamp + " timeString=" + JoH.dateTimeText(bgData.timestamp) + " raw_data=" + bgData.raw_data);
                    } else {
                        Log.d(TAG, "syncTransmitterData add BG; does NOT exist for uuid=" + bgData.uuid + " timestamp=" + bgData.timestamp + " timeString=" + JoH.dateTimeText(bgData.timestamp) + " raw_data=" + bgData.raw_data);
                        if (!bBenchmark) {
                            bgData.save();

                            //Check
                            if (TransmitterData.findByUuid(bgData.uuid) != null)
                                Log.d(TAG, "syncTransmitterData: TransmitterData was saved for uuid:" + bgData.uuid);
                            else {
                                Log.e(TAG, "syncTransmitterData: TransmitterData was NOT saved for uuid:" + bgData.uuid);
                                return;
                            }

                            //KS the following is from G5CollectionService processNewTransmitterData()
                            Sensor sensor = Sensor.currentSensor();
                            if (sensor == null) {
                                Log.e(TAG, "syncTransmitterData: No Active Sensor, Data only stored in Transmitter Data");
                                return;
                            }
                            //TODO : LOG if unfiltered or filtered values are zero
                            Sensor.updateBatteryLevel(sensor, bgData.sensor_battery_level);
                            Log.i(TAG, "syncTransmitterData: BG timestamp create " + Long.toString(bgData.timestamp));//android.util.Log.i
                            BgReading bgExists;

                            //KS TODO wear implements limited alerts, therefore continue to process all alerts on phone for last entry
                            if (count > 1 && idx < count) {
                                bgExists = BgReading.create(bgData.raw_data, bgData.filtered_data, this, bgData.timestamp, true);//Disable Notifications for bulk insert
                            }
                            else {
                                bgExists = BgReading.create(bgData.raw_data, bgData.filtered_data, this, bgData.timestamp);
                            }
                            if (bgExists != null)
                                Log.d(TAG, "syncTransmitterData BG GSON saved BG: " + bgExists.toS());
                            else
                                Log.e(TAG, "syncTransmitterData BG GSON NOT saved");
                        }
                    }
                }
            }
        }
        sendDataReceived(DATA_ITEM_RECEIVED_PATH,"DATA_RECEIVED_BGS count=" + entries.size(), timeOfLastBG, bBenchmark?"BM":"BG", -1);
    }
}
 

开发者ID:NightscoutFoundation,
项目名称:xDrip,
代码行数:75,
代码来源:WatchUpdaterService.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)