12
12
import android .bluetooth .BluetoothGattService ;
13
13
import android .bluetooth .BluetoothManager ;
14
14
import android .bluetooth .BluetoothProfile ;
15
- import android .bluetooth .BluetoothStatusCodes ;
16
15
import android .content .BroadcastReceiver ;
17
16
import android .content .Context ;
18
17
import android .content .Intent ;
28
27
import java .io .IOException ;
29
28
import java .lang .reflect .Method ;
30
29
import java .util .Arrays ;
31
- import java .util .List ;
32
30
import java .util .UUID ;
33
31
34
32
/**
@@ -70,7 +68,6 @@ public PartialFlashingBaseService() {
70
68
71
69
/* Receive updates on user interaction */
72
70
private BroadcastReceiver broadcastReceiver = new BroadcastReceiver () {
73
-
74
71
@ Override
75
72
public void onReceive (Context context , final Intent intent ) {
76
73
logi ( "Received Broadcast: " + intent .toString ());
@@ -106,36 +103,27 @@ public void onDestroy() {
106
103
}
107
104
108
105
private void sendProgressBroadcast (final int progress ) {
109
-
110
106
logi ( "Sending progress broadcast: " + progress + "%" );
111
-
112
107
final Intent broadcast = new Intent (BROADCAST_PROGRESS );
113
108
broadcast .putExtra (EXTRA_PROGRESS , progress );
114
-
115
109
LocalBroadcastManager .getInstance (this ).sendBroadcast (broadcast );
116
110
}
117
111
118
112
private void sendProgressBroadcastStart () {
119
-
120
113
logi ( "Sending progress broadcast start" );
121
-
122
114
final Intent broadcast = new Intent (BROADCAST_START );
123
-
124
115
LocalBroadcastManager .getInstance (this ).sendBroadcast (broadcast );
125
116
}
126
117
127
118
private void sendProgressBroadcastComplete () {
128
-
129
119
logi ( "Sending progress broadcast complete" );
130
-
131
120
final Intent broadcast = new Intent (BROADCAST_COMPLETE );
132
-
133
121
LocalBroadcastManager .getInstance (this ).sendBroadcast (broadcast );
134
122
}
135
123
136
124
@ Override
137
125
protected void onHandleIntent (@ Nullable Intent intent ) {
138
- logi ("onHandleIntent" );
126
+ logi ( "onHandleIntent" );
139
127
140
128
final String filePath = intent .getStringExtra ("filepath" );
141
129
final String deviceAddress = intent .getStringExtra ("deviceAddress" );
@@ -193,10 +181,8 @@ protected boolean isDebug() {
193
181
194
182
private BluetoothManager mBluetoothManager ;
195
183
private BluetoothAdapter mBluetoothAdapter ;
196
- private String mBluetoothDeviceAddress ;
197
184
private BluetoothGatt mBluetoothGatt = null ;
198
185
private int mConnectionState = STATE_DISCONNECTED ;
199
- private BluetoothDevice device ;
200
186
private boolean descriptorWriteSuccess = false ;
201
187
BluetoothGattDescriptor descriptorRead = null ;
202
188
boolean descriptorReadSuccess = false ;
@@ -215,10 +201,6 @@ protected boolean isDebug() {
215
201
216
202
private byte packetState = PACKET_STATE_WAITING ;
217
203
218
- // Used to lock the program state while we wait for a Bluetooth operation to complete
219
- private static final boolean BLE_WAITING = false ;
220
- private static final boolean BLE_READY = true ;
221
-
222
204
private static final int STATE_DISCONNECTED = 0 ;
223
205
private static final int STATE_CONNECTING = 1 ;
224
206
private static final int STATE_CONNECTED = 2 ;
@@ -245,17 +227,13 @@ protected boolean isDebug() {
245
227
// Partial Flashing Commands
246
228
private static final byte REGION_INFO_COMMAND = 0x0 ;
247
229
private static final byte FLASH_COMMAND = 0x1 ;
248
- Boolean notificationReceived ;
249
-
250
- // Regions
251
- String [] regions = {"SoftDevice" , "DAL" , "MakeCode" };
252
230
253
231
// Microbit Type
254
232
private final int MICROBIT_V1 = 1 ;
255
233
private final int MICROBIT_V2 = 2 ;
256
234
int hardwareType = MICROBIT_V1 ;
257
235
258
- // Partial Flashing Return Vals
236
+ // Partial Flashing Return Values
259
237
private static final int PF_SUCCESS = 0x0 ;
260
238
private static final int PF_ATTEMPT_DFU = 0x1 ;
261
239
private static final int PF_FAILED = 0x2 ;
0 commit comments