com.eveningoutpost.dexdrip.ImportedLibraries.dexcom.Constants Java Examples

The following examples show how to use com.eveningoutpost.dexdrip.ImportedLibraries.dexcom.Constants. 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: PageHeader.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public PageHeader(byte[] packet) {
    Log.d("ShareTest", "Header Packet Data Length: " + packet.length);

    firstRecordIndex = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(FIRSTRECORDINDEX_OFFSET);
    numOfRecords = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(NUMRECS_OFFSET);
    recordType = Constants.RECORD_TYPES.values()[packet[RECTYPE_OFFSET]];
    revision = packet[REV_OFFSET];
    pageNumber = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(PAGENUMBER_OFFSET);
    reserved2 = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(RESERVED2_OFFSET);
    reserved3 = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(RESERVED3_OFFSET);
    reserved4 = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(RESERVED4_OFFSET);
    System.arraycopy(packet,HEADER_SIZE-Constants.CRC_LEN,crc,0,Constants.CRC_LEN);
    byte[] crc_calc = CRC16.calculate(packet,0,HEADER_SIZE - Constants.CRC_LEN);
    if (!Arrays.equals(this.crc, crc_calc)) {
        throw new CRCFailRuntimeException("CRC check failed: " + Utils.bytesToHex(this.crc) + " vs " + Utils.bytesToHex(crc_calc));
    }
}
 
Example #2
Source File: PageHeader.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public PageHeader(byte[] packet) {
    Log.d("ShareTest", "Header Packet Data Length: " + packet.length);

    firstRecordIndex = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(FIRSTRECORDINDEX_OFFSET);
    numOfRecords = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(NUMRECS_OFFSET);
    recordType = Constants.RECORD_TYPES.values()[packet[RECTYPE_OFFSET]];
    revision = packet[REV_OFFSET];
    pageNumber = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(PAGENUMBER_OFFSET);
    reserved2 = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(RESERVED2_OFFSET);
    reserved3 = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(RESERVED3_OFFSET);
    reserved4 = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(RESERVED4_OFFSET);
    System.arraycopy(packet,HEADER_SIZE-Constants.CRC_LEN,crc,0,Constants.CRC_LEN);
    byte[] crc_calc = CRC16.calculate(packet,0,HEADER_SIZE - Constants.CRC_LEN);
    if (!Arrays.equals(this.crc, crc_calc)) {
        throw new CRCFailRuntimeException("CRC check failed: " + Utils.bytesToHex(this.crc) + " vs " + Utils.bytesToHex(crc_calc));
    }
}
 
Example #3
Source File: PageHeader.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public PageHeader(byte[] packet) {
    Log.d("ShareTest", "Header Packet Data Length: " + packet.length);

    firstRecordIndex = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(FIRSTRECORDINDEX_OFFSET);
    numOfRecords = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(NUMRECS_OFFSET);
    recordType = Constants.RECORD_TYPES.values()[packet[RECTYPE_OFFSET]];
    revision = packet[REV_OFFSET];
    pageNumber = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(PAGENUMBER_OFFSET);
    reserved2 = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(RESERVED2_OFFSET);
    reserved3 = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(RESERVED3_OFFSET);
    reserved4 = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(RESERVED4_OFFSET);
    System.arraycopy(packet,HEADER_SIZE-Constants.CRC_LEN,crc,0,Constants.CRC_LEN);
    byte[] crc_calc = CRC16.calculate(packet,0,HEADER_SIZE - Constants.CRC_LEN);
    if (!Arrays.equals(this.crc, crc_calc)) {
        throw new CRCFailRuntimeException("CRC check failed: " + Utils.bytesToHex(this.crc) + " vs " + Utils.bytesToHex(crc_calc));
    }
}
 
Example #4
Source File: PageHeader.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
public PageHeader(byte[] packet) {
    Log.d("ShareTest", "Header Packet Data Length: " + packet.length);

    firstRecordIndex = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(FIRSTRECORDINDEX_OFFSET);
    numOfRecords = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(NUMRECS_OFFSET);
    recordType = Constants.RECORD_TYPES.values()[packet[RECTYPE_OFFSET]];
    revision = packet[REV_OFFSET];
    pageNumber = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(PAGENUMBER_OFFSET);
    reserved2 = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(RESERVED2_OFFSET);
    reserved3 = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(RESERVED3_OFFSET);
    reserved4 = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(RESERVED4_OFFSET);
    System.arraycopy(packet,HEADER_SIZE-Constants.CRC_LEN,crc,0,Constants.CRC_LEN);
    byte[] crc_calc = CRC16.calculate(packet,0,HEADER_SIZE - Constants.CRC_LEN);
    if (!Arrays.equals(this.crc, crc_calc)) {
        throw new CRCFailRuntimeException("CRC check failed: " + Utils.bytesToHex(this.crc) + " vs " + Utils.bytesToHex(crc_calc));
    }
}
 
Example #5
Source File: EGVRecord.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public EGVRecord(byte[] packet) {
    // system_time (UInt), display_time (UInt), glucose (UShort), trend_arrow (Byte), crc (UShort))
    super(packet);
    bGValue = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getShort(8) & Constants.EGV_VALUE_MASK;
    byte trendAndNoise = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).get(10);
    int trendValue = trendAndNoise & Constants.EGV_TREND_ARROW_MASK;
    byte noiseValue = (byte) ((trendAndNoise & Constants.EGV_NOISE_MASK) >> 4);
    trend = Constants.TREND_ARROW_VALUES.values()[trendValue];
    noise = noiseValue;
}
 
Example #6
Source File: EGVRecord.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public EGVRecord(byte[] packet) {
    // system_time (UInt), display_time (UInt), glucose (UShort), trend_arrow (Byte), crc (UShort))
    super(packet);
    bGValue = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getShort(8) & Constants.EGV_VALUE_MASK;
    byte trendAndNoise = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).get(10);
    int trendValue = trendAndNoise & Constants.EGV_TREND_ARROW_MASK;
    byte noiseValue = (byte) ((trendAndNoise & Constants.EGV_NOISE_MASK) >> 4);
    trend = Constants.TREND_ARROW_VALUES.values()[trendValue];
    noise = noiseValue;
}
 
Example #7
Source File: EGVRecord.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public EGVRecord(byte[] packet) {
    // system_time (UInt), display_time (UInt), glucose (UShort), trend_arrow (Byte), crc (UShort))
    super(packet);
    bGValue = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getShort(8) & Constants.EGV_VALUE_MASK;
    byte trendAndNoise = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).get(10);
    int trendValue = trendAndNoise & Constants.EGV_TREND_ARROW_MASK;
    byte noiseValue = (byte) ((trendAndNoise & Constants.EGV_NOISE_MASK) >> 4);
    trend = Constants.TREND_ARROW_VALUES.values()[trendValue];
    noise = noiseValue;
}
 
Example #8
Source File: SystemStatus.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
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");
            }
        }

    }
 
Example #9
Source File: EGVRecord.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
public EGVRecord(byte[] packet) {
    // system_time (UInt), display_time (UInt), glucose (UShort), trend_arrow (Byte), crc (UShort))
    super(packet);
    bGValue = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getShort(8) & Constants.EGV_VALUE_MASK;
    byte trendAndNoise = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).get(10);
    int trendValue = trendAndNoise & Constants.EGV_TREND_ARROW_MASK;
    byte noiseValue = (byte) ((trendAndNoise & Constants.EGV_NOISE_MASK) >> 4);
    trend = Constants.TREND_ARROW_VALUES.values()[trendValue];
    noise = noiseValue;
}
 
Example #10
Source File: GlucoseDataSet.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public Constants.TREND_ARROW_VALUES getTrend() {
    return trend;
}
 
Example #11
Source File: EGVRecord.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public Constants.TREND_ARROW_VALUES getTrend() {
    return trend;
}
 
Example #12
Source File: EGVRecord.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public EGVRecord(int bGValue,Constants.TREND_ARROW_VALUES trend,Date displayTime, Date systemTime){
    super(displayTime, systemTime);
    this.bGValue=bGValue;
    this.trend=trend;
}
 
Example #13
Source File: PageHeader.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public Constants.RECORD_TYPES getRecordType() {
    return recordType;
}
 
Example #14
Source File: GlucoseDataSet.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
public Constants.TREND_ARROW_VALUES getTrend() {
    return trend;
}
 
Example #15
Source File: EGVRecord.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
public Constants.TREND_ARROW_VALUES getTrend() {
    return trend;
}
 
Example #16
Source File: EGVRecord.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
public EGVRecord(int bGValue,Constants.TREND_ARROW_VALUES trend,Date displayTime, Date systemTime){
    super(displayTime, systemTime);
    this.bGValue=bGValue;
    this.trend=trend;
}
 
Example #17
Source File: PageHeader.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
public Constants.RECORD_TYPES getRecordType() {
    return recordType;
}
 
Example #18
Source File: Home.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
private void setupCharts() {
    bgGraphBuilder = new BgGraphBuilder(this);
    updateStuff = false;
    chart = (LineChartView) findViewById(R.id.chart);

    chart.setZoomType(ZoomType.HORIZONTAL);

    //Transmitter Battery Level
    final Sensor sensor = Sensor.currentSensor();
    if (sensor != null && sensor.latest_battery_level != 0 && sensor.latest_battery_level <= Constants.TRANSMITTER_BATTERY_LOW && ! mPreferences.getBoolean("disable_battery_warning", false)) {
        Drawable background = new Drawable() {

            @Override
            public void draw(Canvas canvas) {

                DisplayMetrics metrics = getApplicationContext().getResources().getDisplayMetrics();
                int px = (int) (30 * (metrics.densityDpi / 160f));
                Paint paint = new Paint();
                paint.setTextSize(px);
                paint.setAntiAlias(true);
                paint.setColor(Color.parseColor("#FFFFAA"));
                paint.setStyle(Paint.Style.STROKE);
                paint.setAlpha(100);
                canvas.drawText("transmitter battery", 10, chart.getHeight() / 3 - (int) (1.2 * px), paint);
                if(sensor.latest_battery_level <= Constants.TRANSMITTER_BATTERY_EMPTY){
                    paint.setTextSize((int)(px*1.5));
                    canvas.drawText("VERY LOW", 10, chart.getHeight() / 3, paint);
                } else {
                    canvas.drawText("low", 10, chart.getHeight() / 3, paint);
                }
            }

            @Override
            public void setAlpha(int alpha) {}
            @Override
            public void setColorFilter(ColorFilter cf) {}
            @Override
            public int getOpacity() {return 0;}
        };
        chart.setBackground(background);
    }
    previewChart = (PreviewLineChartView) findViewById(R.id.chart_preview);
    previewChart.setZoomType(ZoomType.HORIZONTAL);

    chart.setLineChartData(bgGraphBuilder.lineData());
    chart.setOnValueTouchListener(bgGraphBuilder.getOnValueSelectTooltipListener());
    previewChart.setLineChartData(bgGraphBuilder.previewLineData());
    updateStuff = true;

    previewChart.setViewportCalculationEnabled(true);
    chart.setViewportCalculationEnabled(true);
    previewChart.setViewportChangeListener(new ViewportListener());
    chart.setViewportChangeListener(new ChartViewPortListener());
    setViewport();
}
 
Example #19
Source File: GlucoseDataSet.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public Constants.TREND_ARROW_VALUES getTrend() {
    return trend;
}
 
Example #20
Source File: EGVRecord.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public Constants.TREND_ARROW_VALUES getTrend() {
    return trend;
}
 
Example #21
Source File: EGVRecord.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public EGVRecord(int bGValue,Constants.TREND_ARROW_VALUES trend,Date displayTime, Date systemTime){
    super(displayTime, systemTime);
    this.bGValue=bGValue;
    this.trend=trend;
}
 
Example #22
Source File: PageHeader.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public Constants.RECORD_TYPES getRecordType() {
    return recordType;
}
 
Example #23
Source File: GlucoseDataSet.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public Constants.TREND_ARROW_VALUES getTrend() {
    return trend;
}
 
Example #24
Source File: EGVRecord.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public Constants.TREND_ARROW_VALUES getTrend() {
    return trend;
}
 
Example #25
Source File: EGVRecord.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public EGVRecord(int bGValue,Constants.TREND_ARROW_VALUES trend,Date displayTime, Date systemTime){
    super(displayTime, systemTime);
    this.bGValue=bGValue;
    this.trend=trend;
}
 
Example #26
Source File: PageHeader.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public Constants.RECORD_TYPES getRecordType() {
    return recordType;
}