Skip to content

Commit 492e738

Browse files
authored
Merge pull request #1 from microbit-foundation/update-for-latest-nordic-dfu
Update for latest nordic dfu
2 parents 9ce5c6a + 3b389a2 commit 492e738

File tree

4 files changed

+390
-110
lines changed

4 files changed

+390
-110
lines changed

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 23
4+
compileSdkVersion 29
55

66
defaultConfig {
7-
minSdkVersion 21
8-
targetSdkVersion 22
7+
minSdkVersion 19
8+
targetSdkVersion 29
99
}
1010

1111
buildTypes {

src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="org.microbit.partialflashing"
33
android:versionCode="1"
4-
android:versionName="1.0" >
4+
android:versionName="1.1" >
55

66
<uses-permission android:name="android.permission.BLUETOOTH" />
77
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

src/main/java/org/microbit/android/partialflashing/HexUtils.java

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@
33
import android.util.Log;
44

55
import java.io.BufferedReader;
6-
import java.io.EOFException;
76
import java.io.FileInputStream;
87
import java.io.FileNotFoundException;
98
import java.io.IOException;
109
import java.io.InputStreamReader;
11-
import java.io.InterruptedIOException;
12-
13-
import java.util.*;
14-
import java.util.List;
1510
import java.util.ArrayList;
16-
import java.util.Iterator;
11+
import java.util.List;
12+
import java.util.ListIterator;
1713

1814

1915
/**
@@ -101,6 +97,29 @@ public int searchForData(String search) throws IOException {
10197
// Return -1 if no match
10298
return -1;
10399
}
100+
101+
/*
102+
* A function to search for data in a hex file
103+
* @param the _string_ of data to search for
104+
* @return the index of the data. -1 if not found.
105+
*/
106+
public int searchForDataRegEx(String search) throws IOException {
107+
// Iterate through
108+
ListIterator i = hexLines.listIterator();
109+
while (i.hasNext()) {
110+
// Have to call nextIndex() before next()
111+
int index = i.nextIndex();
112+
113+
// Return index if successful
114+
String match = i.next().toString();
115+
if(match.matches(search)){
116+
return index;
117+
}
118+
}
119+
120+
// Return -1 if no match
121+
return -1;
122+
}
104123

105124
/*
106125
* Returns data from an index
@@ -130,6 +149,15 @@ public int getRecordAddressFromIndex(int index) throws IOException {
130149
return getRecordAddress(hexLines.get(index));
131150
}
132151

152+
/*
153+
Used to get the data length from a record
154+
@param Record as a String
155+
@return Data length as a decimal / # of chars
156+
*/
157+
public int getRecordDataLengthFromIndex(int index){
158+
return getRecordDataLength(hexLines.get(index));
159+
}
160+
133161
/*
134162
* Returns segment address from an index
135163
* @param index

0 commit comments

Comments
 (0)