Nimble BLE central

2020-12-16 Thread Ondrej Pilat
Hi all,

I would like to know how nimble is managing interval windows especially
when peripheral doesn't have packet to send. Is there way how to reduce
Empty PDU sent in such scenarios and instead send more packets from
central device to peripheral?

I attached small snippet from our communication. It looks like Nimble is
asking for more packets from peripheral regardless information that
peripheral have nothing to sent.

Regards

Ondrej

-- 


OpenPGP_signature
Description: OpenPGP digital signature


gdb view threads

2020-08-14 Thread Ondrej Pilat
Hi All,

is there a way how to view mynewt threads and switch between them with GDB?

I have an issue with tinyusb which causes that python write timeouts. My
suspicion is that a PC is writing too fast and NRF52 isn't able to
process received data. Which causes freeze of the tinyusb.

Regards

Ondrej

-- 


signature.asc
Description: OpenPGP digital signature


Re: missing "newtmgr/newtmgr.h"

2020-08-14 Thread Ondrej Pilat
Hi Łukasz,

Is there a porting manual from newtmgr API to mcumgr?

We are using nmgr_transport_init and newtmgr_process what are mcumgr
equivalents?

Regards

Ondrej

Dne 8/14/2020 v 9:46 AM Łukasz Rymanowski napsal(a):
> Hi Ondrej,
>
> Newtmgr has been removed as we moved to mcumgr
> (https://github.com/apache/mynewt-mcumgr) , which is basically an
> extracted version of newtmgr.
> It is in release notes:
> https://cwiki.apache.org/confluence/display/MYNEWT/RN-1.8.0
>
> Best
> Łukasz
>
>
> On Fri, 14 Aug 2020 at 09:32, Ondrej Pilat  <mailto:ondrej.pi...@ozobot.com>> wrote:
>
> Hi all,
>
> we used newtmgr in application for image update and its
> management. When we upgrade apache-mynewt-core to the latest
> version 1.8.0 newtmgr.h and newtmgr.c is missing. What we should
> use instead or why newtmgr support was removed from the 1.8.0?
>
> We need to upgrade apache-mynewt-core because 1.7.0 isn't
> compatible with the latest changes in the tinyusb repo (nrf52 USB
> API changed).
>
> Best regards
>
> Ondrej Pilat
>
> -- 
>
-- 


signature.asc
Description: OpenPGP digital signature


Re: missing "newtmgr/newtmgr.h"

2020-08-14 Thread Ondrej Pilat
Hi Łukasz,

thank you for explanation.

Is there a documentation describing  the NMP (plain newtmgr protocol)? I
know that CBOR is well defined RFC standard but what about 8B header? I
can only find mcumgr source code.

Best regards

Ondrej

Dne 8/14/2020 v 9:46 AM Łukasz Rymanowski napsal(a):
> Hi Ondrej,
>
> Newtmgr has been removed as we moved to mcumgr
> (https://github.com/apache/mynewt-mcumgr) , which is basically an
> extracted version of newtmgr.
> It is in release notes:
> https://cwiki.apache.org/confluence/display/MYNEWT/RN-1.8.0
>
> Best
> Łukasz
>
>
> On Fri, 14 Aug 2020 at 09:32, Ondrej Pilat  <mailto:ondrej.pi...@ozobot.com>> wrote:
>
> Hi all,
>
> we used newtmgr in application for image update and its
> management. When we upgrade apache-mynewt-core to the latest
> version 1.8.0 newtmgr.h and newtmgr.c is missing. What we should
> use instead or why newtmgr support was removed from the 1.8.0?
>
> We need to upgrade apache-mynewt-core because 1.7.0 isn't
> compatible with the latest changes in the tinyusb repo (nrf52 USB
> API changed).
>
> Best regards
>
> Ondrej Pilat
>
> -- 
>
-- 


signature.asc
Description: OpenPGP digital signature


missing "newtmgr/newtmgr.h"

2020-08-14 Thread Ondrej Pilat
Hi all,

we used newtmgr in application for image update and its management. When
we upgrade apache-mynewt-core to the latest version 1.8.0 newtmgr.h and
newtmgr.c is missing. What we should use instead or why newtmgr support
was removed from the 1.8.0?

We need to upgrade apache-mynewt-core because 1.7.0 isn't compatible
with the latest changes in the tinyusb repo (nrf52 USB API changed).

Best regards

Ondrej Pilat

-- 
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
# 
#  http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#

project.name: "my_project"

project.repositories:
- apache-mynewt-core
- tinyusb

# Use github's distribution mechanism for core ASF libraries.
# This provides mirroring automatically for us.
#
repository.apache-mynewt-core:
type: github
vers: 1.8.0
user: apache
repo: mynewt-core

repository.tinyusb:
type: github
vers: c39dc03331683167be3c2a6ca59a4ee8e6e6620d-commit
user: hathach
repo: tinyusb

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#
pkg.name: apps/blecent
pkg.type: app
pkg.description: Simple BLE central application.
pkg.author: "Apache Mynewt "
pkg.homepage: "http://mynewt.apache.org/;
pkg.keywords:
- usb

pkg.deps:
- "@apache-mynewt-core/kernel/os"
- "@apache-mynewt-core/sys/console/stub"
- "@apache-mynewt-nimble/nimble/controller"
- "@apache-mynewt-nimble/nimble/host"
- "@apache-mynewt-nimble/nimble/host/util"
- "@apache-mynewt-nimble/nimble/host/services/gap"
- "@apache-mynewt-nimble/nimble/host/services/gatt"
- "@apache-mynewt-nimble/nimble/host/store/ram"
- "@apache-mynewt-nimble/nimble/transport/ram"

- "@apache-mynewt-core/fs/fs" # include the file operations 
interfaces
- "@apache-mynewt-core/fs/nffs"   # include the NFFS filesystem 
implementation

- "@apache-mynewt-core/mgmt/smp"
- "@apache-mynewt-core/mgmt/imgmgr"
#- "@apache-mynewt-core/mgmt/newtmgr/transport/ble"
 
- "@apache-mynewt-core/sys/log/full"
- "@apache-mynewt-core/sys/stats/full"
- "@apache-mynewt-core/sys/reboot"
- "@apache-mynewt-core/sys/config"
- "@apache-mynewt-core/sys/id"
   # - "@apache-mynewt-core/test/crash_test"
   # - "@apache-mynewt-core/test/runtest"
- "@mcuboot/boot/bootutil"

- "@apache-mynewt-core/hw/hal"
- "@tinyusb/tinyusb"

pkg.cflags: 
- "-I@tinyusb/src"


pkg.lflags:
- "-lm"


signature.asc
Description: OpenPGP digital signature


c++ support

2020-07-09 Thread Ondrej Pilat
Hi All,

tried anybody to use C++ with NRF52? When I patch some files I can use
C++ but startup code doesn't call global object constructors. Should I
add a linker flag or something else in the project.yml or somewhere else
or this isn't supported?

Thank you

Ondrej Pilat

-- 


signature.asc
Description: OpenPGP digital signature


Re: how to restrict Nimble to send only 1 or 2 message/s per connection event when Nimble is as peripheral

2020-06-21 Thread Ondrej Pilat
Hi All,

I am resending this mail because nobody responded. Can please somebody
look on this issue?

Regards

Ondrej Pilat

Dne 6/9/2020 v 10:22 AM Ondrej Pilat napsal(a):
>
> Hi All,
>
> Is it possible to tell Nimble to send only 1 or 2 packets per each
> connection event when Nimble is as peripheral? I have application
> which serves as 1 to X bridge (X can be up to 18). I need to restrict
> connection between PC and the NRF52 to send only 1 to 2 packets per
> connection event otherwise it uses to much from the throughput that
> connection between nrf52 and 18 devices cannot have interval window 60
> to 120ms. Instead they are communicating with 300 to 500ms period.
>
> From previous communication:
>
> /My assumption are following:/
>
> //
>
>   * /only one packet per each connection event/
>   * /send/receive 132B packet between NRF52 and PC each connection event/
>   * /send/receive 20B packet between NRF52 and peripheral each
> connection event/
>
> //
>
> /I made following rough computation:/
>
> //
>
> /PC <-> NRF52: 132B data + 21B header => (153B * 8) / 1Mbps => 1224 uS
> + 150 uS IFR + 80 uS ACK + 150 uS IFR => 1604 uS * 2 (send/receive) =>
> 3208 uS //
> /
>
> //
>
> /NRF52 <-> peripheral: 20B data + 21B header => (41B * 8)  / 1Mbps =>
> 328uS + 150 uS IFR + 80 uS ACK + 150uS IFR => 708uS * 2 (send/receive)
> => 1416 uS/
>
> /It means one big and six small packets should fit in each PC <->
> NRF52 connection event 3208 + 6 * 1416 = 11 704 < 12.5ms interval
> window. For 18 peripherals it means 3 such cycles to serve them all
> therefore 37.5ms interval window between NRF52 and a peripheral.
> /
>
> /On this I received response:/
>
> You need to take NimBLE scheduling into account here. Each connection event
> is preallocated a fixed amount of time in 1250us slots - see
> BLE_LL_CONN_INIT_SLOTS. This means effectively connection events cannot be
> scheduled less than 1250us apart. Also, scheduler overhead is ~200us (for
> nRF52, may be different for nRF51) for each connection event so effective
> connection event time with 1 slot allocated is 1050us. Note that this is
> min time since connection events can be extended pretty much indefinitely
> as long as there is no other activity scheduled so e.g. until another
> connection event.
>
> I do not know if "20B packet" means "20 bytes of LL payload", but will
> assume so since we are talking LL level here. This can fit into a single
> scheduled slot: 240us + 150us + 80us = 470us < 1050us. Let's assume 1ms for
> each connection event including scheduler overhead so you need 18ms to
> serve all 18 devices in one direction. If you need to send data in both
> directions you need 240us + 150us + 240us = 630us < 1050us so nothing
> changes and you still have quite a lot of extra time to spare in each
> connection event (e.g. for retransmissions). It will be a bit different if
> you need to transfer data in both directions in separate connection events
> as basically you need twice as much connection events, this means you need
> at least 36ms to serve all peripherals. One possible problem here is that
> connection may not be scheduled exactly 1.25ms apart and this will create
> gaps where no connection can be scheduled, you can't really control this
> with default scheduler. Possible solution would be to use
> BLE_LL_STRICT_CONN_SCHEDULING which schedules connections in central role
> at fixed intervals, although I never used it so not sure if there's
> anything that requires more configuration than just enabling this feature.
>
> When I take these information in account I get that Nimble should be
> able to have:
> 10ms interval window between a PC and NRF52 (Nimble is as peripheral)
> 60ms interval windows with 18 devices (Nimble is as central device)
>
> I am not able to achive such values. Attached is sniffed communication
> between PC and NRF52 which shows that there is no space left for the
> other devices to communicate with 60ms windows. During my tests the
> Nimble is sending packets betwen NRF52 and devices with 300ms to 500ms
> period although interval windows is set to 120ms with them.
>
> Best regards
> Ondrej Pilat
>
> -- 
-- 


signature.asc
Description: OpenPGP digital signature


Re: nimble doesn't receive 31B scan response

2020-05-12 Thread Ondrej Pilat
Hi,

does nimble ask for the scan response only once? It looks that it was
fault in our code and cheap sniffer doesn't catch it :(.

Regards

Ondrej

Dne 5/12/2020 v 4:51 PM Andrzej Kaczmarek napsal(a):
> Hi,
>
> On Tue, May 12, 2020 at 4:05 PM Ondrej Pilat  <mailto:ondrej.pi...@ozobot.com>> wrote:
>
> Hi All,
>
> we have device which in the past had 29B scan response and nimble
> properly asked for it. Now We extended scan response at 31B to use
> it whole but now nimble doesn't ask for it. No ble_gap_disc_desc
> *disc with disc->event_type === BLE_HCI_ADV_RPT_EVTYPE_SCAN_RSP
> for our device.
>
> The scanner cannot decide whether to send a scan request or not based
> on the length of the scan response because it does not know that
> length in advance. Did you really see that NimBLE does not send a scan
> request to your device? Could be simply that your device does not send
> a scan response or there's something wrong (configuration?) with
> advertising packets. The best would be if you could provide some logs
> (HCI, air, etc.) that would show us how advertising is configured on
> your device and how the scanner is configured in NimBLE.
>
> Where can be an issue? Does nimble support 31B scan response?
>
> Yes, it's required by spec.
>
> Regards
>
> Ondrej
>
> Best,
> Andrzej
>  
>
> -- 
>
>
-- 


signature.asc
Description: OpenPGP digital signature


nimble doesn't receive 31B scan response

2020-05-12 Thread Ondrej Pilat
Hi All,

we have device which in the past had 29B scan response and nimble
properly asked for it. Now We extended scan response at 31B to use it
whole but now nimble doesn't ask for it. No ble_gap_disc_desc *disc with
disc->event_type === BLE_HCI_ADV_RPT_EVTYPE_SCAN_RSP for our device.

Where can be an issue? Does nimble support 31B scan response?

Regards

Ondrej

-- 


signature.asc
Description: OpenPGP digital signature


how to link a static library or copy repo from the bitbucket

2020-04-23 Thread Ondrej Pilat
Hi All,

I would like to link my newt code with my static library or its code and
let newt to build it from the source code. My library is on the
bitbucket, uses mercurial and cmake.

What is the best way and how to make includes visible?

Newt can generate cmake for a target. Can it load/use cmake project too?

Newt build system documentation describes only way with github and git.
I do not want to convert my repository to git and move it to the github.

Regards

Ondrej

-- 


signature.asc
Description: OpenPGP digital signature


BLE communication scheduling

2020-04-09 Thread Ondrej Pilat
Hi,

I cannot find any documentation about Nimble connection events
scheduling. I have following scenario:

NRF52 Nimble is in dual role setting. Peripheral device connected to a
PC with at least BLE 4.2 and MTU more than 153B. Central is connected to
18 peripheral devices BLE 4.1 with MTU 27B.

Do you think that Nimble can keep interval window 12.5ms with the PC and
37.5ms with all peripherals?

My assumption are following:

  * only one packet per each connection event
  * send/receive 132B packet between NRF52 and PC each connection event
  * send/receive 20B packet between NRF52 and peripheral each connection
event

I made following rough computation:

PC <-> NRF52: 132B data + 21B header => (153B * 8) / 1Mbps => 1224 uS +
150 uS IFR + 80 uS ACK + 150 uS IFR => 1604 uS * 2 (send/receive) =>
3208 uS

NRF52 <-> peripheral: 20B data + 21B header => (41B * 8)  / 1Mbps =>
328uS + 150 uS IFR + 80 uS ACK + 150uS IFR => 708uS * 2 (send/receive)
=> 1416 uS

It means one big and six small packets should fit in each PC <-> NRF52
connection event 3208 + 6 * 1416 = 11 704 < 12.5ms interval window. For
18 peripherals it means 3 such cycles to serve them all therefore 37.5ms
interval window between NRF52 and a peripheral.

Are following parameters good to achieve this:

NRF52 <-> PC

static const struct ble_gap_conn_params ble_gap_conn_params_ideal = {
   .scan_itvl = BLE_GAP_SCAN_FAST_INTERVAL_MIN,
   .scan_window = BLE_GAP_SCAN_FAST_WINDOW,
   .itvl_min = 10,
   .itvl_max = 10,
   .latency = 0,
   .supervision_timeout = 500,
   .min_ce_len = 5, // 3.208 / 0.625 = 5.1328
   .max_ce_len = 6,
};

NRF52 <-> Peripheral

static const struct ble_gap_conn_params ble_gap_conn_params_ideal = {
   .scan_itvl = BLE_GAP_SCAN_FAST_INTERVAL_MIN,
   .scan_window = BLE_GAP_SCAN_FAST_WINDOW,
   .itvl_min = 30,
   .itvl_max = 30,
   .latency = 0,
   .supervision_timeout = 500,
   .min_ce_len = 2, // 1.416 / 0.625 = 2.2656
   .max_ce_len = 3,
};

Regards

Ondrej

--