Java Code Examples for com.eveningoutpost.dexdrip.ImportedLibraries.dexcom.Utils

The following examples show how to use com.eveningoutpost.dexdrip.ImportedLibraries.dexcom.Utils. These examples are extracted from open source projects. 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 Project: xDrip   Source File: PageHeader.java    License: 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 Project: xDrip   Source File: PageHeader.java    License: 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 = Dex_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- Dex_Constants.CRC_LEN,crc,0, Dex_Constants.CRC_LEN);
    byte[] crc_calc = CRC16.calculate(packet,0,HEADER_SIZE - Dex_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 Project: xDrip-plus   Source File: PageHeader.java    License: 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 Project: xDrip-plus   Source File: PageHeader.java    License: 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 = Dex_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- Dex_Constants.CRC_LEN,crc,0, Dex_Constants.CRC_LEN);
    byte[] crc_calc = CRC16.calculate(packet,0,HEADER_SIZE - Dex_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
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 6
Source Project: xDrip   Source File: PageHeader.java    License: 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 7
Source Project: xDrip   Source File: CalSubrecord.java    License: GNU General Public License v3.0 5 votes vote down vote up
public CalSubrecord(byte[] packet, long displayTimeOffset) {
    int delta = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt();
    dateEntered = Utils.receiverTimeToDate(delta + displayTimeOffset);
    calBGL = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(4);
    calRaw = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(8);
    delta = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(12);
    dateApplied = Utils.receiverTimeToDate(delta + displayTimeOffset);
    unk = packet[16];
}
 
Example 8
Source Project: xDrip   Source File: CalSubrecord.java    License: GNU General Public License v3.0 5 votes vote down vote up
public CalSubrecord(byte[] packet, long displayTimeOffset) {
    int delta = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt();
    dateEntered = Utils.receiverTimeToDate(delta + displayTimeOffset);
    calBGL = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(4);
    calRaw = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(8);
    delta = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(12);
    dateApplied = Utils.receiverTimeToDate(delta + displayTimeOffset);
    unk = packet[16];
}
 
Example 9
Source Project: xDrip-plus   Source File: CalSubrecord.java    License: GNU General Public License v3.0 5 votes vote down vote up
public CalSubrecord(byte[] packet, long displayTimeOffset) {
    int delta = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt();
    dateEntered = Utils.receiverTimeToDate(delta + displayTimeOffset);
    calBGL = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(4);
    calRaw = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(8);
    delta = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(12);
    dateApplied = Utils.receiverTimeToDate(delta + displayTimeOffset);
    unk = packet[16];
}
 
Example 10
Source Project: xDrip-plus   Source File: CalSubrecord.java    License: GNU General Public License v3.0 5 votes vote down vote up
public CalSubrecord(byte[] packet, long displayTimeOffset) {
    int delta = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt();
    dateEntered = Utils.receiverTimeToDate(delta + displayTimeOffset);
    calBGL = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(4);
    calRaw = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(8);
    delta = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(12);
    dateApplied = Utils.receiverTimeToDate(delta + displayTimeOffset);
    unk = packet[16];
}
 
Example 11
public CalSubrecord(byte[] packet, long displayTimeOffset) {
    int delta = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt();
    dateEntered = Utils.receiverTimeToDate(delta + displayTimeOffset);
    calBGL = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(4);
    calRaw = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(8);
    delta = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(12);
    dateApplied = Utils.receiverTimeToDate(delta + displayTimeOffset);
    unk = packet[16];
}
 
Example 12
Source Project: xDrip   Source File: CalSubrecord.java    License: GNU General Public License v3.0 5 votes vote down vote up
public CalSubrecord(byte[] packet, long displayTimeOffset) {
    int delta = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt();
    dateEntered = Utils.receiverTimeToDate(delta + displayTimeOffset);
    calBGL = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(4);
    calRaw = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(8);
    delta = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(12);
    dateApplied = Utils.receiverTimeToDate(delta + displayTimeOffset);
    unk = packet[16];
}
 
Example 13
Source Project: xDrip   Source File: GenericTimestampRecord.java    License: GNU General Public License v3.0 4 votes vote down vote up
public GenericTimestampRecord(byte[] packet) {
    systemTimeSeconds = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(OFFSET_SYS_TIME);
    systemTime = Utils.receiverTimeToDate(systemTimeSeconds);
    int dt = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(OFFSET_DISPLAY_TIME);
    displayTime = Utils.receiverTimeToDate(dt);
}
 
Example 14
Source Project: xDrip   Source File: GenericTimestampRecord.java    License: GNU General Public License v3.0 4 votes vote down vote up
public GenericTimestampRecord(byte[] packet) {
    systemTimeSeconds = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(OFFSET_SYS_TIME);
    systemTime = Utils.receiverTimeToDate(systemTimeSeconds);
    int dt = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(OFFSET_DISPLAY_TIME);
    displayTime = Utils.receiverTimeToDate(dt);
}
 
Example 15
public GenericTimestampRecord(byte[] packet) {
    systemTimeSeconds = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(OFFSET_SYS_TIME);
    systemTime = Utils.receiverTimeToDate(systemTimeSeconds);
    int dt = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(OFFSET_DISPLAY_TIME);
    displayTime = Utils.receiverTimeToDate(dt);
}
 
Example 16
public GenericTimestampRecord(byte[] packet) {
    systemTimeSeconds = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(OFFSET_SYS_TIME);
    systemTime = Utils.receiverTimeToDate(systemTimeSeconds);
    int dt = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(OFFSET_DISPLAY_TIME);
    displayTime = Utils.receiverTimeToDate(dt);
}
 
Example 17
public GenericTimestampRecord(byte[] packet) {
    systemTimeSeconds = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(OFFSET_SYS_TIME);
    systemTime = Utils.receiverTimeToDate(systemTimeSeconds);
    int dt = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(OFFSET_DISPLAY_TIME);
    displayTime = Utils.receiverTimeToDate(dt);
}
 
Example 18
Source Project: xDrip   Source File: GenericTimestampRecord.java    License: GNU General Public License v3.0 4 votes vote down vote up
public GenericTimestampRecord(byte[] packet) {
    systemTimeSeconds = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(OFFSET_SYS_TIME);
    systemTime = Utils.receiverTimeToDate(systemTimeSeconds);
    int dt = ByteBuffer.wrap(packet).order(ByteOrder.LITTLE_ENDIAN).getInt(OFFSET_DISPLAY_TIME);
    displayTime = Utils.receiverTimeToDate(dt);
}