mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-29 13:26:50 +01:00
improved file upload error handling
This commit is contained in:
parent
f5c8ea39b1
commit
c99a3c91b5
@ -375,6 +375,11 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean handleFileUploadCharacteristic(BluetoothGattCharacteristic characteristic) {
|
private boolean handleFileUploadCharacteristic(BluetoothGattCharacteristic characteristic) {
|
||||||
|
if(uploadFileRequest == null){
|
||||||
|
logger.debug("no uploadFileRequest to handle response");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
uploadFileRequest.handleResponse(characteristic);
|
uploadFileRequest.handleResponse(characteristic);
|
||||||
|
|
||||||
switch (uploadFileRequest.state){
|
switch (uploadFileRequest.state){
|
||||||
@ -388,6 +393,7 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
break;
|
break;
|
||||||
case UPLOADED:
|
case UPLOADED:
|
||||||
buttonOverwriteListener.OnButtonOverwrite(true);
|
buttonOverwriteListener.OnButtonOverwrite(true);
|
||||||
|
uploadFileRequest = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -409,15 +415,15 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
Intent i = new Intent(QHYBRID_EVENT_BUTTON_PRESS);
|
Intent i = new Intent(QHYBRID_EVENT_BUTTON_PRESS);
|
||||||
i.putExtra("BUTTON", button);
|
i.putExtra("BUTTON", button);
|
||||||
|
|
||||||
ByteBuffer buffer = ByteBuffer.allocate(16);
|
//ByteBuffer buffer = ByteBuffer.allocate(16);
|
||||||
buffer.put(new byte[]{0x01, 0x00, 0x08});
|
//buffer.put(new byte[]{0x01, 0x00, 0x08});
|
||||||
buffer.put(value, 2, 8);
|
//buffer.put(value, 2, 8);
|
||||||
buffer.put(new byte[]{(byte)0xFF, 0x05, 0x00, 0x01, 0x00});
|
//buffer.put(new byte[]{(byte)0xFF, 0x05, 0x00, 0x01, 0x00});
|
||||||
|
|
||||||
UploadFileRequest request = new UploadFileRequest((short)0, buffer.array());
|
//UploadFileRequest request = new UploadFileRequest((short)0, buffer.array());
|
||||||
for(byte[] packet : request.packets){
|
//for(byte[] packet : request.packets){
|
||||||
new TransactionBuilder("File upload").write(getCharacteristic(UUID.fromString("3dda0007-957f-7d4a-34a6-74696673696d")), packet).queue(getQueue());
|
// new TransactionBuilder("File upload").write(getCharacteristic(UUID.fromString("3dda0007-957f-7d4a-34a6-74696673696d")), packet).queue(getQueue());
|
||||||
}
|
//}
|
||||||
|
|
||||||
getContext().sendBroadcast(i);
|
getContext().sendBroadcast(i);
|
||||||
}
|
}
|
||||||
|
@ -38,11 +38,13 @@ public class UploadFileRequest extends Request {
|
|||||||
if (value.length == 4) {
|
if (value.length == 4) {
|
||||||
if (value[1] != 0) {
|
if (value[1] != 0) {
|
||||||
state = UploadState.ERROR;
|
state = UploadState.ERROR;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
state = UploadState.UPLOAD;
|
state = UploadState.UPLOAD;
|
||||||
}else if(value.length == 9){
|
}else if(value.length == 9){
|
||||||
if(value[1] != 0){
|
if(value[1] != 0){
|
||||||
state = UploadState.ERROR;
|
state = UploadState.ERROR;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
state = UploadState.UPLOADED;
|
state = UploadState.UPLOADED;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user