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

The following examples show how to use com.eveningoutpost.dexdrip.ImportedLibraries.dexcom.Utils. 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 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 = 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 #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: 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 #6
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 = 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 #7
Source File: CalSubrecord.java    From xDrip-plus with 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 File: CalSubrecord.java    From xDrip with 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 File: CalSubrecord.java    From xDrip-Experimental with 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 File: CalSubrecord.java    From xDrip with 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
Source File: CalSubrecord.java    From xDrip-plus with 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 #12
Source File: CalSubrecord.java    From xDrip with 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 File: GenericTimestampRecord.java    From xDrip-plus with 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 File: GenericTimestampRecord.java    From xDrip-plus with 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
Source File: GenericTimestampRecord.java    From xDrip with 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 #16
Source File: GenericTimestampRecord.java    From xDrip-Experimental with 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 #17
Source File: GenericTimestampRecord.java    From xDrip with 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 #18
Source File: GenericTimestampRecord.java    From xDrip with 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);
}