Giter Site home page Giter Site logo

juullabs-oss / mcumgr-android Goto Github PK

View Code? Open in Web Editor NEW
50.0 50.0 18.0 1.43 MB

A mobile management library for devices running Apache Mynewt and Zephyr (DFU, logs, stats, config, etc.)

License: Apache License 2.0

Java 85.46% Shell 0.30% Kotlin 14.24%
android ble dfu iot mcumgr mynewt newtmgr zephyr

mcumgr-android's People

Contributors

aditihilbert avatar bgiori avatar giulianofranchetto avatar philips77 avatar ritikakapade avatar twyatt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mcumgr-android's Issues

Sample does not work with Zephyr SMP server

The sample provided in this repo does not work with Zephyr's smp_svr sample. The go implementation does work for me. Any ideas what the issue could be? The output from the sample is

I/McuMgrBleTransport: Connected to FA:1D:5E:72:9D:C3
D/McuMgrBleTransport: wait(1600)
V/McuMgrBleTransport: Discovering services...
D/McuMgrBleTransport: gatt.discoverServices()
D/BluetoothGatt: discoverServices() - device: FA:1D:5E:72:9D:C3
D/BluetoothGatt: onSearchComplete() = Device=FA:1D:5E:72:9D:C3 Status=0
I/McuMgrBleTransport: Services discovered
E/McuMgrBleTransport: Device does not support SMP service
W/McuMgrBleTransport: Device is not supported
V/McuMgrBleTransport: Disconnecting...
D/McuMgrBleTransport: gatt.disconnect()
D/BluetoothGatt: cancelOpen() - device: FA:1D:5E:72:9D:C3
D/BluetoothGatt: onClientConnectionState() - status=0 clientIf=9 device=FA:1D:5E:72:9D:C3
D/McuMgrBleTransport: [Callback] Connection state changed with status: 0 and new state: 0 (DISCONNECTED)
I/McuMgrBleTransport: Disconnected
D/McuMgrBleTransport: gatt.close()

Target
nrf52840dk
Firmware
https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/subsys/mgmt/mcumgr/smp_svr
go implementation
https://github.com/apache/mynewt-mcumgr-cli

Prepare for public

@philips77

I have been given the go-ahead to make this repo public. I think it is ready to go, but if you have objections or any changes you would like to squeeze in, I'm happy to delay. Once you're ready I will tag a release and make the repo public.

TransactionTimeoutException thrown few seconds after upload complete

Hi,
I'm testing mcumgr-android 0.12.0-beta2. In my case I'm flashing the same fw, that's on the device, so Firmware Upgrade Manager immediately transitions to Complete after validating.
Few seconds later I get TransactionTimeoutException with message

Transaction 0 timed out without receiving a response

I believe the exception originates here:

fail(sequenceNumber, TransactionTimeoutException(sequenceNumber))

DFU Image State Edge Case Error

Image state edge case found recently where validate moves to the wrong state (test) causing an McuManagerError BAD_STATE (6).

With the image state as shown below, when an upgrade is started to upgrade to 2.2.2.2 the validate state first checks that the image is not pending (which it is not, since it is confirmed). It then attempts to test, causing the bad state.

{  
   "images":[  
      {  
         "slot":0,
         "version":"1.1.1.1",
         "hash":"vYr+4YhDqREH4EpE/k+58hSgsL8bSLKPSzuAnGf0TPs=",
         "bootable":true,
         "pending":false,
         "confirmed":false,
         "active":true,
         "permanent":false
      },
      {  
         "slot":1,
         "version":"2.2.2.2",
         "hash":"M/h0po2Olfy0enE4X1cXKZsjYLozz+qPffUAaV9UXbQ=",
         "bootable":true,
         "pending":false,
         "confirmed":true,
         "active":false,
         "permanent":false
      }
   ],
   "splitStatus":0,
   "_h":"AQAAAgABAAA="
}

The fix would be to check that the image in slot 1 is confirmed (regardless of the image hash) before the the other slot 1 check for the upload image is made. Then the device would reset and re-do the validate step which would either cause the firmware upgrade to succeed (in the case above) or start the upload.

I can make the fix for this. I just wanted to give myself a reminder.

Errors during RESET step

I have been receiving 2 errors during the reset state:

one is: io.runtime.mcumgr.exception.McuMgrException: UNKNOWN(-5)
the other is: io.runtime.mcumgr.exception.McuMgrException: io.runtime.mcumgr.ble.callback.TransactionTimeoutException: Transaction 2 timed out without receiving a response

I think both are due to the device disconnecting at reset and then taking too long to come back up.
If a subsequent upload of the same firmware is attempted it goes straight to confirm after validate so I think the library is just not waiting long enough after a reset/not retrying if the first connection fails.

Sample app creates new McuMgrTransport each time MainActivity is recreated

In the current version of the sample app, the McuMgrTransport instance


is recreated each time the MainActivity is created, e.g. on orientation changes.
However, as the transport is used in view models, only the first created instance is in fact being used to send/receive data, as all view models are created at the same time together with the MainActivity and live until the user navigates back to the ScannerActivity. On the other hand, MainActivity#onDestroy() was the only place where the transport object was released (device was disconnected), so it phone orientation has changed after it was connected, original transport instance was never released:
@Override
protected void onDestroy() {
super.onDestroy();
if (isFinishing()) {
mMcuMgrTransport.release();
mMcuMgrTransport = null;
}
}

Sample app fails to update nrf52840

Hi,

I tried the sample application to flash a nrf52840 board. However, when I start the DFU, the request goes in timeout.

The "echo" function works, so we are indeed connected to the nrf52.

Will this library be usable with the nrf52840? If so, do you have a milestone for it?

Regards

About License

Hello,

Firstly, thank you for this nice project.
I would like to get some information about licensing ? I suppose it is under BSD like your BLE lib dependency ?

Image in slot 1 confirmed, upgrade can never complete, fails at UPLOAD

There is an image state which remains unhandled in FirmwareUpgradeManager and causes the UPLOAD state to fail every time:

  • Slot 0: version 1.2.3.4
    • active
  • Slot 1: version 3.3.3.3
    • confirmed

In this case, an upload of a different version (e.g. 5.5.5.5) will pass VALIDATE and move on to UPLOAD where it will immediately fail will McuMgrError 2 NO_MEM because the image in slot one cannot be erased to allow the new image to be uploaded.

The solution would be to reset the device, wait for disconnect, then perform the upgrade as per usual.

mcumgr-core could not be found

Following the instructions, using implementation 'io.runtime.mcumgr:mcumgr-ble:0.7-alpha2' in my gradle file gets me an error saying mcumgr-core could not be resolved

changing alpha2 to alpha1 works but I'm assuming there's issues with the older library

Multi-image support

For multi-core CPUs it is required to update all cores in a single DFU procedure. The current impl is always sending the BIN file to secondary slot, even if there are more slots to choose from.
An update is required for mcumgr libs for iOS and Android that will allow an image to be sent to specified partition. Each(!) fw upload packet may contain "image" parameter with the slot number, which defaults to the secondary slot.

The multi-image update should look as follows:

  1. Upload new fw for core 0 to secondary slot
  2. Upload new fw for core 1 to tertiary slot
  3. Repeat until all fw complet
  4. Test / confirm slots
  5. Reset

Additionally, a command may be sent to remove app data if that is not handled by the app automatically (kinda factory reset).

This is a notice about coming changes.

No progress info in 0.12.0-beta3

Hi,
I have tested 0.12.0-beta3 and I don't get any progress updates. The state goes to Uploading and that's the last thing I get. However, the fw seems to be sent after some time, as when I retry it after some time it immediately tests and confirms.

Logs:

D/McuManager(26403): Connecting...
D/McuManager(26403): gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, LE 1M)
D/BluetoothGatt(26403): connect() - device: FC:50:6E:F3:B5:AC, auto: false
D/BluetoothGatt(26403): registerApp()
D/BluetoothGatt(26403): registerApp() - UUID=e454c85d-e76b-406e-903d-aea03222d2f7
D/AA      (26403): onUpgradeStarted
D/UpdateManager(26403): onStateChanged: VALIDATE
D/BluetoothGatt(26403): onClientRegistered() - status=0 clientIf=10
D/BluetoothGatt(26403): onClientConnectionState() - status=0 clientIf=10 device=FC:50:6E:F3:B5:AC
D/McuManager(26403): [Callback] Connection state changed with status: 0 and new state: 2 (CONNECTED)
D/McuManager(26403): Connected to FC:50:6E:F3:B5:AC
D/McuManager(26403): wait(300)
D/McuManager(26403): Discovering services...
D/McuManager(26403): gatt.discoverServices()
D/BluetoothGatt(26403): discoverServices() - device: FC:50:6E:F3:B5:AC
D/BluetoothGatt(26403): onConnectionUpdated() - Device=FC:50:6E:F3:B5:AC interval=6 latency=0 timeout=500 status=0
D/BluetoothGatt(26403): onSearchComplete() = Device=FC:50:6E:F3:B5:AC Status=0
D/McuManager(26403): Services discovered
D/McuManager(26403): Primary service found
D/McuManager(26403): Requesting new MTU...
D/McuManager(26403): gatt.requestMtu(515)
D/BluetoothGatt(26403): configureMTU() - device: FC:50:6E:F3:B5:AC mtu: 515
D/BluetoothGatt(26403): onConfigureMTU() - Device=FC:50:6E:F3:B5:AC mtu=252 status=0
D/McuManager(26403): MTU changed to: 252
D/McuManager(26403): gatt.setCharacteristicNotification(da2e7828-fbce-4e01-ae9e-261174997c48, true)
D/BluetoothGatt(26403): setCharacteristicNotification() - uuid: da2e7828-fbce-4e01-ae9e-261174997c48 enable: true
D/McuManager(26403): Enabling notifications for da2e7828-fbce-4e01-ae9e-261174997c48
D/McuManager(26403): gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x01-00)
D/McuManager(26403): Data written to descr. 00002902-0000-1000-8000-00805f9b34fb, value: (0x) 01-00
D/McuManager(26403): Notifications enabled
D/BluetoothGatt(26403): onConnectionUpdated() - Device=FC:50:6E:F3:B5:AC interval=36 latency=0 timeout=500 status=0
D/McuManager(26403): Sending (10 bytes) Header (Op: 0, Flags: 0, Len: 2, Group: 1, Seq: 0, Command: 0) CBOR {}
D/McuManager(26403): Writing characteristic da2e7828-fbce-4e01-ae9e-261174997c48 (WRITE COMMAND)
D/McuManager(26403): gatt.writeCharacteristic(da2e7828-fbce-4e01-ae9e-261174997c48)
D/McuManager(26403): Data written to da2e7828-fbce-4e01-ae9e-261174997c48, value: (0x) 00-00-00-02-00-01-00-00-BF-FF
D/McuManager(26403): Notification received from da2e7828-fbce-4e01-ae9e-261174997c48, value: (0x) 01-00-00-F4-00-01-00-00-BF-66-69-6D-61-67-65-73-9F-BF-64-73-6C-6F-74-00-67-76-65-72-73-69-6F-6E-65-30-2E-30-2E-30-64-68-61-73-68-58-20-00-DD-D0-C1-31-E9-E7-7C-68-53-FB-92-49-BD-F4-6E-14-95-52-3F-FF-42-00-3D-F3-99-C7-71-2C-F7-C2-69-68-62-6F-6F-74-61-62-6C-65-F5-67-70-65-6E-64-69-6E-67-F4-69-63-6F-6E-66-69-72-6D-65-64-F5-66-61-63-74-69-76-65-F5-69-70-65-72-6D-61-6E-65-6E-74-F4-FF-BF-64-73-6C-6F-74-01-67-76-65-72-73-69-6F-6E-65-30-2E-30-2E-30-64-68-61-73-68-58-20-43-99-C8-8F-0B-D4-3D-BA-13-3E-CD-9F-48-C0-E1-13-98-98-53-13-19-A7-68-2D-89-55-2A-3B-A1-82-2F-A4-68-62-6F-6F-74-61-62-6C-65-F5-67-70-65-6E-64-69-6E-67-F4-69-63-6F-6E-66-69-72-6D-65-64-F4-66-61-63-74-69-76-65-F4-69-70-65-72-6D-61-6E-65-6E-74-F4-FF-FF-6B-73-70-6C-69-74-53-74-61-74-75
D/McuManager(26403): Notification received from da2e7828-fbce-4e01-ae9e-261174997c48, value: (0x) 73-00-FF
D/McuManager(26403): Received Header (Op: 1, Flags: 0, Len: 244, Group: 1, Seq: 0, Command: 0) CBOR {"images":[{"slot":0,"version":"0.0.0","hash":"AN3QwTHp53xoU/uSSb30bhSVUj//QgA985nHcSz3wmk=","bootable":true,"pending":false,"confirmed":true,"active":true,"permanent":false},{"slot":1,"version":"0.0.0","hash":"Q5nIjwvUPboTPs2fSMDhE5iYUxMZp2gtiVUqO6GCL6Q=","bootable":true,"pending":false,"confirmed":false,"active":false,"permanent":false}],"splitStatus":0}
D/UpdateManager(26403): onStateChanged: UPLOAD
D/BluetoothGatt(26403): onConnectionUpdated() - Device=FC:50:6E:F3:B5:AC interval=36 latency=0 timeout=42 status=0

Complete nullability annotations

Some classes/utilities do not have nullability annotations. These need to be added and any possible null pointer exceptions fixed.

CancelUpload only works if the upload is already paused

Hello everyone!

Using the ImageManager i tried to cancel a upload using its cancelUpload() method, but i still got callbacks after doing so. I inspected the code and saw that the upload is only fully cancelled if the file transfer was paused to begin with:

    public synchronized void cancelUpload() {
        if (mUploadState == STATE_NONE) {
            LOG.debug("Image upload is not in progress");
        } else if (mUploadState == STATE_PAUSED) {
            LOG.debug("Upload canceled!");
            resetUpload();
            mUploadCallback.onUploadCanceled();
            mUploadCallback = null;
        }
        mUploadState = STATE_NONE;
    }

My question: Is this the intended design? - Shouldn't the upload be cancelled also if the upload is currently in progress and not paused? Like so:

    public synchronized void cancelUpload() {
        if (mUploadState == STATE_NONE) {
            LOG.debug("Image upload is not in progress");
        } else if (mUploadState == STATE_PAUSED || mUploadState == STATE_UPLOADING) {
            LOG.debug("Upload canceled!");
            resetUpload();
            mUploadCallback.onUploadCanceled();
            mUploadCallback = null;
        }
        mUploadState = STATE_NONE;
    }

I can create a PR if you'd like.
Thanks

crashing on FirmwareUpgradeManager start()

When I call the start() function the app crashes. Errors are not really clear, maybe someone can help me out. I select a file, read it as bytes, then start(). My firmware file has .bin file extension (if that makes any difference). I don't think it is a problem with my phone, since I can update firmware using nRF Connect, but my code crashes. Thank you.

MyCode
public class FlashActivity extends AppCompatActivity {
    TextView fileText;
    private Uri fileUri;
    private String filePath;
    BluetoothDevice bluetoothDevice;
    File file;
    byte[] bytes;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        final Intent intent = getIntent();
        bluetoothDevice = (BluetoothDevice) intent.getExtras().get("Device");

        setContentView(R.layout.activity_flash);
    }

    public void selectFile(View v){
        Intent chooseFile = new Intent(Intent.ACTION_GET_CONTENT);
        chooseFile.setType("*/*");
        chooseFile = Intent.createChooser(chooseFile, "Choose a file");
        startActivityForResult(chooseFile, 1);
    }





    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case 1:
                if (resultCode == -1) {


                    fileUri = data.getData();
                    filePath = fileUri.getPath();
                    file = new File(fileUri.getPath());
                    try {

                        InputStream ips = getContentResolver().openInputStream(fileUri);

                        bytes = new byte[ips.available()];
                        ips.read(bytes, 0, bytes.length);

                        fileText = findViewById(R.id.fileText);
                        fileText.setText(filePath);
                    } catch (FileNotFoundException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }

                    break;
                }
        }
    }

    public void clickFlash(View v) throws McuMgrException, IOException {
        McuMgrTransport transport = new McuMgrBleTransport(this, bluetoothDevice);
        FirmwareUpgradeManager dfuManager = new FirmwareUpgradeManager(transport);

        dfuManager.start(bytes);
    }


}
Logs
W/System.err: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
W/System.err: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
W/System: A resource failed to call close. 
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.safety_app, PID: 32495
    java.lang.IllegalStateException: Could not execute method for android:onClick
        at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:414)
        at android.view.View.performClick(View.java:6608)
        at android.view.View.performClickInternal(View.java:6585)
        at android.view.View.access$3100(View.java:785)
        at android.view.View$PerformClick.run(View.java:25921)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:201)
        at android.app.ActivityThread.main(ActivityThread.java:6810)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:409)
        at android.view.View.performClick(View.java:6608) 
        at android.view.View.performClickInternal(View.java:6585) 
        at android.view.View.access$3100(View.java:785) 
        at android.view.View$PerformClick.run(View.java:25921) 
        at android.os.Handler.handleCallback(Handler.java:873) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:201) 
        at android.app.ActivityThread.main(ActivityThread.java:6810) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873) 
     Caused by: java.lang.BootstrapMethodError: Exception from call site #67 bootstrap method
        at no.nordicsemi.android.ble.Request.notifyStarted(Request.java:1175)
        at no.nordicsemi.android.ble.TimeoutableRequest.notifyStarted(TimeoutableRequest.java:195)
        at no.nordicsemi.android.ble.BleManagerHandler.nextRequest(BleManagerHandler.java:2857)
        at no.nordicsemi.android.ble.BleManagerHandler.enqueue(BleManagerHandler.java:1161)
        at no.nordicsemi.android.ble.Request.enqueue(Request.java:1166)
        at no.nordicsemi.android.ble.TimeoutableRequest.enqueue(TimeoutableRequest.java:76)
        at io.runtime.mcumgr.ble.McuMgrBleTransport.send(McuMgrBleTransport.java:380)
        at io.runtime.mcumgr.McuManager.send(McuManager.java:259)
        at io.runtime.mcumgr.McuManager.send(McuManager.java:216)
        at io.runtime.mcumgr.McuManager.send(McuManager.java:168)
        at io.runtime.mcumgr.managers.ImageManager.list(ImageManager.java:88)
        at io.runtime.mcumgr.dfu.FirmwareUpgradeManager.validate(FirmwareUpgradeManager.java:337)
        at io.runtime.mcumgr.dfu.FirmwareUpgradeManager.start(FirmwareUpgradeManager.java:275)
        at com.example.safety_app.FlashActivity.clickFlash(FlashActivity.java:101)
        at java.lang.reflect.Method.invoke(Native Method) 
        at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:409) 
        at android.view.View.performClick(View.java:6608) 
        at android.view.View.performClickInternal(View.java:6585) 
        at android.view.View.access$3100(View.java:785) 
        at android.view.View$PerformClick.run(View.java:25921) 
        at android.os.Handler.handleCallback(Handler.java:873) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:201) 
        at android.app.ActivityThread.main(ActivityThread.java:6810) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873) 
     Caused by: java.lang.ClassCastException: Bootstrap method returned null
        at no.nordicsemi.android.ble.Request.notifyStarted(Request.java:1175) 
        at no.nordicsemi.android.ble.TimeoutableRequest.notifyStarted(TimeoutableRequest.java:195) 
        at no.nordicsemi.android.ble.BleManagerHandler.nextRequest(BleManagerHandler.java:2857) 
        at no.nordicsemi.android.ble.BleManagerHandler.enqueue(BleManagerHandler.java:1161) 
        at no.nordicsemi.android.ble.Request.enqueue(Request.java:1166) 
        at no.nordicsemi.android.ble.TimeoutableRequest.enqueue(TimeoutableRequest.java:76) 
        at io.runtime.mcumgr.ble.McuMgrBleTransport.send(McuMgrBleTransport.java:380) 
        at io.runtime.mcumgr.McuManager.send(McuManager.java:259) 
        at io.runtime.mcumgr.McuManager.send(McuManager.java:216) 
        at io.runtime.mcumgr.McuManager.send(McuManager.java:168) 
        at io.runtime.mcumgr.managers.ImageManager.list(ImageManager.java:88) 
        at io.runtime.mcumgr.dfu.FirmwareUpgradeManager.validate(FirmwareUpgradeManager.java:337) 
        at io.runtime.mcumgr.dfu.FirmwareUpgradeManager.start(FirmwareUpgradeManager.java:275) 
        at com.example.safety_app.FlashActivity.clickFlash(FlashActivity.java:101) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:409) 
        at android.view.View.performClick(View.java:6608) 
        at android.view.View.performClickInternal(View.java:6585) 
        at android.view.View.access$3100(View.java:785) 
        at android.view.View$PerformClick.run(View.java:25921) 
        at android.os.Handler.handleCallback(Handler.java:873) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:201) 
        at android.app.ActivityThread.main(ActivityThread.java:6810) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873) 

DefaultManager should be renamed in next major release.

The name for managing the device operating system (DefaultManager) is bad, and doesn't match the actual functionality of the command group. This should be renamed something like OsManager, SystemManager, or OperatingSystemManager.

requiresDefragmentation in McuMgrResponse is lying

Check out combination of those 2 methods:

public static boolean requiresDefragmentation(@NotNull McuMgrScheme scheme, @NotNull byte[] bytes)
throws IOException {
if (scheme.isCoap()) {
throw new UnsupportedOperationException("Method not implemented for CoAP");
} else {
int expectedLength = getExpectedLength(scheme, bytes);
return (expectedLength > (bytes.length - McuMgrHeader.HEADER_LENGTH));
}
}
public static int getExpectedLength(@NotNull McuMgrScheme scheme, @NotNull byte[] bytes)
throws IOException {
if (scheme.isCoap()) {
throw new UnsupportedOperationException("Method not implemented for CoAP");
} else {
byte[] headerBytes = Arrays.copyOf(bytes, McuMgrHeader.HEADER_LENGTH);
McuMgrHeader header = McuMgrHeader.fromBytes(headerBytes);
if (header == null) {
throw new IOException("Invalid McuMgrHeader");
}
return header.getLen() + McuMgrHeader.HEADER_LENGTH;
}
}

The getExpectedLength(...) returns expected length of the packet including header (header length is added).
However, requiresDefragmentation(...) deducts the header length in the comparison.

Comprehensive Unit Tests

We need a mock transport adapter to "respond" to requests in order to test formatting and logic.

LogManager response with invalid format

Hi,

I'm trying to get the logs from a device using the LogManager, and while trying to getAllFromState(State) or manager.getAll() I'm getting an exception on the parse of an entry on the response object.

The Object is McuMgrLogResponse.Entry and the property that I'm getting the error is msg because the format is in Byte[] and I'm receiving it as String.

Does this error has something to do with any Mynewt updates that are breaking the SDK?

Thank you

onUpgradFailed gets called but update continues

The callback:

public void onUpgradeFailed(FirmwareUpgradeManager.State state, McuMgrException error);

gets called. state.toString() is "VALIDATE" and error.getMessage() is "Payload (10 bytes) too long for MTU: 0"

However, the device keeps going through the update process. The next state is "UPLOAD"

Upgrade reverts to old image when device is restarted

I see the device revert its image after the library reports a successful upgrade. The library reports all stages of the upgrade succeeded (onUpgradeCompleted is invoked), but afterward, when the device is turned off and turned on again, the firmware reverts to the image prior to the upgrade. What could be causing this behavior?

Version: McuManager BLE 0.11.0
Android Version: 12

2021-11-04 13:26:53.150 [main] TRACE FirmwareUpgradeManager - Moving from state RESET to state CONFIRM
2021-11-04 13:26:53.153 [main] DEBUG RadioFirmwareUpdater - onStateChanged: old=RESET, new=CONFIRM
2021-11-04 13:26:53.154 [main] TRACE McuMgrBleTransport - Writing characteristic da2e7828-fbce-4e01-ae9e-261174997c48 (WRITE COMMAND)
2021-11-04 13:26:53.155 [main] DEBUG McuMgrBleTransport - gatt.writeCharacteristic(da2e7828-fbce-4e01-ae9e-261174997c48)
2021-11-04 13:26:53.160 [Binder:18103_1] INFO  McuMgrBleTransport - Data written to da2e7828-fbce-4e01-ae9e-261174997c48, value: (0x) 02-00-00-0B-00-01-00-00-BF-67-63-6F-6E-66-69-72-6D-F5-FF
2021-11-04 13:26:53.191 [Binder:18103_1] INFO  McuMgrBleTransport - Notification received from da2e7828-fbce-4e01-ae9e-261174997c48, value: (0x) 03-00-00-87-00-01-00-00-BF-66-69-6D-61-67-65-73-9F-BF-64-73-6C-6F-74-00-67-76-65-72-73-69-6F-6E-66-33-2E-36-2E-31-31-64-68-61-73-68-58-20-71-84-15-ED-C9-E1-A5-B9-96-9E-3D-49-7F-B6-56-AA-C2-03-6F-C0-37-50-CA-05-69-06-A0-23-E8-CB-05-4F-68-62-6F-6F-74-61-62-6C-65-F5-67-70-65-6E-64-69-6E-67-F4-69-63-6F-6E-66-69-72-6D-65-64-F5-66-61-63-74-69-76-65-F5-69-70-65-72-6D-61-6E-65-6E-74-F4-FF-FF-6B-73-70-6C-69-74-53-74-61-74-75-73-00-FF
2021-11-04 13:26:53.201 [main] TRACE FirmwareUpgradeManager - Confirm response: {"images":[{"slot":0,"version":"3.6.11","hash":"cYQV7cnhpbmWnj1Jf7ZWqsIDb8A3UMoFaQagI+jLBU8=","bootable":true,"pending":false,"confirmed":true,"active":true,"permanent":false}],"splitStatus":0}
2021-11-04 13:26:53.203 [main] DEBUG RadioFirmwareUpdater - onUpgradeCompleted

Sample App fails to update nrf52840

Similar issue as #49 cannot update nrf52840 using the sample app, tried to use both ImageManager and FirmwareUpgradeManager

I believe this is an issue with the android implementation since the iOS sample app works flawlessly on the same device. I tried it with both 0.11.0 and 0.12.0-beta4 same problem exists on both versions.

here's the pastebin containing Logcat logs, please let me know any additional info I can provide to help with this issue.

Below is the screenshot of the app when the upload fails.
2021-08-24-19-12-18

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.