Skip to content

Update for latest nordic dfu #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 23
compileSdkVersion 29

defaultConfig {
minSdkVersion 21
targetSdkVersion 22
minSdkVersion 19
targetSdkVersion 29
}

buildTypes {
Expand Down
2 changes: 1 addition & 1 deletion src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.microbit.partialflashing"
android:versionCode="1"
android:versionName="1.0" >
android:versionName="1.1" >

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
Expand Down
40 changes: 34 additions & 6 deletions src/main/java/org/microbit/android/partialflashing/HexUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
import android.util.Log;

import java.io.BufferedReader;
import java.io.EOFException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.InterruptedIOException;

import java.util.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;


/**
Expand Down Expand Up @@ -101,6 +97,29 @@ public int searchForData(String search) throws IOException {
// Return -1 if no match
return -1;
}

/*
* A function to search for data in a hex file
* @param the _string_ of data to search for
* @return the index of the data. -1 if not found.
*/
public int searchForDataRegEx(String search) throws IOException {
// Iterate through
ListIterator i = hexLines.listIterator();
while (i.hasNext()) {
// Have to call nextIndex() before next()
int index = i.nextIndex();

// Return index if successful
String match = i.next().toString();
if(match.matches(search)){
return index;
}
}

// Return -1 if no match
return -1;
}

/*
* Returns data from an index
Expand Down Expand Up @@ -130,6 +149,15 @@ public int getRecordAddressFromIndex(int index) throws IOException {
return getRecordAddress(hexLines.get(index));
}

/*
Used to get the data length from a record
@param Record as a String
@return Data length as a decimal / # of chars
*/
public int getRecordDataLengthFromIndex(int index){
return getRecordDataLength(hexLines.get(index));
}

/*
* Returns segment address from an index
* @param index
Expand Down
Loading