(mynewt-nimble) branch master updated: nimble/audio/bass: Fix infinite loop

2024-05-16 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new 7ec17b68 nimble/audio/bass: Fix infinite loop
7ec17b68 is described below

commit 7ec17b684d818ca6367cefc94c6b51daa299c8d4
Author: Mariusz Skamra 
AuthorDate: Thu May 16 14:26:51 2024 +0200

nimble/audio/bass: Fix infinite loop

This fixes infinite loop while sending BASS Receive state notifications.
---
 nimble/host/audio/services/bass/src/ble_audio_svc_bass.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/nimble/host/audio/services/bass/src/ble_audio_svc_bass.c 
b/nimble/host/audio/services/bass/src/ble_audio_svc_bass.c
index 97f8afd9..1c4ff639 100644
--- a/nimble/host/audio/services/bass/src/ble_audio_svc_bass.c
+++ b/nimble/host/audio/services/bass/src/ble_audio_svc_bass.c
@@ -408,7 +408,6 @@ done:
 if (!rc) {
 rc = ble_svc_audio_bass_receive_state_notify(rcv_state);
 ev.bass_operation_status.status = rc;
-goto done;
 }
 
 ble_audio_event_listener_call();



(mynewt-nimble) branch master updated: host/ble_l2cap_coc: fix possible race condition in L2CAP COC

2024-04-23 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new 154398242 host/ble_l2cap_coc: fix possible race condition in L2CAP COC
154398242 is described below

commit 1543982424d3c5ef7d4c4dbae2203f8e3c020f18
Author: Krzysztof Kopyściński 
AuthorDate: Wed Apr 17 14:41:40 2024 +0200

host/ble_l2cap_coc: fix possible race condition in L2CAP COC

Two functions: `ble_l2cap_coc_continue_tx` and `ble_l2cap_coc_recv_ready`
can be reached from other task than host, for example separate thread
running in application, by calling `ble_l2cap_recv_ready` or
`ble_l2cap_send`. Because pointer to chan passed into  these functions
may be outdated (connection is being terminated by host) this will lead
to either:
 - triggering BLE_HS_DBG_ASSERT(conn != NULL) in ble_hs_conn_find_assert
 - dereferencing NULL pointer to conn, after ble_hs_conn_find_assert
   returns NULL (case with disabled BLE_HS_DEBUG)
These two cases shall not cause assert, and should be prepared for chan
not existing anymore. Now, BLE_HS_ENOTCONN is returned if connection no
longer exists.
---
 nimble/host/src/ble_l2cap_coc.c | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/nimble/host/src/ble_l2cap_coc.c b/nimble/host/src/ble_l2cap_coc.c
index 25727ee19..a3d1b1c22 100644
--- a/nimble/host/src/ble_l2cap_coc.c
+++ b/nimble/host/src/ble_l2cap_coc.c
@@ -506,7 +506,12 @@ ble_l2cap_coc_continue_tx(struct ble_l2cap_chan *chan)
 goto failed;
 }
 
-conn = ble_hs_conn_find_assert(chan->conn_handle);
+conn = ble_hs_conn_find(chan->conn_handle);
+if (!conn) {
+rc = BLE_HS_ENOTCONN;
+BLE_HS_LOG(DEBUG, "Connection does not exist");
+goto failed;
+}
 rc = ble_l2cap_tx(conn, chan, txom);
 
 if (rc) {
@@ -619,7 +624,13 @@ ble_l2cap_coc_recv_ready(struct ble_l2cap_chan *chan, 
struct os_mbuf *sdu_rx)
 (chan->coc_rx.next_sdu_alloc_idx + 1) % BLE_L2CAP_SDU_BUFF_CNT;
 
 ble_hs_lock();
-conn = ble_hs_conn_find_assert(chan->conn_handle);
+conn = ble_hs_conn_find(chan->conn_handle);
+if (!conn) {
+BLE_HS_LOG(DEBUG, "Connection does not exist");
+ble_hs_unlock();
+return BLE_HS_ENOTCONN;
+}
+
 c = ble_hs_conn_chan_find_by_scid(conn, chan->scid);
 if (!c) {
 ble_hs_unlock();



(mynewt-nimble) branch master updated (6750a13cc -> a3cef5881)

2024-02-28 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


from 6750a13cc apps/btshell: Add 'silent' option to scan commands
 add b3cd0b628 nimble/audio: Add BASE parser
 add a3cef5881 nimble/audio: Add LE Audio event listener

No new revisions were added by this update.

Summary of changes:
 nimble/host/audio/include/host/audio/ble_audio.h   | 293 
 nimble/host/{util => audio}/pkg.yml|   7 +-
 nimble/host/audio/src/ble_audio.c  | 530 +
 .../host/audio/src/ble_audio_priv.h|  19 +-
 nimble/host/{util => audio}/syscfg.yml |   2 +
 nimble/{controller => host/audio}/test/pkg.yml |  12 +-
 .../audio/test/src/ble_audio_test.c}   |  23 +-
 .../test/src/testcases/ble_audio_base_parse_test.c | 361 ++
 .../testcases/ble_audio_listener_register_test.c   |  59 +++
 .../{transport/usb => host/audio/test}/syscfg.yml  |  11 +-
 nimble/host/include/host/ble_audio_common.h|   4 +-
 .../host/services/auracast/src/ble_svc_auracast.c  |   2 +-
 12 files changed, 1289 insertions(+), 34 deletions(-)
 create mode 100644 nimble/host/audio/include/host/audio/ble_audio.h
 copy nimble/host/{util => audio}/pkg.yml (89%)
 create mode 100644 nimble/host/audio/src/ble_audio.c
 copy babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_watchdog.c => 
nimble/host/audio/src/ble_audio_priv.h (81%)
 copy nimble/host/{util => audio}/syscfg.yml (98%)
 copy nimble/{controller => host/audio}/test/pkg.yml (89%)
 copy nimble/{controller/test/src/ble_ll_test.c => 
host/audio/test/src/ble_audio_test.c} (74%)
 create mode 100644 
nimble/host/audio/test/src/testcases/ble_audio_base_parse_test.c
 create mode 100644 
nimble/host/audio/test/src/testcases/ble_audio_listener_register_test.c
 copy nimble/{transport/usb => host/audio/test}/syscfg.yml (81%)



(mynewt-nimble) 05/08: apps/btshell: Add ISO related commands

2024-02-27 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit a2e68282f57b206c5a6ba6146a019877cae5a994
Author: Mariusz Skamra 
AuthorDate: Thu Feb 22 16:03:22 2024 +0100

apps/btshell: Add ISO related commands

This adds ISO related commands to the btshell application.
The commands can be used for testing purposes.
---
 apps/btshell/src/cmd.c |  51 -
 apps/btshell/src/cmd_iso.c | 513 +
 apps/btshell/src/cmd_iso.h |  39 
 3 files changed, 602 insertions(+), 1 deletion(-)

diff --git a/apps/btshell/src/cmd.c b/apps/btshell/src/cmd.c
index ff8bae8c7..1b20078e8 100644
--- a/apps/btshell/src/cmd.c
+++ b/apps/btshell/src/cmd.c
@@ -41,6 +41,7 @@
 #include "cmd.h"
 #include "btshell.h"
 #include "cmd_gatt.h"
+#include "cmd_iso.h"
 #include "cmd_l2cap.h"
 #include "cmd_leaudio.h"
 
@@ -4858,7 +4859,7 @@ static const struct shell_cmd btshell_commands[] = {
 },
 #endif
 #endif
-#if MYNEWT_VAL(BLE_ISO)
+#if MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE)
 {
 .sc_cmd = "base_add",
 .sc_cmd_func = cmd_leaudio_base_add,
@@ -4915,7 +4916,55 @@ static const struct shell_cmd btshell_commands[] = {
 .help = _broadcast_stop_help,
 #endif
 },
+#endif /* BLE_ISO_BROADCAST_SOURCE */
+#if MYNEWT_VAL(BLE_ISO)
+#if MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE)
+{
+.sc_cmd = "big-create",
+.sc_cmd_func = cmd_iso_big_create,
+#if MYNEWT_VAL(SHELL_CMD_HELP)
+.help = _iso_big_create_help,
+#endif
+},
+{
+.sc_cmd = "big-terminate",
+.sc_cmd_func = cmd_iso_big_terminate,
+#if MYNEWT_VAL(SHELL_CMD_HELP)
+.help = _iso_big_terminate_help,
+#endif
+},
+#endif /* BLE_ISO_BROADCAST_SOURCE */
+#if MYNEWT_VAL(BLE_ISO_BROADCAST_SINK)
+{
+.sc_cmd = "big-sync-create",
+.sc_cmd_func = cmd_iso_big_sync_create,
+#if MYNEWT_VAL(SHELL_CMD_HELP)
+.help = _iso_big_sync_create_help,
 #endif
+},
+{
+.sc_cmd = "big-sync-terminate",
+.sc_cmd_func = cmd_iso_big_sync_terminate,
+#if MYNEWT_VAL(SHELL_CMD_HELP)
+.help = _iso_big_sync_terminate_help,
+#endif
+},
+#endif /* BLE_ISO_BROADCAST_SINK */
+{
+.sc_cmd = "iso-data-path-setup",
+.sc_cmd_func = cmd_iso_data_path_setup,
+#if MYNEWT_VAL(SHELL_CMD_HELP)
+.help = _iso_data_path_setup_help,
+#endif
+},
+{
+.sc_cmd = "iso-data-path-remove",
+.sc_cmd_func = cmd_iso_data_path_remove,
+#if MYNEWT_VAL(SHELL_CMD_HELP)
+.help = _iso_data_path_remove_help,
+#endif
+},
+#endif /* BLE_ISO */
 { 0 },
 };
 
diff --git a/apps/btshell/src/cmd_iso.c b/apps/btshell/src/cmd_iso.c
new file mode 100644
index 0..8d0ef343d
--- /dev/null
+++ b/apps/btshell/src/cmd_iso.c
@@ -0,0 +1,513 @@
+/*
+ * 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.
+ */
+
+#include "host/ble_iso.h"
+
+#include "cmd_iso.h"
+
+#include "console/console.h"
+#include "shell/shell.h"
+
+#if (MYNEWT_VAL(BLE_ISO))
+static struct iso_rx_stats {
+uint8_t bis_index;
+bool ts_valid;
+uint32_t ts;
+uint16_t seq_num;
+uint64_t total_cnt;
+uint64_t valid_cnt;
+uint64_t error_cnt;
+uint64_t lost_cnt;
+} rx_stats_pool[MYNEWT_VAL(BLE_MAX_BIS)];
+
+static void
+iso_rx_stats_update(uint16_t conn_handle, const struct ble_iso_rx_data_info 
*info,
+struct iso_rx_stats *stats)
+{
+stats->ts_valid = info->ts_valid;
+if (stats->ts_valid) {
+stats->ts = info->ts;
+}
+
+stats->seq_num = info->seq_num;
+
+if (info->status == BLE_ISO_DATA_STATUS_VALID) {
+stats->valid_cnt++;
+} else if (info->status == BLE_ISO_DATA_STATUS_ERROR) {
+stats->error_cnt++;
+} else if (info->status == BLE_ISO_DATA_STATUS_LOST) {
+stats->lost_cnt++;
+}
+
+stats->total_cnt++;
+
+if ((stats->t

(mynewt-nimble) branch master updated (26df457d7 -> 6750a13cc)

2024-02-27 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


from 26df457d7 host/audio_common: Add doxygen comments in the header file
 new 90d270dfa nimble/controller: Conditionally enable 
BLE_LL_ISO_BROADCASTER
 new 47d1bb50d nimble/iso: Fix BLE_ISO dependency
 new 8c06f2563 nimble/iso: Add ISO Rx datapath and extend ISO Broadcast API
 new eacdbc36e nimble/iso: Fix missing BLE_ISO_BROADCAST_SOURCE guard
 new a2e68282f apps/btshell: Add ISO related commands
 new 2e368caab nimble/audio: Add LE Audio btshell target
 new 56a23bc0f apps/btshell: Fix minor coding style issue
 new 6750a13cc apps/btshell: Add 'silent' option to scan commands

The 8 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 apps/btshell/src/btshell.h |   5 +-
 apps/btshell/src/cmd.c |  67 ++-
 apps/btshell/src/cmd_iso.c | 513 
 apps/btshell/src/{cmd_l2cap.h => cmd_iso.h}|  26 +-
 apps/btshell/src/main.c|  19 +-
 nimble/controller/syscfg.yml   |   6 +-
 .../host/audio/targets/btshell_native}/pkg.yml |   6 +-
 .../host/audio/targets/btshell_native}/syscfg.yml  |  40 +-
 .../host/audio/targets/btshell_native}/target.yml  |   1 -
 nimble/host/include/host/ble_iso.h | 230 +++-
 nimble/host/src/ble_hs.c   |   5 +
 nimble/host/src/ble_hs_hci_evt.c   |  43 ++
 nimble/host/src/ble_hs_startup.c   |  11 +
 nimble/host/src/ble_iso.c  | 650 +++--
 nimble/host/src/ble_iso_priv.h |   9 +
 nimble/include/nimble/hci_common.h |  28 +-
 nimble/syscfg.yml  |   4 +
 nimble/transport/socket/src/ble_hci_socket.c   |  38 ++
 18 files changed, 1609 insertions(+), 92 deletions(-)
 create mode 100644 apps/btshell/src/cmd_iso.c
 copy apps/btshell/src/{cmd_l2cap.h => cmd_iso.h} (52%)
 copy {targets/nordic_pca10095_net-blehci => 
nimble/host/audio/targets/btshell_native}/pkg.yml (85%)
 copy {apps/btshell => nimble/host/audio/targets/btshell_native}/syscfg.yml 
(65%)
 copy {.github/targets_linux/native_btshell => 
nimble/host/audio/targets/btshell_native}/target.yml (99%)



(mynewt-nimble) 01/08: nimble/controller: Conditionally enable BLE_LL_ISO_BROADCASTER

2024-02-27 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 90d270dfa1d5b9d80e330aab5c5a65e00734fe93
Author: Mariusz Skamra 
AuthorDate: Tue Jan 23 08:12:18 2024 +0100

nimble/controller: Conditionally enable BLE_LL_ISO_BROADCASTER

Enable BLE_LL_ISO_BROADCASTER if BLE_ISO_BROADCAST_SOURCE and/or
BLE_ISO_BROADCAST_SINK is enabled.

Signed-off-by: Mariusz Skamra 
---
 nimble/controller/syscfg.yml | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/nimble/controller/syscfg.yml b/nimble/controller/syscfg.yml
index 19fae4754..8a32e2e02 100644
--- a/nimble/controller/syscfg.yml
+++ b/nimble/controller/syscfg.yml
@@ -483,8 +483,9 @@ syscfg.defs:
 Enable support for Isochronous Broadcasting state.
 restrictions:
 - BLE_LL_ISO if 1
-value: MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE)
+value: 0
 state: experimental
+
 BLE_LL_ISO_HCI_FEEDBACK_INTERVAL_MS:
 description: >
 Enables ISO synchronization feedback using vendor-specific HCI 
event.
@@ -613,6 +614,9 @@ syscfg.vals.BLE_LL_CFG_FEAT_LL_EXT_ADV:
 BLE_HW_WHITELIST_ENABLE: 0
 BLE_LL_SCAN_AUX_SEGMENT_CNT: 8
 
+syscfg.vals.'BLE_ISO_BROADCAST_SOURCE || BLE_ISO_BROADCAST_SINK':
+BLE_LL_ISO_BROADCASTER: 1
+
 syscfg.vals.BLE_LL_ISO_BROADCASTER:
 BLE_LL_CFG_FEAT_LE_ENCRYPTION: 1
 BLE_LL_STACK_SIZE: 180



(mynewt-nimble) 02/08: nimble/iso: Fix BLE_ISO dependency

2024-02-27 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 47d1bb50dfff9bb77736db70f5d93578861bde5a
Author: Mariusz Skamra 
AuthorDate: Tue Feb 27 13:08:45 2024 +0100

nimble/iso: Fix BLE_ISO dependency

This adds the BLE_ISO dependency on BLE_ISO_BROADCAST_SOURCE and
BLE_ISO_BROADCAST_SINK.
Once one of those roles is enabled, the BLE_ISO shall be enabled.
---
 nimble/syscfg.yml | 4 
 1 file changed, 4 insertions(+)

diff --git a/nimble/syscfg.yml b/nimble/syscfg.yml
index 47bd266ce..6264d0bc2 100644
--- a/nimble/syscfg.yml
+++ b/nimble/syscfg.yml
@@ -95,6 +95,7 @@ syscfg.defs:
 value: 0
 restrictions:
 - '(BLE_VERSION >= 52) if 1'
+- '(BLE_ISO_BROADCAST_SOURCE || BLE_ISO_BROADCAST_SINK) if 1'
 BLE_ISO_BROADCAST_SOURCE:
 description: >
 This enables LE Audio Broadcast Source feature
@@ -160,3 +161,6 @@ syscfg.restrictions:
 # Enable VS HCI by default for combined or standalone controller build
 syscfg.vals.BLE_CONTROLLER:
 BLE_HCI_VS: 1
+
+syscfg.vals.'BLE_ISO_BROADCAST_SOURCE || BLE_ISO_BROADCAST_SINK':
+BLE_ISO: 1



(mynewt-nimble) 07/08: apps/btshell: Fix minor coding style issue

2024-02-27 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 56a23bc0feafd8726eea65863e882bb036d566af
Author: Mariusz Skamra 
AuthorDate: Tue Feb 27 14:08:39 2024 +0100

apps/btshell: Fix minor coding style issue

This fixes minor coding style issue in btshell_scan_opts.
---
 apps/btshell/src/btshell.h | 4 ++--
 apps/btshell/src/cmd.c | 8 
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/apps/btshell/src/btshell.h b/apps/btshell/src/btshell.h
index 83dadede5..c74ca2fa5 100644
--- a/apps/btshell/src/btshell.h
+++ b/apps/btshell/src/btshell.h
@@ -90,8 +90,8 @@ struct btshell_conn {
 
 struct btshell_scan_opts {
 uint16_t limit;
-uint8_t ignore_legacy:1;
-uint8_t periodic_only:1;
+uint8_t ignore_legacy : 1;
+uint8_t periodic_only : 1;
 uint8_t name_filter_len;
 char name_filter[NAME_FILTER_LEN_MAX];
 };
diff --git a/apps/btshell/src/cmd.c b/apps/btshell/src/cmd.c
index 1b20078e8..1924e4f4e 100644
--- a/apps/btshell/src/cmd.c
+++ b/apps/btshell/src/cmd.c
@@ -1107,10 +1107,10 @@ static const struct shell_cmd_help disconnect_help = {
  */
 
 static struct btshell_scan_opts g_scan_opts = {
-.limit = UINT16_MAX,
-.ignore_legacy = 0,
-.periodic_only = 0,
-.name_filter_len = 0,
+.limit = UINT16_MAX,
+.ignore_legacy = 0,
+.periodic_only = 0,
+.name_filter_len = 0,
 };
 
 static int



(mynewt-nimble) 08/08: apps/btshell: Add 'silent' option to scan commands

2024-02-27 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 6750a13ccb1e943006d58e8f2c21d749000c4314
Author: Mariusz Skamra 
AuthorDate: Mon Jan 22 20:14:37 2024 +0100

apps/btshell: Add 'silent' option to scan commands

This adds option to silent the discovery results. This is useful in case
there is another callback listener registered that handles the scan
results, and the user does not want the default handler to print the
results.
---
 apps/btshell/src/btshell.h |  1 +
 apps/btshell/src/cmd.c |  8 
 apps/btshell/src/main.c| 19 ---
 3 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/apps/btshell/src/btshell.h b/apps/btshell/src/btshell.h
index c74ca2fa5..c457fd7f9 100644
--- a/apps/btshell/src/btshell.h
+++ b/apps/btshell/src/btshell.h
@@ -92,6 +92,7 @@ struct btshell_scan_opts {
 uint16_t limit;
 uint8_t ignore_legacy : 1;
 uint8_t periodic_only : 1;
+uint8_t silent : 1;
 uint8_t name_filter_len;
 char name_filter[NAME_FILTER_LEN_MAX];
 };
diff --git a/apps/btshell/src/cmd.c b/apps/btshell/src/cmd.c
index 1924e4f4e..4c00d7ba3 100644
--- a/apps/btshell/src/cmd.c
+++ b/apps/btshell/src/cmd.c
@@ -1110,6 +1110,7 @@ static struct btshell_scan_opts g_scan_opts = {
 .limit = UINT16_MAX,
 .ignore_legacy = 0,
 .periodic_only = 0,
+.silent = 0,
 .name_filter_len = 0,
 };
 
@@ -1136,6 +1137,12 @@ cmd_set_scan_opts(int argc, char **argv)
 return rc;
 }
 
+g_scan_opts.silent = parse_arg_bool_dflt("silent", 0, );
+if (rc != 0) {
+console_printf("invalid 'silent' parameter\n");
+return rc;
+}
+
 g_scan_opts.periodic_only = parse_arg_bool_dflt("periodic_only", 0, );
 if (rc != 0) {
 console_printf("invalid 'periodic_only' parameter\n");
@@ -1160,6 +1167,7 @@ static const struct shell_param set_scan_opts_params[] = {
 {"decode_limit", "usage: =[0-UINT16_MAX], default: UINT16_MAX"},
 {"ignore_legacy", "usage: =[0-1], default: 0"},
 {"periodic_only", "usage: =[0-1], default: 0"},
+{"silent", "usage: =[0-1], default: 0"},
 {"name_filter", "usage: =name, default: {none}"},
 {NULL, NULL}
 };
diff --git a/apps/btshell/src/main.c b/apps/btshell/src/main.c
index 0f87b5c23..6424bf6b8 100644
--- a/apps/btshell/src/main.c
+++ b/apps/btshell/src/main.c
@@ -1315,11 +1315,23 @@ btshell_gap_event(struct ble_gap_event *event, void 
*arg)
 
 return btshell_restart_adv(event);
 #if MYNEWT_VAL(BLE_EXT_ADV)
-case BLE_GAP_EVENT_EXT_DISC:
-btshell_decode_event_type(>ext_disc, arg);
+case BLE_GAP_EVENT_EXT_DISC: {
+struct btshell_scan_opts *scan_opts = arg;
+
+if (!scan_opts->silent) {
+btshell_decode_event_type(>ext_disc, arg);
+}
+
 return 0;
+}
 #endif
-case BLE_GAP_EVENT_DISC:
+case BLE_GAP_EVENT_DISC: {
+struct btshell_scan_opts *scan_opts = arg;
+
+if (scan_opts->silent) {
+return 0;
+}
+
 console_printf("received advertisement; event_type=%d rssi=%d "
"addr_type=%d addr=", event->disc.event_type,
event->disc.rssi, event->disc.addr.type);
@@ -1337,6 +1349,7 @@ btshell_gap_event(struct ble_gap_event *event, void *arg)
 btshell_decode_adv_data(event->disc.data, event->disc.length_data, 
arg);
 
 return 0;
+}
 
 case BLE_GAP_EVENT_CONN_UPDATE:
 console_printf("connection updated; status=%d ",



(mynewt-nimble) 06/08: nimble/audio: Add LE Audio btshell target

2024-02-27 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 2e368caab2c7d910922f3b281adb5f5f98267014
Author: Mariusz Skamra 
AuthorDate: Thu Jan 25 14:04:22 2024 +0100

nimble/audio: Add LE Audio btshell target

This adds btshell for native target build with the LE Audio
functionality enabled.
---
 nimble/host/audio/targets/btshell_native/pkg.yml   | 26 
 .../host/audio/targets/btshell_native/syscfg.yml   | 74 ++
 .../host/audio/targets/btshell_native/target.yml   | 22 +++
 3 files changed, 122 insertions(+)

diff --git a/nimble/host/audio/targets/btshell_native/pkg.yml 
b/nimble/host/audio/targets/btshell_native/pkg.yml
new file mode 100644
index 0..67eb2d6fe
--- /dev/null
+++ b/nimble/host/audio/targets/btshell_native/pkg.yml
@@ -0,0 +1,26 @@
+#
+# 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: audio/targets/btshell_native
+pkg.type: target
+pkg.description: Target for native btshell application with LE Audio
+ functionality enabled
+pkg.author: "Apache Mynewt "
+pkg.homepage: "http://mynewt.apache.org/;
+pkg.deps:
diff --git a/nimble/host/audio/targets/btshell_native/syscfg.yml 
b/nimble/host/audio/targets/btshell_native/syscfg.yml
new file mode 100644
index 0..d631ea798
--- /dev/null
+++ b/nimble/host/audio/targets/btshell_native/syscfg.yml
@@ -0,0 +1,74 @@
+#
+# 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.
+#
+
+syscfg.vals:
+CONSOLE_IMPLEMENTATION: full
+LOG_IMPLEMENTATION: full
+STATS_IMPLEMENTATION: full
+
+# Enable the shell task.
+SHELL_TASK: 1
+
+# Set log level to info (disable debug logging).
+LOG_LEVEL: 1
+
+# Disable security manager (pairing and bonding).
+BLE_SM_LEGACY: 0
+BLE_SM_SC: 0
+
+# Default task settings
+OS_MAIN_STACK_SIZE: 512
+
+# SMP is not supported in this app, so disable smp-over-shell.
+SHELL_MGMT: 0
+
+# Whether to save data to sys/config, or just keep it in RAM.
+BLE_STORE_CONFIG_PERSIST: 0
+
+# Enable Extended Advertising
+BLE_EXT_ADV: 1
+BLE_EXT_ADV_MAX_SIZE: 261
+
+BLE_MULTI_ADV_INSTANCES: 1
+
+# Enable Periodic Advertising
+BLE_PERIODIC_ADV: 1
+BLE_PERIODIC_ADV_SYNC_TRANSFER: 1
+BLE_PERIODIC_ADV_SYNC_BIGINFO_REPORTS: 1
+
+BLE_SOCK_USE_TCP: 0
+BLE_SOCK_USE_LINUX_BLUE: 1
+BLE_SOCK_LINUX_DEV: 1
+BLE_TRANSPORT_HS: native
+BLE_TRANSPORT_LL: socket
+
+BLE_VERSION: 54
+BLE_ISO_BROADCAST_SINK: 1
+BLE_ISO_BROADCAST_SOURCE: 1
+BLE_MAX_BIG: 1
+BLE_MAX_BIS: 2
+
+CONSOLE_UART: 1
+CONSOLE_UART_BAUD: 100
+CONSOLE_STICKY_PROMPT: 1
+CONSOLE_UART_TX_BUF_SIZE: 256
+STATS_CLI: 1
+STATS_NAMES: 1
+
+MSYS_1_BLOCK_COUNT: 100
diff --git a/nimble/host/audio/targets/btshell_native/target.yml 
b/nimble/host/audio/targets/btshell_native/target.yml
new file mode 100644
index 0..30b7d5b74
--- /dev/null
+++ b/nimble/host/audio/targets/btshell_native/target.yml
@@ -0,0 +1,22 @@
+#
+# 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
+# &qu

(mynewt-nimble) 04/08: nimble/iso: Fix missing BLE_ISO_BROADCAST_SOURCE guard

2024-02-27 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit eacdbc36e020a270181a7c8bf36dd352beec4d13
Author: Mariusz Skamra 
AuthorDate: Fri Feb 23 09:39:52 2024 +0100

nimble/iso: Fix missing BLE_ISO_BROADCAST_SOURCE guard

This makes Broadcast ISO source related code dependent on
BLE_ISO_BROADCAST_SOURCE mynewt option.
---
 nimble/host/src/ble_iso.c | 46 --
 1 file changed, 24 insertions(+), 22 deletions(-)

diff --git a/nimble/host/src/ble_iso.c b/nimble/host/src/ble_iso.c
index 271bd27cb..90bd613d0 100644
--- a/nimble/host/src/ble_iso.c
+++ b/nimble/host/src/ble_iso.c
@@ -225,6 +225,7 @@ ble_iso_big_free(struct ble_iso_big *big)
 return 0;
 }
 
+#if MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE)
 int
 ble_iso_create_big(const struct ble_iso_create_big_params *create_params,
const struct ble_iso_big_params *big_params)
@@ -298,28 +299,6 @@ ble_iso_terminate_big(uint8_t big_handle)
 return rc;
 }
 
-int
-ble_iso_init(void)
-{
-int rc;
-
-SLIST_INIT(_iso_bigs);
-
-rc = os_mempool_init(_iso_big_pool,
- MYNEWT_VAL(BLE_MAX_BIG),
- sizeof (struct ble_iso_big),
- ble_iso_big_mem, "ble_iso_big_pool");
-SYSINIT_PANIC_ASSERT(rc == 0);
-
-rc = os_mempool_init(_iso_bis_pool,
- MYNEWT_VAL(BLE_MAX_BIS),
- sizeof (struct ble_iso_bis),
- ble_iso_bis_mem, "ble_iso_bis_pool");
-SYSINIT_PANIC_ASSERT(rc == 0);
-
-return 0;
-}
-
 void
 ble_iso_rx_create_big_complete(const struct 
ble_hci_ev_le_subev_create_big_complete *ev)
 {
@@ -497,6 +476,7 @@ ble_iso_tx(uint16_t conn_handle, void *data, uint16_t 
data_len)
 
 return rc;
 }
+#endif /* BLE_ISO_BROADCAST_SOURCE */
 
 #if MYNEWT_VAL(BLE_ISO_BROADCAST_SINK)
 static struct ble_iso_conn *
@@ -933,4 +913,26 @@ ble_iso_data_path_remove(const struct 
ble_iso_data_path_remove_params *param)
 
 return rc;
 }
+
+int
+ble_iso_init(void)
+{
+int rc;
+
+SLIST_INIT(_iso_bigs);
+
+rc = os_mempool_init(_iso_big_pool,
+ MYNEWT_VAL(BLE_MAX_BIG),
+ sizeof (struct ble_iso_big),
+ ble_iso_big_mem, "ble_iso_big_pool");
+SYSINIT_PANIC_ASSERT(rc == 0);
+
+rc = os_mempool_init(_iso_bis_pool,
+ MYNEWT_VAL(BLE_MAX_BIS),
+ sizeof (struct ble_iso_bis),
+ ble_iso_bis_mem, "ble_iso_bis_pool");
+SYSINIT_PANIC_ASSERT(rc == 0);
+
+return 0;
+}
 #endif /* BLE_ISO */



(mynewt-nimble) 03/08: nimble/iso: Add ISO Rx datapath and extend ISO Broadcast API

2024-02-27 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 8c06f256374ae9be9ff43d9270bcee3e9481a01f
Author: Mariusz Skamra 
AuthorDate: Mon Jan 22 20:00:49 2024 +0100

nimble/iso: Add ISO Rx datapath and extend ISO Broadcast API

This adds ISO Rx datapath and along with Broadcast Sink ISO API
and implementation.
---
 nimble/host/include/host/ble_iso.h   | 230 +-
 nimble/host/src/ble_hs.c |   5 +
 nimble/host/src/ble_hs_hci_evt.c |  43 ++
 nimble/host/src/ble_hs_startup.c |  11 +
 nimble/host/src/ble_iso.c| 616 +--
 nimble/host/src/ble_iso_priv.h   |   9 +
 nimble/include/nimble/hci_common.h   |  28 +-
 nimble/transport/socket/src/ble_hci_socket.c |  38 ++
 8 files changed, 937 insertions(+), 43 deletions(-)

diff --git a/nimble/host/include/host/ble_iso.h 
b/nimble/host/include/host/ble_iso.h
index 786d2eb21..8b0182fa6 100644
--- a/nimble/host/include/host/ble_iso.h
+++ b/nimble/host/include/host/ble_iso.h
@@ -19,22 +19,31 @@
 
 #ifndef H_BLE_ISO_
 #define H_BLE_ISO_
+#include 
+
+#include "nimble/hci_common.h"
 #include "syscfg/syscfg.h"
 
 /** ISO event: BIG Create Completed */
-#define BLE_ISO_EVENT_BIG_CREATE_COMPLETE  0
+#define BLE_ISO_EVENT_BIG_CREATE_COMPLETE   0
 
 /** ISO event: BIG Terminate Completed */
-#define BLE_ISO_EVENT_BIG_TERMINATE_COMPLETE   1
+#define BLE_ISO_EVENT_BIG_TERMINATE_COMPLETE1
 
-#include 
+/** ISO event: BIG Sync Established */
+#define BLE_ISO_EVENT_BIG_SYNC_ESTABLISHED  2
 
-struct ble_iso_big_desc
-{
+/** ISO event: BIG Sync Terminated */
+#define BLE_ISO_EVENT_BIG_SYNC_TERMINATED   3
+
+/** ISO event: ISO Data received */
+#define BLE_ISO_EVENT_ISO_RX4
+
+/** @brief Broadcast Isochronous Group (BIG) description */
+struct ble_iso_big_desc {
 uint8_t big_handle;
 uint32_t big_sync_delay;
 uint32_t transport_latency_big;
-uint8_t phy;
 uint8_t nse;
 uint8_t bn;
 uint8_t pto;
@@ -45,6 +54,36 @@ struct ble_iso_big_desc
 uint16_t conn_handle[MYNEWT_VAL(BLE_MAX_BIS)];
 };
 
+/** @brief Received ISO Data status possible values */
+enum ble_iso_rx_data_status {
+/** The complete SDU was received correctly. */
+BLE_ISO_DATA_STATUS_VALID = BLE_HCI_ISO_PKT_STATUS_VALID,
+
+/** May contain errors or part of the SDU may be missing. */
+BLE_ISO_DATA_STATUS_ERROR = BLE_HCI_ISO_PKT_STATUS_INVALID,
+
+/** Part(s) of the SDU were not received correctly */
+BLE_ISO_DATA_STATUS_LOST = BLE_HCI_ISO_PKT_STATUS_LOST,
+};
+
+/** @brief Received ISO data info structure */
+struct ble_iso_rx_data_info {
+/** ISO Data timestamp. Valid if @ref ble_iso_data_info.ts_valid is set */
+uint32_t ts;
+
+/** Packet sequence number */
+uint16_t seq_num;
+
+/** SDU length */
+uint16_t sdu_len : 12;
+
+/** ISO Data status. See @ref ble_iso_data_status */
+uint16_t status : 2;
+
+/** Timestamp is valid */
+uint16_t ts_valid : 1;
+};
+
 /**
  * Represents a ISO-related event.  When such an event occurs, the host
  * notifies the application by passing an instance of this structure to an
@@ -69,17 +108,41 @@ struct ble_iso_event {
  */
 struct {
 struct ble_iso_big_desc desc;
+uint8_t status;
+uint8_t phy;
 } big_created;
 
 /**
  * Represents a completion of BIG termination. Valid for the following
  * event types:
  * o BLE_ISO_EVENT_BIG_TERMINATE_COMPLETE
+ * o BLE_ISO_EVENT_BIG_SYNC_TERMINATED
  */
 struct {
 uint16_t big_handle;
 uint8_t reason;
 } big_terminated;
+
+/**
+ * Represents a completion of BIG synchronization. Valid for the 
following
+ * event types:
+ * o BLE_ISO_EVENT_BIG_SYNC_ESTABLISHED
+ */
+struct {
+struct ble_iso_big_desc desc;
+uint8_t status;
+} big_sync_established;
+
+/**
+ * Represents a reception of ISO Data. Valid for the following
+ * event types:
+ * o BLE_ISO_EVENT_ISO_RX
+ */
+struct {
+uint16_t conn_handle;
+const struct ble_iso_rx_data_info *info;
+struct os_mbuf *om;
+} iso_rx;
 };
 };
 
@@ -109,8 +172,161 @@ int ble_iso_create_big(const struct 
ble_iso_create_big_params *create_params,
 
 int ble_iso_terminate_big(uint8_t big_handle);
 
+/** @brief BIS parameters for @ref ble_iso_big_sync_create */
+struct ble_iso_bis_params {
+/** BIS index */
+uint8_t bis_index;
+
+/** The callback to associate with the BIS.
+ *  Received 

(mynewt-nimble) branch master updated: nimble/controller: Enable LL encryption if BLE_LL_ISO_BROADCASTER

2024-02-26 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new 23eec0a5a nimble/controller: Enable LL encryption if 
BLE_LL_ISO_BROADCASTER
23eec0a5a is described below

commit 23eec0a5adf44f7dd313d3e7ee882473772cc250
Author: Mariusz Skamra 
AuthorDate: Tue Jan 23 08:15:53 2024 +0100

nimble/controller: Enable LL encryption if BLE_LL_ISO_BROADCASTER

To support encrypting/decrypting broadcasts, LL Encryption shall be
enabled by BLE_LL_ISO_BROADCASTER.
---
 nimble/controller/syscfg.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/nimble/controller/syscfg.yml b/nimble/controller/syscfg.yml
index c55107bcb..19fae4754 100644
--- a/nimble/controller/syscfg.yml
+++ b/nimble/controller/syscfg.yml
@@ -614,6 +614,7 @@ syscfg.vals.BLE_LL_CFG_FEAT_LL_EXT_ADV:
 BLE_LL_SCAN_AUX_SEGMENT_CNT: 8
 
 syscfg.vals.BLE_LL_ISO_BROADCASTER:
+BLE_LL_CFG_FEAT_LE_ENCRYPTION: 1
 BLE_LL_STACK_SIZE: 180
 
 # Enable vendor event on assert in standalone build to make failed assertions 
in



(mynewt-nimble) branch master updated: nimble/host: prepare for Broadcast sink

2024-02-26 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new 365468bfe nimble/host: prepare for Broadcast sink
365468bfe is described below

commit 365468bfeceac62fc1ca7c8bd6a63a56d33974ec
Author: Krzysztof Kopyściński 
AuthorDate: Mon Dec 18 12:30:19 2023 +0100

nimble/host: prepare for Broadcast sink

This patch renames files, functions and configs from `broadcaster` to
`broadcast source` so new `broadcast sink` files and functions can be
created. Adds `BLE_ISO_BROADCAST_SINK` sysconfig
---
 .github/test_build_apps_syscfg.yml |  2 +-
 apps/auracast/syscfg.yml   |  2 +-
 apps/btshell/src/btshell.h |  6 +++---
 apps/btshell/src/cmd.c |  2 +-
 apps/btshell/src/cmd_leaudio.c |  4 ++--
 apps/btshell/src/main.c|  8 
 apps/leaudio_broadcaster/src/main.c|  2 +-
 apps/leaudio_broadcaster/syscfg.yml|  2 +-
 nimble/controller/syscfg.yml   |  2 +-
 .../{ble_audio_broadcast.h => ble_audio_broadcast_source.h}|  4 ++--
 nimble/host/include/host/ble_audio_common.h|  1 +
 .../auracast/include/services/auracast/ble_svc_auracast.h  |  2 +-
 nimble/host/services/auracast/src/ble_svc_auracast.c   |  5 +++--
 .../{ble_audio_broadcast.c => ble_audio_broadcast_source.c}|  4 ++--
 nimble/host/src/ble_hs.c   |  4 ++--
 nimble/host/src/ble_hs_hci_evt.c   |  6 +++---
 nimble/host/syscfg.yml |  4 ++--
 nimble/syscfg.yml  | 10 --
 porting/examples/linux/include/syscfg/syscfg.h |  8 ++--
 porting/examples/linux_blemesh/include/syscfg/syscfg.h |  8 ++--
 porting/examples/nuttx/include/syscfg/syscfg.h |  8 ++--
 porting/nimble/include/syscfg/syscfg.h |  8 ++--
 porting/npl/riot/include/syscfg/syscfg.h   | 10 +++---
 targets/nordic_pca10095_net-blehci_broadcaster/syscfg.yml  |  2 +-
 24 files changed, 71 insertions(+), 43 deletions(-)

diff --git a/.github/test_build_apps_syscfg.yml 
b/.github/test_build_apps_syscfg.yml
index 44bcb5efe..faafa8a3c 100644
--- a/.github/test_build_apps_syscfg.yml
+++ b/.github/test_build_apps_syscfg.yml
@@ -27,7 +27,7 @@ syscfg.vals:
 BLE_PERIODIC_ADV_SYNC_BIGINFO_REPORTS: 1
 BLE_ISO: 1
 BLE_ISO_TEST: 1
-BLE_ISO_BROADCASTER: 1
+BLE_ISO_BROADCAST_SOURCE: 1
 BLE_HCI_VS: 1
 BLE_POWER_CONTROL: 1
 BLE_CONN_SUBRATING: 1
diff --git a/apps/auracast/syscfg.yml b/apps/auracast/syscfg.yml
index 26dbc8da8..e67af5a00 100644
--- a/apps/auracast/syscfg.yml
+++ b/apps/auracast/syscfg.yml
@@ -55,7 +55,7 @@ syscfg.vals:
 
 BLE_VERSION: 54
 BLE_ISO: 1
-BLE_ISO_BROADCASTER: 1
+BLE_ISO_BROADCAST_SOURCE: 1
 BLE_MAX_BIG: 1
 BLE_MAX_BIS: 2
 
diff --git a/apps/btshell/src/btshell.h b/apps/btshell/src/btshell.h
index d7beb1490..83dadede5 100644
--- a/apps/btshell/src/btshell.h
+++ b/apps/btshell/src/btshell.h
@@ -28,8 +28,8 @@
 
 #include "host/ble_gatt.h"
 #include "host/ble_gap.h"
-#if (MYNEWT_VAL(BLE_ISO_BROADCASTER))
-#include "host/ble_audio_broadcast.h"
+#if (MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE))
+#include "host/ble_audio_broadcast_source.h"
 #endif
 
 #ifdef __cplusplus
@@ -191,7 +191,7 @@ int btshell_l2cap_send(uint16_t conn, uint16_t idx, 
uint16_t bytes);
 int btshell_l2cap_reconfig(uint16_t conn_handle, uint16_t mtu,
uint8_t num, uint8_t idxs[]);
 
-#if (MYNEWT_VAL(BLE_ISO_BROADCASTER))
+#if (MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE))
 int btshell_broadcast_base_add(uint8_t adv_instance, uint32_t 
presentation_delay);
 int btshell_broadcast_big_sub_add(uint8_t adv_instance,
   uint8_t codec_fmt,
diff --git a/apps/btshell/src/cmd.c b/apps/btshell/src/cmd.c
index f23c4b923..ff8bae8c7 100644
--- a/apps/btshell/src/cmd.c
+++ b/apps/btshell/src/cmd.c
@@ -4206,7 +4206,7 @@ static const struct shell_cmd_help sync_stats_help = {
 #endif
 #endif
 
-#if MYNEWT_VAL(BLE_ISO_BROADCASTER)
+#if MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE)
 #if MYNEWT_VAL(SHELL_CMD_HELP)
 static const struct shell_param leaudio_base_add_params[] = {
 {"adv_instance", "Advertising instance, usage: ="},
diff --git a/apps/btshell/src/cmd_leaudio.c b/apps/btshell/src/cmd_leaudio.c
index bdbc82584..fc4fcd17a 100644
--- a/apps/btshell/src/cmd_leaudio.c
+++ b/apps/b

(mynewt-nimble) branch master updated (adfa1b812 -> c102b8b24)

2024-02-23 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


from adfa1b812 host/ble_audio_broadcast: add clarification for big_params 
pointer
 add c102b8b24 nimble/drivers/native: Add missing function stubs

No new revisions were added by this update.

Summary of changes:
 nimble/drivers/native/src/ble_phy.c | 10 ++
 1 file changed, 10 insertions(+)



(mynewt-core) branch master updated (5d0bf9d61 -> 64e4e36db)

2024-01-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


from 5d0bf9d61 ci: Build application samples
 new 959231163 mcu/nordic: Update NRFX to version 3.3.0
 new 93793c9bd nrf5340/tfm: update nrfx to version 3.3.0
 new 036d9c176 hw/pwm_nrf52: Update nrfx to version 3.3.0
 new 8561a0c4b hw/i2s_nrfx: Update to nrfx 3.3.0
 new 91117b860 hw/i2s_nrf52: Update to nrfx 3.3.0
 new 64e4e36db hw/bsp: Update boards to nrfx 3.3.0

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .style_ignored_dirs|9 +
 hw/bsp/ada_feather_nrf52/pkg.yml   |1 +
 hw/bsp/arduino_primo_nrf52/pkg.yml |1 +
 hw/bsp/bbc_microbit/pkg.yml|1 +
 hw/bsp/ble400/pkg.yml  |1 +
 hw/bsp/bmd200/pkg.yml  |1 +
 hw/bsp/bmd300eval/pkg.yml  |1 +
 hw/bsp/calliope_mini/pkg.yml   |1 +
 hw/bsp/dwm1001-dev/pkg.yml |1 +
 hw/bsp/nina-b1/pkg.yml |1 +
 hw/bsp/nordic_pca10028-16k/pkg.yml |1 +
 hw/bsp/nordic_pca10028/pkg.yml |1 +
 hw/bsp/nordic_pca10040/pkg.yml |1 +
 hw/bsp/nordic_pca20020/pkg.yml |1 +
 hw/bsp/nrf51-arduino_101/pkg.yml   |1 +
 hw/bsp/nrf51-blenano/pkg.yml   |1 +
 hw/bsp/pinetime/pkg.yml|1 +
 hw/bsp/puckjs/pkg.yml  |1 +
 hw/bsp/rb-blend2/pkg.yml   |1 +
 hw/bsp/rb-nano2/pkg.yml|1 +
 hw/bsp/ruuvitag_rev_b/pkg.yml  |1 +
 hw/bsp/telee02/pkg.yml |1 +
 hw/bsp/vbluno51/pkg.yml|1 +
 hw/bsp/vbluno52/pkg.yml|1 +
 hw/drivers/i2s/i2s_nrf52/src/i2s_nrf52.c   |   26 +-
 hw/drivers/i2s/i2s_nrfx/src/i2s_nrfx.c |   21 +-
 hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c   |   47 +-
 hw/mcu/nordic/include/nrfx_config.h|   74 +
 .../nordic/include/nrfx_config_common.h}   |   62 +-
 hw/mcu/nordic/include/nrfx_glue.h  |   91 +-
 hw/mcu/nordic/include/nrfx_log.h   |  137 ++
 .../include/{nrfx_config.h => nrfx_config_nrf51.h} |6 +-
 hw/mcu/nordic/nrf52xxx/include/nrfx52810_config.h  |  208 --
 hw/mcu/nordic/nrf52xxx/include/nrfx52811_config.h  |  208 --
 hw/mcu/nordic/nrf52xxx/include/nrfx52840_config.h  |  171 --
 hw/mcu/nordic/nrf52xxx/include/nrfx52_config.h |  216 --
 hw/mcu/nordic/nrf52xxx/include/nrfx_config.h   |   35 -
 .../nordic/nrf52xxx/include/nrfx_config_nrf52810.h | 1363 
 .../nordic/nrf52xxx/include/nrfx_config_nrf52811.h | 1390 
 .../nordic/nrf52xxx/include/nrfx_config_nrf52832.h | 1735 +++
 .../nordic/nrf52xxx/include/nrfx_config_nrf52840.h | 1760 +++
 hw/mcu/nordic/nrf5340/include/nrfx_config.h| 2240 
 .../include/nrfx_config_nrf5340_application.h  | 1775 
 hw/mcu/nordic/nrf5340/tfm/include/tfm/tfm.h|2 +-
 hw/mcu/nordic/nrf5340/tfm/src/tfm.c|4 +-
 hw/mcu/nordic/nrf5340_net/include/nrfx_config.h| 1248 ---
 .../include/nrfx_config_nrf5340_network.h  |  934 
 hw/mcu/nordic/nrf91xx/include/nrfx9160_config.h|  199 --
 hw/mcu/nordic/nrf91xx/include/nrfx91_config.h  |  204 --
 hw/mcu/nordic/nrf91xx/include/nrfx_config.h|   29 -
 hw/mcu/nordic/nrf91xx/include/nrfx_config_nrf91.h  | 1346 
 hw/mcu/nordic/nrf91xx/syscfg.yml   |   13 +
 hw/mcu/nordic/pkg.yml  |8 +-
 53 files changed, 10719 insertions(+), 4865 deletions(-)
 create mode 100644 hw/mcu/nordic/include/nrfx_config.h
 copy hw/{mips-hal/src/arch/mips/__exit.c => 
mcu/nordic/include/nrfx_config_common.h} (51%)
 create mode 100644 hw/mcu/nordic/include/nrfx_log.h
 rename hw/mcu/nordic/nrf51xxx/include/{nrfx_config.h => nrfx_config_nrf51.h} 
(95%)
 delete mode 100644 hw/mcu/nordic/nrf52xxx/include/nrfx52810_config.h
 delete mode 100644 hw/mcu/nordic/nrf52xxx/include/nrfx52811_config.h
 delete mode 100644 hw/mcu/nordic/nrf52xxx/include/nrfx52840_config.h
 delete mode 100644 hw/mcu/nordic/nrf52xxx/include/nrfx52_config.h
 delete mode 100644 hw/mcu/nordic/nrf52xxx/include/nrfx_config.h
 create mode 100644 hw/mcu/nordic/nrf52xxx/include/nrfx_config_nrf52810.h
 create mode 100644 h

(mynewt-core) 03/06: hw/pwm_nrf52: Update nrfx to version 3.3.0

2024-01-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 036d9c176b8eb69e618c0f43b9bd5b8ac869f7c5
Author: Jerzy Kasenberg 
AuthorDate: Mon Jan 8 10:46:51 2024 +0100

hw/pwm_nrf52: Update nrfx to version 3.3.0

- NRFX_PWM_PIN_NOT_USED change to NRF_PWM_PIN_NOT_CONNECTED.
- Pin inversion update to match NRFX.
- NRF91 now have syscfg values for PWM

Signed-off-by: Jerzy Kasenberg 
---
 hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c | 47 
 hw/mcu/nordic/nrf91xx/syscfg.yml | 13 +
 2 files changed, 36 insertions(+), 24 deletions(-)

diff --git a/hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c 
b/hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c
index cdb4c5ac4..be00a274b 100644
--- a/hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c
+++ b/hw/drivers/pwm/pwm_nrf52/src/pwm_nrf52.c
@@ -58,10 +58,10 @@ static struct nrf52_pwm_dev_global instances[] =
 [0].in_use = false,
 [0].playing = false,
 [0].drv_instance = NRFX_PWM_INSTANCE(0),
-[0].config = NRFX_PWM_DEFAULT_CONFIG(NRFX_PWM_PIN_NOT_USED,
- NRFX_PWM_PIN_NOT_USED,
- NRFX_PWM_PIN_NOT_USED,
- NRFX_PWM_PIN_NOT_USED),
+[0].config = NRFX_PWM_DEFAULT_CONFIG(NRF_PWM_PIN_NOT_CONNECTED,
+ NRF_PWM_PIN_NOT_CONNECTED,
+ NRF_PWM_PIN_NOT_CONNECTED,
+ NRF_PWM_PIN_NOT_CONNECTED),
 [0].flags = NRFX_PWM_FLAG_LOOP,
 [0].duty_cycles = {0},
 [0].n_cycles = 1,
@@ -75,10 +75,10 @@ static struct nrf52_pwm_dev_global instances[] =
 [1].in_use = false,
 [1].playing = false,
 [1].drv_instance = NRFX_PWM_INSTANCE(1),
-[1].config = NRFX_PWM_DEFAULT_CONFIG(NRFX_PWM_PIN_NOT_USED,
- NRFX_PWM_PIN_NOT_USED,
- NRFX_PWM_PIN_NOT_USED,
- NRFX_PWM_PIN_NOT_USED),
+[1].config = NRFX_PWM_DEFAULT_CONFIG(NRF_PWM_PIN_NOT_CONNECTED,
+ NRF_PWM_PIN_NOT_CONNECTED,
+ NRF_PWM_PIN_NOT_CONNECTED,
+ NRF_PWM_PIN_NOT_CONNECTED),
 [1].flags = NRFX_PWM_FLAG_LOOP,
 [1].duty_cycles = {0},
 [1].n_cycles = 1,
@@ -92,10 +92,10 @@ static struct nrf52_pwm_dev_global instances[] =
 [2].in_use = false,
 [2].playing = false,
 [2].drv_instance = NRFX_PWM_INSTANCE(2),
-[2].config = NRFX_PWM_DEFAULT_CONFIG(NRFX_PWM_PIN_NOT_USED,
- NRFX_PWM_PIN_NOT_USED,
- NRFX_PWM_PIN_NOT_USED,
- NRFX_PWM_PIN_NOT_USED),
+[2].config = NRFX_PWM_DEFAULT_CONFIG(NRF_PWM_PIN_NOT_CONNECTED,
+ NRF_PWM_PIN_NOT_CONNECTED,
+ NRF_PWM_PIN_NOT_CONNECTED,
+ NRF_PWM_PIN_NOT_CONNECTED),
 [2].flags = NRFX_PWM_FLAG_LOOP,
 [2].duty_cycles = {0},
 [2].n_cycles = 1,
@@ -109,10 +109,10 @@ static struct nrf52_pwm_dev_global instances[] =
 [3].in_use = false,
 [3].playing = false,
 [3].drv_instance = NRFX_PWM_INSTANCE(3),
-[3].config = NRFX_PWM_DEFAULT_CONFIG(NRFX_PWM_PIN_NOT_USED,
- NRFX_PWM_PIN_NOT_USED,
- NRFX_PWM_PIN_NOT_USED,
- NRFX_PWM_PIN_NOT_USED),
+[3].config = NRFX_PWM_DEFAULT_CONFIG(NRF_PWM_PIN_NOT_CONNECTED,
+ NRF_PWM_PIN_NOT_CONNECTED,
+ NRF_PWM_PIN_NOT_CONNECTED,
+ NRF_PWM_PIN_NOT_CONNECTED),
 [3].flags = NRFX_PWM_FLAG_LOOP,
 [3].duty_cycles = {0},
 [3].n_cycles = 1,
@@ -250,10 +250,10 @@ init_instance(int inst_id, nrfx_pwm_config_t* init_conf)
 
 config = [inst_id].config;
 if (!init_conf) {
-config->output_pins[0] = NRFX_PWM_PIN_NOT_USED;
-config->output_pins[1] = NRFX_PWM_PIN_NOT_USED;
-config->output_pins[2] = NRFX_PWM_PIN_NOT_USED;
-config->output_pins[3] = NRFX_PWM_PIN_NOT_USED;
+config->output_pins[0] = NRF_PWM_PIN_NOT_CONNECTED;
+config->output_pins[1] = NRF_PWM_PIN_NOT_CONNECTED;
+config->output_pins[2] = NRF_PWM_PIN_NOT_CONNECTED;
+config->output_pins[3] = NRF_PWM_PIN_NOT_CONNECTED;
 config->irq_priority = 3; /* APP_IRQ_PRIORITY_LOW */
 config->base_clock = NRF_PWM_CLK_1MHz;
 config->count_mode = NRF_PWM_MODE_UP;
@@ -466,8 +466,7 @@ nrf52_pwm_configure_channel(struct pwm_dev *dev,
 

(mynewt-core) 04/06: hw/i2s_nrfx: Update to nrfx 3.3.0

2024-01-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 8561a0c4b7cf2cc8004eb9a4ac78faf077dd02da
Author: Jerzy Kasenberg 
AuthorDate: Mon Jan 8 10:47:54 2024 +0100

hw/i2s_nrfx: Update to nrfx 3.3.0

I2S driver was updated due to API change in version 3.3
Code seems to be able to support multiply instances of I2S peripherals.
NRFX_I2S_PIN_NOT_USED changed to NRF_I2S_PIN_NOT_CONNECTED.
---
 hw/drivers/i2s/i2s_nrfx/src/i2s_nrfx.c | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/hw/drivers/i2s/i2s_nrfx/src/i2s_nrfx.c 
b/hw/drivers/i2s/i2s_nrfx/src/i2s_nrfx.c
index c08d18b51..20cd154df 100644
--- a/hw/drivers/i2s/i2s_nrfx/src/i2s_nrfx.c
+++ b/hw/drivers/i2s/i2s_nrfx/src/i2s_nrfx.c
@@ -26,6 +26,7 @@
 #include 
 
 struct i2s_nrfx {
+nrfx_i2s_t inst;
 nrfx_i2s_config_t nrfx_i2s_cfg;
 bool running;
 int8_t nrfx_queued_count;
@@ -33,7 +34,9 @@ struct i2s_nrfx {
 struct i2s_sample_buffer *nrfx_buffers[2];
 };
 
-static struct i2s_nrfx i2s_nrfx;
+static struct i2s_nrfx i2s_nrfx = {
+NRFX_I2S_INSTANCE(0),
+};
 
 static void
 nrfx_add_buffer(struct i2s *i2s, struct i2s_sample_buffer *buffer)
@@ -64,9 +67,9 @@ nrfx_add_buffer(struct i2s *i2s, struct i2s_sample_buffer 
*buffer)
 i2s_nrfx.nrfx_queued_count++;
 if (i2s_nrfx.nrfx_queued_count == 1) {
 i2s_driver_state_changed (i2s, I2S_STATE_RUNNING);
-err = nrfx_i2s_start(_buffers, buffer_size, 0);
+err = nrfx_i2s_start(_nrfx.inst, _buffers, buffer_size, 0);
 } else {
-err = nrfx_i2s_next_buffers_set(_buffers);
+err = nrfx_i2s_next_buffers_set(_nrfx.inst, _buffers);
 }
 
 assert(err == NRFX_SUCCESS);
@@ -113,7 +116,7 @@ i2s_nrfx_init(struct i2s *i2s, const struct i2s_cfg *cfg)
 
 i2s_nrfx.i2s = i2s;
 
-NVIC_SetVector(nrfx_get_irq_number(NRF_I2S), 
(uint32_t)nrfx_i2s_irq_handler);
+NVIC_SetVector(nrfx_get_irq_number(NRF_I2S0), 
(uint32_t)nrfx_i2s_0_irq_handler);
 
 i2s_nrfx.nrfx_i2s_cfg = cfg->nrfx_i2s_cfg;
 switch (cfg->nrfx_i2s_cfg.sample_width) {
@@ -144,17 +147,17 @@ i2s_nrfx_init(struct i2s *i2s, const struct i2s_cfg *cfg)
 }
 
 i2s->direction = I2S_INVALID;
-if (cfg->nrfx_i2s_cfg.sdin_pin != NRFX_I2S_PIN_NOT_USED) {
+if (cfg->nrfx_i2s_cfg.sdin_pin != NRF_I2S_PIN_NOT_CONNECTED) {
 i2s->direction = I2S_IN;
 }
-if (cfg->nrfx_i2s_cfg.sdout_pin != NRFX_I2S_PIN_NOT_USED) {
+if (cfg->nrfx_i2s_cfg.sdout_pin != NRF_I2S_PIN_NOT_CONNECTED) {
 i2s->direction |= I2S_OUT;
 }
 
 rc = i2s_init(i2s, cfg->pool);
 
 if (rc != OS_OK) {
-nrfx_i2s_uninit();
+nrfx_i2s_uninit(_nrfx.inst);
 goto end;
 }
 
@@ -178,7 +181,7 @@ i2s_driver_stop(struct i2s *i2s)
 
 if (i2s_nrfx.running) {
 i2s_nrfx.running = false;
-nrfx_i2s_stop();
+nrfx_i2s_stop(_nrfx.inst);
 }
 
 while (NULL != (buffer = i2s_driver_buffer_get(i2s))) {
@@ -280,7 +283,7 @@ i2s_driver_start(struct i2s *i2s)
 if (!i2s_nrfx.running) {
 i2s_nrfx.running = true;
 i2s_nrfx_select_clock_cfg(_nrfx.nrfx_i2s_cfg, i2s->sample_rate);
-nrfx_i2s_init(_nrfx.nrfx_i2s_cfg, i2s_nrfx_data_handler);
+nrfx_i2s_init(_nrfx.inst, _nrfx.nrfx_i2s_cfg, 
i2s_nrfx_data_handler);
 
 assert(i2s_nrfx.nrfx_buffers[0] == NULL);
 assert(i2s_nrfx.nrfx_buffers[1] == NULL);



(mynewt-core) 06/06: hw/bsp: Update boards to nrfx 3.3.0

2024-01-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 64e4e36dbceea102ac334145ae4d045589be1119
Author: Jerzy Kasenberg 
AuthorDate: Wed Jan 10 09:49:16 2024 +0100

hw/bsp: Update boards to nrfx 3.3.0

Now nrfx_config.h uses more specific selector for Nordic MCUs.
This adds definition NRF5_XXAA to all affected BSPs.
Definition NRF52/1 is still in place in case code other then NRFX
needs it.

Signed-off-by: Jerzy Kasenberg 
---
 hw/bsp/ada_feather_nrf52/pkg.yml   | 1 +
 hw/bsp/arduino_primo_nrf52/pkg.yml | 1 +
 hw/bsp/bbc_microbit/pkg.yml| 1 +
 hw/bsp/ble400/pkg.yml  | 1 +
 hw/bsp/bmd200/pkg.yml  | 1 +
 hw/bsp/bmd300eval/pkg.yml  | 1 +
 hw/bsp/calliope_mini/pkg.yml   | 1 +
 hw/bsp/dwm1001-dev/pkg.yml | 1 +
 hw/bsp/nina-b1/pkg.yml | 1 +
 hw/bsp/nordic_pca10028-16k/pkg.yml | 1 +
 hw/bsp/nordic_pca10028/pkg.yml | 1 +
 hw/bsp/nordic_pca10040/pkg.yml | 1 +
 hw/bsp/nordic_pca20020/pkg.yml | 1 +
 hw/bsp/nrf51-arduino_101/pkg.yml   | 1 +
 hw/bsp/nrf51-blenano/pkg.yml   | 1 +
 hw/bsp/pinetime/pkg.yml| 1 +
 hw/bsp/puckjs/pkg.yml  | 1 +
 hw/bsp/rb-blend2/pkg.yml   | 1 +
 hw/bsp/rb-nano2/pkg.yml| 1 +
 hw/bsp/ruuvitag_rev_b/pkg.yml  | 1 +
 hw/bsp/telee02/pkg.yml | 1 +
 hw/bsp/vbluno51/pkg.yml| 1 +
 hw/bsp/vbluno52/pkg.yml| 1 +
 23 files changed, 23 insertions(+)

diff --git a/hw/bsp/ada_feather_nrf52/pkg.yml b/hw/bsp/ada_feather_nrf52/pkg.yml
index d75ff688f..0807d9dac 100644
--- a/hw/bsp/ada_feather_nrf52/pkg.yml
+++ b/hw/bsp/ada_feather_nrf52/pkg.yml
@@ -29,6 +29,7 @@ pkg.keywords:
 
 pkg.cflags:
 - '-DNRF52'
+- '-DNRF52832_XXAA'
 
 pkg.cflags.HARDFLOAT:
 - -mfloat-abi=hard -mfpu=fpv4-sp-d16
diff --git a/hw/bsp/arduino_primo_nrf52/pkg.yml 
b/hw/bsp/arduino_primo_nrf52/pkg.yml
index 1624b0afd..cceacf26e 100644
--- a/hw/bsp/arduino_primo_nrf52/pkg.yml
+++ b/hw/bsp/arduino_primo_nrf52/pkg.yml
@@ -29,6 +29,7 @@ pkg.keywords:
 
 pkg.cflags:
 - '-DNRF52'
+- '-DNRF52832_XXAA'
 
 pkg.cflags.HARDFLOAT:
 - -mfloat-abi=hard -mfpu=fpv4-sp-d16
diff --git a/hw/bsp/bbc_microbit/pkg.yml b/hw/bsp/bbc_microbit/pkg.yml
index 8659b1945..3d42ed33d 100644
--- a/hw/bsp/bbc_microbit/pkg.yml
+++ b/hw/bsp/bbc_microbit/pkg.yml
@@ -28,6 +28,7 @@ pkg.keywords:
 
 pkg.cflags:
 - '-DNRF51'
+- '-DNRF51822_XXAA'
 
 pkg.deps:
 - "@apache-mynewt-core/hw/mcu/nordic/nrf51xxx"
diff --git a/hw/bsp/ble400/pkg.yml b/hw/bsp/ble400/pkg.yml
index 83365dd05..a9ecd6c29 100644
--- a/hw/bsp/ble400/pkg.yml
+++ b/hw/bsp/ble400/pkg.yml
@@ -29,6 +29,7 @@ pkg.keywords:
 
 pkg.cflags:
 - '-DNRF51'
+- '-DNRF51822_XXAA'
 
 pkg.deps:
 - "@apache-mynewt-core/hw/mcu/nordic/nrf51xxx"
diff --git a/hw/bsp/bmd200/pkg.yml b/hw/bsp/bmd200/pkg.yml
index caced4de6..de9052446 100644
--- a/hw/bsp/bmd200/pkg.yml
+++ b/hw/bsp/bmd200/pkg.yml
@@ -29,6 +29,7 @@ pkg.keywords:
 
 pkg.cflags:
 - '-DNRF51'
+- '-DNRF51822_XXAA'
 
 pkg.deps:
 - "@apache-mynewt-core/hw/mcu/nordic/nrf51xxx"
diff --git a/hw/bsp/bmd300eval/pkg.yml b/hw/bsp/bmd300eval/pkg.yml
index a3037514f..71fde048e 100644
--- a/hw/bsp/bmd300eval/pkg.yml
+++ b/hw/bsp/bmd300eval/pkg.yml
@@ -29,6 +29,7 @@ pkg.keywords:
 
 pkg.cflags:
 - '-DNRF52'
+- '-DNRF52832_XXAA'
 
 pkg.cflags.HARDFLOAT:
 - -mfloat-abi=hard -mfpu=fpv4-sp-d16
diff --git a/hw/bsp/calliope_mini/pkg.yml b/hw/bsp/calliope_mini/pkg.yml
index e698a2c91..f838bf2df 100644
--- a/hw/bsp/calliope_mini/pkg.yml
+++ b/hw/bsp/calliope_mini/pkg.yml
@@ -28,6 +28,7 @@ pkg.keywords:
 
 pkg.cflags:
 - '-DNRF51'
+- '-DNRF51822_XXAA'
 
 pkg.deps:
 - "@apache-mynewt-core/hw/mcu/nordic/nrf51xxx"
diff --git a/hw/bsp/dwm1001-dev/pkg.yml b/hw/bsp/dwm1001-dev/pkg.yml
index f7dfce5cc..e441878c5 100644
--- a/hw/bsp/dwm1001-dev/pkg.yml
+++ b/hw/bsp/dwm1001-dev/pkg.yml
@@ -28,6 +28,7 @@ pkg.keywords:
 
 pkg.cflags:
 - '-DNRF52'
+- '-DNRF52832_XXAA'
 
 pkg.cflags.HARDFLOAT:
 - -mfloat-abi=hard -mfpu=fpv4-sp-d16
diff --git a/hw/bsp/nina-b1/pkg.yml b/hw/bsp/nina-b1/pkg.yml
index 98a2277ab..c5383ea82 100644
--- a/hw/bsp/nina-b1/pkg.yml
+++ b/hw/bsp/nina-b1/pkg.yml
@@ -28,6 +28,7 @@ pkg.keywords:
 
 pkg.cflags:
 - '-DNRF52'
+- '-DNRF52832_XXAA'
 
 pkg.cflags.HARDFLOAT:
 - -mfloat-abi=hard -mfpu=fpv4-sp-d16
diff --git a/hw/bsp/nordic_pca10028-16k/pkg.yml 
b/hw/bsp/nordic_pca10028-16k/pkg.yml
index c96278f98..70c9f40fc 100644
--- a/hw/bsp/nordic_pca10028-16k/pkg.yml
+++ b/hw/bsp/nordic_pca10028-16k/pkg.yml
@@ -30,6 +30,7 @@ pkg.keywords:
 
 pkg.cflags:
 - '-DNRF51'
+- '-DNRF51422_XXAA'
 
 pkg.deps:
 - "@apache-mynewt-core/hw/mcu/nordic/nrf51xxx"
diff --git a/hw/bsp/nordic_pca10028/pkg.yml b/hw/bsp/nordic_pca10028/

(mynewt-core) 05/06: hw/i2s_nrf52: Update to nrfx 3.3.0

2024-01-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 91117b860924f3449cc7c14cc4e0e5682b80e9e4
Author: Jerzy Kasenberg 
AuthorDate: Tue Jan 9 14:19:07 2024 +0100

hw/i2s_nrf52: Update to nrfx 3.3.0

I2S driver was updated due to API change in version 3.3
Code seems to be able to support multiply instances of I2S peripherals.
NRFX_I2S_PIN_NOT_USED changed to NRF_I2S_PIN_NOT_CONNECTED.

Error in microphone handling was also fixed (with change that is already
present in i2s_nrfx.c

Signed-off-by: Jerzy Kasenberg 
---
 hw/drivers/i2s/i2s_nrf52/src/i2s_nrf52.c | 26 +-
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/hw/drivers/i2s/i2s_nrf52/src/i2s_nrf52.c 
b/hw/drivers/i2s/i2s_nrf52/src/i2s_nrf52.c
index 9eba38fc7..d3032ed51 100644
--- a/hw/drivers/i2s/i2s_nrf52/src/i2s_nrf52.c
+++ b/hw/drivers/i2s/i2s_nrf52/src/i2s_nrf52.c
@@ -25,6 +25,7 @@
 #include 
 
 struct nrf52_i2s {
+nrfx_i2s_t inst;
 nrfx_i2s_config_t nrfx_i2s_cfg;
 bool running;
 int8_t nrfx_queued_count;
@@ -32,13 +33,16 @@ struct nrf52_i2s {
 struct i2s_sample_buffer *nrfx_buffers[2];
 };
 
-static struct nrf52_i2s nrf52_i2s;
+static struct nrf52_i2s nrf52_i2s = {
+NRFX_I2S_INSTANCE(0),
+};
 
 static void
 nrfx_add_buffer(struct i2s *i2s, struct i2s_sample_buffer *buffer)
 {
 nrfx_i2s_buffers_t nrfx_buffers = {0};
 nrfx_err_t err;
+uint16_t buffer_size;
 
 assert(i2s != NULL);
 if (buffer == NULL) {
@@ -47,6 +51,9 @@ nrfx_add_buffer(struct i2s *i2s, struct i2s_sample_buffer 
*buffer)
 
 if (i2s->direction == I2S_OUT || i2s->direction == I2S_OUT_IN) {
 nrfx_buffers.p_tx_buffer = buffer->sample_data;
+buffer_size = buffer->sample_count * i2s->sample_size_in_bytes / 4;
+} else {
+buffer_size = buffer->capacity * i2s->sample_size_in_bytes / 4;
 }
 if (i2s->direction == I2S_IN || i2s->direction == I2S_OUT_IN) {
 nrfx_buffers.p_rx_buffer = buffer->sample_data;
@@ -59,9 +66,9 @@ nrfx_add_buffer(struct i2s *i2s, struct i2s_sample_buffer 
*buffer)
 nrf52_i2s.nrfx_queued_count++;
 if (nrf52_i2s.nrfx_queued_count == 1) {
 i2s_driver_state_changed (i2s, I2S_STATE_RUNNING);
-err = nrfx_i2s_start(_buffers, buffer->sample_count * 
i2s->sample_size_in_bytes / 4, 0);
+err = nrfx_i2s_start(_i2s.inst, _buffers, buffer_size, 0);
 } else {
-err = nrfx_i2s_next_buffers_set(_buffers);
+err = nrfx_i2s_next_buffers_set(_i2s.inst, _buffers);
 }
 
 assert(err == NRFX_SUCCESS);
@@ -89,6 +96,7 @@ nrf52_i2s_data_handler(const nrfx_i2s_buffers_t *p_released, 
uint32_t status)
 assert(buffer->sample_data == p_released->p_tx_buffer || 
buffer->sample_data == p_released->p_rx_buffer);
 nrf52_i2s.nrfx_buffers[0] = nrf52_i2s.nrfx_buffers[1];
 nrf52_i2s.nrfx_buffers[1] = NULL;
+buffer->sample_count = buffer->capacity;
 i2s_driver_buffer_put(nrf52_i2s.i2s, buffer);
 }
 if (nrf52_i2s.running && nrf52_i2s.nrfx_queued_count < 2) {
@@ -107,7 +115,7 @@ nrf52_i2s_init(struct i2s *i2s, const struct i2s_cfg *cfg)
 
 nrf52_i2s.i2s = i2s;
 
-NVIC_SetVector(nrfx_get_irq_number(NRF_I2S), (uint32_t) 
nrfx_i2s_irq_handler);
+NVIC_SetVector(nrfx_get_irq_number(NRF_I2S), 
(uint32_t)nrfx_i2s_0_irq_handler);
 
 nrf52_i2s.nrfx_i2s_cfg = cfg->nrfx_i2s_cfg;
 switch (cfg->nrfx_i2s_cfg.sample_width) {
@@ -123,17 +131,17 @@ nrf52_i2s_init(struct i2s *i2s, const struct i2s_cfg *cfg)
 }
 
 i2s->direction = I2S_INVALID;
-if (cfg->nrfx_i2s_cfg.sdin_pin != NRFX_I2S_PIN_NOT_USED) {
+if (cfg->nrfx_i2s_cfg.sdin_pin != NRF_I2S_PIN_NOT_CONNECTED) {
 i2s->direction = I2S_IN;
 }
-if (cfg->nrfx_i2s_cfg.sdout_pin != NRFX_I2S_PIN_NOT_USED) {
+if (cfg->nrfx_i2s_cfg.sdout_pin != NRF_I2S_PIN_NOT_CONNECTED) {
 i2s->direction |= I2S_OUT;
 }
 
 rc = i2s_init(i2s, cfg->pool);
 
 if (rc != OS_OK) {
-nrfx_i2s_uninit();
+nrfx_i2s_uninit(_i2s.inst);
 goto end;
 }
 
@@ -157,7 +165,7 @@ i2s_driver_stop(struct i2s *i2s)
 
 if (nrf52_i2s.running) {
 nrf52_i2s.running = false;
-nrfx_i2s_stop();
+nrfx_i2s_stop(_i2s.inst);
 }
 
 while (NULL != (buffer = i2s_driver_buffer_get(i2s))) {
@@ -230,7 +238,7 @@ i2s_driver_start(struct i2s *i2s)
 if (!nrf52_i2s.running) {
 nrf52_i2s.running = true;
 nrf52_select_i2s_clock_cfg(_i2s.nrfx_i2s_cfg, i2s->sample_rate);
-nrfx_i2s_init(_i2s.nrfx_i2s_cfg, nrf52_i2s_data_handler);
+nrfx_i2s_init(_i2s.inst, _i2s.nrfx_i2s_cfg, 
nrf52_i2s_data_handler);
 
 assert(nrf52_i2s.nrfx_buffers[0] == NULL);
 assert(nrf52_i2s.nrfx_buffers[1] == NULL);



(mynewt-core) 02/06: nrf5340/tfm: update nrfx to version 3.3.0

2024-01-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 93793c9bdfeb4e7930ddd46b2c34c296c35086f6
Author: Jerzy Kasenberg 
AuthorDate: Mon Jan 8 10:43:32 2024 +0100

nrf5340/tfm: update nrfx to version 3.3.0

Signed-off-by: Jerzy Kasenberg 
---
 hw/mcu/nordic/nrf5340/tfm/include/tfm/tfm.h | 2 +-
 hw/mcu/nordic/nrf5340/tfm/src/tfm.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/mcu/nordic/nrf5340/tfm/include/tfm/tfm.h 
b/hw/mcu/nordic/nrf5340/tfm/include/tfm/tfm.h
index 5e50d0c57..e6482eb0a 100644
--- a/hw/mcu/nordic/nrf5340/tfm/include/tfm/tfm.h
+++ b/hw/mcu/nordic/nrf5340/tfm/include/tfm/tfm.h
@@ -63,7 +63,7 @@ int SECURE_CALL tfm_uicr_otp_write(uint8_t n, uint32_t val);
  * TFM_ERR_INVALID_PARAM - when pin_number is not present on chip
  * TFM_ERR_ACCESS_DENIED - when non-secure code is not allowed to 
change pin's MCU
  */
-int SECURE_CALL tfm_gpio_pin_mcu_select(uint32_t pin_number, 
nrf_gpio_pin_mcusel_t mcu_sel);
+int SECURE_CALL tfm_gpio_pin_mcu_select(uint32_t pin_number, 
nrf_gpio_pin_sel_t mcu_sel);
 
 /**
  * Function to set or read device protection status
diff --git a/hw/mcu/nordic/nrf5340/tfm/src/tfm.c 
b/hw/mcu/nordic/nrf5340/tfm/src/tfm.c
index 22573db65..cc8c293a4 100644
--- a/hw/mcu/nordic/nrf5340/tfm/src/tfm.c
+++ b/hw/mcu/nordic/nrf5340/tfm/src/tfm.c
@@ -85,7 +85,7 @@ tfm_uicr_protect_device(uint8_t *approtect, uint8_t 
*secure_approtect, uint8_t *
 }
 
 int SECURE_CALL
-tfm_gpio_pin_mcu_select(uint32_t pin_number, nrf_gpio_pin_mcusel_t mcu_sel)
+tfm_gpio_pin_mcu_select(uint32_t pin_number, nrf_gpio_pin_sel_t mcu_sel)
 {
 int err = 0;
 uint32_t pin_mask = (1u << (pin_number & 31));
@@ -95,7 +95,7 @@ tfm_gpio_pin_mcu_select(uint32_t pin_number, 
nrf_gpio_pin_mcusel_t mcu_sel)
 } else if (((pin_number < 32) && (MYNEWT_VAL(TFM_MCU_SEL_GPIO0) & 
pin_mask)) ||
((pin_number >= 32) && (pin_number < 64) &&
 (MYNEWT_VAL(TFM_MCU_SEL_GPIO1) & pin_mask))) {
-nrf_gpio_pin_mcu_select(pin_number, mcu_sel);
+nrf_gpio_pin_control_select(pin_number, mcu_sel);
 } else {
 err = TFM_ERR_ACCESS_DENIED;
 }



[mynewt-nimble] branch master updated: apps/bttester: disable EATT in default config

2023-08-31 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new b5e107e9 apps/bttester: disable EATT in default config
b5e107e9 is described below

commit b5e107e9c55f32d18b16e5afc0a7e1720b901b68
Author: Krzysztof Kopyściński 
AuthorDate: Thu Aug 31 11:07:59 2023 +0200

apps/bttester: disable EATT in default config

EATT causes issues with tests GAP/SEC/SEM/BV-{65-67}-C. It is
experimental feature and should not influence config for current test plan.
---
 apps/bttester/syscfg.yml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/apps/bttester/syscfg.yml b/apps/bttester/syscfg.yml
index 4bd16fc7..5db9af2e 100644
--- a/apps/bttester/syscfg.yml
+++ b/apps/bttester/syscfg.yml
@@ -144,5 +144,3 @@ syscfg.vals:
 
 BLE_MESH_ADV_BUF_COUNT: 20
 BLE_MESH_TX_SEG_MAX: 6
-
-BLE_EATT_CHAN_NUM: 1



[mynewt-nimble] branch master updated: host/ble_l2cap_coc: coc_rx.sdus index should not exceed BLE_L2CAP_SDU_BUFF_CNT

2023-07-25 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new dc60f90a3 host/ble_l2cap_coc: coc_rx.sdus index should not exceed 
BLE_L2CAP_SDU_BUFF_CNT
dc60f90a3 is described below

commit dc60f90a379b92262b2e58fc2e48ae65cd4f45d1
Author: Krzysztof Kopyściński 
AuthorDate: Tue Jul 25 08:39:41 2023 +0200

host/ble_l2cap_coc: coc_rx.sdus index should not exceed 
BLE_L2CAP_SDU_BUFF_CNT

Multiple calls to `ble_l2cap_coc_recv_ready` with
`BLE_L2CAP_SDU_BUFF_CNT == 1` will lead to assigning coc_rx.sdus outside
array range - so this will (most likely) overwrite rest of stucture.
This will lead to either undefined behavior or crash when structure
members are accessed.
---
 nimble/host/src/ble_l2cap_coc.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/nimble/host/src/ble_l2cap_coc.c b/nimble/host/src/ble_l2cap_coc.c
index ae5624ce9..25727ee19 100644
--- a/nimble/host/src/ble_l2cap_coc.c
+++ b/nimble/host/src/ble_l2cap_coc.c
@@ -341,7 +341,12 @@ ble_l2cap_coc_chan_alloc(struct ble_hs_conn *conn, 
uint16_t psm, uint16_t mtu,
 chan->coc_rx.sdus[i] = NULL;
 }
 chan->coc_rx.current_sdu_idx = 0;
-chan->coc_rx.next_sdu_alloc_idx = chan->coc_rx.sdus[0] == NULL ? 0 : 1;
+
+if (BLE_L2CAP_SDU_BUFF_CNT == 1) {
+chan->coc_rx.next_sdu_alloc_idx = 0;
+} else {
+chan->coc_rx.next_sdu_alloc_idx = chan->coc_rx.sdus[0] == NULL ? 0 : 1;
+}
 
 /* Number of credits should allow to send full SDU with on given
  * L2CAP MTU



[mynewt-core] 01/02: lvgl/trackball: Add cursor image

2023-06-07 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 9ac0d86ed0bcbae99e788d58253ed67b9f595cb1
Author: Jerzy Kasenberg 
AuthorDate: Tue Jun 6 14:21:25 2023 +0200

lvgl/trackball: Add cursor image

As temporary solution character from font was used as cursor
image.
Now there is normal triangle shaped cursor.
Additionally cursor will change to drag cursor when button
(track ball) is held for specific number of ms.

Signed-off-by: Jerzy Kasenberg 
---
 .../display/lvgl/indev/trackball/src/trackball.c   | 129 -
 1 file changed, 126 insertions(+), 3 deletions(-)

diff --git a/hw/drivers/display/lvgl/indev/trackball/src/trackball.c 
b/hw/drivers/display/lvgl/indev/trackball/src/trackball.c
index f1a2eec93..9a98366bc 100644
--- a/hw/drivers/display/lvgl/indev/trackball/src/trackball.c
+++ b/hw/drivers/display/lvgl/indev/trackball/src/trackball.c
@@ -158,6 +158,116 @@ trackball_button(void *arg)
 }
 }
 
+#ifndef LV_ATTRIBUTE_MEM_ALIGN
+#define LV_ATTRIBUTE_MEM_ALIGN
+#endif
+
+#ifndef LV_ATTRIBUTE_IMG_CURSOR
+#define LV_ATTRIBUTE_IMG_CURSOR
+#endif
+
+static const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST uint8_t 
cursor_normal_map[] = {
+0x00, 0x00, 0x00, 0x00, /*Color of index 0*/
+0xff, 0xff, 0xff, 0xff, /*Color of index 1*/
+0x00, 0x00, 0x00, 0xff, /*Color of index 2*/
+0x00, 0x00, 0x00, 0x00, /*Color of index 3*/
+0x00, 0x00, 0x00, 0x00, /*Color of index 4*/
+0x00, 0x00, 0x00, 0x00, /*Color of index 5*/
+0x00, 0x00, 0x00, 0x00, /*Color of index 6*/
+0x00, 0x00, 0x00, 0x00, /*Color of index 7*/
+0x00, 0x00, 0x00, 0x00, /*Color of index 8*/
+0x00, 0x00, 0x00, 0x00, /*Color of index 9*/
+0x00, 0x00, 0x00, 0x00, /*Color of index 10*/
+0x00, 0x00, 0x00, 0x00, /*Color of index 11*/
+0x00, 0x00, 0x00, 0x00, /*Color of index 12*/
+0x00, 0x00, 0x00, 0x00, /*Color of index 13*/
+0x00, 0x00, 0x00, 0x00, /*Color of index 14*/
+0x00, 0x00, 0x00, 0x00, /*Color of index 15*/
+
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x11, 0x12, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x11, 0x11, 0x20, 0x00, 0x00, 0x00,
+0x02, 0x11, 0x11, 0x12, 0x00, 0x00, 0x00,
+0x02, 0x11, 0x11, 0x11, 0x20, 0x00, 0x00,
+0x02, 0x11, 0x11, 0x11, 0x12, 0x00, 0x00,
+0x02, 0x11, 0x11, 0x11, 0x11, 0x20, 0x00,
+0x02, 0x11, 0x11, 0x11, 0x11, 0x22, 0x00,
+0x02, 0x11, 0x11, 0x11, 0x22, 0x00, 0x00,
+0x02, 0x11, 0x12, 0x22, 0x00, 0x00, 0x00,
+0x02, 0x12, 0x20, 0x00, 0x00, 0x00, 0x00,
+0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const lv_img_dsc_t cursor_normal_img_dsc = {
+.header.cf = LV_IMG_CF_INDEXED_4BIT,
+.header.always_zero = 0,
+.header.reserved = 0,
+.header.w = 13,
+.header.h = 17,
+.data_size = 183,
+.data = cursor_normal_map,
+};
+
+
+static const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST uint8_t 
cursor_drag_map[] = {
+0x00, 0x00, 0x00, 0x00, /*Color of index 0*/
+0xff, 0xff, 0x00, 0x01, /*Color of index 1*/
+0x80, 0x80, 0x15, 0x04, /*Color of index 2*/
+0x9d, 0x9d, 0x34, 0x06, /*Color of index 3*/
+0xb8, 0xb8, 0x45, 0x12, /*Color of index 4*/
+0x83, 0x83, 0x30, 0x1a, /*Color of index 5*/
+0xb8, 0xb8, 0x44, 0x3a, /*Color of index 6*/
+0x81, 0x82, 0x30, 0x4b, /*Color of index 7*/
+0xb7, 0xb7, 0x44, 0x79, /*Color of index 8*/
+0xb7, 0xb7, 0x43, 0x91, /*Color of index 9*/
+0x81, 0x82, 0x30, 0x69, /*Color of index 10*/
+0xb8, 0xb8, 0x43, 0xae, /*Color of index 11*/
+0x80, 0x81, 0x2f, 0x85, /*Color of index 12*/
+0xb8, 0xb8, 0x43, 0xe8, /*Color of index 13*/
+0x81, 0x81, 0x30, 0xc8, /*Color of index 14*/
+0x81, 0x82, 0x30, 0xed, /*Color of index 15*/
+
+0x00, 0x00, 0x5c, 0xe7, 0x07, 0xec, 0x50, 0x00, 0x00,
+0x00, 0x2a, 0xfe, 0xa5, 0x05, 0xae, 0xfa, 0x10, 0x00,
+0x01, 0xcf, 0x73, 0x69, 0x99, 0x63, 0x7f, 0xc0, 0x00,
+0x0a, 0xf5, 0x6d, 0xdb, 0x9b, 0xdd, 0x47, 0xfa, 0x00,
+0x5f, 0x76, 0xd9, 0x41, 0x01, 0x49, 0xd4, 0xaf, 0x50,
+0xae, 0x3b, 0xb4, 0x96, 0x06, 0x94, 0xbb, 0x5e, 0xa0,
+0xec, 0x6d, 0x49, 0xd4, 0x04, 0xd8, 0x4d, 0x6c, 0xe0,
+0xf7, 0x8b, 0x4d, 0x60, 0x00, 0x6d, 0x4b, 0x87, 0xe0,
+0xf5, 0x99, 0x6d, 0x40, 0x00, 0x4d, 0x4b, 0x87, 0xf0,
+0xf7, 0x8b, 0x4d, 0x60, 0x00, 0x6d, 0x4b, 0x87, 0xf0,
+0xea, 0x6d, 0x49, 0xd6, 0x46, 0xd9, 0x4d, 0x6a, 0xe0,
+0xae, 0x3d, 0x94, 0x9d, 0xdd, 0x94, 0xbb, 0x5e, 0xa0,
+0x5f, 0xa4, 0xd9, 0x44, 0x64, 0x49, 0xd4

[mynewt-core] branch master updated (7fc827ed2 -> 2a4996335)

2023-06-07 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


from 7fc827ed2 Use syscfg settign for sysinit stage numbers This allows the 
target to rearrange package initialization order via syscfg override
 new 9ac0d86ed lvgl/trackball: Add cursor image
 new 2a4996335 lvgl/trackball: Update drag time

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../display/lvgl/indev/trackball/src/trackball.c   | 129 -
 hw/drivers/display/lvgl/indev/trackball/syscfg.yml |   2 +-
 2 files changed, 127 insertions(+), 4 deletions(-)



[mynewt-core] 02/02: lvgl/trackball: Update drag time

2023-06-07 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 2a49963354057758821afd236d124faa1f00de98
Author: Jerzy Kasenberg 
AuthorDate: Tue Jun 6 14:22:37 2023 +0200

lvgl/trackball: Update drag time

Time needed to engage drag mode reduced to 0.5s

Signed-off-by: Jerzy Kasenberg 
---
 hw/drivers/display/lvgl/indev/trackball/syscfg.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/drivers/display/lvgl/indev/trackball/syscfg.yml 
b/hw/drivers/display/lvgl/indev/trackball/syscfg.yml
index 7ec695f88..4086455d7 100644
--- a/hw/drivers/display/lvgl/indev/trackball/syscfg.yml
+++ b/hw/drivers/display/lvgl/indev/trackball/syscfg.yml
@@ -63,4 +63,4 @@ syscfg.defs:
 description: >
 When this time is specified, holding button for this amount of time
 start sticky button functionality.
-value: 800
+value: 500



[mynewt-core] 12/13: adc_touch: Add adc handler for nrfx/stm32f7/stm32f4

2023-05-24 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 7a07e9c9c33d9337bdd7e16505378b4939939aa2
Author: Jerzy Kasenberg 
AuthorDate: Thu May 18 14:45:04 2023 +0200

adc_touch: Add adc handler for nrfx/stm32f7/stm32f4

adc_touch driver requires code that actually reads ADC.
This change provides implementations for nrfx and two STM32 families.

Signed-off-by: Jerzy Kasenberg 
---
 .../display/lvgl/indev/adc_touch/adc_nrfx/pkg.yml  |  31 +++
 .../lvgl/indev/adc_touch/adc_nrfx/src/adc_nrfx.c   | 117 +++
 .../lvgl/indev/adc_touch/adc_stm32f4/pkg.yml   |  30 +++
 .../indev/adc_touch/adc_stm32f4/src/adc_stm32f4.c  | 179 
 .../lvgl/indev/adc_touch/adc_stm32f7/pkg.yml   |  30 +++
 .../indev/adc_touch/adc_stm32f7/src/adc_stm32f7.c  | 224 +
 hw/drivers/display/lvgl/indev/adc_touch/syscfg.yml |   5 +
 7 files changed, 616 insertions(+)

diff --git a/hw/drivers/display/lvgl/indev/adc_touch/adc_nrfx/pkg.yml 
b/hw/drivers/display/lvgl/indev/adc_touch/adc_nrfx/pkg.yml
new file mode 100644
index 0..4a96bbecb
--- /dev/null
+++ b/hw/drivers/display/lvgl/indev/adc_touch/adc_nrfx/pkg.yml
@@ -0,0 +1,31 @@
+#
+# 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: hw/drivers/display/lvgl/indev/adc_touch/adc_nrfx
+pkg.description: ADC driver for touch driver
+pkg.keywords:
+- display
+- touch
+- nrfx
+
+pkg.apis:
+- adc_touch_adc
+
+pkg.deps:
+- hw/drivers/display/lvgl/indev/adc_touch
diff --git a/hw/drivers/display/lvgl/indev/adc_touch/adc_nrfx/src/adc_nrfx.c 
b/hw/drivers/display/lvgl/indev/adc_touch/adc_nrfx/src/adc_nrfx.c
new file mode 100644
index 0..c1764e298
--- /dev/null
+++ b/hw/drivers/display/lvgl/indev/adc_touch/adc_nrfx/src/adc_nrfx.c
@@ -0,0 +1,117 @@
+/**
+ * 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.
+ */
+
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+static adc_dev_t adc_dev;
+
+static struct ain_pin {
+int pin;
+nrf_saadc_input_t ain;
+} const ain_pins[8] = {
+#if defined (NRF52)
+{2, NRF_SAADC_INPUT_AIN0},
+{3, NRF_SAADC_INPUT_AIN1},
+{4, NRF_SAADC_INPUT_AIN2},
+{5, NRF_SAADC_INPUT_AIN3},
+{28, NRF_SAADC_INPUT_AIN4},
+{29, NRF_SAADC_INPUT_AIN5},
+{30, NRF_SAADC_INPUT_AIN6},
+{31, NRF_SAADC_INPUT_AIN7},
+#elif defined (NRF53_SERIES)
+{4, NRF_SAADC_INPUT_AIN0},
+{5, NRF_SAADC_INPUT_AIN1},
+{6, NRF_SAADC_INPUT_AIN2},
+{7, NRF_SAADC_INPUT_AIN3},
+{25, NRF_SAADC_INPUT_AIN4},
+{26, NRF_SAADC_INPUT_AIN5},
+{27, NRF_SAADC_INPUT_AIN6},
+{28, NRF_SAADC_INPUT_AIN7},
+#endif
+};
+
+static struct adc_chan_cfg adc_x = {
+.acq_time = ADC_ACQTIME_40US,
+.differential = false,
+.gain = ADC_GAIN1_4,
+.pin = NRF_SAADC_INPUT_DISABLED,
+.pin_negative = NRF_SAADC_INPUT_DISABLED,
+.reference = ADC_REFERENCE_VDD_DIV_4,
+};
+
+static struct adc_chan_cfg adc_y = {
+.acq_time = ADC_ACQTIME_40US,
+.differential = false,
+.gain = ADC_GAIN1_4,
+.pin = NRF_SAADC_INPUT_DISABLED,
+.pin_negative = NRF_SAADC_INPUT_DISABLED,
+.reference = ADC_REFERENCE_VDD_DIV_4,
+};
+
+static int adc_x_pin;
+static int adc_y_pin;
+
+adc_dev_t
+adc_touch_adc_open(int x_pin, int y_pin)
+{
+struct adc_dev_cfg adc_cfg = {
+.calibrate = 1,
+ 

[mynewt-core] 10/13: apps: Add LVGL demos

2023-05-24 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit fee8e5fc62eb85422e59ef17e88e42569378b940
Author: Jerzy Kasenberg 
AuthorDate: Thu Mar 2 15:56:30 2023 +0100

apps: Add LVGL demos

This adds application that allows to run LVGL provided
demos. Several demos can be selected by LVGL_DEMO syscfg value.
---
 apps/lvgl/demo/README.md  | 91 +++
 apps/lvgl/demo/pkg.yml| 32 +
 apps/lvgl/demo/src/main.c | 54 
 apps/lvgl/demo/syscfg.yml | 31 
 4 files changed, 208 insertions(+)

diff --git a/apps/lvgl/demo/README.md b/apps/lvgl/demo/README.md
new file mode 100644
index 0..cce212d6c
--- /dev/null
+++ b/apps/lvgl/demo/README.md
@@ -0,0 +1,91 @@
+
+
+# LVGL demo
+
+## Overview
+
+This application allows to run LVGL demos in mynewt environment.
+Following LVGL demos can be selected in the syscfg.yml of the target by 
settings **LVGL_DEMO** variable to one of the following:
+- benchmark
+- flex_layout
+- keypad_encoder
+- music
+- stress
+- widgets
+
+ Several displays are supported:
+- ILI9341 (240x320)
+- ILI9486 (320x480)
+- ST7735S (128x160)
+- ST7789  (240x320)
+- GC9A01  (240x240)
+
+ Two touch screen controllers:
+- XPT2046
+- STMPE610
+
+### Example display boards with configuration
+- Adafruit 2.8" https://www.adafruit.com/product/1651
+suscfg.yml values
+```yaml
+LVGL_ILI9341: 1
+LVGL_STMPE610: 1
+
+LCD_ITF: spi
+LCD_SPI_DEV_NAME: '"spi0"'
+LCD_SPI_FREQ: 16000
+LCD_CS_PIN: ARDUINO_PIN_D10
+LCD_DC_PIN: ARDUINO_PIN_D9
+LCD_BL_PIN: ARDUINO_PIN_D3
+LCD_RESET_PIN: -1
+
+STMPE610_SPI_DEV_NAME: '"spi0"'
+STMPE610_SPI_CS_PIN: ARDUINO_PIN_D8
+STMPE610_SPI_FREQ: 1200
+
+```
+- Waveshare 3.5" https://www.waveshare.com/3.5inch-tft-touch-shield.htm
+  suscfg.yml values
+```yaml
+LVGL_ILI9486: 1
+LVGL_XPT2046: 1
+
+LCD_ITF: spi
+LCD_SPI_DEV_NAME: '"spi0"'
+LCD_SPI_WITH_SHIFT_REGISTER: 1
+LCD_SPI_FREQ: 32000
+LCD_CS_PIN: ARDUINO_PIN_D10
+LCD_DC_PIN: ARDUINO_PIN_D7
+LCD_BL_PIN: ARDUINO_PIN_D9
+LCD_RESET_PIN: ARDUINO_PIN_D8
+
+XPT2046_SPI_DEV_NAME: '"spi0"'
+XPT2046_SPI_FREQ: 1200
+XPT2046_SPI_CS_PIN: ARDUINO_PIN_D4
+XPT2046_INT_PIN: ARDUINO_PIN_D3
+XPT2046_XY_SWAP: 1
+XPT2046_X_INV: 1
+XPT2046_Y_INV: 1
+XPT2046_MIN_X: 300
+XPT2046_MIN_Y: 300
+
+```
diff --git a/apps/lvgl/demo/pkg.yml b/apps/lvgl/demo/pkg.yml
new file mode 100644
index 0..6c7b9a742
--- /dev/null
+++ b/apps/lvgl/demo/pkg.yml
@@ -0,0 +1,32 @@
+#
+# 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/lvgl/demo
+pkg.type: app
+pkg.description: Application that runs LVGL demos.
+pkg.author: "Apache Mynewt "
+pkg.homepage: "http://mynewt.apache.org/;
+pkg.keywords:
+
+pkg.deps:
+- "@apache-mynewt-core/sys/log"
+- "@apache-mynewt-core/sys/console"
+- "@apache-mynewt-core/hw/drivers/display/lvgl"
+
+pkg.cflags:
diff --git a/apps/lvgl/demo/src/main.c b/apps/lvgl/demo/src/main.c
new file mode 100644
index 0..f087e9e0f
--- /dev/null
+++ b/apps/lvgl/demo/src/main.c
@@ -0,0 +1,54 @@
+/**
+ * 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

[mynewt-core] 11/13: lvgl: Add support for ADC touch screen

2023-05-24 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit fd0c300b2fccb6f6c2a58575f0193aa46fed1e0e
Author: Jerzy Kasenberg 
AuthorDate: Fri May 12 11:32:28 2023 +0200

lvgl: Add support for ADC touch screen

This add support for resistive 4 wire touch screen,
where X+/X-/Y+/Y- electrodes are connected to GPIO
pins and MCU's ADC.

Signed-off-by: Jerzy Kasenberg 
---
 .../lvgl/indev/adc_touch/include/adc_touch.h   |  56 +
 hw/drivers/display/lvgl/indev/adc_touch/pkg.yml|  43 
 .../display/lvgl/indev/adc_touch/src/adc_touch.c   | 227 +
 hw/drivers/display/lvgl/indev/adc_touch/syscfg.yml |  83 
 hw/drivers/display/lvgl/pkg.yml|   2 +
 hw/drivers/display/lvgl/syscfg.yml |   3 +
 6 files changed, 414 insertions(+)

diff --git a/hw/drivers/display/lvgl/indev/adc_touch/include/adc_touch.h 
b/hw/drivers/display/lvgl/indev/adc_touch/include/adc_touch.h
new file mode 100644
index 0..337770651
--- /dev/null
+++ b/hw/drivers/display/lvgl/indev/adc_touch/include/adc_touch.h
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+
+#ifndef ADC_TOUCH_H
+#define ADC_TOUCH_H
+
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void * adc_dev_t;
+
+/**
+ * Open ADC device for touch screen access
+ *
+ * Function should be implemented by user to setup ADC that will be used
+ * to measure values connected to X and Y electrodes.
+ *
+ * @param x_pin - pin to use for X coordinate measurement.
+ * @param y_pin - pit to use for Y coordinate measurement.
+ * @return value to be used in subsequent adc_touch_adc_read function
+ */
+adc_dev_t adc_touch_adc_open(int x_pin, int y_pin);
+
+/**
+ * Read ADC value for given pin
+ *
+ * @param adc - value returned form adc_touch_adc_open()
+ * @param pin - one of the pins to measure
+ * @return value measured on selected pin
+ */
+uint16_t adc_touch_adc_read(adc_dev_t adc, int pin);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ADC_TOUCH_H */
diff --git a/hw/drivers/display/lvgl/indev/adc_touch/pkg.yml 
b/hw/drivers/display/lvgl/indev/adc_touch/pkg.yml
new file mode 100644
index 0..f7eca8c20
--- /dev/null
+++ b/hw/drivers/display/lvgl/indev/adc_touch/pkg.yml
@@ -0,0 +1,43 @@
+#
+# 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: hw/drivers/display/lvgl/indev/adc_touch
+pkg.description: ADC touch driver
+pkg.keywords:
+- display
+- touch
+
+
+pkg.cflags:
+- -DLV_CONF_INCLUDE_SIMPLE
+
+pkg.req_apis:
+- adc_touch_adc
+
+pkg.deps.(ADC_TOUCH_DEFAULT_ADC && NORDIC_NRFX):
+- hw/drivers/display/lvgl/indev/adc_touch/adc_nrfx
+
+pkg.deps.(ADC_TOUCH_DEFAULT_ADC && MCU_STM32F4):
+- hw/drivers/display/lvgl/indev/adc_touch/adc_stm32f4
+
+pkg.deps.(ADC_TOUCH_DEFAULT_ADC && MCU_STM32F7):
+- hw/drivers/display/lvgl/indev/adc_touch/adc_stm32f7
+
+pkg.init:
+adc_touch_init: 1100
diff --git a/hw/drivers/display/lvgl/indev/adc_touch/src/adc_touch.c 
b/hw/drivers/display/lvgl/indev/adc_touch/src/adc_touch.c
new file mode 100644
index 0..453591b45
--- /dev/null
+++ b/hw/drivers/display/lvgl/indev/adc_touch/src/adc_touch.c
@@ -0,0 +1,227 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or

[mynewt-core] 13/13: lvgl/trackball: Add support for Blackberry trackball

2023-05-24 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit be347d1edfd81fef7cf10a7d13906a5e4ecbbe97
Author: Jerzy Kasenberg 
AuthorDate: Wed May 24 15:41:28 2023 +0200

lvgl/trackball: Add support for Blackberry trackball

Signed-off-by: Jerzy Kasenberg 
---
 hw/drivers/display/lvgl/indev/trackball/pkg.yml|  33 
 .../display/lvgl/indev/trackball/src/trackball.c   | 217 +
 hw/drivers/display/lvgl/indev/trackball/syscfg.yml |  66 +++
 hw/drivers/display/lvgl/pkg.yml|   2 +
 hw/drivers/display/lvgl/syscfg.yml |   3 +
 5 files changed, 321 insertions(+)

diff --git a/hw/drivers/display/lvgl/indev/trackball/pkg.yml 
b/hw/drivers/display/lvgl/indev/trackball/pkg.yml
new file mode 100644
index 0..35995db9c
--- /dev/null
+++ b/hw/drivers/display/lvgl/indev/trackball/pkg.yml
@@ -0,0 +1,33 @@
+# 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: hw/drivers/display/lvgl/indev/trackball
+pkg.description: LVGL Blackberry trackball driver
+pkg.author: "Apache Mynewt "
+pkg.homepage: "http://mynewt.apache.org/;
+pkg.keywords:
+- mouse
+- lvgl
+
+pkg.deps:
+
+pkg.include_dirs:
+- "@lvgl/src"
+
+pkg.init:
+trackball_register_lv_indev: 1100
diff --git a/hw/drivers/display/lvgl/indev/trackball/src/trackball.c 
b/hw/drivers/display/lvgl/indev/trackball/src/trackball.c
new file mode 100644
index 0..9fd51e3e8
--- /dev/null
+++ b/hw/drivers/display/lvgl/indev/trackball/src/trackball.c
@@ -0,0 +1,217 @@
+/*
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static lv_indev_drv_t trackball_drv;
+static lv_indev_t *trackball_dev;
+
+#define UP_PIN MYNEWT_VAL(TRACKBALL_UP_PIN)
+#define DOWN_PIN MYNEWT_VAL(TRACKBALL_DOWN_PIN)
+#define LEFT_PIN MYNEWT_VAL(TRACKBALL_LEFT_PIN)
+#define RIGHT_PIN MYNEWT_VAL(TRACKBALL_RIGHT_PIN)
+#define BUTTON_PIN MYNEWT_VAL(TRACKBALL_BUTTON_PIN)
+#define BUTTON_PIN_PULL MYNEWT_VAL(TRACKBALL_BUTTON_PIN_PULL)
+#define BUTTON_PIN_VALUE MYNEWT_VAL(TRACKBALL_BUTTON_PIN_VALUE)
+#define DRAG_PIN MYNEWT_VAL(TRACKBALL_DRAG_PIN)
+#define DRAG_PIN_VALUE MYNEWT_VAL(TRACKBALL_DRAG_PIN_VALUE)
+#define HOLD_TIME MYNEWT_VAL(TRACKBALL_HOLD_TO_DRAG_TIME_MS)
+
+struct accel {
+uint32_t limit;
+int increment;
+};
+
+static const struct accel accel_steps[] = {
+{ 10, 4 },
+{ 15, 3 },
+{ 30, 2 },
+{ 0, 1 },
+};
+struct trackball_data {
+uint32_t up_time;
+uint32_t down_time;
+uint32_t left_time;
+uint32_t right_time;
+uint32_t press_time;
+enum {
+RELEASED,
+PRESSED_WAITING_FOR_HOLD,
+PRESSED,
+PRESS_HELD,
+} state;
+bool hold;
+bool reported;
+/* Current value for X, Y detected */
+int x;
+int y;
+};
+
+static struct trackball_data trackball_data;
+
+static void
+movement_detected(void)
+{
+if (trackball_data.state == PRESSED_WAITING_FOR_HOLD) {
+trackball_data.state = PRESSED;
+}
+}
+
+static int
+increment(uint32_t *t)
+{
+uint32_t now = os_time_ticks_to_ms32(os_time_get());
+uint32_t diff = now - *t;
+*t = now;
+int i;
+
+for (i = 0; accel_steps[i].limit; ++i)

[mynewt-core] 05/13: lvgl/st7735s: Add initial support for ST7735S TFT

2023-05-24 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit a149e18b39c720a1e26f9eabe9ffa2e3706152b8
Author: Jerzy Kasenberg 
AuthorDate: Thu Mar 2 12:26:57 2023 +0100

lvgl/st7735s: Add initial support for ST7735S TFT
---
 hw/drivers/display/lvgl/pkg.yml   |   2 +
 hw/drivers/display/lvgl/syscfg.yml|   3 +
 hw/drivers/display/lvgl/tft/st7735s/pkg.yml   |  25 +++
 hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c | 245 ++
 hw/drivers/display/lvgl/tft/st7735s/syscfg.yml|  23 ++
 5 files changed, 298 insertions(+)

diff --git a/hw/drivers/display/lvgl/pkg.yml b/hw/drivers/display/lvgl/pkg.yml
index c3955ba67..ad2b72ea9 100644
--- a/hw/drivers/display/lvgl/pkg.yml
+++ b/hw/drivers/display/lvgl/pkg.yml
@@ -62,6 +62,8 @@ pkg.deps.LVGL_ILI9341:
 - "@apache-mynewt-core/hw/drivers/display/lvgl/tft/ili9341"
 pkg.deps.LVGL_ILI9486:
 - "@apache-mynewt-core/hw/drivers/display/lvgl/tft/ili9486"
+pkg.deps.LVGL_ST7735S:
+- "@apache-mynewt-core/hw/drivers/display/lvgl/tft/st7735s"
 
 pkg.cflags:
 - -DLV_CONF_INCLUDE_SIMPLE=1
diff --git a/hw/drivers/display/lvgl/syscfg.yml 
b/hw/drivers/display/lvgl/syscfg.yml
index f55e5fb9a..b83a20d05 100644
--- a/hw/drivers/display/lvgl/syscfg.yml
+++ b/hw/drivers/display/lvgl/syscfg.yml
@@ -28,6 +28,9 @@ syscfg.defs:
 LVGL_ILI9486:
 description: Enable ILI9486 display driver.
 value:
+LVGL_ST7735S:
+description: Enable ST7735S display driver.
+value:
 LVGL_TIMER_PERIOD_MS:
 description: LV timer interval for periodical refresh and touch read
 value: 10
diff --git a/hw/drivers/display/lvgl/tft/st7735s/pkg.yml 
b/hw/drivers/display/lvgl/tft/st7735s/pkg.yml
new file mode 100644
index 0..1bf50aa54
--- /dev/null
+++ b/hw/drivers/display/lvgl/tft/st7735s/pkg.yml
@@ -0,0 +1,25 @@
+# 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: hw/drivers/display/lvgl/tft/st7735s
+pkg.description: LVGL display driver for ST7735S
+pkg.author: "Apache Mynewt "
+pkg.homepage: "http://mynewt.apache.org/;
+pkg.keywords:
+
+pkg.cflags:
diff --git a/hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c 
b/hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c
new file mode 100644
index 0..c7b79d1d9
--- /dev/null
+++ b/hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c
@@ -0,0 +1,245 @@
+/*
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define ST7735S_TFTWIDTH128
+#define ST7735S_TFTHEIGHT   160
+
+#define ST7735S_NOP 0x00
+#define ST7735S_SWRESET 0x01
+#define ST7735S_RDDID   0x04
+#define ST7735S_RDDST   0x09
+#define ST7735S_RDDPM   0x0A
+#define ST7735S_RDDDMADCTL  0x0B
+#define ST7735S_RDDCOLMOD   0x0C
+#define ST7735S_RDDIM   0x0D
+#define ST7735S_RDDSM   0x0E
+#define ST7735S_RDDSDR  0x0F
+
+#define ST7735S_SLPIN   0x10
+#define ST7735S_SLPOUT  0x11
+#define ST7735S_PTLON   0x12
+#define ST7735S_NORON   0x13
+
+#define ST7735S_INVOFF  0x20
+#define ST7735S_INVON   0x21
+#define ST7735S_GAMSET  0x26
+#define ST7735S_DISPOFF 0x28
+#define ST77

[mynewt-core] 09/13: lvgl/stmpe610: Add initial support for STMPE610 touch screen

2023-05-24 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 0f7b1a5b54a7e1bb33fbd7ad2a78df7b7dc7b1d0
Author: Jerzy Kasenberg 
AuthorDate: Thu Mar 2 15:09:10 2023 +0100

lvgl/stmpe610: Add initial support for STMPE610 touch screen
---
 hw/drivers/display/lvgl/indev/stmpe610/pkg.yml |  35 ++
 .../display/lvgl/indev/stmpe610/src/stmpe610.c | 354 +
 hw/drivers/display/lvgl/indev/stmpe610/syscfg.yml  |  53 +++
 hw/drivers/display/lvgl/pkg.yml|   2 +
 hw/drivers/display/lvgl/syscfg.yml |   3 +
 5 files changed, 447 insertions(+)

diff --git a/hw/drivers/display/lvgl/indev/stmpe610/pkg.yml 
b/hw/drivers/display/lvgl/indev/stmpe610/pkg.yml
new file mode 100644
index 0..215acc57b
--- /dev/null
+++ b/hw/drivers/display/lvgl/indev/stmpe610/pkg.yml
@@ -0,0 +1,35 @@
+# 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: hw/drivers/display/lvgl/indev/stmpe610
+pkg.description: LVGL touch screen driver for STMPE610
+pkg.author: "Apache Mynewt "
+pkg.homepage: "http://mynewt.apache.org/;
+pkg.keywords:
+- touchscreen
+- lvgl
+
+pkg.deps:
+- "@apache-mynewt-core/hw/bus/drivers/spi_common"
+
+pkg.include_dirs:
+- "@lvgl/src"
+
+pkg.init:
+stmpe610_os_dev_create: 400
+stmpe610_register_lv_indev: 1100
diff --git a/hw/drivers/display/lvgl/indev/stmpe610/src/stmpe610.c 
b/hw/drivers/display/lvgl/indev/stmpe610/src/stmpe610.c
new file mode 100644
index 0..dd17f603e
--- /dev/null
+++ b/hw/drivers/display/lvgl/indev/stmpe610/src/stmpe610.c
@@ -0,0 +1,354 @@
+/*
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define STMPE610_XY_SWAP MYNEWT_VAL(STMPE610_XY_SWAP)
+#define STMPE610_X_INV   MYNEWT_VAL(STMPE610_X_INV)
+#define STMPE610_Y_INV   MYNEWT_VAL(STMPE610_Y_INV)
+#define STMPE610_MIN_X   MYNEWT_VAL(STMPE610_MIN_X)
+#define STMPE610_MIN_Y   MYNEWT_VAL(STMPE610_MIN_Y)
+#define STMPE610_MAX_X   MYNEWT_VAL(STMPE610_MAX_X)
+#define STMPE610_MAX_Y   MYNEWT_VAL(STMPE610_MAX_Y)
+#define STMPE610_X_RANGE ((STMPE610_MAX_X) - (STMPE610_MIN_X))
+#define STMPE610_Y_RANGE ((STMPE610_MAX_Y) - (STMPE610_MIN_Y))
+#define STMPE610_HOR_RES MYNEWT_VAL(STMPE610_HOR_RES)
+#define STMPE610_VER_RES MYNEWT_VAL(STMPE610_VER_RES)
+
+struct bus_spi_node touch;
+struct bus_spi_node_cfg touch_spi_cfg = {
+.node_cfg.bus_name = MYNEWT_VAL(STMPE610_SPI_DEV_NAME),
+.pin_cs = MYNEWT_VAL(STMPE610_SPI_CS_PIN),
+.mode = BUS_SPI_MODE_0,
+.data_order = HAL_SPI_MSB_FIRST,
+.freq = MYNEWT_VAL(STMPE610_SPI_FREQ),
+};
+
+static struct os_dev *touch_dev;
+static lv_indev_drv_t stmpe610_drv;
+static lv_indev_t *stmpe610_dev;
+
+/** Reset Control **/
+#define STMPE_SYS_CTRL1 0x03
+#define STMPE_SYS_CTRL1_RESET   0x02
+
+#define STMPE_SYS_CTRL2 0x04
+
+#define STMPE_SPI_CFG   0x08
+#define STMPE_SPI_AUTO_INCR 0x04
+
+#define STMPE_TSC_CTRL  0x40
+#define STMPE_TSC_CTRL_EN   0x01
+#define STMPE_TSC_CTRL_XYZ  0x00
+#define STMPE_TSC_CTRL_XY   0x02
+#define STMPE_TSC_CTRL_X0x04
+#define STMPE_TS

[mynewt-core] 07/13: lvgl/st7789: Add initial support for ST7789 TFT

2023-05-24 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 4a153600c072d6f5a4b92ee2d25da6d6d20856cd
Author: Jerzy Kasenberg 
AuthorDate: Fri Apr 21 11:30:25 2023 +0200

lvgl/st7789: Add initial support for ST7789 TFT
---
 hw/drivers/display/lvgl/pkg.yml |   2 +
 hw/drivers/display/lvgl/syscfg.yml  |   3 +
 hw/drivers/display/lvgl/tft/st7789/pkg.yml  |  27 +++
 hw/drivers/display/lvgl/tft/st7789/src/st7789.c | 298 
 hw/drivers/display/lvgl/tft/st7789/syscfg.yml   |  26 +++
 5 files changed, 356 insertions(+)

diff --git a/hw/drivers/display/lvgl/pkg.yml b/hw/drivers/display/lvgl/pkg.yml
index 58c1a228c..56360660f 100644
--- a/hw/drivers/display/lvgl/pkg.yml
+++ b/hw/drivers/display/lvgl/pkg.yml
@@ -66,6 +66,8 @@ pkg.deps.LVGL_ILI9486:
 - "@apache-mynewt-core/hw/drivers/display/lvgl/tft/ili9486"
 pkg.deps.LVGL_ST7735S:
 - "@apache-mynewt-core/hw/drivers/display/lvgl/tft/st7735s"
+pkg.deps.LVGL_ST7789:
+- "@apache-mynewt-core/hw/drivers/display/lvgl/tft/st7789"
 
 pkg.cflags:
 - -DLV_CONF_INCLUDE_SIMPLE=1
diff --git a/hw/drivers/display/lvgl/syscfg.yml 
b/hw/drivers/display/lvgl/syscfg.yml
index 9c7b3278b..67a4a5837 100644
--- a/hw/drivers/display/lvgl/syscfg.yml
+++ b/hw/drivers/display/lvgl/syscfg.yml
@@ -34,6 +34,9 @@ syscfg.defs:
 LVGL_ST7735S:
 description: Enable ST7735S display driver.
 value:
+LVGL_ST7789:
+description: Enable ST7789 display driver.
+value:
 LVGL_TIMER_PERIOD_MS:
 description: LV timer interval for periodical refresh and touch read
 value: 10
diff --git a/hw/drivers/display/lvgl/tft/st7789/pkg.yml 
b/hw/drivers/display/lvgl/tft/st7789/pkg.yml
new file mode 100644
index 0..46b0467c5
--- /dev/null
+++ b/hw/drivers/display/lvgl/tft/st7789/pkg.yml
@@ -0,0 +1,27 @@
+# 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: hw/drivers/display/lvgl/tft/st7789
+pkg.description: LVGL display driver for ST7789
+pkg.author: "Apache Mynewt "
+pkg.homepage: "http://mynewt.apache.org/;
+pkg.keywords:
+
+pkg.cflags:
+
+pkg.deps:
diff --git a/hw/drivers/display/lvgl/tft/st7789/src/st7789.c 
b/hw/drivers/display/lvgl/tft/st7789/src/st7789.c
new file mode 100644
index 0..54ddefef7
--- /dev/null
+++ b/hw/drivers/display/lvgl/tft/st7789/src/st7789.c
@@ -0,0 +1,298 @@
+/*
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define ST7789_NOP  0x00
+#define ST7789_SWRESET  0x01
+#define ST7789_RDDID0x04
+#define ST7789_RDDST0x09
+#define ST7789_RDDPM0x0A
+#define ST7789_RDDDMADCTL   0x0B
+#define ST7789_RDDCOLMOD0x0C
+#define ST7789_RDDIM0x0D
+#define ST7789_RDDSM0x0E
+#define ST7789_RDDSDR   0x0F
+
+#define ST7789_SLPIN0x10
+#define ST7789_SLPOUT   0x11
+#define ST7789_PTLON0x12
+#define ST7789_NORON0x13
+
+#define ST7789_INVOFF   0x20
+#define ST7789_INVON0x21
+#define ST7789_GAMSET   0x26
+#define ST7789_DISPOFF  0x28
+#define ST7789_DISPON   0x29
+#define ST7789_CASET0x2A
+#define ST7

[mynewt-core] 04/13: lvgl/ili9486: Add initial support for ILI9486 TFT

2023-05-24 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 5e5d002171f960b4ac8c01ff630693c72e984478
Author: Jerzy Kasenberg 
AuthorDate: Thu Mar 2 12:24:39 2023 +0100

lvgl/ili9486: Add initial support for ILI9486 TFT
---
 hw/drivers/display/lvgl/pkg.yml   |   2 +
 hw/drivers/display/lvgl/syscfg.yml|   3 +
 hw/drivers/display/lvgl/tft/ili9486/pkg.yml   |  25 +++
 hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c | 252 ++
 hw/drivers/display/lvgl/tft/ili9486/syscfg.yml|  23 ++
 5 files changed, 305 insertions(+)

diff --git a/hw/drivers/display/lvgl/pkg.yml b/hw/drivers/display/lvgl/pkg.yml
index 8a34ac60b..c3955ba67 100644
--- a/hw/drivers/display/lvgl/pkg.yml
+++ b/hw/drivers/display/lvgl/pkg.yml
@@ -60,6 +60,8 @@ pkg.deps:
 
 pkg.deps.LVGL_ILI9341:
 - "@apache-mynewt-core/hw/drivers/display/lvgl/tft/ili9341"
+pkg.deps.LVGL_ILI9486:
+- "@apache-mynewt-core/hw/drivers/display/lvgl/tft/ili9486"
 
 pkg.cflags:
 - -DLV_CONF_INCLUDE_SIMPLE=1
diff --git a/hw/drivers/display/lvgl/syscfg.yml 
b/hw/drivers/display/lvgl/syscfg.yml
index 7f4dd4af6..f55e5fb9a 100644
--- a/hw/drivers/display/lvgl/syscfg.yml
+++ b/hw/drivers/display/lvgl/syscfg.yml
@@ -25,6 +25,9 @@ syscfg.defs:
 LVGL_ILI9341:
 description: Enable ILI9341 display driver.
 value:
+LVGL_ILI9486:
+description: Enable ILI9486 display driver.
+value:
 LVGL_TIMER_PERIOD_MS:
 description: LV timer interval for periodical refresh and touch read
 value: 10
diff --git a/hw/drivers/display/lvgl/tft/ili9486/pkg.yml 
b/hw/drivers/display/lvgl/tft/ili9486/pkg.yml
new file mode 100644
index 0..cf89f436d
--- /dev/null
+++ b/hw/drivers/display/lvgl/tft/ili9486/pkg.yml
@@ -0,0 +1,25 @@
+# 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: hw/drivers/display/lvgl/tft/ili9486
+pkg.description: LVGL display driver for ili9486
+pkg.author: "Apache Mynewt "
+pkg.homepage: "http://mynewt.apache.org/;
+pkg.keywords:
+
+pkg.cflags:
diff --git a/hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c 
b/hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c
new file mode 100644
index 0..73eabb4eb
--- /dev/null
+++ b/hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c
@@ -0,0 +1,252 @@
+/*
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define ILI9486_TFTWIDTH320
+#define ILI9486_TFTHEIGHT   480
+
+/* Level 1 Commands -- [section] Description */
+
+#define ILI9486_NOP 0x00 /* [8.2.1 ] No Operation / Terminate Frame 
Memory Write */
+#define ILI9486_SWRESET 0x01 /* [8.2.2 ] Software Reset */
+#define ILI9486_RDDIDIF 0x04 /* [8.2.3 ] Read Display Identification 
Information */
+#define ILI9486_RDNOE   0x05 /* [8.2.4 ] Read Number of the Errors on DSI 
*/
+#define ILI9486_RDDST   0x09 /* [8.2.5 ] Read Display Status */
+#define ILI9486_RDDPM   0x0A /* [8.2.6 ] Read Display Power Mode */
+#define ILI9486_RDDMADCTL   0x0B /* [8.2.7 ] Read Display MADCTL */
+#define ILI9486_RDDCOLMOD   0x0C /* [8.2.8 ] Read Display Pixel Format */
+#define ILI9486_RDDIM   0x0D /* [8.2.9 ] Read Display Image Mode */
+#define ILI9486_RDDSM   0x0E /* [8.2.1

[mynewt-core] 02/13: lvgl: Add support for SPI and 8080 MIPI DSI

2023-05-24 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit e621b5ae146ce0d8c0c9173e2f24336d2bef7381
Author: Jerzy Kasenberg 
AuthorDate: Fri Apr 21 10:41:22 2023 +0200

lvgl: Add support for SPI and 8080 MIPI DSI

This adds general interface for communication with
LCD display.

Two implementations are ready:
- Four wire SPI
- Parallel 8080
---
 hw/drivers/display/lcd_itf/include/lcd_itf.h   | 101 +++
 hw/drivers/display/lcd_itf/itf_8080/pkg.yml|  28 ++
 hw/drivers/display/lcd_itf/itf_8080/src/itf_8080.c | 110 
 hw/drivers/display/lcd_itf/itf_8080/syscfg.yml |  60 +++
 hw/drivers/display/lcd_itf/itf_spi/pkg.yml |  29 ++
 hw/drivers/display/lcd_itf/itf_spi/src/itf_spi.c   | 111 +
 hw/drivers/display/lcd_itf/itf_spi/syscfg.yml  |  37 +++
 hw/drivers/display/lcd_itf/pkg.yml |  33 ++
 hw/drivers/display/lcd_itf/src/lcd_itf.c   |  77 ++
 hw/drivers/display/lcd_itf/syscfg.yml  |  40 
 hw/drivers/display/lvgl/pkg.yml|   2 +-
 11 files changed, 627 insertions(+), 1 deletion(-)

diff --git a/hw/drivers/display/lcd_itf/include/lcd_itf.h 
b/hw/drivers/display/lcd_itf/include/lcd_itf.h
new file mode 100644
index 0..dfa7f0256
--- /dev/null
+++ b/hw/drivers/display/lcd_itf/include/lcd_itf.h
@@ -0,0 +1,101 @@
+/*
+ * 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.
+ */
+
+#ifndef LCD_ITF_H
+#define LCD_ITF_H
+
+#include 
+#include 
+#include 
+
+#ifdef LCD_ITF_INCLUDE
+#include LCD_ITF_INCLUDE
+#endif
+
+#ifndef LCD_CS_PIN_ACTIVE
+#if MYNEWT_VAL(LCD_CS_PIN) >= 0
+#define LCD_CS_PIN_ACTIVE() hal_gpio_write(MYNEWT_VAL(LCD_CS_PIN), 0)
+#else
+#define LCD_CS_PIN_ACTIVE()
+#endif
+#endif
+
+#ifndef LCD_CS_PIN_INACTIVE
+#if MYNEWT_VAL(LCD_CS_PIN) >= 0
+#define LCD_CS_PIN_INACTIVE() hal_gpio_write(MYNEWT_VAL(LCD_CS_PIN), 1)
+#else
+#define LCD_CS_PIN_INACTIVE()
+#endif
+#endif
+
+#ifndef LCD_DC_PIN_DATA
+#define LCD_DC_PIN_DATA() hal_gpio_write(MYNEWT_VAL(LCD_DC_PIN), 1)
+#endif
+
+#ifndef LCD_DC_PIN_COMMAND
+#define LCD_DC_PIN_COMMAND() hal_gpio_write(MYNEWT_VAL(LCD_DC_PIN), 0)
+#endif
+
+#ifndef LCD_RESET_PIN_INACTIVE
+#if MYNEWT_VAL(LCD_RESET_PIN) >= 0
+#define LCD_RESET_PIN_INACTIVE() hal_gpio_write(MYNEWT_VAL(LCD_RESET_PIN), 1)
+#else
+#define LCD_RESET_PIN_INACTIVE()
+#endif
+#endif
+
+#ifndef LCD_RESET_PIN_ACTIVE
+#if MYNEWT_VAL(LCD_RESET_PIN) >= 0
+#define LCD_RESET_PIN_ACTIVE() hal_gpio_write(MYNEWT_VAL(LCD_RESET_PIN), 0)
+#else
+#define LCD_RESET_PIN_ACTIVE()
+#endif
+#endif
+
+#define LCD_SEQUENCE_DELAY_REQ  0xFE
+#define LCD_SEQUENCE_DELAY_US_REQ   0xFD
+#define LCD_SEQUENCE_LCD_CS_ACTIVATE_REQ0xFC
+#define LCD_SEQUENCE_LCD_CS_INACTIVATE_REQ  0xFB
+#define LCD_SEQUENCE_LCD_DC_DATA_REQ0xFA
+#define LCD_SEQUENCE_LCD_DC_COMMAND_REQ 0xF9
+#define LCD_SEQUENCE_LCD_RESET_ACTIVATE_REQ 0xF8
+#define LCD_SEQUENCE_LCD_RESET_INACTIVATE_REQ   0xF7
+#define LCD_SEQUENCE_GPIO_REQ   0xF6
+#define LCD_SEQUENCE(name) \
+static const uint8_t name[] = {
+#define LCD_SEQUENCE_DELAY(n) LCD_SEQUENCE_DELAY_REQ, (uint8_t)n, ((uint8_t)(n 
>> 8))
+#define LCD_SEQUENCE_DELAY_US(n) LCD_SEQUENCE_DELAY_US_REQ, (uint8_t)n, 
((uint8_t)(n >> 8))
+#define LCD_SEQUENCE_GPIO(pin, val) LCD_SEQUENCE_GPIO_REQ, n, val
+#define LCD_SEQUENCE_LCD_CS_ACTIVATE() LCD_SEQUENCE_LCD_CS_ACTIVATE_REQ
+#define LCD_SEQUENCE_LCD_CS_INACTIVATE() LCD_SEQUENCE_LCD_CS_INACTIVATE_REQ
+#define LCD_SEQUENCE_LCD_DC_DATA() LCD_SEQUENCE_LCD_DC_DATA_REQ
+#define LCD_SEQUENCE_LCD_DC_COMMAND() LCD_SEQUENCE_LCD_DC_COMMAND_REQ
+#define LCD_SEQUENCE_LCD_RESET_ACTIVATE() LCD_SEQUENCE_LCD_RESET_ACTIVATE_REQ
+#define LCD_SEQUENCE_LCD_RESET_INACTIVATE() 
LCD_SEQUENCE_LCD_RESET_INACTIVATE_REQ
+#define LCD_SEQUENCE_END 0xFF };
+
+void lcd_command_sequence(const uint8_t *cmds);
+
+void lcd_itf_init(void);
+
+/* Function implemented by LCD interface driver */
+void lcd_ift_write_cm

[mynewt-core] 08/13: lvgl/xpt2046: Add initial support for XPT2046 touch screen

2023-05-24 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 220e8ebca1573eebab276cc179996da13fa479fb
Author: Jerzy Kasenberg 
AuthorDate: Thu Mar 2 14:10:36 2023 +0100

lvgl/xpt2046: Add initial support for XPT2046 touch screen

Signed-off-by: Jerzy Kasenberg 
---
 hw/drivers/display/lvgl/indev/xpt2046/pkg.yml  |  35 
 .../display/lvgl/indev/xpt2046/src/xpt2046.c   | 192 +
 hw/drivers/display/lvgl/indev/xpt2046/syscfg.yml   |  54 ++
 hw/drivers/display/lvgl/pkg.yml|   3 +
 hw/drivers/display/lvgl/syscfg.yml |   3 +
 5 files changed, 287 insertions(+)

diff --git a/hw/drivers/display/lvgl/indev/xpt2046/pkg.yml 
b/hw/drivers/display/lvgl/indev/xpt2046/pkg.yml
new file mode 100644
index 0..b0ef9e5b6
--- /dev/null
+++ b/hw/drivers/display/lvgl/indev/xpt2046/pkg.yml
@@ -0,0 +1,35 @@
+# 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: hw/drivers/display/lvgl/indev/xpt2046
+pkg.description: LVGL touch screen driver for XPT2046
+pkg.author: "Apache Mynewt "
+pkg.homepage: "http://mynewt.apache.org/;
+pkg.keywords:
+- touchscreen
+- lvgl
+
+pkg.deps:
+- "@apache-mynewt-core/hw/bus/drivers/spi_common"
+
+pkg.include_dirs:
+- "@lvgl/src"
+
+pkg.init:
+xpt2046_os_dev_create: 400
+xpt2046_register_lv_indev: 1100
diff --git a/hw/drivers/display/lvgl/indev/xpt2046/src/xpt2046.c 
b/hw/drivers/display/lvgl/indev/xpt2046/src/xpt2046.c
new file mode 100644
index 0..9ec052066
--- /dev/null
+++ b/hw/drivers/display/lvgl/indev/xpt2046/src/xpt2046.c
@@ -0,0 +1,192 @@
+/*
+ * 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.
+ */
+
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define CMD_X_READ  0x90
+#define CMD_Y_READ  0xD0
+#define XPT2046_XY_SWAP MYNEWT_VAL(XPT2046_XY_SWAP)
+#define XPT2046_X_INV   MYNEWT_VAL(XPT2046_X_INV)
+#define XPT2046_Y_INV   MYNEWT_VAL(XPT2046_Y_INV)
+#define XPT2046_MIN_X   MYNEWT_VAL(XPT2046_MIN_X)
+#define XPT2046_MIN_Y   MYNEWT_VAL(XPT2046_MIN_Y)
+#define XPT2046_MAX_X   MYNEWT_VAL(XPT2046_MAX_X)
+#define XPT2046_MAX_Y   MYNEWT_VAL(XPT2046_MAX_Y)
+#define XPT2046_X_RANGE ((XPT2046_MAX_X) - (XPT2046_MIN_X))
+#define XPT2046_Y_RANGE ((XPT2046_MAX_Y) - (XPT2046_MIN_Y))
+#define XPT2046_HOR_RES MYNEWT_VAL(XPT2046_HOR_RES)
+#define XPT2046_VER_RES MYNEWT_VAL(XPT2046_VER_RES)
+
+struct bus_spi_node touch;
+struct bus_spi_node_cfg touch_spi_cfg = {
+.node_cfg.bus_name = MYNEWT_VAL(XPT2046_SPI_DEV_NAME),
+.pin_cs = MYNEWT_VAL(XPT2046_SPI_CS_PIN),
+.mode = BUS_SPI_MODE_0,
+.data_order = HAL_SPI_MSB_FIRST,
+.freq = MYNEWT_VAL(XPT2046_SPI_FREQ),
+};
+
+static struct os_dev *touch_dev;
+static lv_indev_drv_t xpt2046_drv;
+static lv_indev_t *xpt2046_dev;
+
+struct touch_screen_data {
+/* ADC value for left edge */
+uint16_t left;
+/* ADC value for right edge */
+uint16_t right;
+/* ADC value for top edge */
+uint16_t top;
+/* ADC value for bottom edge */
+uint16_t bottom;
+/* Current value for X, Y detected */
+int x;
+int y;
+/* Values that were last reported 

[mynewt-core] 01/13: lvgl: Add initial support for LVGL library

2023-05-24 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit e9b2f7a57808357b92ffc33061375311ce7fd772
Author: Jerzy Kasenberg 
AuthorDate: Thu Mar 2 12:18:30 2023 +0100

lvgl: Add initial support for LVGL library
---
 .rat-excludes |   3 +-
 .style_ignored_dirs   |   3 +
 LICENSE   |   4 +
 hw/drivers/display/lvgl/default/lv_conf.h | 757 ++
 hw/drivers/display/lvgl/include/lv_glue.h |  36 ++
 hw/drivers/display/lvgl/pkg.yml   |  74 +++
 hw/drivers/display/lvgl/src/mynewt_lvgl.c |  84 
 hw/drivers/display/lvgl/syscfg.yml|  65 +++
 8 files changed, 1025 insertions(+), 1 deletion(-)

diff --git a/.rat-excludes b/.rat-excludes
index d84d0b50a..43d0c2229 100644
--- a/.rat-excludes
+++ b/.rat-excludes
@@ -499,4 +499,5 @@ startup_stm32l073xx.s
 # MK64F12 SDK - BSD License
 MK64F12
 
-
+# LVGL configuration file - MIT license
+lv_conf.h
diff --git a/.style_ignored_dirs b/.style_ignored_dirs
index d170cafad..b39da5fac 100644
--- a/.style_ignored_dirs
+++ b/.style_ignored_dirs
@@ -54,3 +54,6 @@ fs/littlefs/include/littlefs/lfs.h
 fs/littlefs/include/littlefs/lfs_util.h
 fs/littlefs/src/lfs.c
 fs/littlefs/src/lfs_util.c
+
+# LVGL formated file
+hw/drivers/display/lvgl/default/lv_conf.h
diff --git a/LICENSE b/LICENSE
index 6d5941891..b9ab67054 100644
--- a/LICENSE
+++ b/LICENSE
@@ -748,3 +748,7 @@ license. Bundled files are:
 * fs/littlefs/DESIGN.md
 * fs/littlefs/README.md
 * fs/littlefs/SPEC.md
+
+This product bundles part of lvgl, which is available under the MIT license.
+Bundled files are:
+* hw/drivers/display/lvgl/default/lv_conf.h
diff --git a/hw/drivers/display/lvgl/default/lv_conf.h 
b/hw/drivers/display/lvgl/default/lv_conf.h
new file mode 100644
index 0..df7a40b1c
--- /dev/null
+++ b/hw/drivers/display/lvgl/default/lv_conf.h
@@ -0,0 +1,757 @@
+/**
+ * Copy of template file found in lvgl repository
+ * Copy of template file found in lvgl repository
+ * Configuration file for v8.3.6
+ */
+
+/* clang-format off */
+#if 1 /*Set it to "1" to enable content*/
+
+#ifndef LV_CONF_H
+#define LV_CONF_H
+
+#include 
+#include 
+
+/*
+   COLOR SETTINGS
+ **/
+
+/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB)*/
+#define LV_COLOR_DEPTH 16
+
+/*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit 
interface (e.g. SPI)*/
+#define LV_COLOR_16_SWAP MYNEWT_VAL(LV_COLOR_16_SWAP)
+
+/*Enable features to draw on transparent background.
+ *It's required if opa, and transform_* style properties are used.
+ *Can be also used if the UI is above another layer, e.g. an OSD menu or video 
player.*/
+#define LV_COLOR_SCREEN_TRANSP 0
+
+/* Adjust color mix functions rounding. GPUs might calculate color mix 
(blending) differently.
+ * 0: round down, 64: round up from x.75, 128: round up from half, 192: round 
up from x.25, 254: round up */
+#define LV_COLOR_MIX_ROUND_OFS 0
+
+/*Images pixels with this color will not be drawn if they are chroma keyed)*/
+#define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00) /*pure green*/
+
+/*=
+   MEMORY SETTINGS
+ *=*/
+
+/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and 
`lv_mem_free()`*/
+#define LV_MEM_CUSTOM 0
+#if LV_MEM_CUSTOM == 0
+/*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
+#define LV_MEM_SIZE (48U * 1024U)  /*[bytes]*/
+
+/*Set an address for the memory pool instead of allocating it as a normal 
array. Can be in external SRAM too.*/
+#define LV_MEM_ADR 0 /*0: unused*/
+/*Instead of an address give a memory allocator that will be called to get 
a memory pool for LVGL. E.g. my_malloc*/
+#if LV_MEM_ADR == 0
+#undef LV_MEM_POOL_INCLUDE
+#undef LV_MEM_POOL_ALLOC
+#endif
+
+#else   /*LV_MEM_CUSTOM*/
+#define LV_MEM_CUSTOM_INCLUDE/*Header for the dynamic memory 
function*/
+#define LV_MEM_CUSTOM_ALLOC   malloc
+#define LV_MEM_CUSTOM_FREEfree
+#define LV_MEM_CUSTOM_REALLOC realloc
+#endif /*LV_MEM_CUSTOM*/
+
+/*Number of the intermediate memory buffer used during rendering and other 
internal processing mechanisms.
+ *You will see an error log message if there wasn't enough buffers. */
+#define LV_MEM_BUF_MAX_NUM 16
+
+/*Use the standard `memcpy` and `memset` instead of LVGL's own functions. 
(Might or might not be faster).*/
+#define LV_MEMCPY_MEMSET_STD 0
+
+/*
+   HAL SETTINGS
+ **/
+
+/*Default display refresh period. LVG will redraw changed areas with this 
period time*/
+#define LV_DISP_DEF_REFR_PERIOD 30  /*[ms]*/
+
+/*Input device read period in milliseconds*/
+#define LV_INDEV_DEF_READ_PERIOD

[mynewt-core] 06/13: lvgl/gc9a01: Add initial support for GC9A01 TFT

2023-05-24 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 8cb3a992d67e16eb70c8823a1a5077ea1cc84da5
Author: Jerzy Kasenberg 
AuthorDate: Fri Apr 21 11:24:33 2023 +0200

lvgl/gc9a01: Add initial support for GC9A01 TFT
---
 hw/drivers/display/lvgl/pkg.yml |   2 +
 hw/drivers/display/lvgl/syscfg.yml  |   3 +
 hw/drivers/display/lvgl/tft/gc9a01/pkg.yml  |  28 +++
 hw/drivers/display/lvgl/tft/gc9a01/src/gc9a01.c | 267 
 hw/drivers/display/lvgl/tft/gc9a01/syscfg.yml   |  23 ++
 5 files changed, 323 insertions(+)

diff --git a/hw/drivers/display/lvgl/pkg.yml b/hw/drivers/display/lvgl/pkg.yml
index ad2b72ea9..58c1a228c 100644
--- a/hw/drivers/display/lvgl/pkg.yml
+++ b/hw/drivers/display/lvgl/pkg.yml
@@ -58,6 +58,8 @@ pkg.deps:
 - "@apache-mynewt-core/hw/hal"
 - "@apache-mynewt-core/hw/drivers/display/lcd_itf"
 
+pkg.deps.LVGL_GC9A01:
+- "@apache-mynewt-core/hw/drivers/display/lvgl/tft/gc9a01"
 pkg.deps.LVGL_ILI9341:
 - "@apache-mynewt-core/hw/drivers/display/lvgl/tft/ili9341"
 pkg.deps.LVGL_ILI9486:
diff --git a/hw/drivers/display/lvgl/syscfg.yml 
b/hw/drivers/display/lvgl/syscfg.yml
index b83a20d05..9c7b3278b 100644
--- a/hw/drivers/display/lvgl/syscfg.yml
+++ b/hw/drivers/display/lvgl/syscfg.yml
@@ -22,6 +22,9 @@ syscfg.defs:
 LV_COLOR_16_SWAP changes order of 16 bit RGB value to
 better match 8 bit SPI protocol.
 value: 0
+LVGL_GC9A01:
+description: Enable GC9A01 display driver.
+value:
 LVGL_ILI9341:
 description: Enable ILI9341 display driver.
 value:
diff --git a/hw/drivers/display/lvgl/tft/gc9a01/pkg.yml 
b/hw/drivers/display/lvgl/tft/gc9a01/pkg.yml
new file mode 100644
index 0..122b03381
--- /dev/null
+++ b/hw/drivers/display/lvgl/tft/gc9a01/pkg.yml
@@ -0,0 +1,28 @@
+# 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: hw/drivers/display/lvgl/tft/gc9a01
+pkg.description: LVGL display driver for GC9A01
+pkg.author: "Apache Mynewt "
+pkg.homepage: "http://mynewt.apache.org/;
+pkg.keywords:
+
+pkg.cflags:
+
+pkg.deps:
+- "@apache-mynewt-core/hw/drivers/display/lcd_itf"
diff --git a/hw/drivers/display/lvgl/tft/gc9a01/src/gc9a01.c 
b/hw/drivers/display/lvgl/tft/gc9a01/src/gc9a01.c
new file mode 100644
index 0..87a8c8a5d
--- /dev/null
+++ b/hw/drivers/display/lvgl/tft/gc9a01/src/gc9a01.c
@@ -0,0 +1,267 @@
+/*
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define GC9A01_TFTWIDTH240
+#define GC9A01_TFTHEIGHT   240
+
+#define GC9A01_RDDID   0x04
+#define GC9A01_RDDST   0x09
+
+#define GC9A01_SLPIN   0x10
+#define GC9A01_SLPOUT  0x11
+#define GC9A01_PTLON   0x12
+#define GC9A01_NORON   0x13
+
+#define GC9A01_INVOFF  0x20
+#define GC9A01_INVON   0x21
+
+#define GC9A01_DISPOFF 0x28
+#define GC9A01_DISPON  0x29
+#define GC9A01_CASET   0x2A
+#define GC9A01_RASET   0x2B
+#define GC9A01_RAMWR   0x2C
+
+#define GC9A01_PTLAR   0x30
+#define GC9A01_SCRLAR  0x33
+#define GC9A01_TEOFF   0x34
+#define GC9A01_TEON0x35
+#def

[mynewt-core] 03/13: lvgl/ili9341: Add initial support for ILI9341 TFT

2023-05-24 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 737cce54287db975698c7863974e2f8453ff095e
Author: Jerzy Kasenberg 
AuthorDate: Thu Mar 2 12:23:19 2023 +0100

lvgl/ili9341: Add initial support for ILI9341 TFT
---
 hw/drivers/display/lvgl/pkg.yml   |   3 +
 hw/drivers/display/lvgl/syscfg.yml|   3 +
 hw/drivers/display/lvgl/tft/ili9341/pkg.yml   |  28 +++
 hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c | 269 ++
 hw/drivers/display/lvgl/tft/ili9341/syscfg.yml|  23 ++
 5 files changed, 326 insertions(+)

diff --git a/hw/drivers/display/lvgl/pkg.yml b/hw/drivers/display/lvgl/pkg.yml
index 6a026fcb2..8a34ac60b 100644
--- a/hw/drivers/display/lvgl/pkg.yml
+++ b/hw/drivers/display/lvgl/pkg.yml
@@ -58,6 +58,9 @@ pkg.deps:
 - "@apache-mynewt-core/hw/hal"
 - "@apache-mynewt-core/hw/drivers/display/lcd_itf"
 
+pkg.deps.LVGL_ILI9341:
+- "@apache-mynewt-core/hw/drivers/display/lvgl/tft/ili9341"
+
 pkg.cflags:
 - -DLV_CONF_INCLUDE_SIMPLE=1
 - -Wno-unused-variable
diff --git a/hw/drivers/display/lvgl/syscfg.yml 
b/hw/drivers/display/lvgl/syscfg.yml
index 145147a5b..7f4dd4af6 100644
--- a/hw/drivers/display/lvgl/syscfg.yml
+++ b/hw/drivers/display/lvgl/syscfg.yml
@@ -22,6 +22,9 @@ syscfg.defs:
 LV_COLOR_16_SWAP changes order of 16 bit RGB value to
 better match 8 bit SPI protocol.
 value: 0
+LVGL_ILI9341:
+description: Enable ILI9341 display driver.
+value:
 LVGL_TIMER_PERIOD_MS:
 description: LV timer interval for periodical refresh and touch read
 value: 10
diff --git a/hw/drivers/display/lvgl/tft/ili9341/pkg.yml 
b/hw/drivers/display/lvgl/tft/ili9341/pkg.yml
new file mode 100644
index 0..d6a2aa439
--- /dev/null
+++ b/hw/drivers/display/lvgl/tft/ili9341/pkg.yml
@@ -0,0 +1,28 @@
+# 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: hw/drivers/display/lvgl/tft/ili9341
+pkg.description: LVGL display driver for ili9341
+pkg.author: "Apache Mynewt "
+pkg.homepage: "http://mynewt.apache.org/;
+pkg.keywords:
+
+pkg.cflags:
+
+pkg.deps:
+- "@apache-mynewt-core/hw/bus/drivers/spi_common"
diff --git a/hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c 
b/hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c
new file mode 100644
index 0..5f3a3e293
--- /dev/null
+++ b/hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c
@@ -0,0 +1,269 @@
+/*
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define ILI9341_TFTWIDTH240
+#define ILI9341_TFTHEIGHT   320
+
+/* Level 1 Commands -- [section] Description */
+
+#define ILI9341_NOP 0x00 /* [8.2.1 ] No Operation / Terminate Frame 
Memory Write */
+#define ILI9341_SWRESET 0x01 /* [8.2.2 ] Software Reset */
+#define ILI9341_RDDIDIF 0x04 /* [8.2.3 ] Read Display Identification 
Information */
+#define ILI9341_RDDST   0x09 /* [8.2.4 ] Read Display Status */
+#define ILI9341_RDDPM   0x0A /* [8.2.5 ] Read Display Power Mode */
+#define ILI9341_RDDMADCTL   0x0B /* [8.2.6 ] Read Display MADCTL */
+#define ILI9341_RDDCOLMOD   0x0C /* [8.2.7 ] Read Display Pixel Format */
+#define ILI9341_RDDI

[mynewt-core] branch master updated (c65fe7cb2 -> be347d1ed)

2023-05-24 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


from c65fe7cb2 mcu/stm32: Fix ADC dependencies
 new e9b2f7a57 lvgl: Add initial support for LVGL library
 new e621b5ae1 lvgl: Add support for SPI and 8080 MIPI DSI
 new 737cce542 lvgl/ili9341: Add initial support for ILI9341 TFT
 new 5e5d00217 lvgl/ili9486: Add initial support for ILI9486 TFT
 new a149e18b3 lvgl/st7735s: Add initial support for ST7735S TFT
 new 8cb3a992d lvgl/gc9a01: Add initial support for GC9A01 TFT
 new 4a153600c lvgl/st7789: Add initial support for ST7789 TFT
 new 220e8ebca lvgl/xpt2046: Add initial support for XPT2046 touch screen
 new 0f7b1a5b5 lvgl/stmpe610: Add initial support for STMPE610 touch screen
 new fee8e5fc6 apps: Add LVGL demos
 new fd0c300b2 lvgl: Add support for ADC touch screen
 new 7a07e9c9c adc_touch: Add adc handler for nrfx/stm32f7/stm32f4
 new be347d1ed lvgl/trackball: Add support for Blackberry trackball

The 13 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .rat-excludes  |   3 +-
 .style_ignored_dirs|   3 +
 LICENSE|   4 +
 apps/lvgl/demo/README.md   |  91 +++
 apps/lvgl/demo/pkg.yml |  32 +
 apps/lvgl/demo/src/main.c  |  54 ++
 apps/lvgl/demo/syscfg.yml  |  31 +
 hw/drivers/display/lcd_itf/include/lcd_itf.h   | 101 +++
 hw/drivers/display/lcd_itf/itf_8080/pkg.yml|  28 +
 hw/drivers/display/lcd_itf/itf_8080/src/itf_8080.c | 110 +++
 hw/drivers/display/lcd_itf/itf_8080/syscfg.yml |  60 ++
 hw/drivers/display/lcd_itf/itf_spi/pkg.yml |  29 +
 hw/drivers/display/lcd_itf/itf_spi/src/itf_spi.c   | 111 +++
 hw/drivers/display/lcd_itf/itf_spi/syscfg.yml  |  37 +
 hw/drivers/display/lcd_itf/pkg.yml |  33 +
 hw/drivers/display/lcd_itf/src/lcd_itf.c   |  77 +++
 hw/drivers/display/lcd_itf/syscfg.yml  |  40 ++
 hw/drivers/display/lvgl/default/lv_conf.h  | 757 +
 hw/drivers/display/lvgl/include/lv_glue.h  |  36 +
 .../display/lvgl/indev/adc_touch/adc_nrfx/pkg.yml  |  31 +
 .../lvgl/indev/adc_touch/adc_nrfx/src/adc_nrfx.c   | 117 
 .../lvgl/indev/adc_touch/adc_stm32f4/pkg.yml   |  30 +
 .../indev/adc_touch/adc_stm32f4/src/adc_stm32f4.c  | 179 +
 .../lvgl/indev/adc_touch/adc_stm32f7/pkg.yml   |  30 +
 .../indev/adc_touch/adc_stm32f7/src/adc_stm32f7.c  | 224 ++
 .../lvgl/indev/adc_touch/include/adc_touch.h   |  56 ++
 hw/drivers/display/lvgl/indev/adc_touch/pkg.yml|  43 ++
 .../display/lvgl/indev/adc_touch/src/adc_touch.c   | 227 ++
 hw/drivers/display/lvgl/indev/adc_touch/syscfg.yml |  88 +++
 hw/drivers/display/lvgl/indev/stmpe610/pkg.yml |  35 +
 .../display/lvgl/indev/stmpe610/src/stmpe610.c | 354 ++
 hw/drivers/display/lvgl/indev/stmpe610/syscfg.yml  |  53 ++
 hw/drivers/display/lvgl/indev/trackball/pkg.yml|  33 +
 .../display/lvgl/indev/trackball/src/trackball.c   | 217 ++
 hw/drivers/display/lvgl/indev/trackball/syscfg.yml |  66 ++
 hw/drivers/display/lvgl/indev/xpt2046/pkg.yml  |  35 +
 .../display/lvgl/indev/xpt2046/src/xpt2046.c   | 192 ++
 hw/drivers/display/lvgl/indev/xpt2046/syscfg.yml   |  54 ++
 hw/drivers/display/lvgl/pkg.yml|  94 +++
 hw/drivers/display/lvgl/src/mynewt_lvgl.c  |  84 +++
 hw/drivers/display/lvgl/syscfg.yml |  92 +++
 hw/drivers/display/lvgl/tft/gc9a01/pkg.yml |  28 +
 hw/drivers/display/lvgl/tft/gc9a01/src/gc9a01.c| 267 
 hw/drivers/display/lvgl/tft/gc9a01/syscfg.yml  |  23 +
 hw/drivers/display/lvgl/tft/ili9341/pkg.yml|  28 +
 hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c  | 269 
 hw/drivers/display/lvgl/tft/ili9341/syscfg.yml |  23 +
 hw/drivers/display/lvgl/tft/ili9486/pkg.yml|  25 +
 hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c  | 252 +++
 hw/drivers/display/lvgl/tft/ili9486/syscfg.yml |  23 +
 hw/drivers/display/lvgl/tft/st7735s/pkg.yml|  25 +
 hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c  | 245 +++
 hw/drivers/display/lvgl/tft/st7735s/syscfg.yml |  23 +
 hw/drivers/display/lvgl/tft/st7789/pkg.yml |  27 +
 hw/drivers/display/lvgl/tft/st7789/src/st7789.c| 298 
 hw/drivers/display/lvgl/tft/st7789/syscfg.yml  |  26 +
 56 files changed, 5552 insertions(+), 1 deletion(-)
 create mode 100644 apps/lvgl/demo/README.md
 create mode 100644 apps/lvgl/demo/pkg.yml
 create mode 1

[mynewt-nimble] branch master updated: nimble/doc: Fix typo in HCI transport document

2023-03-01 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new b61889fa nimble/doc: Fix typo in HCI transport document
b61889fa is described below

commit b61889fa433af0cb42f38b8d078aac77dfb537eb
Author: Axel Lin 
AuthorDate: Sat Feb 25 10:40:59 2023 +0800

nimble/doc: Fix typo in HCI transport document

Trivial copy-paste mistake fix.

Signed-off-by: Axel Lin 
---
 nimble/doc/transport.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/nimble/doc/transport.md b/nimble/doc/transport.md
index cd14993a..35065197 100644
--- a/nimble/doc/transport.md
+++ b/nimble/doc/transport.md
@@ -36,8 +36,8 @@ another core).
 +--+   +--+
   ||   ||
 ++   ++
-|| <--- ble_transport_to_ll_acl  ||
-|| <--- ble_transport_to_ll_evt  ||
+|| <--- ble_transport_to_hs_acl  ||
+|| <--- ble_transport_to_hs_evt  ||
 | HS |   | LL |
 ||  ble_transport_to_ll_cmd ---> ||
 ||  ble_transport_to_ll_acl ---> ||



[mynewt-nimble] branch master updated: Nimble/host: Add check status before executing stack command

2023-03-01 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new ca22da24 Nimble/host: Add check status before executing stack command
ca22da24 is described below

commit ca22da24b46424f117fec1b1e26e40871f57732f
Author: Rahul Tank 
AuthorDate: Wed Mar 1 12:11:55 2023 +0530

Nimble/host: Add check status before executing stack command

Added change of checking stack status in APIs exposed to user to avoid
incorrect behaviour of executing commands without stack initialized.
---
 nimble/host/src/ble_gap.c | 186 --
 1 file changed, 180 insertions(+), 6 deletions(-)

diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c
index b6d54bc3..85b4c441 100644
--- a/nimble/host/src/ble_gap.c
+++ b/nimble/host/src/ble_gap.c
@@ -490,6 +490,10 @@ ble_gap_conn_find_by_addr(const ble_addr_t *addr,
 #if NIMBLE_BLE_CONNECT
 struct ble_hs_conn *conn;
 
+if (!ble_hs_is_enabled()) {
+return BLE_HS_EDISABLED;
+}
+
 ble_hs_lock();
 
 conn = ble_hs_conn_find_by_addr(addr);
@@ -543,6 +547,10 @@ int
 ble_gap_set_priv_mode(const ble_addr_t *peer_addr, uint8_t priv_mode)
 {
 #if NIMBLE_BLE_CONNECT
+if (!ble_hs_is_enabled()) {
+return BLE_HS_EDISABLED;
+}
+
 return ble_hs_pvcy_set_mode(peer_addr, priv_mode);
 #else
 return BLE_HS_ENOTSUP;
@@ -558,6 +566,10 @@ ble_gap_read_le_phy(uint16_t conn_handle, uint8_t *tx_phy, 
uint8_t *rx_phy)
 struct ble_hs_conn *conn;
 int rc;
 
+if (!ble_hs_is_enabled()) {
+return BLE_HS_EDISABLED;
+}
+
 ble_hs_lock();
 conn = ble_hs_conn_find(conn_handle);
 ble_hs_unlock();
@@ -606,6 +618,10 @@ ble_gap_set_prefered_default_le_phy(uint8_t tx_phys_mask, 
uint8_t rx_phys_mask)
 return BLE_ERR_INV_HCI_CMD_PARMS;
 }
 
+if (!ble_hs_is_enabled()) {
+return BLE_HS_EDISABLED;
+}
+
 memset(, 0, sizeof(cmd));
 
 if (tx_phys_mask == 0) {
@@ -636,6 +652,10 @@ ble_gap_set_prefered_le_phy(uint16_t conn_handle, uint8_t 
tx_phys_mask,
 struct ble_hci_le_set_phy_cp cmd;
 struct ble_hs_conn *conn;
 
+if (!ble_hs_is_enabled()) {
+return BLE_HS_EDISABLED;
+}
+
 ble_hs_lock();
 conn = ble_hs_conn_find(conn_handle);
 ble_hs_unlock();
@@ -2239,6 +2259,10 @@ ble_gap_wl_set(const ble_addr_t *addrs, uint8_t 
white_list_count)
 
 STATS_INC(ble_gap_stats, wl_set);
 
+if (!ble_hs_is_enabled()) {
+return BLE_HS_EDISABLED;
+}
+
 ble_hs_lock();
 
 for (i = 0; i < white_list_count; i++) {
@@ -2343,6 +2367,10 @@ ble_gap_adv_stop(void)
 #if NIMBLE_BLE_ADVERTISE && !MYNEWT_VAL(BLE_EXT_ADV)
 int rc;
 
+if (!ble_hs_is_enabled()) {
+return BLE_HS_EDISABLED;
+}
+
 ble_hs_lock();
 rc = ble_gap_adv_stop_no_lock();
 ble_hs_unlock();
@@ -2540,6 +2568,10 @@ ble_gap_adv_start(uint8_t own_addr_type, const 
ble_addr_t *direct_addr,
 
 STATS_INC(ble_gap_stats, adv_start);
 
+if (!ble_hs_is_enabled()) {
+return BLE_HS_EDISABLED;
+}
+
 ble_hs_lock();
 
 rc = ble_gap_adv_validate(own_addr_type, direct_addr, adv_params);
@@ -2556,11 +2588,6 @@ ble_gap_adv_start(uint8_t own_addr_type, const 
ble_addr_t *direct_addr,
 }
 }
 
-if (!ble_hs_is_enabled()) {
-rc = BLE_HS_EDISABLED;
-goto done;
-}
-
 if (ble_gap_is_preempted()) {
 rc = BLE_HS_EPREEMPTED;
 goto done;
@@ -2625,6 +2652,10 @@ ble_gap_adv_set_data(const uint8_t *data, int data_len)
 
 STATS_INC(ble_gap_stats, adv_set_data);
 
+if (!ble_hs_is_enabled()) {
+return BLE_HS_EDISABLED;
+}
+
 /* Check for valid parameters */
 if (((data == NULL) && (data_len != 0)) ||
 (data_len > BLE_HCI_MAX_ADV_DATA_LEN)) {
@@ -2649,6 +2680,9 @@ ble_gap_adv_rsp_set_data(const uint8_t *data, int 
data_len)
 struct ble_hci_le_set_scan_rsp_data_cp cmd;
 uint16_t opcode;
 
+if (!ble_hs_is_enabled()) {
+return BLE_HS_EDISABLED;
+}
 
 /* Check for valid parameters */
 if (((data == NULL) && (data_len != 0)) ||
@@ -2675,6 +2709,10 @@ ble_gap_adv_set_fields(const struct ble_hs_adv_fields 
*adv_fields)
 uint8_t buf_sz;
 int rc;
 
+if (!ble_hs_is_enabled()) {
+return BLE_HS_EDISABLED;
+}
+
 rc = ble_hs_adv_set_fields(adv_fields, buf, _sz, sizeof buf);
 if (rc != 0) {
 return rc;
@@ -2883,6 +2921,10 @@ ble_gap_ext_adv_configure(uint8_t instance,
 return BLE_HS_EINVAL;
 }
 
+if (!ble_hs_is_enabled()) {
+return BLE_HS_EDISABLED;
+}
+
 rc = ble_gap_ext_adv_params_validate(params);
 if (rc) {
 return rc;
@@ -2947,6 +2989,10 @@ ble_gap_ext_adv_set_addr(uint8_t instance, const 
ble_addr_t *addr)

[mynewt-nimble] branch master updated: ll: Fix compiler error

2023-01-18 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new e7dead61 ll: Fix compiler error
e7dead61 is described below

commit e7dead61af783631c828824e4e80636828cb6520
Author: Łukasz Rymanowski 
AuthorDate: Fri Jan 13 11:28:46 2023 +0100

ll: Fix compiler error

Fixing false possitive compiler error


/home/rymek/projects/bletiny_proj/repos/apache-mynewt-nimble/nimble/controller/src/ble_ll_scan.c:456:12:
 error: array subscript  is outside array bounds of 'struct 
ble_ll_scan_advertisers[0]' 
[␛]8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Warray-bounds␇-Werror=array-bounds␛]8;;␇]
  456 | memcpy(>adv_addr, addr, BLE_DEV_ADDR_LEN);
---
 nimble/controller/src/ble_ll_scan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nimble/controller/src/ble_ll_scan.c 
b/nimble/controller/src/ble_ll_scan.c
index 7c16dd35..b7516e78 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -442,7 +442,7 @@ ble_ll_scan_add_scan_rsp_adv(uint8_t *addr, uint8_t txadd,
 
 /* XXX: for now, if we dont have room, just leave */
 num_advs = g_ble_ll_scan_num_rsp_advs;
-if (num_advs == MYNEWT_VAL(BLE_LL_NUM_SCAN_RSP_ADVS)) {
+if (num_advs >= MYNEWT_VAL(BLE_LL_NUM_SCAN_RSP_ADVS)) {
 return;
 }
 



[mynewt-nimble] branch master updated: nimble: Fix a few types in many places

2021-11-03 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new 9559689  nimble: Fix a few types in many places
9559689 is described below

commit 9559689bc076bb1a46be78f56a7c302609324b22
Author: Tim Gates 
AuthorDate: Thu Sep 23 06:29:19 2021 +1000

nimble: Fix a few types in many places
---
 apps/blecsc/src/main.c  | 2 +-
 docs/btshell/btshell_GAP.rst| 2 +-
 nimble/controller/src/ble_ll_adv.c  | 2 +-
 nimble/controller/src/ble_ll_conn.c | 4 ++--
 nimble/drivers/nrf51/src/ble_phy.c  | 4 ++--
 nimble/drivers/nrf52/src/ble_phy.c  | 2 +-
 nimble/host/mesh/src/pb_adv.c   | 2 +-
 nimble/host/mesh/src/subnet.h   | 2 +-
 nimble/host/src/ble_att_svr.c   | 2 +-
 nimble/host/src/ble_gap.c   | 2 +-
 nimble/host/src/ble_sm_lgcy.c   | 2 +-
 11 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/apps/blecsc/src/main.c b/apps/blecsc/src/main.c
index 60f0b3d..5cca6b7 100644
--- a/apps/blecsc/src/main.c
+++ b/apps/blecsc/src/main.c
@@ -58,7 +58,7 @@ static struct os_callout blecsc_measure_timer;
 /* Variable holds current CSC measurement state */
 static struct ble_csc_measurement_state csc_measurement_state;
 
-/* Variable holds simulted speed (kilometers per hour) */
+/* Variable holds simulated speed (kilometers per hour) */
 static uint16_t csc_sim_speed_kph = CSC_SIM_SPEED_KPH_MIN;
 
 /* Variable holds simulated cadence (RPM) */
diff --git a/docs/btshell/btshell_GAP.rst b/docs/btshell/btshell_GAP.rst
index ce64755..738d146 100644
--- a/docs/btshell/btshell_GAP.rst
+++ b/docs/btshell/btshell_GAP.rst
@@ -411,7 +411,7 @@ Advertising with Extended Advertising enabled
 
+--+--++-+
 |  | scan\_req\_notif | [``0``-1]  
| Enable SCAN\_REQ notifications
  |
 
+--+--++-+
-| **advertise-set-addr**   |  |
| Configure *random* adress for instance
  |
+| **advertise-set-addr**   |  |
| Configure *random* address for instance   
   |
 
+--+--++-+
 |  | instance | [``0``-UINT8\_MAX] 
| Advertising instance  
  |
 
+--+--++-+
diff --git a/nimble/controller/src/ble_ll_adv.c 
b/nimble/controller/src/ble_ll_adv.c
index 19270ac..88c4ae1 100644
--- a/nimble/controller/src/ble_ll_adv.c
+++ b/nimble/controller/src/ble_ll_adv.c
@@ -4479,7 +4479,7 @@ ble_ll_adv_rx_pkt_in(uint8_t ptype, uint8_t *rxbuf, 
struct ble_mbuf_hdr *hdr)
 #endif
 
 /*
- * It is possible that advertising was stopped and a packet plcaed on the
+ * It is possible that advertising was stopped and a packet placed on the
  * LL receive packet queue. In this case, just ignore the received packet
  * as the advertising state machine is no longer "valid"
  */
diff --git a/nimble/controller/src/ble_ll_conn.c 
b/nimble/controller/src/ble_ll_conn.c
index 08bc1fc..55ca20e 100644
--- a/nimble/controller/src/ble_ll_conn.c
+++ b/nimble/controller/src/ble_ll_conn.c
@@ -3163,7 +3163,7 @@ ble_ll_conn_rx_isr_end(uint8_t *rxbuf, struct 
ble_mbuf_hdr *rxhdr)
 /*
  * Check the packet CRC. A connection event can continue even if the
  * received PDU does not pass the CRC check. If we receive two consecutive
- * CRC errors we end the conection event.
+ * CRC errors we end the connection event.
  */
 if (!BLE_MBUF_HDR_CRC_OK(rxhdr)) {
 /*
@@ -3753,7 +3753,7 @@ ble_ll_conn_module_init(void)
 uint16_t i;
 struct ble_ll_conn_sm *connsm;
 
-/* Initialize list of active conections */
+/* Initialize list of active connections */
 SLIST_INIT(_ble_ll_conn_active_list);
 STAILQ_INIT(_ble_ll_conn_free_list);
 
diff --git a/nimble/drivers/nrf51/src/ble_phy.c 
b/nimble/drivers/nrf51/src/ble_phy.c
index b7e6329..d3bc3c2 100644
--- a/nimble/drivers/nrf51/src/ble_phy.c
+++ b/nimble/drivers/nrf51/src/ble_phy.c
@@ -40

[mynewt-nimble] branch master updated: ble_sm: add Secure Connections Only mode

2021-05-06 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new 4ad4395  ble_sm: add Secure Connections Only mode
4ad4395 is described below

commit 4ad4395d7ca0de9607f766700f5b85708ae7b7a1
Author: Krzysztof Kopyściński 
AuthorDate: Thu Mar 18 13:15:02 2021 +0100

ble_sm: add Secure Connections Only mode

Added mode allowing to enforce pairing only in SC mode 1 level 4. This mode 
is required to pass
GAP/SEC/SEM/BI testcases. Added BLE_SM_SC_LVL config to allow pairing only 
in selected levels.
---
 nimble/host/src/ble_att_svr.c  | 10 
 nimble/host/src/ble_sm.c   | 25 +--
 nimble/host/syscfg.yml | 28 ++
 porting/examples/linux/include/syscfg/syscfg.h |  8 +++
 .../examples/linux_blemesh/include/syscfg/syscfg.h |  8 +++
 porting/examples/nuttx/include/syscfg/syscfg.h |  8 +++
 porting/nimble/include/syscfg/syscfg.h |  8 +++
 porting/npl/riot/include/syscfg/syscfg.h   |  8 +++
 8 files changed, 101 insertions(+), 2 deletions(-)

diff --git a/nimble/host/src/ble_att_svr.c b/nimble/host/src/ble_att_svr.c
index 0cfbc7d..7b2611a 100644
--- a/nimble/host/src/ble_att_svr.c
+++ b/nimble/host/src/ble_att_svr.c
@@ -284,6 +284,16 @@ ble_att_svr_check_perms(uint16_t conn_handle, int is_read,
 }
 
 ble_att_svr_get_sec_state(conn_handle, _state);
+/* In SC Only mode all characteristics requiring security
+ * require it on level 4
+ */
+if (MYNEWT_VAL(BLE_SM_SC_ONLY)) {
+if (sec_state.key_size != 128 ||
+!sec_state.authenticated ||
+!sec_state.encrypted) {
+return BLE_ATT_ERR_INSUFFICIENT_KEY_SZ;
+}
+}
 if ((enc || authen) && !sec_state.encrypted) {
 ble_hs_lock();
 conn = ble_hs_conn_find(conn_handle);
diff --git a/nimble/host/src/ble_sm.c b/nimble/host/src/ble_sm.c
index b4e8096..c63af40 100644
--- a/nimble/host/src/ble_sm.c
+++ b/nimble/host/src/ble_sm.c
@@ -1726,17 +1726,23 @@ err:
 }
 
 static bool
-ble_sm_verify_auth_requirements(uint8_t authreq)
+ble_sm_verify_auth_requirements(uint8_t cmd)
 {
 /* For now we check only SC only mode. I.e.: when remote indicates
  * to not support SC pairing, let us make sure legacy pairing is supported
  * on our side. If not, we can fail right away.
  */
-if (!(authreq & BLE_SM_PAIR_AUTHREQ_SC)) {
+if (!(cmd & BLE_SM_PAIR_AUTHREQ_SC)) {
 if (MYNEWT_VAL(BLE_SM_LEGACY) == 0) {
 return false;
 }
 }
+/* Fail if Secure Connections level forces MITM protection and remote does 
not
+ * support it
+ */
+if (MYNEWT_VAL(BLE_SM_SC_LVL) >= 3 && !(cmd & BLE_SM_PAIR_AUTHREQ_MITM)) {
+return false;
+}
 return true;
 }
 
@@ -1817,12 +1823,21 @@ ble_sm_pair_req_rx(uint16_t conn_handle, struct os_mbuf 
**om,
 if (conn->bhc_flags & BLE_HS_CONN_F_MASTER) {
 res->sm_err = BLE_SM_ERR_CMD_NOT_SUPP;
 res->app_status = BLE_HS_SM_US_ERR(BLE_SM_ERR_CMD_NOT_SUPP);
+} else if (MYNEWT_VAL(BLE_SM_SC_LVL) == 1) {
+res->sm_err = BLE_SM_ERR_CMD_NOT_SUPP;
+res->app_status = BLE_HS_SM_US_ERR(BLE_SM_ERR_CMD_NOT_SUPP);
 } else if (req->max_enc_key_size < BLE_SM_PAIR_KEY_SZ_MIN) {
 res->sm_err = BLE_SM_ERR_ENC_KEY_SZ;
 res->app_status = BLE_HS_SM_US_ERR(BLE_SM_ERR_ENC_KEY_SZ);
 } else if (req->max_enc_key_size > BLE_SM_PAIR_KEY_SZ_MAX) {
 res->sm_err = BLE_SM_ERR_INVAL;
 res->app_status = BLE_HS_SM_US_ERR(BLE_SM_ERR_INVAL);
+} else if (MYNEWT_VAL(BLE_SM_SC_ONLY) && (req->max_enc_key_size != 
BLE_SM_PAIR_KEY_SZ_MAX)) {
+/* Fail if Secure Connections Only mode is on and remote does not 
meet
+* key size requirements - MITM was checked in last step
+*/
+res->sm_err = BLE_SM_ERR_ENC_KEY_SZ;
+res->app_status = BLE_HS_SM_US_ERR(BLE_SM_ERR_ENC_KEY_SZ);
 } else if (!ble_sm_verify_auth_requirements(req->authreq)) {
 res->sm_err = BLE_SM_ERR_AUTHREQ;
 res->app_status = BLE_HS_SM_US_ERR(BLE_SM_ERR_AUTHREQ);
@@ -1886,6 +1901,12 @@ ble_sm_pair_rsp_rx(uint16_t conn_handle, struct os_mbuf 
**om,
 } else if (rsp->max_enc_key_size > BLE_SM_PAIR_KEY_SZ_MAX) {
 res->sm_err = BLE_SM_ERR_INVAL;
 res->app_status = BLE_HS_SM_US_ERR(BLE_SM_ERR_INVAL);
+} else if (MYNEWT_VAL(BLE_SM_SC_ONLY) && (rsp->max_enc_key_size != 
BLE_SM_PAIR_KEY_SZ_MAX)) {
+/* Fail if Secure Connections Only mode is on and 

[mynewt-nimble] 02/02: nimble/test: Add SC unit test to flag error on same public key

2021-05-06 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit b106ddbdd4ddbdefae8cef2692cf2ea268fed870
Author: Prasad Alatkar 
AuthorDate: Mon May 3 20:20:14 2021 +0530

nimble/test: Add SC unit test to flag error on same public key
---
 nimble/host/test/src/ble_sm_sc_test.c   | 606 
 nimble/host/test/src/ble_sm_test_util.c | 106 +-
 nimble/host/test/src/ble_sm_test_util.h |   1 +
 3 files changed, 708 insertions(+), 5 deletions(-)

diff --git a/nimble/host/test/src/ble_sm_sc_test.c 
b/nimble/host/test/src/ble_sm_sc_test.c
index c3d1955..cd453e0 100644
--- a/nimble/host/test/src/ble_sm_sc_test.c
+++ b/nimble/host/test/src/ble_sm_sc_test.c
@@ -2289,6 +2289,612 @@ 
TEST_CASE_SELF(ble_sm_sc_us_pk_iio2_rio4_b1_iat0_rat0_ik7_rk5)
  * Secure connections pairing
  * Master: us
  * Pair algorithm: passkey entry
+ * Initiator IO capabilities: 2
+ * Responder IO capabilities: 4
+ * Bonding: true
+ * Initiator address type: 0
+ * Responder address type: 0
+ * Initiator key distribution: 7
+ * Responder key distribution: 5
+ * Peer responds with same public key
+ */
+TEST_CASE_SELF(ble_sm_sc_us_pk_iio2_rio4_b1_iat0_rat0_ik7_rk5_peer_same_pk) {
+struct ble_sm_test_params params;
+
+params = (struct ble_sm_test_params) {
+.init_id_addr = {
+0x01, 0x01, 0x01, 0x07, 0x08, 0x01,
+},
+.resp_id_addr = {
+0xca, 0x61, 0xa0, 0x67, 0x94, 0xe0,
+},
+.pair_req = {
+.io_cap = 0x02,
+.oob_data_flag = 0x00,
+.authreq = 0x0d,
+.max_enc_key_size = 0x10,
+.init_key_dist = 0x07,
+.resp_key_dist = 0x07,
+},
+.pair_rsp = {
+.io_cap = 0x04,
+.oob_data_flag = 0x00,
+.authreq = 0x0d,
+.max_enc_key_size = 0x10,
+.init_key_dist = 0x07,
+.resp_key_dist = 0x05,
+},
+.our_priv_key = {
+0xb1, 0x6b, 0x4f, 0x81, 0xbc, 0xe3, 0x60, 0x9e,
+0x00, 0x20, 0xf1, 0x73, 0x3e, 0xfb, 0xcc, 0x6e,
+0x8c, 0xb6, 0xd2, 0x51, 0xd9, 0x36, 0x8a, 0x6d,
+0xca, 0x8c, 0xd7, 0xbe, 0x96, 0x03, 0xdf, 0xd6,
+},
+.public_key_req = {
+.x = {
+0xe5, 0x0f, 0x02, 0x0a, 0x37, 0x90, 0x94, 0x5a,
+0x06, 0x21, 0xf7, 0xbc, 0xd5, 0xbe, 0xb9, 0x24,
+0x8a, 0x35, 0xfd, 0xf8, 0x5e, 0xe2, 0x70, 0xd5,
+0x5a, 0xe8, 0xe7, 0xdd, 0x13, 0x90, 0xeb, 0xd4,
+},
+.y = {
+0x41, 0xc8, 0x51, 0x1a, 0x25, 0x44, 0x01, 0x53,
+0x42, 0x74, 0x07, 0x9c, 0x18, 0xe6, 0x3b, 0x8a,
+0xce, 0x7a, 0x37, 0x1f, 0x18, 0x5c, 0x02, 0x7c,
+0x67, 0x16, 0xf5, 0x30, 0x2b, 0x31, 0xa9, 0xc7,
+},
+},
+.public_key_rsp = {
+.x = {
+0xe5, 0x0f, 0x02, 0x0a, 0x37, 0x90, 0x94, 0x5a,
+0x06, 0x21, 0xf7, 0xbc, 0xd5, 0xbe, 0xb9, 0x24,
+0x8a, 0x35, 0xfd, 0xf8, 0x5e, 0xe2, 0x70, 0xd5,
+0x5a, 0xe8, 0xe7, 0xdd, 0x13, 0x90, 0xeb, 0xd4,
+},
+.y = {
+0x41, 0xc8, 0x51, 0x1a, 0x25, 0x44, 0x01, 0x53,
+0x42, 0x74, 0x07, 0x9c, 0x18, 0xe6, 0x3b, 0x8a,
+0xce, 0x7a, 0x37, 0x1f, 0x18, 0x5c, 0x02, 0x7c,
+0x67, 0x16, 0xf5, 0x30, 0x2b, 0x31, 0xa9, 0xc7,
+},
+},
+.confirm_req[0] = {
+.value = {
+0x55, 0x2c, 0xaa, 0x41, 0x59, 0x42, 0x4d, 0xfe,
+0x47, 0x74, 0xcd, 0x2b, 0x11, 0xab, 0x21, 0xe6,
+},
+},
+.confirm_rsp[0] = {
+.value = {
+0x6a, 0x3c, 0x45, 0xf5, 0xb2, 0xe2, 0x04, 0x30,
+0xde, 0xd6, 0x3c, 0x6d, 0x85, 0x00, 0x00, 0x2c,
+},
+},
+.random_req[0] = {
+.value = {
+0x78, 0x06, 0x04, 0x60, 0x76, 0xe9, 0xc4, 0x5a,
+0xfb, 0x34, 0x44, 0xae, 0x45, 0xa0, 0x84, 0xde,
+},
+},
+.random_rsp[0] = {
+.value = {
+0x91, 0xc8, 0xfd, 0x1b, 0xb2, 0x85, 0x08, 0x76,
+0xd3, 0xf1, 0xc4, 0xa0, 0xfa, 0x92, 0x8c, 0x94,
+},
+},
+.confirm_req[1] = {
+.value = {
+0xb1, 0x2f, 0x68, 0x35, 0xa1, 0xa5, 0x84, 0xb1,
+0x4f, 0x1a, 0xb1, 0xb5, 0xf0, 0xb2, 0xbe, 0x61,
+},
+},
+.confirm_rsp[1] = {
+.value = {
+0x07, 0xd8, 0x43, 0x74, 0xe8, 0x42, 0xf3, 0xf1,
+0x87, 0x3d, 0x9e, 0x92, 0xea, 0x33, 0xe8, 0x54,
+},
+},
+.random_req[1] = {
+.value = {
+0x4c, 0xb7, 0xcc, 0x6d, 0x90, 0x9f, 0x1e, 0x2d

[mynewt-nimble] 01/02: nimble/host: Fix MITM vulnerability during public key exchange in secure connection

2021-05-06 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 6bb3c0c66839b6422e7eeb69f56733dcaa4b656b
Author: Prasad Alatkar 
AuthorDate: Wed Apr 14 20:55:41 2021 +0530

nimble/host: Fix MITM vulnerability during public key exchange in secure 
connection
---
 nimble/host/src/ble_sm_sc.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/nimble/host/src/ble_sm_sc.c b/nimble/host/src/ble_sm_sc.c
index 7fae5b1..162a4a2 100644
--- a/nimble/host/src/ble_sm_sc.c
+++ b/nimble/host/src/ble_sm_sc.c
@@ -612,6 +612,13 @@ ble_sm_sc_public_key_rx(uint16_t conn_handle, struct 
os_mbuf **om,
 }
 
 cmd = (struct ble_sm_public_key *)(*om)->om_data;
+/* Check if the peer public key is same as our generated public key.
+ * Return fail if the public keys match. */
+if (memcmp(cmd, ble_sm_sc_pub_key, 64) == 0) {
+res->enc_cb = 1;
+res->sm_err = BLE_SM_ERR_AUTHREQ;
+return;
+}
 
 ble_hs_lock();
 proc = ble_sm_proc_find(conn_handle, BLE_SM_PROC_STATE_PUBLIC_KEY, -1,


[mynewt-nimble] branch master updated (68c2594 -> b106ddb)

2021-05-06 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git.


from 68c2594  host/gap: fix doxygen for ble_gap_ext_disc()
 new 6bb3c0c  nimble/host: Fix MITM vulnerability during public key 
exchange in secure connection
 new b106ddb  nimble/test: Add SC unit test to flag error on same public key

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 nimble/host/src/ble_sm_sc.c |   7 +
 nimble/host/test/src/ble_sm_sc_test.c   | 606 
 nimble/host/test/src/ble_sm_test_util.c | 106 +-
 nimble/host/test/src/ble_sm_test_util.h |   1 +
 4 files changed, 715 insertions(+), 5 deletions(-)


[mynewt-nimble] branch master updated: mesh/cdb.c: fix code style

2021-01-12 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new 58fa831  mesh/cdb.c: fix code style
58fa831 is described below

commit 58fa831f31ac3cbcbc4150f4656c0c971899c88a
Author: Krzysztof Kopyściński 
AuthorDate: Tue Jan 12 15:29:01 2021 +0100

mesh/cdb.c: fix code style
---
 nimble/host/mesh/src/cdb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/nimble/host/mesh/src/cdb.c b/nimble/host/mesh/src/cdb.c
index fca502d..bcca3b9 100644
--- a/nimble/host/mesh/src/cdb.c
+++ b/nimble/host/mesh/src/cdb.c
@@ -227,7 +227,7 @@ struct bt_mesh_cdb_subnet *bt_mesh_cdb_subnet_get(uint16_t 
net_idx)
 
 void bt_mesh_cdb_subnet_store(const struct bt_mesh_cdb_subnet *sub)
 {
-   if MYNEWT_VAL(BLE_MESH_SETTINGS) {
+   if (MYNEWT_VAL(BLE_MESH_SETTINGS)) {
bt_mesh_store_cdb_subnet(sub);
}
 }
@@ -309,7 +309,7 @@ struct bt_mesh_cdb_node *bt_mesh_cdb_node_get(uint16_t addr)
 
 void bt_mesh_cdb_node_store(const struct bt_mesh_cdb_node *node)
 {
-   if MYNEWT_VAL(BLE_MESH_SETTINGS) {
+   if (MYNEWT_VAL(BLE_MESH_SETTINGS)) {
bt_mesh_store_cdb_node(node);
}
 }
@@ -382,7 +382,7 @@ struct bt_mesh_cdb_app_key 
*bt_mesh_cdb_app_key_get(uint16_t app_idx)
 
 void bt_mesh_cdb_app_key_store(const struct bt_mesh_cdb_app_key *key)
 {
-   if MYNEWT_VAL(BLE_MESH_SETTINGS) {
+   if (MYNEWT_VAL(BLE_MESH_SETTINGS)) {
bt_mesh_store_cdb_app_key(key);
}
 }



[mynewt-nimble] branch master updated (5fbb666 -> 5bcfd16)

2021-01-12 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git.


from 5fbb666  ble_gap: fix warning about implicit cast form pointer to int
 new 4982bc7  mesh: Fixes seg_tx_reset adv buf unref In seg_tx_reset() in 
transport.c, set the busy flag to 0U before doing adv buf unref, which will 
avoid sending unnecessary adv packets in case the adv buf is already put in the 
mesh adv_queue.
 new 999f4a1  mesh: Fixes wrong return value
 new 90e624b  mesh: Fixes Delete On Node Fixes a issue where nodes could 
not be deleted.
 new 569a625  mesh: Fixes Config client send publish message When Config 
client model send publish message, app_idx will be need, however, currently 
code clear this value use &, this will be generate error when app_idx not zero.
 new 07928f5  mesh: Fixes wrong subnet used for Friend Clear When Friend 
node tries to send Friend Clear message to other Friend nodes, it should use 
the subnet information based on the net_idx from friendship.
 new e088a9d  mesh: Refactor CCM Unifies the Mesh CCM implementation parts 
for encryption and decryption into a crypt and an auth step, reducing stack 
usage and code size.
 new 7710771  mesh: Enable Segmented Control Messages
 new 13c48e2  mesh: Model start callback
 new 0b1e0d7  mesh: Add database for managing nodes and keys
 new 1cfa2e8  mesh: Fix PreviousAddress endianess in Friend Request
 new 95051c6  mesh: Skip publish if update fails
 new 748f568  mesh: Fix provisioning buffer initialization
 new 6920683  mesh: create aes-ccm module aes-ccm now has it's own file. 
Added functions and file structure introduced by 
24db9e029c67afa971ed708b79ab86cebc99c895
 new 3ee80fe  mesh: Support reliable sending when publishing
 new 567bb54  mesh: CDB for config client in shell
 new 5b2b9ea  mesh: typo in condition in comp_add_elem of cfg_srv
 new f4d5f4c  mesh: Rework msg_cache
 new fe96603  Bluetooth: mesh: Use 24-bit functions
 new 08d0397  mesh: Segmented TX to groups
 new 13900a1  mesh: Group resends in proxy nodes
 new 7b15f67  mesh: Split out provisioning bearers
 new 05b30af  mesh: Fix restore when revoke keys
 new 74a57e5  mesh: optimize performance for lpn node
 new d5e0507  mesh: Fix handling of app index and local device key
 new 6b6c67e  mesh: Slab based segmentation handling
 new 30cbff9  mesh: Fix transport tx and rx
 new 4c2a60c  mesh: Fixes duplicated close callback
 new 5c4d4fe  mesh: PB-GATT common link closed
 new e2048d9  mesh: Fix add model group address to sub list
 new f8c5a0e  mesh: Remove net_idx params when with app key
 new d5adbe2  mesh: Add cfg cli list getters
 new 02df6df  mesh: net_key_status only pull one key idx
 new 7cffc8d  mesh: Add a define representing max transaction id
 new e6fd327  mesh: Start protocol timer on send message in advertising 
bearer
 new fa3c93c  mesh: Add reset link functionality to provisioning bearers
 new 1c702e0  mesh: Fix net_buf leak in advertising provisioning bearer
 new 052a034  mesh: Enhancement prov segment received
 new 8be692f  mesh: Fix tx seg buffer with NULL pointer reference
 new 14f7dd9  mesh: configurable advertiser stack size
 new eaa36c9  mesh: Silence proxy not connected log
 new bfe7f21  mesh: Add Option config unprov beacon interval
 new 27cb1c9  mesh: Network loopback
 new 0e77fee  mesh: Config client net_key_del
 new ca59f8d  mesh: Adds three Config Client API
 new 2bcd23d  mesh: Store Krp phase after krp value changed
 new 9727915  mesh: Move Replay Protect to seperate module
 new 9ea97bd  mesh: Virtual address memory leak
 new 1b38d8b  mesh: Fix bug with storing node in CDB
 new e6f3a2e  mesh: Fix cdb key update iteration
 new e08f2f3  mesh: Remove redundant expression
 new 3f79c76  mesh: Fix dereferencing pointer before checking for NULL
 new d6525d5  mesh: Friend with unknown appkey
 new 51370cc  mesh: Transport seg with few adv bufs
 new a684f02  mesh: Transport tx seg_o overflow
 new e147290  mesh: Transport tx fields overflow
 new 2272327  mesh: fix shadow declare this is port of 
bb5ce8ae30e5e44bb2c337988e08e1c90c42f40e
 new 557c6f9  mesh: correct the return type
 new f317241  mesh: Fail init on model init error
 new 78f95c5  mesh: replace zephyr integer types with C99 types
 new 92483a2  mesh: Add key-value concept to store model data
 new 6ffa901  mesh: Null check buf before unref
 new e9ebd2d  mesh: Keep PB-GATT callback through disconnect
 new 86c5d77  mesh: Fix response to Provisioning PDU with invalid type
 new e51ecd5  mesh: Wait for proxy on node reset
 new ec3e4b4  mesh: Transport seg send timeout
 new a45035e  mesh: Use BT_UUID_16_ENCODE to set UUIDs in adv data
 new 97023e6  

[mynewt-nimble] branch master updated: nimble/ll: Fix stuck in the encryption process

2020-11-05 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new f11bc67  nimble/ll: Fix stuck in the encryption process
f11bc67 is described below

commit f11bc676f380a40f73744bd83a72e5db3a3e4a37
Author: Łukasz Rymanowski 
AuthorDate: Tue Oct 6 13:04:46 2020 +0200

nimble/ll: Fix stuck in the encryption process

Background:
When Central sends LL_ENC_REQ, Peripheral is allowed to send unencrypted
data until LL_ENC_RSP is sent back to Central. This is why, Nimble LL puts
LL_ENC_RSP to the tail of the conn_txq.

Issue description:
When lot of trafic is ongoing in the link while encryption, we might
stuck in the process.
This is because enc_state CONN_ENC_S_LTK_REQ_WAIT is set just after
LL_ENC_REQ has been received. If there are still packets in the conn_txq
to send, those will not be sent because of the enc_state. Instead empty
packets will be send and LL_ENC_RSP will stack in the conn_txq.

Fix:
Add addition state for Peripheral role and make sure that LL is able to
send unecypted packets from its conn_txq until LL_ENC_RSP is sent.
---
 nimble/controller/include/controller/ble_ll_conn.h |  1 +
 nimble/controller/src/ble_ll_conn.c| 20 +++-
 nimble/controller/src/ble_ll_ctrl.c|  3 ++-
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/nimble/controller/include/controller/ble_ll_conn.h 
b/nimble/controller/include/controller/ble_ll_conn.h
index 8c07462..d7db687 100644
--- a/nimble/controller/include/controller/ble_ll_conn.h
+++ b/nimble/controller/include/controller/ble_ll_conn.h
@@ -71,6 +71,7 @@ extern "C" {
 enum conn_enc_state {
 CONN_ENC_S_UNENCRYPTED = 1,
 CONN_ENC_S_ENCRYPTED,
+CONN_ENC_S_ENC_RSP_TO_BE_SENT,
 CONN_ENC_S_ENC_RSP_WAIT,
 CONN_ENC_S_PAUSE_ENC_RSP_WAIT,
 CONN_ENC_S_PAUSED,
diff --git a/nimble/controller/src/ble_ll_conn.c 
b/nimble/controller/src/ble_ll_conn.c
index cb80250..371ca42 100644
--- a/nimble/controller/src/ble_ll_conn.c
+++ b/nimble/controller/src/ble_ll_conn.c
@@ -1015,8 +1015,14 @@ ble_ll_conn_tx_pdu(struct ble_ll_conn_sm *connsm)
 /*
  * If we are encrypting, we are only allowed to send certain
  * kinds of LL control PDU's. If none is enqueued, send empty pdu!
+ *
+ * In Slave role, we are allowed to send unencrypted packets until
+ * LL_ENC_RSP is sent.
  */
-if (connsm->enc_data.enc_state > CONN_ENC_S_ENCRYPTED) {
+if (((connsm->enc_data.enc_state > CONN_ENC_S_ENCRYPTED) &&
+ CONN_IS_MASTER(connsm)) ||
+((connsm->enc_data.enc_state > CONN_ENC_S_ENC_RSP_TO_BE_SENT) &&
+ CONN_IS_SLAVE(connsm))) {
 if (!ble_ll_ctrl_enc_allowed_pdu_tx(pkthdr)) {
 CONN_F_EMPTY_PDU_TXD(connsm) = 1;
 goto conn_tx_pdu;
@@ -3652,10 +3658,14 @@ ble_ll_conn_rx_data_pdu(struct os_mbuf *rxpdu, struct 
ble_mbuf_hdr *hdr)
  *
  * Reference: Core 5.0, Vol 6, Part B, 5.1.3.1
  */
-if ((connsm->enc_data.enc_state > CONN_ENC_S_PAUSE_ENC_RSP_WAIT) &&
-!ble_ll_ctrl_enc_allowed_pdu_rx(rxpdu)) {
-ble_ll_conn_timeout(connsm, BLE_ERR_CONN_TERM_MIC);
-goto conn_rx_data_pdu_end;
+if ((connsm->enc_data.enc_state > CONN_ENC_S_PAUSE_ENC_RSP_WAIT &&
+ CONN_IS_MASTER(connsm)) ||
+(connsm->enc_data.enc_state >= CONN_ENC_S_ENC_RSP_TO_BE_SENT &&
+ CONN_IS_SLAVE(connsm))) {
+if (!ble_ll_ctrl_enc_allowed_pdu_rx(rxpdu)) {
+ble_ll_conn_timeout(connsm, BLE_ERR_CONN_TERM_MIC);
+goto conn_rx_data_pdu_end;
+}
 }
 #endif
 
diff --git a/nimble/controller/src/ble_ll_ctrl.c 
b/nimble/controller/src/ble_ll_ctrl.c
index ade8d7b..c4ac650 100644
--- a/nimble/controller/src/ble_ll_ctrl.c
+++ b/nimble/controller/src/ble_ll_ctrl.c
@@ -1443,7 +1443,7 @@ ble_ll_ctrl_rx_enc_req(struct ble_ll_conn_sm *connsm, 
uint8_t *dptr,
 return BLE_LL_CTRL_UNKNOWN_RSP;
 }
 
-connsm->enc_data.enc_state = CONN_ENC_S_LTK_REQ_WAIT;
+connsm->enc_data.enc_state = CONN_ENC_S_ENC_RSP_TO_BE_SENT;
 
 /* In case we were already encrypted we need to reset packet counters */
 connsm->enc_data.rx_pkt_cntr = 0;
@@ -2839,6 +2839,7 @@ ble_ll_ctrl_tx_done(struct os_mbuf *txpdu, struct 
ble_ll_conn_sm *connsm)
 connsm->enc_data.enc_state = CONN_ENC_S_ENC_RSP_WAIT;
 break;
 case BLE_LL_CTRL_ENC_RSP:
+connsm->enc_data.enc_state = CONN_ENC_S_LTK_REQ_WAIT;
 connsm->csmflags.cfbit.send_ltk_req = 1;
 break;
 case BLE_LL_CTRL_START_ENC_RSP:



[mynewt-nimble] branch master updated: apps/blestress: error correction Failed sending data via L2CAP in test 10 was always assumed to be BLE_HS_ESTALLED error, and it's not always the case.

2020-09-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new 4b6f331  apps/blestress: error correction Failed sending data via 
L2CAP in test 10 was always assumed to be BLE_HS_ESTALLED error, and it's not 
always the case.
4b6f331 is described below

commit 4b6f3317483003bee0db3dc5b2ff188a663cef95
Author: Krzysztof Kopyściński 
AuthorDate: Fri Aug 28 12:05:32 2020 +0200

apps/blestress: error correction
Failed sending data via L2CAP in test 10 was always assumed to be
BLE_HS_ESTALLED error, and it's not always the case.
---
 apps/blestress/src/rx_stress.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/apps/blestress/src/rx_stress.c b/apps/blestress/src/rx_stress.c
index d9ba980..440966a 100644
--- a/apps/blestress/src/rx_stress.c
+++ b/apps/blestress/src/rx_stress.c
@@ -844,8 +844,13 @@ rx_stress_10_l2cap_event(struct ble_l2cap_event *event, 
void *arg)
 rc = ble_l2cap_send(rx_stress_ctx->chan, data_buf);
 MODLOG_DFLT(INFO, "Return code=%d\n", rc);
 if (rc) {
-MODLOG_DFLT(INFO, "L2CAP stalled - waiting\n");
-stalled = true;
+if (rc == BLE_HS_ESTALLED) {
+MODLOG_DFLT(INFO, "L2CAP stalled - waiting\n");
+stalled = true;
+} else {
+MODLOG_DFLT(INFO, "Sending data via L2CAP failed with error "
+"code %d\n", rc);
+}
 }
 
 MODLOG_DFLT(INFO, " %d, %d\n", ++send_cnt, data_len);



[mynewt-nimble] 07/09: mesh/beacon.c: Fix key refresh procedure Key refresh procedure was ignored on non-primary subnet.

2020-09-15 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 2c7186445fa51331f28618dab1ae535134784ce0
Author: Krzysztof Kopyściński 
AuthorDate: Thu Sep 3 11:27:17 2020 +0200

mesh/beacon.c: Fix key refresh procedure
Key refresh procedure was ignored on non-primary subnet.
---
 nimble/host/mesh/src/beacon.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/nimble/host/mesh/src/beacon.c b/nimble/host/mesh/src/beacon.c
index cd540aa..4f848c6 100644
--- a/nimble/host/mesh/src/beacon.c
+++ b/nimble/host/mesh/src/beacon.c
@@ -329,6 +329,13 @@ static void secure_beacon_recv(struct os_mbuf *buf)
 
cache_add(data, sub);
 
+   kr_change = bt_mesh_kr_update(sub, BT_MESH_KEY_REFRESH(flags), new_key);
+   if (kr_change) {
+   bt_mesh_net_beacon_update(sub);
+   /* Key Refresh without IV Update only impacts one subnet */
+   bt_mesh_net_sec_update(sub);
+   }
+
/* If we have NetKey0 accept initiation only from it */
if (bt_mesh_subnet_get(BT_MESH_KEY_PRIMARY) &&
sub->net_idx != BT_MESH_KEY_PRIMARY) {
@@ -347,17 +354,9 @@ static void secure_beacon_recv(struct os_mbuf *buf)
 
iv_change = bt_mesh_net_iv_update(iv_index, BT_MESH_IV_UPDATE(flags));
 
-   kr_change = bt_mesh_kr_update(sub, BT_MESH_KEY_REFRESH(flags), new_key);
-   if (kr_change) {
-   bt_mesh_net_beacon_update(sub);
-   }
-
if (iv_change) {
/* Update all subnets */
bt_mesh_net_sec_update(NULL);
-   } else if (kr_change) {
-   /* Key Refresh without IV Update only impacts one subnet */
-   bt_mesh_net_sec_update(sub);
}
 
 update_stats:



[mynewt-nimble] branch master updated (e9a4eed -> f4fe7b9)

2020-09-15 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git.


from e9a4eed  controller: properly seed srand() during init
 new e7009b8  mesh/prov.c: change order of checks in prov_msg_recv() First, 
PDU type should be checked first and then if PDU is valid. Otherwise, we'll 
never check if PDU type is valid, and always return PROV_ERR_UNEXP_PDU. If PDU 
type isn't valid, PROV_ERR_NVAL_FMT shall be returned (0x02).
 new a98eb44  mesh/friend.c: Ignore Freind Request from local interface 
Friend Request is also transmitted over local queue and if both Friend and LPN 
features are enabled then we would try to establish friendship with ourselves.
 new b4522c0  mesh/net.c: replace dup_cache size magic value
 new b14f163  mesh/net.c: don't drop messages with RFU as their destination 
Dropping such messages doesn't comply with Mesh Profile Test Specification.
 new 390041b  apps/bttester: Adjust config values for mesh PTS test cases
 new 25dca96  mesh/cfg_srv.c: Fix Vendor Model Subscription Get procedure 
Invalid argument was passed to bt_mesh_model_tree_walk.
 new 2c71864  mesh/beacon.c: Fix key refresh procedure Key refresh 
procedure was ignored on non-primary subnet.
 new 2820845  mesh/prov.c: Fix resending provisioning link ack The 
comparison of a current tx link transaction id caused us to not send ack and in 
effect fail provisioning.
 new f4fe7b9  Bluetooth: Mesh: Heartbeat period starts at tx Starts the 
periodic heartbeat publish period at the end of the publication, instead of at 
the ordering time. This ensures that the heartbeat period doesn't get shortened 
by other enqueued messages.

The 9 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 apps/bttester/syscfg.yml |  3 +++
 nimble/host/mesh/src/beacon.c| 15 ++--
 nimble/host/mesh/src/cfg_srv.c   | 52 +---
 nimble/host/mesh/src/friend.c|  5 
 nimble/host/mesh/src/lpn.c   |  4 ++--
 nimble/host/mesh/src/net.c   |  7 +-
 nimble/host/mesh/src/prov.c  | 14 +--
 nimble/host/mesh/src/transport.c |  8 +++
 nimble/host/mesh/src/transport.h |  2 +-
 9 files changed, 68 insertions(+), 42 deletions(-)



[mynewt-nimble] 05/09: apps/bttester: Adjust config values for mesh PTS test cases

2020-09-15 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 390041b638a6cca88bda8ea91a1d58dd88aaced4
Author: Krzysztof Kopyściński 
AuthorDate: Thu Sep 3 10:41:07 2020 +0200

apps/bttester: Adjust config values for mesh PTS test cases
---
 apps/bttester/syscfg.yml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/apps/bttester/syscfg.yml b/apps/bttester/syscfg.yml
index dd36f74..8aeac10 100644
--- a/apps/bttester/syscfg.yml
+++ b/apps/bttester/syscfg.yml
@@ -124,6 +124,9 @@ syscfg.vals:
 BLE_MESH_FRIEND: 1
 BLE_MESH_CFG_CLI: 1
 BLE_MESH_RX_SDU_MAX: 110
+BLE_MESH_HEALTH_CLI: 1
+BLE_MESH_FRIEND_QUEUE_SIZE: 32
+CONFIG_BT_MESH_TX_SEG_MSG_COUNT: 6
 
 BLE_MESH_ADV_BUF_COUNT: 20
 BLE_MESH_TX_SEG_MAX: 6



[mynewt-nimble] 01/09: mesh/prov.c: change order of checks in prov_msg_recv() First, PDU type should be checked first and then if PDU is valid. Otherwise, we'll never check if PDU type is valid, and a

2020-09-15 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit e7009b8a7c4e9babae805cb87d420050301dc268
Author: Krzysztof Kopyściński 
AuthorDate: Thu Sep 3 07:26:43 2020 +0200

mesh/prov.c: change order of checks in prov_msg_recv()
First, PDU type should be checked first and then if PDU is valid. Otherwise,
we'll never check if PDU type is valid, and always return 
PROV_ERR_UNEXP_PDU.
If PDU type isn't valid, PROV_ERR_NVAL_FMT shall be returned (0x02).
---
 nimble/host/mesh/src/prov.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/nimble/host/mesh/src/prov.c b/nimble/host/mesh/src/prov.c
index fe92c0e..dbb086a 100644
--- a/nimble/host/mesh/src/prov.c
+++ b/nimble/host/mesh/src/prov.c
@@ -1616,15 +1616,15 @@ static void prov_msg_recv(void)
return;
}
 
-   if (type != PROV_FAILED && type != link.expect) {
-   BT_WARN("Unexpected msg 0x%02x != 0x%02x", type, link.expect);
-   prov_send_fail_msg(PROV_ERR_UNEXP_PDU);
+   if (type >= ARRAY_SIZE(prov_handlers)) {
+   BT_ERR("Unknown provisioning PDU type 0x%02x", type);
+   prov_send_fail_msg(PROV_ERR_NVAL_FMT);
return;
}
 
-   if (type >= ARRAY_SIZE(prov_handlers)) {
-   BT_ERR("Unknown provisioning PDU type 0x%02x", type);
-   prov_send_fail_msg(PROV_ERR_NVAL_PDU);
+   if (type != PROV_FAILED && type != link.expect) {
+   BT_WARN("Unexpected msg 0x%02x != 0x%02x", type, link.expect);
+   prov_send_fail_msg(PROV_ERR_UNEXP_PDU);
return;
}
 



[mynewt-nimble] 03/09: mesh/net.c: replace dup_cache size magic value

2020-09-15 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit b4522c051f46af070061f495e10823874b122f15
Author: Krzysztof Kopyściński 
AuthorDate: Thu Sep 3 09:13:24 2020 +0200

mesh/net.c: replace dup_cache size magic value
---
 nimble/host/mesh/src/net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nimble/host/mesh/src/net.c b/nimble/host/mesh/src/net.c
index 240314d..887ceda 100644
--- a/nimble/host/mesh/src/net.c
+++ b/nimble/host/mesh/src/net.c
@@ -86,7 +86,7 @@ struct bt_mesh_net bt_mesh = {
 #endif
 };
 
-static u32_t dup_cache[4];
+static u32_t dup_cache[MYNEWT_VAL(BLE_MESH_MSG_CACHE_SIZE)];
 static int   dup_cache_next;
 
 static bool check_dup(struct os_mbuf *data)



[mynewt-nimble] 09/09: Bluetooth: Mesh: Heartbeat period starts at tx Starts the periodic heartbeat publish period at the end of the publication, instead of at the ordering time. This ensures that the

2020-09-15 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit f4fe7b90df01b8ca2294af771ce43b1828a70de5
Author: Krzysztof Kopyściński 
AuthorDate: Mon Sep 7 10:21:58 2020 +0200

Bluetooth: Mesh: Heartbeat period starts at tx
Starts the periodic heartbeat publish period at the end of the
publication, instead of at the ordering time. This ensures that the
heartbeat period doesn't get shortened by other enqueued messages.
---
 nimble/host/mesh/src/cfg_srv.c   | 47 +---
 nimble/host/mesh/src/lpn.c   |  4 ++--
 nimble/host/mesh/src/transport.c |  8 +++
 nimble/host/mesh/src/transport.h |  2 +-
 4 files changed, 41 insertions(+), 20 deletions(-)

diff --git a/nimble/host/mesh/src/cfg_srv.c b/nimble/host/mesh/src/cfg_srv.c
index 5cac1ad..c1bb631 100644
--- a/nimble/host/mesh/src/cfg_srv.c
+++ b/nimble/host/mesh/src/cfg_srv.c
@@ -808,7 +808,7 @@ static void gatt_proxy_set(struct bt_mesh_model *model,
bt_mesh_adv_update();
 
if (cfg->hb_pub.feat & BT_MESH_FEAT_PROXY) {
-   bt_mesh_heartbeat_send();
+   (void)bt_mesh_heartbeat_send(NULL, NULL);
}
 
 send_status:
@@ -928,7 +928,7 @@ static void relay_set(struct bt_mesh_model *model,
   BT_MESH_TRANSMIT_INT(cfg->relay_retransmit));
 
if ((cfg->hb_pub.feat & BT_MESH_FEAT_RELAY) && change) {
-   bt_mesh_heartbeat_send();
+   (void)bt_mesh_heartbeat_send(NULL, NULL);
}
} else {
BT_WARN("Invalid Relay value 0x%02x", buf->om_data[0]);
@@ -2782,7 +2782,7 @@ static void friend_set(struct bt_mesh_model *model,
}
 
if (cfg->hb_pub.feat & BT_MESH_FEAT_FRIEND) {
-   bt_mesh_heartbeat_send();
+   (void)bt_mesh_heartbeat_send(NULL, NULL);
}
 
 send_status:
@@ -3283,11 +3283,38 @@ const struct bt_mesh_model_op bt_mesh_cfg_srv_op[] = {
BT_MESH_MODEL_OP_END,
 };
 
+static void hb_publish_end_cb(int err, void *cb_data)
+{
+   struct bt_mesh_cfg_srv *cfg = cb_data;
+   uint16_t period_ms;
+
+   period_ms = hb_pwr2(cfg->hb_pub.period, 1) * 1000U;
+   if (period_ms && cfg->hb_pub.count > 1) {
+   k_delayed_work_submit(>hb_pub.timer, K_MSEC(period_ms));
+   }
+
+   if (cfg->hb_pub.count != 0x) {
+   cfg->hb_pub.count--;
+   }
+}
+
+static void hb_publish_start_cb(uint16_t duration, int err, void *cb_data)
+{
+   if (err) {
+   hb_publish_end_cb(err, cb_data);
+   }
+}
+
 static void hb_publish(struct ble_npl_event *work)
 {
+   static const struct bt_mesh_send_cb publish_cb = {
+   .start = hb_publish_start_cb,
+   .end = hb_publish_end_cb,
+   };
+
struct bt_mesh_cfg_srv *cfg = ble_npl_event_get_arg(work);
struct bt_mesh_subnet *sub;
-   u16_t period_ms;
+   int err;
 
BT_DBG("hb_pub.count: %u", cfg->hb_pub.count);
 
@@ -3303,15 +3330,9 @@ static void hb_publish(struct ble_npl_event *work)
return;
}
 
-   period_ms = hb_pwr2(cfg->hb_pub.period, 1) * 1000;
-   if (period_ms && cfg->hb_pub.count > 1) {
-   k_delayed_work_submit(>hb_pub.timer, period_ms);
-   }
-
-   bt_mesh_heartbeat_send();
-
-   if (cfg->hb_pub.count != 0x) {
-   cfg->hb_pub.count--;
+   err = bt_mesh_heartbeat_send(_cb, cfg);
+   if (err) {
+   hb_publish_end_cb(err, cfg);
}
 }
 
diff --git a/nimble/host/mesh/src/lpn.c b/nimble/host/mesh/src/lpn.c
index ec012a5..0bfc00a 100644
--- a/nimble/host/mesh/src/lpn.c
+++ b/nimble/host/mesh/src/lpn.c
@@ -243,7 +243,7 @@ static void clear_friendship(bool force, bool disable)
lpn->groups_changed = 1;
 
if (cfg->hb_pub.feat & BT_MESH_FEAT_LOW_POWER) {
-   bt_mesh_heartbeat_send();
+   (void)bt_mesh_heartbeat_send(NULL, NULL);
}
 
if (disable) {
@@ -961,7 +961,7 @@ int bt_mesh_lpn_friend_update(struct bt_mesh_net_rx *rx,
BT_INFO("Friendship established with 0x%04x", lpn->frnd);
 
if (cfg->hb_pub.feat & BT_MESH_FEAT_LOW_POWER) {
-   bt_mesh_heartbeat_send();
+   (void)bt_mesh_heartbeat_send(NULL, NULL);
}
 
if (lpn_cb) {
diff --git a/nimble/host/mesh/src/transport.c b/nimble/host/mesh/src/transport.c
index caf1b4f..e771867 100644
--- a/nimble/host/mesh/src/transport.c
+++ b/nimble/host/mesh/src/transport.c
@@ -1569,7 +1569,7 @@ void bt_mesh_rpl_clear(void)
memset(bt_mesh.rpl, 0, sizeof(bt_mesh.rpl));
 }
 
-void bt_mesh_heartbeat_send(void)
+int bt_me

[mynewt-nimble] 06/09: mesh/cfg_srv.c: Fix Vendor Model Subscription Get procedure Invalid argument was passed to bt_mesh_model_tree_walk.

2020-09-15 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 25dca96e0eb0a42c27d7e1bea83d45353b6bd880
Author: Krzysztof Kopyściński 
AuthorDate: Thu Sep 3 11:13:55 2020 +0200

mesh/cfg_srv.c: Fix Vendor Model Subscription Get procedure
Invalid argument was passed to bt_mesh_model_tree_walk.
---
 nimble/host/mesh/src/cfg_srv.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/nimble/host/mesh/src/cfg_srv.c b/nimble/host/mesh/src/cfg_srv.c
index 57aac90..5cac1ad 100644
--- a/nimble/host/mesh/src/cfg_srv.c
+++ b/nimble/host/mesh/src/cfg_srv.c
@@ -1748,6 +1748,7 @@ static void mod_sub_get_vnd(struct bt_mesh_model *model,
struct os_mbuf *buf)
 {
struct os_mbuf *msg = NET_BUF_SIMPLE(BT_MESH_TX_SDU_MAX);
+   struct mod_sub_list_ctx visit_ctx;
struct bt_mesh_model *mod;
struct bt_mesh_elem *elem;
u16_t company, addr, id;
@@ -1789,8 +1790,10 @@ static void mod_sub_get_vnd(struct bt_mesh_model *model,
net_buf_simple_add_le16(msg, company);
net_buf_simple_add_le16(msg, id);
 
+   visit_ctx.msg = msg;
+   visit_ctx.elem_idx = mod->elem_idx;
bt_mesh_model_tree_walk(bt_mesh_model_root(mod), mod_sub_list_visitor,
-   msg);
+   _ctx);
 
 send_list:
if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) {



[mynewt-nimble] 04/09: mesh/net.c: don't drop messages with RFU as their destination Dropping such messages doesn't comply with Mesh Profile Test Specification.

2020-09-15 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit b14f1637a8dfe1ea8dc212da4b2ed16ef1f7e359
Author: Krzysztof Kopyściński 
AuthorDate: Thu Sep 3 09:15:47 2020 +0200

mesh/net.c: don't drop messages with RFU as their destination
Dropping such messages doesn't comply with Mesh Profile Test Specification.
---
 nimble/host/mesh/src/net.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/nimble/host/mesh/src/net.c b/nimble/host/mesh/src/net.c
index 887ceda..bde847a 100644
--- a/nimble/host/mesh/src/net.c
+++ b/nimble/host/mesh/src/net.c
@@ -1287,11 +1287,6 @@ int bt_mesh_net_decode(struct os_mbuf *data, enum 
bt_mesh_net_if net_if,
return -EBADMSG;
}
 
-   if (BT_MESH_ADDR_IS_RFU(rx->ctx.recv_dst)) {
-   BT_ERR("Destination address is RFU; dropping packet");
-   return -EBADMSG;
-   }
-
if (net_if != BT_MESH_NET_IF_LOCAL && bt_mesh_elem_find(rx->ctx.addr)) {
BT_DBG("Dropping locally originated packet");
return -EBADMSG;



[mynewt-nimble] 08/09: mesh/prov.c: Fix resending provisioning link ack The comparison of a current tx link transaction id caused us to not send ack and in effect fail provisioning.

2020-09-15 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 2820845e534ea404b9ab40192a184ecc01f897d0
Author: Krzysztof Kopyściński 
AuthorDate: Fri Sep 4 14:57:56 2020 +0200

mesh/prov.c: Fix resending provisioning link ack
The comparison of a current tx link transaction id caused
us to not send ack and in effect fail provisioning.

Fixes multiple tests from groups: MESH/NODE/CFG/AKL, MESH/NODE/CFG/MAKL
---
 nimble/host/mesh/src/prov.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nimble/host/mesh/src/prov.c b/nimble/host/mesh/src/prov.c
index dbb086a..33f6d60 100644
--- a/nimble/host/mesh/src/prov.c
+++ b/nimble/host/mesh/src/prov.c
@@ -1505,7 +1505,7 @@ static void link_open(struct prov_rx *rx, struct os_mbuf 
*buf)
 
if (atomic_test_bit(link.flags, LINK_ACTIVE)) {
/* Send another link ack if the provisioner missed the last */
-   if (link.id == rx->link_id && link.expect == PROV_INVITE) {
+   if (link.id == rx->link_id) {
BT_DBG("Resending link ack");
bearer_ctl_send(LINK_ACK, NULL, 0);
} else {



[mynewt-nimble] 02/09: mesh/friend.c: Ignore Freind Request from local interface Friend Request is also transmitted over local queue and if both Friend and LPN features are enabled then we would try t

2020-09-15 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit a98ebb14ba06148adf80de664e11a29b42f0
Author: Krzysztof Kopyściński 
AuthorDate: Thu Sep 3 08:14:44 2020 +0200

mesh/friend.c: Ignore Freind Request from local interface
Friend Request is also transmitted over local queue and
if both Friend and LPN features are enabled then we would
try to establish friendship with ourselves.

Fixes MESH/NODE/FRND/LPN testcases.
---
 nimble/host/mesh/src/friend.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/nimble/host/mesh/src/friend.c b/nimble/host/mesh/src/friend.c
index 9056a86..4662f8a 100644
--- a/nimble/host/mesh/src/friend.c
+++ b/nimble/host/mesh/src/friend.c
@@ -935,6 +935,11 @@ int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct 
os_mbuf *buf)
u32_t poll_to;
int i;
 
+   if (rx->net_if == BT_MESH_NET_IF_LOCAL) {
+   BT_WARN("Ignoring Friend request from local interface");
+   return 0;
+   }
+
if (buf->om_len < sizeof(*msg)) {
BT_WARN("Too short Friend Request");
return -EINVAL;



[mynewt-nimble] branch master updated: nimble host: Fix minor bug in ble_eddystone_set_adv_data_gen

2020-09-10 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new 9fd494f  nimble host: Fix minor bug in ble_eddystone_set_adv_data_gen
9fd494f is described below

commit 9fd494f730035e19374a2e6e8e81ec9e9e963b2a
Author: Prasad Alatkar 
AuthorDate: Wed Sep 9 12:54:31 2020 +0530

nimble host: Fix minor bug in ble_eddystone_set_adv_data_gen
---
 nimble/host/src/ble_eddystone.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nimble/host/src/ble_eddystone.c b/nimble/host/src/ble_eddystone.c
index 7d80d13..eccb3e9 100644
--- a/nimble/host/src/ble_eddystone.c
+++ b/nimble/host/src/ble_eddystone.c
@@ -76,7 +76,7 @@ ble_eddystone_set_adv_data_gen(struct ble_hs_adv_fields 
*adv_fields,
 if (adv_fields->num_uuids16 > BLE_EDDYSTONE_MAX_UUIDS16) {
 return BLE_HS_EINVAL;
 }
-if (svc_data_len > BLE_EDDYSTONE_MAX_SVC_DATA_LEN) {
+if (svc_data_len > (BLE_EDDYSTONE_MAX_SVC_DATA_LEN - 
BLE_EDDYSTONE_SVC_DATA_BASE_SZ)) {
 return BLE_HS_EINVAL;
 }
 if (adv_fields->num_uuids16 > 0 && !adv_fields->uuids16_is_complete) {



[mynewt-nimble] 03/03: apps/blestress - change pattern data offset to 0 in stress_fill_mbuf_with_pattern() filling mbuf should begin at start of pattern buffer, as the full length of that buffer if be

2020-08-03 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit a7e3f7cadee00dad2dd24d461033c336f529e3cf
Author: Krzysztof Kopyściński 
AuthorDate: Fri Jul 31 07:59:04 2020 +0200

apps/blestress - change pattern data offset to 0
in stress_fill_mbuf_with_pattern() filling mbuf should begin at start of
pattern buffer, as the full length of that buffer if being copied
---
 apps/blestress/src/stress.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/apps/blestress/src/stress.c b/apps/blestress/src/stress.c
index 0bed576..1bdbafa 100644
--- a/apps/blestress/src/stress.c
+++ b/apps/blestress/src/stress.c
@@ -121,7 +121,7 @@ stress_fill_mbuf_with_pattern(struct os_mbuf *om, uint16_t 
len)
 rest = len % STRESS_PAT_LEN;
 
 for (i = 0; i < mul; ++i) {
-rc = os_mbuf_append(om, _6_pattern[29], STRESS_PAT_LEN);
+rc = os_mbuf_append(om, _6_pattern[0], STRESS_PAT_LEN);
 
 if (rc) {
 os_mbuf_free_chain(om);
@@ -129,7 +129,7 @@ stress_fill_mbuf_with_pattern(struct os_mbuf *om, uint16_t 
len)
 }
 }
 
-rc = os_mbuf_append(om, _6_pattern[29], rest);
+rc = os_mbuf_append(om, _6_pattern[0], rest);
 
 if (rc) {
 os_mbuf_free_chain(om);



[mynewt-nimble] branch master updated (aa2267a -> a7e3f7c)

2020-08-03 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git.


from aa2267a  apps/blestress - compilation error Building the app returned 
error: multiple definition of `stress_timer_callout'. Moving the it's 
declaration to stress.c fixes the issue - this structure is only used there.
 new bf931d5  apps/blestress - switch from PSM = 1 to PSM = 0x80 (128) - 
from dynamic range
 new 205e253  apps/blestress - remove extra SDU lenght info removed 
appending length of pattern data, as that is performed either way by functions 
called by l2cap API
 new a7e3f7c  apps/blestress - change pattern data offset to 0 in 
stress_fill_mbuf_with_pattern() filling mbuf should begin at start of pattern 
buffer, as the full length of that buffer if being copied

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 apps/blestress/src/rx_stress.c | 10 +-
 apps/blestress/src/stress.c|  4 ++--
 apps/blestress/src/stress.h|  2 ++
 apps/blestress/src/tx_stress.c |  2 +-
 4 files changed, 6 insertions(+), 12 deletions(-)



[mynewt-nimble] 01/03: apps/blestress - switch from PSM = 1 to PSM = 0x80 (128) - from dynamic range

2020-08-03 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit bf931d5ee65520c9a69256d711466b210f276a8d
Author: Krzysztof Kopyściński 
AuthorDate: Fri Jul 31 07:56:12 2020 +0200

apps/blestress - switch from PSM = 1 to PSM = 0x80 (128) - from dynamic 
range
---
 apps/blestress/src/rx_stress.c | 2 +-
 apps/blestress/src/stress.h| 2 ++
 apps/blestress/src/tx_stress.c | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/apps/blestress/src/rx_stress.c b/apps/blestress/src/rx_stress.c
index a4253ce..5b91e4d 100644
--- a/apps/blestress/src/rx_stress.c
+++ b/apps/blestress/src/rx_stress.c
@@ -1365,7 +1365,7 @@ rx_stress_start(int test_num)
 break;
 case 10:
 console_printf("Stress L2CAP send\033[0m\n");
-rc = ble_l2cap_create_server(1, STRESS_COC_MTU,
+rc = ble_l2cap_create_server(TEST_PSM, STRESS_COC_MTU,
  rx_stress_10_l2cap_event, NULL);
 assert(rc == 0);
 rx_stress_simple_adv(_stress_adv_sets[10]);
diff --git a/apps/blestress/src/stress.h b/apps/blestress/src/stress.h
index 6f19331..db4fbb3 100644
--- a/apps/blestress/src/stress.h
+++ b/apps/blestress/src/stress.h
@@ -44,6 +44,8 @@ extern "C" {
 #define STRESS_FIND_SRV 1
 #define STRESS_FIND_CHR 2
 #define STRESS_FIND_DSC 3
+/* L2CAP PSM */
+#define TEST_PSM 0x80
 
 struct stress_gatt_search_ctx;
 typedef void stress_gatt_disc_end_fn(struct stress_gatt_search_ctx 
*search_ctx);
diff --git a/apps/blestress/src/tx_stress.c b/apps/blestress/src/tx_stress.c
index 1e62491..4416c56 100644
--- a/apps/blestress/src/tx_stress.c
+++ b/apps/blestress/src/tx_stress.c
@@ -1127,7 +1127,7 @@ tx_stress_10_gap_event(struct ble_gap_event *event, void 
*arg)
 assert(sdu_rx != NULL);
 
 tx_stress_ctx->conn_handle = event->connect.conn_handle;
-rc = ble_l2cap_connect(event->connect.conn_handle, 1,
+rc = ble_l2cap_connect(event->connect.conn_handle, TEST_PSM,
STRESS_COC_MTU, sdu_rx,
tx_stress_10_l2cap_event, NULL);
 assert(rc == 0);



[mynewt-nimble] 02/03: apps/blestress - remove extra SDU lenght info removed appending length of pattern data, as that is performed either way by functions called by l2cap API

2020-08-03 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 205e253200aaad67141d05eebc32fa1447991371
Author: Krzysztof Kopyściński 
AuthorDate: Fri Jul 31 07:57:15 2020 +0200

apps/blestress - remove extra SDU lenght info
removed appending length of pattern data, as that is performed either way
by functions called by l2cap API
---
 apps/blestress/src/rx_stress.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/apps/blestress/src/rx_stress.c b/apps/blestress/src/rx_stress.c
index 5b91e4d..d9ba980 100644
--- a/apps/blestress/src/rx_stress.c
+++ b/apps/blestress/src/rx_stress.c
@@ -837,14 +837,6 @@ rx_stress_10_l2cap_event(struct ble_l2cap_event *event, 
void *arg)
 MODLOG_DFLT(INFO, "Data buf %s\n", data_buf ? "OK" : "NOK");
 assert(data_buf != NULL);
 
-/* The first 2 bytes of data is the size of appended pattern data. */
-rc = os_mbuf_append(data_buf, (uint8_t[]) {data_len >> 8, data_len},
-2);
-if (rc) {
-os_mbuf_free_chain(data_buf);
-assert(0);
-}
-
 /* Fill mbuf with the pattern */
 stress_fill_mbuf_with_pattern(data_buf, data_len);
 



[mynewt-nimble] branch master updated: apps/blestress - compilation error Building the app returned error: multiple definition of `stress_timer_callout'. Moving the it's declaration to stress.c fixes

2020-08-03 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new aa2267a  apps/blestress - compilation error Building the app returned 
error: multiple definition of `stress_timer_callout'. Moving the it's 
declaration to stress.c fixes the issue - this structure is only used there.
aa2267a is described below

commit aa2267ab91a269f7699783993bde3d694a385933
Author: Krzysztof Kopyściński 
AuthorDate: Fri Jul 24 09:53:46 2020 +0200

apps/blestress - compilation error
Building the app returned error: multiple definition of 
`stress_timer_callout'. Moving the it's declaration to stress.c fixes the issue 
- this structure is only used there.
---
 apps/blestress/src/stress.c | 3 +++
 apps/blestress/src/stress.h | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/apps/blestress/src/stress.c b/apps/blestress/src/stress.c
index 6f5badf..0bed576 100644
--- a/apps/blestress/src/stress.c
+++ b/apps/blestress/src/stress.c
@@ -19,6 +19,8 @@
 
 #include "stress.h"
 
+static struct os_callout stress_timer_callout;
+
 void
 com_stress_print_report(const struct com_stress_test_ctx *test_ctxs)
 {
@@ -176,6 +178,7 @@ void
 stress_start_timer(uint32_t timeout_ms, os_event_fn *ev_cb)
 {
 int rc;
+
 os_callout_stop(_timer_callout);
 
 os_callout_init(_timer_callout, os_eventq_dflt_get(), ev_cb, NULL);
diff --git a/apps/blestress/src/stress.h b/apps/blestress/src/stress.h
index 91ab4f4..6f19331 100644
--- a/apps/blestress/src/stress.h
+++ b/apps/blestress/src/stress.h
@@ -45,7 +45,6 @@ extern "C" {
 #define STRESS_FIND_CHR 2
 #define STRESS_FIND_DSC 3
 
-struct os_callout stress_timer_callout;
 struct stress_gatt_search_ctx;
 typedef void stress_gatt_disc_end_fn(struct stress_gatt_search_ctx 
*search_ctx);
 



[mynewt-nimble] 01/02: Allow BLE_ROLE_OBSERVER without BLE_ROLE_CENTRAL or BLE_EXT_ADV

2020-07-08 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 7357ea169bbb762b231b2bceb7d14626758a1965
Author: Hasty Granbery 
AuthorDate: Tue Jun 30 12:57:42 2020 -0700

Allow BLE_ROLE_OBSERVER without BLE_ROLE_CENTRAL or BLE_EXT_ADV

If BLE_ROLE_OBSERVER is set, but neither BLE_ROLE_CENTRAL or BLE_EXT_ADV is 
set, the build fails with a missing ble_gap_master_set_timer. This adds 
BLE_ROLE_OBSERVER to the list for ble_gap_master_set_timer
---
 nimble/host/src/ble_gap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c
index 4df3b7b..0b4de96 100644
--- a/nimble/host/src/ble_gap.c
+++ b/nimble/host/src/ble_gap.c
@@ -998,7 +998,7 @@ ble_gap_update_next_exp(int32_t *out_ticks_from_now)
 
 }
 
-#if MYNEWT_VAL(BLE_ROLE_CENTRAL)
+#if MYNEWT_VAL(BLE_ROLE_CENTRAL) || MYNEWT_VAL(BLE_ROLE_OBSERVER)
 static void
 ble_gap_master_set_timer(uint32_t ticks_from_now)
 {



[mynewt-nimble] 02/02: Change check to NIMBLE_BLE_SCAN

2020-07-08 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 4d25a93af765c8d67c3806962571e1a39aed261e
Author: Hasty Granbery 
AuthorDate: Mon Jul 6 14:29:11 2020 -0700

Change check to NIMBLE_BLE_SCAN

This is synonymous with (MYNEWT_VAL(BLE_ROLE_CENTRAL) || 
MYNEWT_VAL(BLE_ROLE_OBSERVER))
---
 nimble/host/src/ble_gap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c
index 0b4de96..c5bde77 100644
--- a/nimble/host/src/ble_gap.c
+++ b/nimble/host/src/ble_gap.c
@@ -998,7 +998,7 @@ ble_gap_update_next_exp(int32_t *out_ticks_from_now)
 
 }
 
-#if MYNEWT_VAL(BLE_ROLE_CENTRAL) || MYNEWT_VAL(BLE_ROLE_OBSERVER)
+#if NIMBLE_BLE_SCAN
 static void
 ble_gap_master_set_timer(uint32_t ticks_from_now)
 {



[mynewt-nimble] branch master updated (cd7d7aa -> 4d25a93)

2020-07-08 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git.


from cd7d7aa  host/gap: add convenience macros for timings
 new 7357ea1  Allow BLE_ROLE_OBSERVER without BLE_ROLE_CENTRAL or 
BLE_EXT_ADV
 new 4d25a93  Change check to NIMBLE_BLE_SCAN

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 nimble/host/src/ble_gap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)



[mynewt-nimble] 04/05: nimble/ll: Add read peer sca procedure

2020-05-08 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 5ad64e45039d8024a7c4a49fe2639a1935d51eef
Author: Łukasz Rymanowski 
AuthorDate: Fri Apr 17 14:17:01 2020 +0200

nimble/ll: Add read peer sca procedure
---
 nimble/controller/include/controller/ble_ll_ctrl.h |  8 ++-
 nimble/controller/src/ble_ll.c |  3 +
 nimble/controller/src/ble_ll_conn_hci.c| 28 
 nimble/controller/src/ble_ll_conn_priv.h   |  5 ++
 nimble/controller/src/ble_ll_ctrl.c| 77 ++
 nimble/controller/src/ble_ll_hci.c |  9 +++
 nimble/controller/src/ble_ll_hci_ev.c  | 31 +
 nimble/controller/src/ble_ll_supp_cmd.c| 13 +++-
 nimble/controller/syscfg.yml   |  7 ++
 nimble/include/nimble/hci_common.h | 13 
 10 files changed, 192 insertions(+), 2 deletions(-)

diff --git a/nimble/controller/include/controller/ble_ll_ctrl.h 
b/nimble/controller/include/controller/ble_ll_ctrl.h
index b0da1e7..8432422 100644
--- a/nimble/controller/include/controller/ble_ll_ctrl.h
+++ b/nimble/controller/include/controller/ble_ll_ctrl.h
@@ -39,7 +39,8 @@ extern "C" {
 #define BLE_LL_CTRL_PROC_LE_PING(7)
 #define BLE_LL_CTRL_PROC_DATA_LEN_UPD   (8)
 #define BLE_LL_CTRL_PROC_PHY_UPDATE (9)
-#define BLE_LL_CTRL_PROC_NUM(10)
+#define BLE_LL_CTRL_PROC_SCA_UPDATE (10)
+#define BLE_LL_CTRL_PROC_NUM(11)
 #define BLE_LL_CTRL_PROC_IDLE   (255)
 
 /* Checks if a particular control procedure is running */
@@ -306,6 +307,11 @@ void ble_ll_hci_ev_send_vendor_err(const char *file, 
uint32_t line);
 uint8_t ble_ll_ctrl_phy_tx_transition_get(uint8_t phy_mask);
 uint8_t ble_ll_ctrl_phy_from_phy_mask(uint8_t phy_mask);
 
+#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_SCA_UPDATE)
+void ble_ll_hci_ev_sca_update(struct ble_ll_conn_sm *connsm,
+  uint8_t status, uint8_t peer_sca);
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/nimble/controller/src/ble_ll.c b/nimble/controller/src/ble_ll.c
index 996ad9c..c6eefcf 100644
--- a/nimble/controller/src/ble_ll.c
+++ b/nimble/controller/src/ble_ll.c
@@ -1678,6 +1678,9 @@ ble_ll_init(void)
 features |= BLE_LL_FEAT_SYNC_TRANS_SEND;
 #endif
 
+#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_SCA_UPDATE)
+features |= BLE_LL_FEAT_SCA_UPDATE;
+#endif
 /* Initialize random number generation */
 ble_ll_rand_init();
 
diff --git a/nimble/controller/src/ble_ll_conn_hci.c 
b/nimble/controller/src/ble_ll_conn_hci.c
index b84b690..9936b9d 100644
--- a/nimble/controller/src/ble_ll_conn_hci.c
+++ b/nimble/controller/src/ble_ll_conn_hci.c
@@ -1560,6 +1560,34 @@ ltk_key_cmd_complete:
 }
 #endif
 
+#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_SCA_UPDATE)
+int
+ble_ll_conn_req_peer_sca(const uint8_t *cmdbuf, uint8_t len,
+ uint8_t *rspbuf, uint8_t *rsplen)
+{
+const struct ble_hci_le_request_peer_sca_cp *params = (const void *)cmdbuf;
+struct ble_ll_conn_sm *connsm;
+
+connsm = ble_ll_conn_find_active_conn(params->conn_handle);
+if (!connsm) {
+return BLE_ERR_UNK_CONN_ID;
+}
+
+if (!(connsm->remote_features[2] & (BLE_LL_FEAT_SCA_UPDATE >> 24))) {
+return BLE_ERR_UNSUPP_REM_FEATURE;
+}
+
+if (IS_PENDING_CTRL_PROC(connsm, BLE_LL_CTRL_PROC_SCA_UPDATE)) {
+/* Not really specified what we should return */
+return BLE_ERR_CTLR_BUSY;
+}
+
+ble_ll_ctrl_proc_start(connsm, BLE_LL_CTRL_PROC_SCA_UPDATE);
+
+return 0;
+}
+#endif
+
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING)
 /**
  * Read authenticated payload timeout (OGF=3, OCF==0x007B)
diff --git a/nimble/controller/src/ble_ll_conn_priv.h 
b/nimble/controller/src/ble_ll_conn_priv.h
index a836bfe..9891bfa 100644
--- a/nimble/controller/src/ble_ll_conn_priv.h
+++ b/nimble/controller/src/ble_ll_conn_priv.h
@@ -196,6 +196,11 @@ int ble_ll_conn_hci_wr_auth_pyld_tmo(const uint8_t 
*cmdbuf, uint8_t len,
  uint8_t *rspbuf, uint8_t *rsplen);
 int ble_ll_conn_hci_rd_auth_pyld_tmo(const uint8_t *cmdbuf, uint8_t len,
  uint8_t *rspbuf, uint8_t *rsplen);
+#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_SCA_UPDATE)
+int ble_ll_conn_req_peer_sca(const uint8_t *cmdbuf, uint8_t len,
+ uint8_t *rspbuf, uint8_t *rsplen);
+#endif
+
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_PING)
 void ble_ll_conn_auth_pyld_timer_start(struct ble_ll_conn_sm *connsm);
 #else
diff --git a/nimble/controller/src/ble_ll_ctrl.c 
b/nimble/controller/src/ble_ll_ctrl.c
index ea2ba83..f6f3b0b 100644
--- a/nimble/controller/src/ble_ll_ctrl.c
+++ b/nimble/controller/src/ble_ll_ctrl.c
@@ -506,6 +506,12 @@ ble_ll_ctrl_proc_unk_rsp(struct ble_ll_conn_sm *connsm, 
uint8_t *dptr, uint8_t *
 ctrl_proc = B

[mynewt-nimble] branch master updated (0445038 -> 0cf9ad5)

2020-05-08 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git.


from 0445038  btshell: Fix console printout
 new 2a39d40  nimble/ll: Parse hci disconnect in ble_ll_hci
 new 7aadaaa  nimble/ll: Minior coding style
 new 533936c  nimble/ll: Fix for hci supported commands
 new 5ad64e4  nimble/ll: Add read peer sca procedure
 new 0cf9ad5  nimble/ll: Boilerplate for ISO implementation

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 nimble/controller/include/controller/ble_ll_conn.h |   2 +
 nimble/controller/include/controller/ble_ll_ctrl.h |  87 +++---
 nimble/controller/include/controller/ble_ll_hci.h  |   2 +-
 nimble/controller/include/controller/ble_ll_iso.h  |  53 
 nimble/controller/src/ble_ll.c |  14 +
 nimble/controller/src/ble_ll_conn_hci.c|  35 ++-
 nimble/controller/src/ble_ll_conn_priv.h   |   7 +-
 nimble/controller/src/ble_ll_ctrl.c| 130 
 nimble/controller/src/ble_ll_hci.c | 118 +++-
 nimble/controller/src/ble_ll_hci_ev.c  |  31 ++
 nimble/controller/src/ble_ll_iso.c | 146 +
 nimble/controller/src/ble_ll_supp_cmd.c|  74 -
 nimble/controller/syscfg.yml   |  22 ++
 nimble/include/nimble/hci_common.h | 336 -
 nimble/syscfg.yml  |  13 +
 15 files changed, 1024 insertions(+), 46 deletions(-)
 create mode 100644 nimble/controller/include/controller/ble_ll_iso.h
 create mode 100644 nimble/controller/src/ble_ll_iso.c



[mynewt-nimble] 05/05: nimble/ll: Boilerplate for ISO implementation

2020-05-08 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 0cf9ad5593beaec0d75a045ec233569470368548
Author: Łukasz Rymanowski 
AuthorDate: Fri Apr 17 14:51:06 2020 +0200

nimble/ll: Boilerplate for ISO implementation

This patch just adds all the necessary infrastructure for ISO
implementation. Code does nothing.

Also, all code use two MYNEWT_VALs BLE_ISO and BLE_ISO_TEST - we can
introduce more flags e.g. to control CIS_MASTER,CIS_SLAVE, BROADCASTER
---
 nimble/controller/include/controller/ble_ll_conn.h |   2 +
 nimble/controller/include/controller/ble_ll_ctrl.h |  81 +++---
 nimble/controller/include/controller/ble_ll_iso.h  |  53 
 nimble/controller/src/ble_ll.c |  11 +
 nimble/controller/src/ble_ll_ctrl.c|  53 
 nimble/controller/src/ble_ll_hci.c |  93 ++
 nimble/controller/src/ble_ll_iso.c | 146 ++
 nimble/controller/src/ble_ll_supp_cmd.c|  51 +++-
 nimble/controller/syscfg.yml   |  15 +
 nimble/include/nimble/hci_common.h | 321 +
 nimble/syscfg.yml  |  13 +
 11 files changed, 802 insertions(+), 37 deletions(-)

diff --git a/nimble/controller/include/controller/ble_ll_conn.h 
b/nimble/controller/include/controller/ble_ll_conn.h
index 26c9926..94ea42c 100644
--- a/nimble/controller/include/controller/ble_ll_conn.h
+++ b/nimble/controller/include/controller/ble_ll_conn.h
@@ -58,6 +58,8 @@ extern "C" {
 /* Definition for RSSI when the RSSI is unknown */
 #define BLE_LL_CONN_UNKNOWN_RSSI(127)
 
+#define BLE_LL_CONN_HANDLE_ISO_OFFSET   (0x0100)
+
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION)
 /*
  * Encryption states for a connection
diff --git a/nimble/controller/include/controller/ble_ll_ctrl.h 
b/nimble/controller/include/controller/ble_ll_ctrl.h
index 8432422..15a45b2 100644
--- a/nimble/controller/include/controller/ble_ll_ctrl.h
+++ b/nimble/controller/include/controller/ble_ll_ctrl.h
@@ -40,7 +40,8 @@ extern "C" {
 #define BLE_LL_CTRL_PROC_DATA_LEN_UPD   (8)
 #define BLE_LL_CTRL_PROC_PHY_UPDATE (9)
 #define BLE_LL_CTRL_PROC_SCA_UPDATE (10)
-#define BLE_LL_CTRL_PROC_NUM(11)
+#define BLE_LL_CTRL_PROC_CIS_CREATE (11)
+#define BLE_LL_CTRL_PROC_NUM(12)
 #define BLE_LL_CTRL_PROC_IDLE   (255)
 
 /* Checks if a particular control procedure is running */
@@ -55,45 +56,51 @@ extern "C" {
  *  -> Opcode   (1 byte)
  *  -> Data (0 - 26 bytes)
  */
-#define BLE_LL_CTRL_CONN_UPDATE_IND (0)
-#define BLE_LL_CTRL_CHANNEL_MAP_REQ (1)
-#define BLE_LL_CTRL_TERMINATE_IND   (2)
-#define BLE_LL_CTRL_ENC_REQ (3)
-#define BLE_LL_CTRL_ENC_RSP (4)
-#define BLE_LL_CTRL_START_ENC_REQ   (5)
-#define BLE_LL_CTRL_START_ENC_RSP   (6)
-#define BLE_LL_CTRL_UNKNOWN_RSP (7)
-#define BLE_LL_CTRL_FEATURE_REQ (8)
-#define BLE_LL_CTRL_FEATURE_RSP (9)
-#define BLE_LL_CTRL_PAUSE_ENC_REQ   (10)
-#define BLE_LL_CTRL_PAUSE_ENC_RSP   (11)
-#define BLE_LL_CTRL_VERSION_IND (12)
-#define BLE_LL_CTRL_REJECT_IND  (13)
-#define BLE_LL_CTRL_SLAVE_FEATURE_REQ   (14)
-#define BLE_LL_CTRL_CONN_PARM_REQ   (15)
-#define BLE_LL_CTRL_CONN_PARM_RSP   (16)
-#define BLE_LL_CTRL_REJECT_IND_EXT  (17)
-#define BLE_LL_CTRL_PING_REQ(18)
-#define BLE_LL_CTRL_PING_RSP(19)
-#define BLE_LL_CTRL_LENGTH_REQ  (20)
-#define BLE_LL_CTRL_LENGTH_RSP  (21)
-#define BLE_LL_CTRL_PHY_REQ (22)
-#define BLE_LL_CTRL_PHY_RSP (23)
-#define BLE_LL_CTRL_PHY_UPDATE_IND  (24)
-#define BLE_LL_CTRL_MIN_USED_CHAN_IND   (25)
-#define BLE_LL_CTRL_CTE_REQ (26)
-#define BLE_LL_CTRL_CTE_RSP (27)
-#define BLE_LL_CTRL_PERIODIC_SYNC_IND   (28)
-#define BLE_LL_CTRL_CLOCK_ACCURACY_REQ  (29)
-#define BLE_LL_CTRL_CLOCK_ACCURACY_RSP  (30)
+#define BLE_LL_CTRL_CONN_UPDATE_IND (0x00)
+#define BLE_LL_CTRL_CHANNEL_MAP_REQ (0x01)
+#define BLE_LL_CTRL_TERMINATE_IND   (0x02)
+#define BLE_LL_CTRL_ENC_REQ (0x03)
+#define BLE_LL_CTRL_ENC_RSP (0x04)
+#define BLE_LL_CTRL_START_ENC_REQ   (0x05)
+#define BLE_LL_CTRL_START_ENC_RSP   (0x06)
+#define BLE_LL_CTRL_UNKNOWN_RSP (0x07)
+#define BLE_LL_CTRL_FEATURE_REQ (0x08)
+#define BLE_LL_CTRL_FEATURE_RSP (0x09)
+#define BLE_LL_CTRL_PAUSE_ENC_REQ   (0x0A)
+#define BLE_LL_CTRL_PAUSE_ENC_RSP   (0x0B)
+#define BLE_LL_CTRL_VERSION_IND (0x0C)
+#define BLE_LL_CTRL_REJECT_IND  (0x0D)
+#define BLE_LL_CTRL_SLAVE_FEATURE_REQ   (0x0E)
+#define BLE_LL_CTRL_CONN_PARM_REQ   (0x0F)
+#define BLE_LL_CTRL_CONN_PARM_RSP   (0x10)
+#define BLE_LL_CTRL_REJECT_IND_EXT  

[mynewt-nimble] 03/05: nimble/ll: Fix for hci supported commands

2020-05-08 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 533936c15f47b5b482d9f4370f5304cb92dd1be0
Author: Łukasz Rymanowski 
AuthorDate: Wed Apr 22 11:35:06 2020 +0200

nimble/ll: Fix for hci supported commands
---
 nimble/controller/include/controller/ble_ll_hci.h |  2 +-
 nimble/controller/src/ble_ll_supp_cmd.c   | 14 ++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/nimble/controller/include/controller/ble_ll_hci.h 
b/nimble/controller/include/controller/ble_ll_hci.h
index abef874..6a9e48e 100644
--- a/nimble/controller/include/controller/ble_ll_hci.h
+++ b/nimble/controller/include/controller/ble_ll_hci.h
@@ -27,7 +27,7 @@ extern "C" {
 #include "nimble/hci_common.h"
 
 /* For supported commands */
-#define BLE_LL_SUPP_CMD_LEN (42)
+#define BLE_LL_SUPP_CMD_LEN (45)
 extern const uint8_t g_ble_ll_supp_cmds[BLE_LL_SUPP_CMD_LEN];
 
 /* The largest event the controller will send. */
diff --git a/nimble/controller/src/ble_ll_supp_cmd.c 
b/nimble/controller/src/ble_ll_supp_cmd.c
index 834e009..1285d91 100644
--- a/nimble/controller/src/ble_ll_supp_cmd.c
+++ b/nimble/controller/src/ble_ll_supp_cmd.c
@@ -410,6 +410,17 @@
 BLE_SUPP_CMD_LE_PADV_DEFAULT_SYNC_TRANSFER_PARAMS   \
 )
 
+/* Octet 44 */
+#if MYNEWT_VAL(BLE_VERSION) >= 52
+#define BLE_SUPP_CMD_LE_SET_HOST_FEATURE (1 << 0)
+#else
+#define BLE_SUPP_CMD_LE_SET_HOST_FEATURE (0 << 0)
+#endif
+#define BLE_LL_SUPP_CMD_OCTET_44\
+(   \
+BLE_SUPP_CMD_LE_SET_HOST_FEATURE  \
+)
+
 /* Defines the array of supported commands */
 const uint8_t g_ble_ll_supp_cmds[BLE_LL_SUPP_CMD_LEN] =
 {
@@ -455,4 +466,7 @@ const uint8_t g_ble_ll_supp_cmds[BLE_LL_SUPP_CMD_LEN] =
 BLE_LL_SUPP_CMD_OCTET_39,
 BLE_LL_SUPP_CMD_OCTET_40,   /* Octet 40 */
 BLE_LL_SUPP_CMD_OCTET_41,
+0,
+0,
+BLE_LL_SUPP_CMD_OCTET_44,
 };



[mynewt-nimble] 02/05: nimble/ll: Minior coding style

2020-05-08 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 7aadaaa29c0fd74795907c0270f3ce2d06c6139c
Author: Łukasz Rymanowski 
AuthorDate: Thu Apr 16 16:17:25 2020 +0200

nimble/ll: Minior coding style
---
 nimble/include/nimble/hci_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nimble/include/nimble/hci_common.h 
b/nimble/include/nimble/hci_common.h
index c79abb3..4aaf81c 100644
--- a/nimble/include/nimble/hci_common.h
+++ b/nimble/include/nimble/hci_common.h
@@ -1212,7 +1212,7 @@ struct ble_hci_ev_auth_pyld_tmo {
 struct ble_hci_ev_vendor_debug {
 uint8_t id;
 uint8_t data[0];
-}__attribute__((packed));
+} __attribute__((packed));
 
 /* LE sub-event codes */
 #define BLE_HCI_LE_SUBEV_CONN_COMPLETE  (0x01)



[mynewt-nimble] 01/05: nimble/ll: Parse hci disconnect in ble_ll_hci

2020-05-08 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 2a39d40ac098d88bde33fe26333d438f7294b3bf
Author: Łukasz Rymanowski 
AuthorDate: Thu Apr 16 15:06:42 2020 +0200

nimble/ll: Parse hci disconnect in ble_ll_hci

This will be used later when LL will have to decide if it is ACL or CIS
to disconnect
---
 nimble/controller/src/ble_ll_conn_hci.c  |  7 +--
 nimble/controller/src/ble_ll_conn_priv.h |  2 +-
 nimble/controller/src/ble_ll_hci.c   | 16 +++-
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/nimble/controller/src/ble_ll_conn_hci.c 
b/nimble/controller/src/ble_ll_conn_hci.c
index 1350fdc..b84b690 100644
--- a/nimble/controller/src/ble_ll_conn_hci.c
+++ b/nimble/controller/src/ble_ll_conn_hci.c
@@ -1128,16 +1128,11 @@ 
ble_ll_conn_create_cancel(ble_ll_hci_post_cmd_complete_cb *post_cmd_cb)
  * @return int
  */
 int
-ble_ll_conn_hci_disconnect_cmd(const uint8_t *cmdbuf, uint8_t len)
+ble_ll_conn_hci_disconnect_cmd(const struct ble_hci_lc_disconnect_cp *cmd)
 {
 int rc;
 uint16_t handle;
 struct ble_ll_conn_sm *connsm;
-const struct ble_hci_lc_disconnect_cp *cmd = (const void *) cmdbuf;
-
-if (len != sizeof (*cmd)) {
-return BLE_ERR_INV_HCI_CMD_PARMS;
-}
 
 /* Check for valid parameters */
 handle = le16toh(cmd->conn_handle);
diff --git a/nimble/controller/src/ble_ll_conn_priv.h 
b/nimble/controller/src/ble_ll_conn_priv.h
index f2f72d1..a836bfe 100644
--- a/nimble/controller/src/ble_ll_conn_priv.h
+++ b/nimble/controller/src/ble_ll_conn_priv.h
@@ -164,7 +164,7 @@ bool ble_ll_conn_init_pending_aux_conn_rsp(void);
 void ble_ll_disconn_comp_event_send(struct ble_ll_conn_sm *connsm,
 uint8_t reason);
 void ble_ll_auth_pyld_tmo_event_send(struct ble_ll_conn_sm *connsm);
-int ble_ll_conn_hci_disconnect_cmd(const uint8_t *cmdbuf, uint8_t len);
+int ble_ll_conn_hci_disconnect_cmd(const struct ble_hci_lc_disconnect_cp *cmd);
 int ble_ll_conn_hci_rd_rem_ver_cmd(const uint8_t *cmdbuf, uint8_t len);
 int ble_ll_conn_create(const uint8_t *cmdbuf, uint8_t len);
 int ble_ll_conn_hci_update(const uint8_t *cmdbuf, uint8_t len);
diff --git a/nimble/controller/src/ble_ll_hci.c 
b/nimble/controller/src/ble_ll_hci.c
index b82adc2..14f71de 100644
--- a/nimble/controller/src/ble_ll_hci.c
+++ b/nimble/controller/src/ble_ll_hci.c
@@ -1174,6 +1174,20 @@ ble_ll_hci_le_cmd_proc(const uint8_t *cmdbuf, uint8_t 
len, uint16_t ocf,
 return rc;
 }
 
+static int
+ble_ll_hci_disconnect(const uint8_t *cmdbuf, uint8_t len)
+{
+const struct ble_hci_lc_disconnect_cp *cmd;
+
+cmd = (const void *) cmdbuf;
+
+if (len != sizeof (*cmd)) {
+return BLE_ERR_INV_HCI_CMD_PARMS;
+}
+
+return ble_ll_conn_hci_disconnect_cmd(cmd);
+}
+
 /**
  * Process a link control command sent from the host to the controller. The HCI
  * command has a 3 byte command header followed by data. The header is:
@@ -1194,7 +1208,7 @@ ble_ll_hci_link_ctrl_cmd_proc(const uint8_t *cmdbuf, 
uint8_t len, uint16_t ocf)
 
 switch (ocf) {
 case BLE_HCI_OCF_DISCONNECT_CMD:
-rc = ble_ll_conn_hci_disconnect_cmd(cmdbuf, len);
+rc = ble_ll_hci_disconnect(cmdbuf, len);
 /* Send command status instead of command complete */
 rc += (BLE_ERR_MAX + 1);
 break;



[mynewt-nimble] 01/02: blestress: Minor coding style

2020-05-08 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit a2c5dfaa47116431d29df1dbe0d3bb909c43dbf9
Author: Łukasz Rymanowski 
AuthorDate: Fri Apr 17 10:03:14 2020 +0200

blestress: Minor coding style
---
 apps/blestress/src/tx_stress.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/apps/blestress/src/tx_stress.c b/apps/blestress/src/tx_stress.c
index b73adc8..1e62491 100644
--- a/apps/blestress/src/tx_stress.c
+++ b/apps/blestress/src/tx_stress.c
@@ -1292,17 +1292,16 @@ tx_stress_14_subs_cb(uint16_t conn_handle, const struct 
ble_gatt_error *error,
 assert(error->status == 0);
 
 /* If the first subscription after finding cccd */
-if(arg == NULL) {
+if (arg == NULL) {
 return 0;
 }
 
-sub = (bool*)arg;
+sub = (bool *)arg;
 
 /* Enable notifications */
-if(*sub == 0) {
+if (*sub == 0) {
 *sub = true;
-om = ble_hs_mbuf_from_flat(
-(uint8_t[]) {0x01, 0x00}, 2);
+om = ble_hs_mbuf_from_flat((uint8_t[]) {0x01, 0x00}, 2);
 
 tx_stress_ctx->begin_us = tx_stress_ctx->end_us;
 
@@ -1415,7 +1414,7 @@ tx_stress_14_gap_event(struct ble_gap_event *event, void 
*arg)
 
 static int
 tx_stress_15_write_cb(uint16_t conn_handle, const struct ble_gatt_error *error,
- struct ble_gatt_attr *attr, void *arg)
+  struct ble_gatt_attr *attr, void *arg)
 {
 /* Disconnect */
 ble_gap_terminate(conn_handle, BLE_ERR_REM_USER_CONN_TERM);
@@ -1464,7 +1463,7 @@ tx_stress_15_gap_event(struct ble_gap_event *event, void 
*arg)
 
 case BLE_GAP_EVENT_DISCONNECT:
 /* Perform use case specified number of times */
-if(tx_stress_ctx->con_stat[15].num >= MYNEWT_VAL(BLE_STRESS_REPEAT)) {
+if (tx_stress_ctx->con_stat[15].num >= MYNEWT_VAL(BLE_STRESS_REPEAT)) {
 tx_stress_on_test_finish(15);
 return 0;
 }
@@ -1473,7 +1472,7 @@ tx_stress_15_gap_event(struct ble_gap_event *event, void 
*arg)
 return 0;
 
 default:
-MODLOG_DFLT(INFO, "Other event occurs=%d\n", event->type);
+MODLOG_DFLT(INFO, "Other event occurs=%d\n", event->type);
 return 0;
 }
 }
@@ -1607,7 +1606,8 @@ tx_stress_test_perform(int test_num)
 }
 
 static void
-tx_stress_read_command_cb(void) {
+tx_stress_read_command_cb(void)
+{
 console_printf("Start testing\n");
 os_sem_release(_stress_main_sem);
 }
@@ -1642,7 +1642,7 @@ tx_stress_main_task_fn(void *arg)
 /* Wait for the scan to find the test. Then 1 token will be
  * released allowing to pass through semaphore. */
 os_sem_pend(_stress_main_sem, OS_TIMEOUT_NEVER);
-if(tx_stress_ctx->scan_timeout) {
+if (tx_stress_ctx->scan_timeout) {
 break;
 }
 



[mynewt-nimble] branch master updated (760f239 -> 0445038)

2020-05-08 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git.


from 760f239  apps/bttester: Add support for Enhanced L2CAP COC
 new a2c5dfa  blestress: Minor coding style
 new 0445038  btshell: Fix console printout

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 apps/blestress/src/tx_stress.c | 20 ++--
 apps/btshell/src/cmd.c |  2 +-
 2 files changed, 11 insertions(+), 11 deletions(-)



[mynewt-nimble] 02/02: btshell: Fix console printout

2020-05-08 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 0445038a5f91930c6cb596f5c50a8fa21c6b6538
Author: Łukasz Rymanowski 
AuthorDate: Fri Feb 14 14:45:08 2020 +0100

btshell: Fix console printout
---
 apps/btshell/src/cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apps/btshell/src/cmd.c b/apps/btshell/src/cmd.c
index 8a87875..28aa87f 100644
--- a/apps/btshell/src/cmd.c
+++ b/apps/btshell/src/cmd.c
@@ -2712,7 +2712,7 @@ cmd_security_unpair(int argc, char **argv)
 
 rc = parse_dev_addr("peer_", cmd_peer_addr_types, );
 if (rc != 0) {
-console_printf("invalid 'peer_addr' parameter\n");
+console_printf("invalid peer address\n");
 return rc;
 }
 



[mynewt-nimble] branch master updated: nimble/gap: Make initial connection event length constants zero.

2020-04-27 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new 55c904f  nimble/gap: Make initial connection event length constants 
zero.
55c904f is described below

commit 55c904fee7f575a6948a8b51d5388f4a3f2a689b
Author: h2zero 
AuthorDate: Fri Apr 24 08:25:42 2020 -0600

nimble/gap: Make initial connection event length constants zero.

The NimBLE controller currently does not use these parameters, however 
other controllers such as the esp32 do make use of them.

This PR is for changing these to a more "neutral" value to avoid unexpected 
behavior when using a different controller.
---
 nimble/host/include/host/ble_gap.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/nimble/host/include/host/ble_gap.h 
b/nimble/host/include/host/ble_gap.h
index b58f350..8341023 100644
--- a/nimble/host/include/host/ble_gap.h
+++ b/nimble/host/include/host/ble_gap.h
@@ -98,8 +98,8 @@ struct hci_conn_update;
 
 #define BLE_GAP_INITIAL_CONN_LATENCY0
 #define BLE_GAP_INITIAL_SUPERVISION_TIMEOUT 0x0100
-#define BLE_GAP_INITIAL_CONN_MIN_CE_LEN 0x0010
-#define BLE_GAP_INITIAL_CONN_MAX_CE_LEN 0x0300
+#define BLE_GAP_INITIAL_CONN_MIN_CE_LEN 0x
+#define BLE_GAP_INITIAL_CONN_MAX_CE_LEN 0x
 
 #define BLE_GAP_ROLE_MASTER 0
 #define BLE_GAP_ROLE_SLAVE  1



[mynewt-nimble] branch master updated: nimble/host: Add return parameter to the ble_hs_misc_conn_chan_find_reqd()

2020-04-22 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new 6ced1dd  nimble/host: Add return parameter to the 
ble_hs_misc_conn_chan_find_reqd()
6ced1dd is described below

commit 6ced1dd4ca63e6f0bd2df7dcc558afcc2896f1c2
Author: h2zero 
AuthorDate: Sat Apr 18 20:42:41 2020 -0600

nimble/host: Add return parameter to the ble_hs_misc_conn_chan_find_reqd()

ble_hs_misc_conn_chan_find_reqd() did not return an error code if
the connection and or the channel were not found, i.e in a disconnected 
state.
When debug is not enabled and `ble_hs_misc_conn_chan_find_reqd()` is called 
and
the device has disconnected from the peer various functions may attempt to 
access
memory that is not valid causing an null pointer exception.
---
 nimble/host/src/ble_att_cmd.c   |  7 +++
 nimble/host/src/ble_hs_misc.c   |  8 ++--
 nimble/host/src/ble_hs_priv.h   |  6 +++---
 nimble/host/src/ble_l2cap_sig.c |  9 +++--
 nimble/host/src/ble_l2cap_sig_cmd.c |  8 +---
 nimble/host/src/ble_sm_cmd.c| 11 ---
 6 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/nimble/host/src/ble_att_cmd.c b/nimble/host/src/ble_att_cmd.c
index a123c85..81b070f 100644
--- a/nimble/host/src/ble_att_cmd.c
+++ b/nimble/host/src/ble_att_cmd.c
@@ -66,11 +66,10 @@ ble_att_tx(uint16_t conn_handle, struct os_mbuf *txom)
 
 ble_hs_lock();
 
-ble_hs_misc_conn_chan_find_reqd(conn_handle, BLE_L2CAP_CID_ATT, ,
-);
-if (chan == NULL) {
+rc = ble_hs_misc_conn_chan_find_reqd(conn_handle, BLE_L2CAP_CID_ATT, ,
+ );
+if (rc != 0) {
 os_mbuf_free_chain(txom);
-rc = BLE_HS_ENOTCONN;
 } else {
 ble_att_truncate_to_mtu(chan, txom);
 rc = ble_l2cap_tx(conn, chan, txom);
diff --git a/nimble/host/src/ble_hs_misc.c b/nimble/host/src/ble_hs_misc.c
index 6c6da46..dfb46b7 100644
--- a/nimble/host/src/ble_hs_misc.c
+++ b/nimble/host/src/ble_hs_misc.c
@@ -56,7 +56,7 @@ ble_hs_misc_conn_chan_find(uint16_t conn_handle, uint16_t cid,
 return rc;
 }
 
-void
+int
 ble_hs_misc_conn_chan_find_reqd(uint16_t conn_handle, uint16_t cid,
 struct ble_hs_conn **out_conn,
 struct ble_l2cap_chan **out_chan)
@@ -66,7 +66,9 @@ ble_hs_misc_conn_chan_find_reqd(uint16_t conn_handle, 
uint16_t cid,
 int rc;
 
 rc = ble_hs_misc_conn_chan_find(conn_handle, cid, , );
-BLE_HS_DBG_ASSERT_EVAL(rc == 0);
+if (rc != 0) {
+return rc;
+}
 
 if (out_conn != NULL) {
 *out_conn = conn;
@@ -74,6 +76,8 @@ ble_hs_misc_conn_chan_find_reqd(uint16_t conn_handle, 
uint16_t cid,
 if (out_chan != NULL) {
 *out_chan = chan;
 }
+
+return 0;
 }
 
 uint8_t
diff --git a/nimble/host/src/ble_hs_priv.h b/nimble/host/src/ble_hs_priv.h
index 2cad6ef..538d07a 100644
--- a/nimble/host/src/ble_hs_priv.h
+++ b/nimble/host/src/ble_hs_priv.h
@@ -114,9 +114,9 @@ int ble_hs_hci_evt_acl_process(struct os_mbuf *om);
 int ble_hs_misc_conn_chan_find(uint16_t conn_handle, uint16_t cid,
struct ble_hs_conn **out_conn,
struct ble_l2cap_chan **out_chan);
-void ble_hs_misc_conn_chan_find_reqd(uint16_t conn_handle, uint16_t cid,
- struct ble_hs_conn **out_conn,
- struct ble_l2cap_chan **out_chan);
+int ble_hs_misc_conn_chan_find_reqd(uint16_t conn_handle, uint16_t cid,
+struct ble_hs_conn **out_conn,
+struct ble_l2cap_chan **out_chan);
 uint8_t ble_hs_misc_own_addr_type_to_id(uint8_t addr_type);
 uint8_t ble_hs_misc_peer_addr_type_to_id(uint8_t addr_type);
 int ble_hs_misc_restore_irks(void);
diff --git a/nimble/host/src/ble_l2cap_sig.c b/nimble/host/src/ble_l2cap_sig.c
index bb4d8a5..58f96b0 100644
--- a/nimble/host/src/ble_l2cap_sig.c
+++ b/nimble/host/src/ble_l2cap_sig.c
@@ -508,8 +508,13 @@ ble_l2cap_sig_update(uint16_t conn_handle,
 STATS_INC(ble_l2cap_stats, update_init);
 
 ble_hs_lock();
-ble_hs_misc_conn_chan_find_reqd(conn_handle, BLE_L2CAP_CID_SIG,
-, );
+rc = ble_hs_misc_conn_chan_find_reqd(conn_handle, BLE_L2CAP_CID_SIG,
+ , );
+if (rc != 0) {
+ble_hs_unlock();
+goto done;
+}
+
 master = conn->bhc_flags & BLE_HS_CONN_F_MASTER;
 ble_hs_unlock();
 
diff --git a/nimble/host/src/ble_l2cap_sig_cmd.c 
b/nimble/host/src/ble_l2cap_sig_cmd.c
index 366dde6..510420f 100644
--- a/nimble/host/src/ble_l2cap_sig_cmd.c
+++ b/nimble/host/src/ble_l2cap_sig_cmd.c
@@ -28,9 +28,11 @@ ble_l2cap

[mynewt-nimble] branch master updated: nimble/gap: Fix storing CCC for bonded devices.

2020-04-22 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new 2da39a1  nimble/gap: Fix storing CCC for bonded devices.
2da39a1 is described below

commit 2da39a1fe53a635252cc04cac3f8df7305af4eca
Author: Łukasz Rymanowski 
AuthorDate: Tue Apr 21 09:48:02 2020 +0200

nimble/gap: Fix storing CCC for bonded devices.

This PR make sure that ble_gatts_bonding_established is called only when
bonded.

Note: renamed not used "persist_keys" to "bonded" and make use of it

Bug can be easly reproduced when
BLE_SM_BONDING: 0
BLE_HS_DEBUG: 1

Program received signal SIGTRAP, Trace/breakpoint trap.
ble_gatts_bonding_established (conn_handle=conn_handle@entry=1) at 
repos/apache-mynewt-nimble/nimble/host/src/ble_gatts.c:1681
1681BLE_HS_DBG_ASSERT(conn->bhc_sec_state.bonded);
(gdb)
---
 nimble/host/src/ble_gap.c  | 27 ---
 nimble/host/src/ble_gap_priv.h |  2 +-
 nimble/host/src/ble_sm.c   |  5 +++--
 nimble/host/src/ble_sm_priv.h  |  8 
 4 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c
index 53c6bf3..4df3b7b 100644
--- a/nimble/host/src/ble_gap.c
+++ b/nimble/host/src/ble_gap.c
@@ -5654,7 +5654,8 @@ ble_gap_passkey_event(uint16_t conn_handle,
 }
 
 void
-ble_gap_enc_event(uint16_t conn_handle, int status, int security_restored)
+ble_gap_enc_event(uint16_t conn_handle, int status,
+  int security_restored, int bonded)
 {
 #if NIMBLE_BLE_SM
 struct ble_gap_event event;
@@ -5667,12 +5668,24 @@ ble_gap_enc_event(uint16_t conn_handle, int status, int 
security_restored)
 ble_gap_event_listener_call();
 ble_gap_call_conn_event_cb(, conn_handle);
 
-if (status == 0) {
-if (security_restored) {
-ble_gatts_bonding_restored(conn_handle);
-} else {
-ble_gatts_bonding_established(conn_handle);
-}
+if (status != 0) {
+return;
+}
+
+/* If encryption succeded and encryption has been restored for bonded 
device,
+ * notify gatt server so it has chance to send notification/indication if 
needed.
+ */
+if (security_restored) {
+ble_gatts_bonding_restored(conn_handle);
+return;
+}
+
+/* If this is fresh pairing and bonding has been established,
+ * notify gatt server about that so previous subscriptions (before bonding)
+ * can be stored.
+ */
+if (bonded) {
+ble_gatts_bonding_established(conn_handle);
 }
 #endif
 }
diff --git a/nimble/host/src/ble_gap_priv.h b/nimble/host/src/ble_gap_priv.h
index c050435..499823b 100644
--- a/nimble/host/src/ble_gap_priv.h
+++ b/nimble/host/src/ble_gap_priv.h
@@ -116,7 +116,7 @@ int ble_gap_rx_l2cap_update_req(uint16_t conn_handle,
 struct ble_gap_upd_params *params);
 void ble_gap_rx_phy_update_complete(const struct 
ble_hci_ev_le_subev_phy_update_complete *ev);
 void ble_gap_enc_event(uint16_t conn_handle, int status,
-   int security_restored);
+   int security_restored, int bonded);
 void ble_gap_passkey_event(uint16_t conn_handle,
struct ble_gap_passkey_params *passkey_params);
 void ble_gap_notify_rx_event(uint16_t conn_handle, uint16_t attr_handle,
diff --git a/nimble/host/src/ble_sm.c b/nimble/host/src/ble_sm.c
index cfd80fc..91afb75 100644
--- a/nimble/host/src/ble_sm.c
+++ b/nimble/host/src/ble_sm.c
@@ -938,7 +938,7 @@ ble_sm_process_result(uint16_t conn_handle, struct 
ble_sm_result *res)
 
 if (res->enc_cb) {
 BLE_HS_DBG_ASSERT(proc == NULL || rm);
-ble_gap_enc_event(conn_handle, res->app_status, res->restore);
+ble_gap_enc_event(conn_handle, res->app_status, res->restore, 
res->bonded);
 }
 
 if (res->app_status == 0 &&
@@ -1190,6 +1190,7 @@ ble_sm_enc_event_rx(uint16_t conn_handle, uint8_t 
evt_status, int encrypted)
 
 ble_hs_unlock();
 
+res.bonded = bonded;
 ble_sm_process_result(conn_handle, );
 }
 
@@ -2425,7 +2426,7 @@ ble_sm_timer(void)
  * procedures without reconnect.
  */
 while ((proc = STAILQ_FIRST(_list)) != NULL) {
-ble_gap_enc_event(proc->conn_handle, BLE_HS_ETIMEOUT, 0);
+ble_gap_enc_event(proc->conn_handle, BLE_HS_ETIMEOUT, 0, 0);
 
 STAILQ_REMOVE_HEAD(_list, next);
 ble_sm_proc_free(proc);
diff --git a/nimble/host/src/ble_sm_priv.h b/nimble/host/src/ble_sm_priv.h
index 6d5601b..27e75aa 100644
--- a/nimble/host/src/ble_sm_priv.h
+++ b/nimble/host/src/ble_sm_priv.h
@@ -279,10 +279,10 @@ struct ble_sm_result {
 uint8_t sm_err;
 struct ble_gap_passkey_params pas

[mynewt-nimble] branch master updated (6ec9b6b -> dc7d990)

2020-04-21 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git.


from 6ec9b6b  nimble/host: Improve find conn by ble_addr_t
 add fd17c53  add deprectation message to ble store header
 add dc7d990  add deprecation message to ble store source

No new revisions were added by this update.

Summary of changes:
 nimble/host/store/ram/include/store/ram/ble_store_ram.h | 5 +
 nimble/host/store/ram/src/ble_store_ram.c   | 5 +
 2 files changed, 10 insertions(+)



[mynewt-nimble] branch master updated (6661a51 -> 6ec9b6b)

2020-04-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git.


from 6661a51  nimble/store: Fix store behavior when CCCDs exceed maximum 
limit
 add 6ec9b6b  nimble/host: Improve find conn by ble_addr_t

No new revisions were added by this update.

Summary of changes:
 nimble/host/src/ble_hs_conn.c | 9 +
 1 file changed, 9 insertions(+)



[mynewt-nimble] branch master updated (bb0fcde -> 6661a51)

2020-04-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git.


from bb0fcde  nimble/socket: Enhance error log with hci dev num
 new 7260a4e  nimble/host: Fix return code in `ble_gap_unpair_oldest_peer` 
when no bonded peer exist
 new 6661a51  nimble/store: Fix store behavior when CCCDs exceed maximum 
limit

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 nimble/host/include/host/ble_gap.h | 14 ++
 nimble/host/src/ble_gap.c  | 32 +++-
 nimble/host/src/ble_store_util.c   | 16 +---
 3 files changed, 54 insertions(+), 8 deletions(-)



[mynewt-nimble] 02/02: nimble/store: Fix store behavior when CCCDs exceed maximum limit

2020-04-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 6661a5139ae3bce4b123b7089cf6f6d61ee6764d
Author: Prasad Alatkar 
AuthorDate: Wed Apr 1 00:08:29 2020 +0530

nimble/store: Fix store behavior when CCCDs exceed maximum limit

- Add supporting API to skip input peer while unpairing oldest peer
---
 nimble/host/include/host/ble_gap.h | 14 ++
 nimble/host/src/ble_gap.c  | 30 ++
 nimble/host/src/ble_store_util.c   | 16 +---
 3 files changed, 53 insertions(+), 7 deletions(-)

diff --git a/nimble/host/include/host/ble_gap.h 
b/nimble/host/include/host/ble_gap.h
index 20e7dab..b58f350 100644
--- a/nimble/host/include/host/ble_gap.h
+++ b/nimble/host/include/host/ble_gap.h
@@ -1896,6 +1896,20 @@ int ble_gap_unpair(const ble_addr_t *peer_addr);
  */
 int ble_gap_unpair_oldest_peer(void);
 
+/**
+ * Similar to `ble_gap_unpair_oldest_peer()`, except it makes sure that the
+ * peer received in input parameters is not deleted.
+ *
+ * @param peer_addr Address of the peer (not to be deleted)
+ *
+ * @return  0 on success;
+ *  A BLE host HCI return code if the controller
+ *  rejected the request;
+ *  A BLE host core return code on unexpected
+ *  error.
+ */
+int ble_gap_unpair_oldest_except(const ble_addr_t *peer_addr);
+
 #define BLE_GAP_PRIVATE_MODE_NETWORK0
 #define BLE_GAP_PRIVATE_MODE_DEVICE 1
 
diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c
index b44012d..53c6bf3 100644
--- a/nimble/host/src/ble_gap.c
+++ b/nimble/host/src/ble_gap.c
@@ -5605,6 +5605,36 @@ ble_gap_unpair_oldest_peer(void)
 return 0;
 }
 
+int
+ble_gap_unpair_oldest_except(const ble_addr_t *peer_addr)
+{
+ble_addr_t peer_id_addrs[MYNEWT_VAL(BLE_STORE_MAX_BONDS)];
+int num_peers;
+int rc, i;
+
+rc = ble_store_util_bonded_peers(
+_id_addrs[0], _peers, MYNEWT_VAL(BLE_STORE_MAX_BONDS));
+if (rc != 0) {
+return rc;
+}
+
+if (num_peers == 0) {
+return BLE_HS_ENOENT;
+}
+
+for (i = 0; i < num_peers; i++) {
+if (ble_addr_cmp(peer_addr, _id_addrs[i]) != 0) {
+break;
+}
+}
+
+if (i >= num_peers) {
+return BLE_HS_ENOMEM;
+}
+
+return ble_gap_unpair(_id_addrs[i]);
+}
+
 void
 ble_gap_passkey_event(uint16_t conn_handle,
   struct ble_gap_passkey_params *passkey_params)
diff --git a/nimble/host/src/ble_store_util.c b/nimble/host/src/ble_store_util.c
index 444cc55..7de4827 100644
--- a/nimble/host/src/ble_store_util.c
+++ b/nimble/host/src/ble_store_util.c
@@ -233,13 +233,15 @@ ble_store_util_status_rr(struct ble_store_status_event 
*event, void *arg)
 switch (event->event_code) {
 case BLE_STORE_EVENT_OVERFLOW:
 switch (event->overflow.obj_type) {
-case BLE_STORE_OBJ_TYPE_OUR_SEC:
-case BLE_STORE_OBJ_TYPE_PEER_SEC:
-case BLE_STORE_OBJ_TYPE_CCCD:
-return ble_gap_unpair_oldest_peer();
-
-default:
-return BLE_HS_EUNKNOWN;
+case BLE_STORE_OBJ_TYPE_OUR_SEC:
+case BLE_STORE_OBJ_TYPE_PEER_SEC:
+return ble_gap_unpair_oldest_peer();
+case BLE_STORE_OBJ_TYPE_CCCD:
+/* Try unpairing oldest peer except current peer */
+return 
ble_gap_unpair_oldest_except(>overflow.value->cccd.peer_addr);
+
+default:
+return BLE_HS_EUNKNOWN;
 }
 
 case BLE_STORE_EVENT_FULL:



[mynewt-nimble] 01/02: nimble/host: Fix return code in `ble_gap_unpair_oldest_peer` when no bonded peer exist

2020-04-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 7260a4efdb72ab8e1db1767c4f1e502876d8c378
Author: Prasad Alatkar 
AuthorDate: Fri Apr 3 18:42:05 2020 +0530

nimble/host: Fix return code in `ble_gap_unpair_oldest_peer` when no bonded 
peer exist
---
 nimble/host/src/ble_gap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c
index 4729dd0..b44012d 100644
--- a/nimble/host/src/ble_gap.c
+++ b/nimble/host/src/ble_gap.c
@@ -5594,7 +5594,7 @@ ble_gap_unpair_oldest_peer(void)
 }
 
 if (num_peers == 0) {
-return 0;
+return BLE_HS_ENOENT;
 }
 
 rc = ble_gap_unpair(_peer_id_addr);



[mynewt-nimble] 01/04: nimble/sm: Minor coding style fix

2020-04-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit c6eddb058e38cc8faf45d013dc21d7dd53ef7eb7
Author: Łukasz Rymanowski 
AuthorDate: Wed Aug 28 07:42:46 2019 +0200

nimble/sm: Minor coding style fix
---
 nimble/host/src/ble_sm_alg.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/nimble/host/src/ble_sm_alg.c b/nimble/host/src/ble_sm_alg.c
index 50fd77e..148995c 100644
--- a/nimble/host/src/ble_sm_alg.c
+++ b/nimble/host/src/ble_sm_alg.c
@@ -68,8 +68,6 @@ ble_sm_alg_encrypt(const uint8_t *key, const uint8_t 
*plaintext,
 
 swap_buf(tmp, plaintext, 16);
 
-
-
 if (tc_aes_encrypt(enc_data, tmp, ) == TC_CRYPTO_FAIL) {
 return BLE_HS_EUNKNOWN;
 }



[mynewt-nimble] 02/04: nimble/l2cap: Minor coding style fix

2020-04-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 77bca6bc8fcf9e9341c207eff5107b6af625c91d
Author: Łukasz Rymanowski 
AuthorDate: Thu Jan 2 12:23:34 2020 +0100

nimble/l2cap: Minor coding style fix
---
 nimble/host/src/ble_l2cap_coc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/nimble/host/src/ble_l2cap_coc.c b/nimble/host/src/ble_l2cap_coc.c
index 41a8315..54ea321 100644
--- a/nimble/host/src/ble_l2cap_coc.c
+++ b/nimble/host/src/ble_l2cap_coc.c
@@ -73,7 +73,7 @@ ble_l2cap_coc_create_server(uint16_t psm, uint16_t mtu,
 
 srv = ble_l2cap_coc_srv_alloc();
 if (!srv) {
-return BLE_HS_ENOMEM;
+return BLE_HS_ENOMEM;
 }
 
 srv->psm = psm;
@@ -453,7 +453,7 @@ ble_l2cap_coc_continue_tx(struct ble_l2cap_chan *chan)
 len - sdu_size_offset);
 if (rc) {
 BLE_HS_LOG(DEBUG, "Could not append data rc=%d", rc);
-   goto failed;
+goto failed;
 }
 
 ble_hs_lock();



[mynewt-nimble] 04/04: nimble/socket: Enhance error log with hci dev num

2020-04-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit bb0fcde212146894431732ee87601784cac5d444
Author: Łukasz Rymanowski 
AuthorDate: Wed Aug 14 14:44:02 2019 +0200

nimble/socket: Enhance error log with hci dev num
---
 nimble/transport/socket/src/ble_hci_socket.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nimble/transport/socket/src/ble_hci_socket.c 
b/nimble/transport/socket/src/ble_hci_socket.c
index 863d0fb..8bf56f3 100644
--- a/nimble/transport/socket/src/ble_hci_socket.c
+++ b/nimble/transport/socket/src/ble_hci_socket.c
@@ -540,7 +540,7 @@ ble_hci_sock_config(void)
 
 rc = bind(s, (struct sockaddr *), sizeof(shci));
 if (rc) {
-dprintf(1, "bind() failed %d\n", errno);
+dprintf(1, "bind() failed %d hci%d\n", errno, shci.hci_dev);
 goto err;
 }
 



[mynewt-nimble] 03/04: nimble/l2cap: Fix return error code

2020-04-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit ee42c7979eae4f7444ec2678463961521c79fd8a
Author: Łukasz Rymanowski 
AuthorDate: Fri Sep 27 10:15:56 2019 +0200

nimble/l2cap: Fix return error code

os_mbuf_foo() returns OS_ERR codes and we want to return BLE_HS_ERR
codes.
This patch fixes it
---
 nimble/host/src/ble_l2cap_coc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/nimble/host/src/ble_l2cap_coc.c b/nimble/host/src/ble_l2cap_coc.c
index 54ea321..b15646f 100644
--- a/nimble/host/src/ble_l2cap_coc.c
+++ b/nimble/host/src/ble_l2cap_coc.c
@@ -440,6 +440,7 @@ ble_l2cap_coc_continue_tx(struct ble_l2cap_chan *chan)
 BLE_HS_LOG(DEBUG, "Sending SDU len=%d\n", OS_MBUF_PKTLEN(tx->sdu));
 rc = os_mbuf_append(txom, , sizeof(uint16_t));
 if (rc) {
+rc = BLE_HS_ENOMEM;
 BLE_HS_LOG(DEBUG, "Could not append data rc=%d", rc);
 goto failed;
 }
@@ -452,6 +453,7 @@ ble_l2cap_coc_continue_tx(struct ble_l2cap_chan *chan)
 rc = os_mbuf_appendfrom(txom, tx->sdu, tx->data_offset,
 len - sdu_size_offset);
 if (rc) {
+rc = BLE_HS_ENOMEM;
 BLE_HS_LOG(DEBUG, "Could not append data rc=%d", rc);
 goto failed;
 }



[mynewt-nimble] branch master updated (822d6f7 -> bb0fcde)

2020-04-17 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git.


from 822d6f7  Fixes for 1.3.0 release
 new c6eddb0  nimble/sm: Minor coding style fix
 new 77bca6b  nimble/l2cap: Minor coding style fix
 new ee42c79  nimble/l2cap: Fix return error code
 new bb0fcde  nimble/socket: Enhance error log with hci dev num

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 nimble/host/src/ble_l2cap_coc.c  | 6 --
 nimble/host/src/ble_sm_alg.c | 2 --
 nimble/transport/socket/src/ble_hci_socket.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)



[mynewt-nimble] branch master updated: btshell: Add command to unpair oldest device

2020-04-06 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new 6d07410  btshell: Add command to unpair oldest device
6d07410 is described below

commit 6d074107b8a6c7044d0dff95f52f848477643a9a
Author: Łukasz Rymanowski 
AuthorDate: Mon Apr 6 15:50:12 2020 +0200

btshell: Add command to unpair oldest device
---
 apps/btshell/src/cmd.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/apps/btshell/src/cmd.c b/apps/btshell/src/cmd.c
index 2713443..8a87875 100644
--- a/apps/btshell/src/cmd.c
+++ b/apps/btshell/src/cmd.c
@@ -2691,12 +2691,25 @@ cmd_security_unpair(int argc, char **argv)
 {
 ble_addr_t peer;
 int rc;
+int oldest;
 
 rc = parse_arg_all(argc - 1, argv + 1);
 if (rc != 0) {
 return rc;
 }
 
+rc = parse_arg_bool_dflt("oldest", 0, );
+if (rc != 0) {
+console_printf("invalid 'oldest' parameter\n");
+return rc;
+}
+
+if (oldest) {
+rc = ble_gap_unpair_oldest_peer();
+console_printf("Unpair oldest status: 0x%02x\n", rc);
+return 0;
+}
+
 rc = parse_dev_addr("peer_", cmd_peer_addr_types, );
 if (rc != 0) {
 console_printf("invalid 'peer_addr' parameter\n");
@@ -2714,6 +2727,7 @@ cmd_security_unpair(int argc, char **argv)
 
 #if MYNEWT_VAL(SHELL_CMD_HELP)
 static const struct shell_param security_unpair_params[] = {
+{"oldest", "usage: =[true|false], default: false"},
 {"peer_addr_type", "usage: =[public|random|public_id|random_id], default: 
public"},
 {"peer_addr", "usage: =[XX:XX:XX:XX:XX:XX]"},
 {NULL, NULL}



[mynewt-nimble] branch master updated: nimble/host: Reset master and slave states on host reset

2020-03-27 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new 1a963cc  nimble/host: Reset master and slave states on host reset
1a963cc is described below

commit 1a963cc37795c9d55ef21afa5c211bbf75bb0cb1
Author: Prasad Alatkar 
AuthorDate: Fri Mar 20 15:06:51 2020 +0530

nimble/host: Reset master and slave states on host reset
---
 nimble/host/src/ble_gap.c  | 52 +-
 nimble/host/src/ble_gap_priv.h |  1 +
 nimble/host/src/ble_hs.c   | 11 ++---
 3 files changed, 54 insertions(+), 10 deletions(-)

diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c
index 693ba30..4729dd0 100644
--- a/nimble/host/src/ble_gap.c
+++ b/nimble/host/src/ble_gap.c
@@ -1020,7 +1020,7 @@ ble_gap_slave_set_timer(uint32_t ticks_from_now)
 }
 #endif
 
-#if NIMBLE_BLE_CONNECT
+#if (NIMBLE_BLE_CONNECT || NIMBLE_BLE_SCAN)
 /**
  * Called when an error is encountered while the master-connection-fsm is
  * active.
@@ -1034,12 +1034,22 @@ ble_gap_master_failed(int status)
 ble_gap_master_connect_failure(status);
 break;
 
+#if NIMBLE_BLE_SCAN
+case BLE_GAP_OP_M_DISC:
+STATS_INC(ble_gap_stats, initiate_fail);
+ble_gap_disc_complete();
+ble_gap_master_reset_state();
+break;
+#endif
+
 default:
 BLE_HS_DBG_ASSERT(0);
 break;
 }
 }
+#endif
 
+#if NIMBLE_BLE_CONNECT
 static void
 ble_gap_update_failed(uint16_t conn_handle, int status)
 {
@@ -1237,6 +1247,46 @@ ble_gap_adv_active_instance(uint8_t instance)
 return ble_gap_slave[instance].op == BLE_GAP_OP_S_ADV;
 }
 
+/**
+ * Clears advertisement and discovery state.  This function is necessary
+ * when the controller loses its active state (e.g. on stack reset).
+ */
+void
+ble_gap_reset_state(int reason)
+{
+uint16_t conn_handle;
+
+while (1) {
+conn_handle = ble_hs_atomic_first_conn_handle();
+if (conn_handle == BLE_HS_CONN_HANDLE_NONE) {
+break;
+}
+
+ble_gap_conn_broken(conn_handle, reason);
+}
+
+#if NIMBLE_BLE_ADVERTISE
+#if MYNEWT_VAL(BLE_EXT_ADV)
+uint8_t i;
+for (i = 0; i < BLE_ADV_INSTANCES; i++) {
+if (ble_gap_adv_active_instance(i)) {
+/* Indicate to application that advertising has stopped. */
+ble_gap_adv_finished(i, reason, 0, 0);
+}
+}
+#else
+if (ble_gap_adv_active_instance(0)) {
+/* Indicate to application that advertising has stopped. */
+ble_gap_adv_finished(0, reason, 0, 0);
+}
+#endif
+#endif
+
+#if (NIMBLE_BLE_SCAN || NIMBLE_BLE_CONNECT)
+ble_gap_master_failed(reason);
+#endif
+}
+
 #if NIMBLE_BLE_CONNECT
 static int
 ble_gap_accept_master_conn(void)
diff --git a/nimble/host/src/ble_gap_priv.h b/nimble/host/src/ble_gap_priv.h
index ce44319..c050435 100644
--- a/nimble/host/src/ble_gap_priv.h
+++ b/nimble/host/src/ble_gap_priv.h
@@ -136,6 +136,7 @@ void ble_gap_preempt(void);
 void ble_gap_preempt_done(void);
 
 int ble_gap_terminate_with_conn(struct ble_hs_conn *conn, uint8_t hci_reason);
+void ble_gap_reset_state(int reason);
 void ble_gap_conn_broken(uint16_t conn_handle, int reason);
 int32_t ble_gap_timer(void);
 
diff --git a/nimble/host/src/ble_hs.c b/nimble/host/src/ble_hs.c
index 23ac1d1..b41064f 100644
--- a/nimble/host/src/ble_hs.c
+++ b/nimble/host/src/ble_hs.c
@@ -361,7 +361,6 @@ ble_hs_sync(void)
 static int
 ble_hs_reset(void)
 {
-uint16_t conn_handle;
 int rc;
 
 STATS_INC(ble_hs_stats, reset);
@@ -376,14 +375,8 @@ ble_hs_reset(void)
 
 ble_hs_clear_rx_queue();
 
-while (1) {
-conn_handle = ble_hs_atomic_first_conn_handle();
-if (conn_handle == BLE_HS_CONN_HANDLE_NONE) {
-break;
-}
-
-ble_gap_conn_broken(conn_handle, ble_hs_reset_reason);
-}
+/* Clear adverising and scanning states. */
+ble_gap_reset_state(ble_hs_reset_reason);
 
 /* Clear configured addresses. */
 ble_hs_id_reset();



[mynewt-nimble] branch master updated: nimble/gap: Remove notification for update process timeout.

2020-03-27 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
 new 403de2b  nimble/gap: Remove notification for update process timeout.
403de2b is described below

commit 403de2b9818a4ec13ba20900023ec273e2640af9
Author: Zac Bond 
AuthorDate: Wed Mar 25 10:33:08 2020 -0400

nimble/gap: Remove notification for update process timeout.

The connection parameter update process has a hard-coded 40-second timeout,
but in reality, the time it takes to complete a connection parameter might 
take longer, as it
depends on the connection interval and when controller deciders to do it.
This patch changes meaning of this 40 sec timer to be only a guard so the 
application
does not perform too many connection update parameter requests.
Now when timeout fires, application will not be notified about that and 
link will not be dropped.
---
 nimble/host/src/ble_gap.c   |  1 -
 nimble/host/test/src/ble_gap_test.c | 67 -
 2 files changed, 68 deletions(-)

diff --git a/nimble/host/src/ble_gap.c b/nimble/host/src/ble_gap.c
index 6039f6f..693ba30 100644
--- a/nimble/host/src/ble_gap.c
+++ b/nimble/host/src/ble_gap.c
@@ -1943,7 +1943,6 @@ ble_gap_update_timer(void)
 ble_hs_unlock();
 
 if (entry != NULL) {
-ble_gap_update_notify(conn_handle, BLE_HS_ETIMEOUT);
 ble_gap_update_entry_free(entry);
 }
 } while (entry != NULL);
diff --git a/nimble/host/test/src/ble_gap_test.c 
b/nimble/host/test/src/ble_gap_test.c
index 3962bac..7496e31 100644
--- a/nimble/host/test/src/ble_gap_test.c
+++ b/nimble/host/test/src/ble_gap_test.c
@@ -2050,70 +2050,6 @@ ble_gap_test_util_update_l2cap(struct ble_gap_upd_params 
*params,
 }
 
 static void
-ble_gap_test_util_update_no_l2cap_tmo(struct ble_gap_upd_params *params,
-  int master)
-{
-struct ble_hs_conn *conn;
-int rc;
-
-uint8_t peer_addr[6] = { 1, 2, 3, 4, 5, 6 };
-
-ble_gap_test_util_init();
-
-ble_hs_test_util_create_conn(2, peer_addr, ble_gap_test_util_connect_cb,
- NULL);
-
-if (!master) {
-ble_hs_lock();
-conn = ble_hs_conn_find(2);
-TEST_ASSERT_FATAL(conn != NULL);
-conn->bhc_flags &= ~BLE_HS_CONN_F_MASTER;
-ble_hs_unlock();
-}
-
-/* Erase callback info reported during connection establishment; we only
- * care about updates.
- */
-ble_gap_test_util_reset_cb_info();
-
-TEST_ASSERT(!ble_gap_master_in_progress());
-
-rc = ble_hs_test_util_conn_update(2, params, 0);
-TEST_ASSERT(rc == 0);
-TEST_ASSERT(!ble_gap_master_in_progress());
-
-/* Verify tx of connection update command. */
-ble_gap_test_util_verify_tx_update_conn(params);
-
-/* Ensure no update event reported. */
-TEST_ASSERT(ble_gap_test_event.type == 0xff);
-
-/* Advance 39 seconds; ensure no timeout reported. */
-os_time_advance(39 * OS_TICKS_PER_SEC);
-ble_gap_timer();
-TEST_ASSERT(ble_gap_test_event.type == 0xff);
-
-/* Advance 40th second; ensure timeout reported. */
-os_time_advance(1 * OS_TICKS_PER_SEC);
-
-/* Timeout will result in a terminate HCI command being sent; schedule ack
- * from controller.
- */
-ble_hs_test_util_hci_ack_set_disconnect(0);
-
-ble_gap_timer();
-
-/* Verify terminate was sent. */
-ble_gap_test_util_verify_tx_disconnect();
-
-TEST_ASSERT(ble_gap_test_event.type == BLE_GAP_EVENT_CONN_UPDATE);
-TEST_ASSERT(ble_gap_test_conn_status == BLE_HS_ETIMEOUT);
-TEST_ASSERT(ble_gap_test_conn_desc.conn_handle == 2);
-TEST_ASSERT(memcmp(ble_gap_test_conn_desc.peer_id_addr.val,
-   peer_addr, 6) == 0);
-}
-
-static void
 ble_gap_test_util_update_l2cap_tmo(struct ble_gap_upd_params *params,
uint8_t hci_status, uint8_t event_status,
int rx_l2cap)
@@ -2982,9 +2918,6 @@ TEST_CASE_SELF(ble_gap_test_case_update_timeout)
 .max_ce_len = 456,
 };
 
-/* No L2CAP. */
-ble_gap_test_util_update_no_l2cap_tmo(, 1);
-
 /* L2CAP - Local unsupported; L2CAP timeout. */
 ble_gap_test_util_update_l2cap_tmo(, BLE_ERR_UNKNOWN_HCI_CMD, 0, 0);
 



[mynewt-nimble] 02/03: nimble/l2cap: Fix hs locking on reconfigure request

2020-03-12 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 7bc2227df870be557552c723df0b1ec1c0752809
Author: Łukasz Rymanowski 
AuthorDate: Wed Mar 11 20:48:36 2020 +0100

nimble/l2cap: Fix hs locking on reconfigure request
---
 nimble/host/src/ble_l2cap_sig.c | 22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/nimble/host/src/ble_l2cap_sig.c b/nimble/host/src/ble_l2cap_sig.c
index 9252ce5..165af91 100644
--- a/nimble/host/src/ble_l2cap_sig.c
+++ b/nimble/host/src/ble_l2cap_sig.c
@@ -750,14 +750,14 @@ ble_l2cap_sig_credit_base_reconfig_req_rx(uint16_t 
conn_handle,
 
 if (hdr->length <= sizeof(*req)) {
 rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_UNACCAPTED_PARAM);
-goto done;
+goto failed;
 }
 
 req = (struct ble_l2cap_sig_credit_base_reconfig_req *)(*om)->om_data;
 
 if ((req->mps < BLE_L2CAP_ECOC_MIN_MTU) || (req->mtu < 
BLE_L2CAP_ECOC_MIN_MTU)) {
 rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_UNACCAPTED_PARAM);
-goto done;
+goto failed;
 }
 
 /* Assume request will succeed. If not, result will be updated */
@@ -766,41 +766,43 @@ ble_l2cap_sig_credit_base_reconfig_req_rx(uint16_t 
conn_handle,
 cid_cnt = (hdr->length - sizeof(*req)) / sizeof(uint16_t);
 if (cid_cnt > BLE_L2CAP_MAX_COC_CONN_REQ) {
 rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_UNACCAPTED_PARAM);
-goto done;
+goto failed;
 }
 
 for (i = 0; i < cid_cnt; i++) {
 chan[i] = ble_hs_conn_chan_find_by_dcid(conn, req->dcids[i]);
 if (!chan[i]) {
  rsp->result = htole16(BLE_L2CAP_ERR_RECONFIG_INVALID_DCID);
- ble_hs_unlock();
- goto done;
+ goto failed;
 }
 
 if (chan[i]->peer_coc_mps > req->mps) {
 reduction_mps++;
 if (reduction_mps > 1) {
 rsp->result = 
htole16(BLE_L2CAP_ERR_RECONFIG_REDUCTION_MPS_NOT_ALLOWED);
-ble_hs_unlock();
-goto done;
+goto failed;
 }
 }
 
 if (chan[i]->coc_tx.mtu > req->mtu) {
 rsp->result = 
htole16(BLE_L2CAP_ERR_RECONFIG_REDUCTION_MTU_NOT_ALLOWED);
-ble_hs_unlock();
-goto done;
+goto failed;
 }
 }
 
+ble_hs_unlock();
+
 for (i = 0; i < cid_cnt; i++) {
 chan[i]->coc_tx.mtu = req->mtu;
 chan[i]->peer_coc_mps = req->mps;
 ble_l2cap_event_coc_reconfigured(conn_handle, 0, chan[i], true);
 }
 
+ble_l2cap_sig_tx(conn_handle, txom);
+return 0;
+
+failed:
 ble_hs_unlock();
-done:
 ble_l2cap_sig_tx(conn_handle, txom);
 return 0;
 }



[mynewt-nimble] 01/03: nimble/l2cap: Fix possible memory leak

2020-03-12 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit f14bc9b6a045de1d023157a11526cd17ee9bf5b7
Author: Łukasz Rymanowski 
AuthorDate: Wed Feb 26 15:22:08 2020 +0100

nimble/l2cap: Fix possible memory leak
---
 nimble/host/src/ble_l2cap_sig.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/nimble/host/src/ble_l2cap_sig.c b/nimble/host/src/ble_l2cap_sig.c
index 65c826c..9252ce5 100644
--- a/nimble/host/src/ble_l2cap_sig.c
+++ b/nimble/host/src/ble_l2cap_sig.c
@@ -1306,7 +1306,9 @@ ble_l2cap_sig_coc_connect(uint16_t conn_handle, uint16_t 
psm, uint16_t mtu,
 if (!req) {
 ble_l2cap_chan_free(conn, chan);
 ble_hs_unlock();
-return BLE_HS_ENOMEM;
+rc = BLE_HS_ENOMEM;
+/* Goto done to clear proc */
+goto done;
 }
 
 req->psm = htole16(psm);
@@ -1325,6 +1327,7 @@ ble_l2cap_sig_coc_connect(uint16_t conn_handle, uint16_t 
psm, uint16_t mtu,
 ble_hs_unlock();
 }
 
+done:
 ble_l2cap_sig_process_status(proc, rc);
 
 return rc;



[mynewt-nimble] 03/03: nimble/l2cap: Move proc initialization Without that identifier was incorrectly set to 0

2020-03-12 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 56229549cf0cbd0819307936aa15075dc0abac64
Author: Łukasz Rymanowski 
AuthorDate: Wed Mar 11 20:49:25 2020 +0100

nimble/l2cap: Move proc initialization
Without that identifier was incorrectly set to 0
---
 nimble/host/src/ble_l2cap_sig.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/nimble/host/src/ble_l2cap_sig.c b/nimble/host/src/ble_l2cap_sig.c
index 165af91..bb4d8a5 100644
--- a/nimble/host/src/ble_l2cap_sig.c
+++ b/nimble/host/src/ble_l2cap_sig.c
@@ -1368,6 +1368,10 @@ ble_l2cap_sig_ecoc_connect(uint16_t conn_handle, 
uint16_t psm, uint16_t mtu,
 return BLE_HS_ENOMEM;
 }
 
+proc->op = BLE_L2CAP_SIG_PROC_OP_CONNECT;
+proc->id = ble_l2cap_sig_next_id();
+proc->conn_handle = conn_handle;
+
 req = ble_l2cap_sig_cmd_get(BLE_L2CAP_SIG_OP_CREDIT_CONNECT_REQ, proc->id,
 sizeof(*req) + num * sizeof(uint16_t), );
 if (!req) {
@@ -1396,10 +1400,6 @@ ble_l2cap_sig_ecoc_connect(uint16_t conn_handle, 
uint16_t psm, uint16_t mtu,
 }
 proc->connect.chan_cnt = num;
 
-proc->op = BLE_L2CAP_SIG_PROC_OP_CONNECT;
-proc->id = ble_l2cap_sig_next_id();
-proc->conn_handle = conn_handle;
-
 req->psm = htole16(psm);
 req->mtu = htole16(chan->coc_rx.mtu);
 req->mps = htole16(chan->my_mtu);



[mynewt-nimble] branch master updated (11f16a0 -> 5622954)

2020-03-12 Thread rymek
This is an automated email from the ASF dual-hosted git repository.

rymek pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git.


from 11f16a0  nimble/host: Fix check for valid static random address
 new f14bc9b  nimble/l2cap: Fix possible memory leak
 new 7bc2227  nimble/l2cap: Fix hs locking on reconfigure request
 new 5622954  nimble/l2cap: Move proc initialization Without that 
identifier was incorrectly set to 0

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 nimble/host/src/ble_l2cap_sig.c | 35 ---
 1 file changed, 20 insertions(+), 15 deletions(-)



  1   2   3   4   5   >