NimBLE: Exchanging MTU breaks when maximum number of concurrent connections is set to 1

2022-12-07 Thread Henry Hunt
Hi all,

I’m working on an ESP32-based Bluetooth LE peripheral using the NimBLE stack 
(ESP-IDF version 4.4.2) and have come across an issue that occurs when the 
maximum number of concurrent connections is set to 1 (but not 2 or 3). In this 
case, performing an MTU exchange only works once ever, until the device is 
power cycled. Following that second MTU exchange, other BLE operations (such as 
service discovery or reading characteristics) that are done during the same 
connection do not succeed.

The issue is easily reproducible with the existing bleprph example:


  *   Create a new ESP project using the bleprph template
  *   In SDKConfig, change “maximum number of concurrent connections” from 3 to 
1
  *   Using the nRF Connect mobile app:
 *   Connect to the peripheral
 *   Request an MTU exchange from the menu. The requested MTU value is 
shown in the ESP serial output.
 *   Disconnect, reconnect, and perform another MTU exchange. The MTU value 
(which comes from the BLE_GAP_EVENT_MTU event) shown in the ESP serial output 
is 0.
 *   Select “read characteristics” in the menu. See that there is a GATT 
error of 0x85 after some time and the connection terminates.
 *   Reconnect and try "read characteristics" again. See that it completes 
successfully.
 *   Perform another MTU exchange and see 0 in the ESP serial output
 *   Try "read characteristics" again and see that it fails.

Thoughts?

Thanks,
Henry


Re: newtmgr OTA error: slice bounds out of range [:-62]

2022-12-07 Thread Szymon Janc
Hi,

We are able to reproduce this on newtmgr master (1.11-dev), will try to fix
this before next release

On Fri, 16 Sept 2022 at 03:22, Mo Chen  wrote:

> Hi there,
>
> I encountered errors when using mynewt to DFU OTA.
>
> Environment:
> Intel Macbook pro
> MacOS: Monterey 12.5.1
>
> newt version: 1.10.0
> newtmgr version: tried with v1.10.0 and v1.9.0. Neither works with the same
> error.
>
> Any clues or help are highly appreciated!
>
>
> error message:
>
> mndrive@Mos-MBP-MnDRIVE ~ % newtmgr image upload -c testbrd
>
> /Users/xxx/Documents/Mynewt/test/bin/targets/testbrd/app/apps/testbrd/testbrd.img
>
>  0 / 163232 [--]
>   0.00%panic:
> runtime error: slice bounds out of range [:-62]
>
>
> goroutine 1 [running]:
>
> mynewt.apache.org/newtmgr/nmxact/xact.encodeUploadReq({0x451a240
> 
> ?,
> 0xc000304320?}, {0xc2e140?, 0x42bd8c6?, 0x5ba48ab08a0c882f?}, 0x98?,
> {0xc00038?, 0x0?, 0x421300?}, 0x0, ...)
>
>
> /Users/mndrive/Downloads/apache-mynewt-newtmgr-1.10.0/nmxact/xact/image.go:120
> +0x146
>
> mynewt.apache.org/newtmgr/nmxact/xact.findChunkLen({0x451a240
> ,
> 0xc000304320}, {0xc2e140, 0x20, 0x20}, 0x0?, {0xc00038, 0x27da0,
> 0x27da1}, 0x0, ...)
>
>
> /Users/mndrive/Downloads/apache-mynewt-newtmgr-1.10.0/nmxact/xact/image.go:139
> +0x131
>
> mynewt.apache.org/newtmgr/nmxact/xact.nextImageUploadReq({0x451a240
> 
> ,
> 0xc000304320}, 0x0?, {0xc00038, 0x27da0, 0x27da1}, 0x0, 0x0?)
>
>
> /Users/mndrive/Downloads/apache-mynewt-newtmgr-1.10.0/nmxact/xact/image.go:177
> +0x1eb
>
> mynewt.apache.org/newtmgr/nmxact/xact.(*ImageUploadCmd).Run(0xc32200,
> {0x451a240, 0xc000304320})
>
>
> /Users/mndrive/Downloads/apache-mynewt-newtmgr-1.10.0/nmxact/xact/image.go:353
> +0x24e
>
>
> mynewt.apache.org/newtmgr/nmxact/xact.(*ImageUpgradeCmd).runUpload(0xc32100
> ,
> {0x451a240, 0xc000304320})
>
>
> /Users/mndrive/Downloads/apache-mynewt-newtmgr-1.10.0/nmxact/xact/image.go:510
> +0x1cb
>
> mynewt.apache.org/newtmgr/nmxact/xact.(*ImageUpgradeCmd).Run(0x7ff7bfeffbe5
> ?,
> {0x451a240?, 0xc000304320?})
>
>
> /Users/mndrive/Downloads/apache-mynewt-newtmgr-1.10.0/nmxact/xact/image.go:536
> +0x6a
>
> mynewt.apache.org/newtmgr/newtmgr/cli.imageUploadCmd(0xc0001f4c80?,
> {0xc0001ad920?, 0x3?, 0x3?})
>
>
> /Users/mndrive/Downloads/apache-mynewt-newtmgr-1.10.0/newtmgr/cli/image.go:212
> +0x30b
>
> github.com/spf13/cobra.(*Command).execute(0xc0001f4c80, {0xc0001ad830,
> 0x3,
> 0x3})
>
> /Users/mndrive/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:830
> +0x663 
>
> github.com/spf13/cobra.(*Command).ExecuteC(0xccaf00)
>
> /Users/mndrive/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914
> +0x2ee 
>
> github.com/spf13/cobra.(*Command).Execute(...)
>
> /Users/mndrive/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864
>
> main.main()
>
>
> /Users/mndrive/Downloads/apache-mynewt-newtmgr-1.10.0/newtmgr/newtmgr.go:111
> +0x16f
>
>
>
> --
> Mo Chen
>


-- 
pozdrawiam
Szymon K. Janc