@@ -624,7 +624,7 @@ protected Tag doInBackground(Tag... params) {
624624 }
625625
626626 SensorType sensorType = LibreOOPAlgorithm .getSensorType (patchInfo );
627- if (addressed && sensorType != SensorType .Libre1 ) {
627+ if (addressed && sensorType != SensorType .Libre1 && sensorType != SensorType . Libre1New ) {
628628 Log .d (TAG , "Not using addressed mode since not a libre 1 sensor" );
629629 addressed = false ;
630630 }
@@ -636,15 +636,21 @@ protected Tag doInBackground(Tag... params) {
636636 }
637637
638638 if (multiblock ) {
639- Log .e (TAG , "starting multiple blobk reads" );
640- final int correct_reply_size = addressed ? 28 : 25 ;
641- for (int i = 0 ; i <= 43 ; i = i + 3 ) {
639+ Log .e (TAG , "starting multiple block reads" );
640+ for (int i = 0 ; i < 43 ; i = i + 3 ) {
641+ int read_blocks = 3 ;
642+ int correct_reply_size = addressed ? 28 : 25 ;
643+ if (i == 42 && sensorType == SensorType .Libre2 ) {
644+ read_blocks = 1 ;
645+ correct_reply_size = 9 ;
646+ }
647+
642648 final byte [] cmd ;
643649 if (addressed ) {
644- cmd = new byte []{0x60 , 0x23 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , (byte ) i , 0x02 };
650+ cmd = new byte []{0x60 , 0x23 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , (byte ) i , ( byte ) ( read_blocks - 1 ) };
645651 System .arraycopy (uid , 0 , cmd , 2 , 8 );
646652 } else {
647- cmd = new byte []{0x02 , 0x23 , (byte ) i , 0x02 };
653+ cmd = new byte []{0x02 , 0x23 , (byte ) i , ( byte ) ( read_blocks - 1 ) };
648654 }
649655
650656 byte [] replyBlock ;
@@ -681,7 +687,7 @@ protected Tag doInBackground(Tag... params) {
681687 return null ;
682688 }
683689 if (addressed ) {
684- for (int j = 0 ; j < 3 ; j ++) {
690+ for (int j = 0 ; j < read_blocks ; j ++) {
685691 System .arraycopy (replyBlock , 2 + (j * 9 ), data , i * 8 + (j * 8 ), 8 );
686692 }
687693 } else {
0 commit comments