[mynewt-core] branch master updated: sys/shell: Add full command path handling

2019-11-04 Thread jerzy
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
 new 1255073  sys/shell: Add full command path handling
1255073 is described below

commit 1255073bd137daecc45fb5598f31b0557e669aba
Author: Jerzy Kasenberg 
AuthorDate: Tue Oct 22 15:26:07 2019 +0200

sys/shell: Add full command path handling

When module is selected with 'select' command commands
from other modules can't be executed.
They can be execute when no module is selected or correct module is
selected.
To execute tasks command from compat module those lines would work:

shell> comapt tasks
compat> tasks

but once other module is selected tasks can't be executed without
leaving btshell module.

With this change commands from other modules can executed if
module name is prefixed with /

btshell> /compat tasks

Auto completion also works with /
---
 sys/shell/src/shell.c | 45 ++---
 1 file changed, 34 insertions(+), 11 deletions(-)

diff --git a/sys/shell/src/shell.c b/sys/shell/src/shell.c
index e45d009..f14e423 100644
--- a/sys/shell/src/shell.c
+++ b/sys/shell/src/shell.c
@@ -160,6 +160,8 @@ get_destination_module(const char *module_str, int len)
 static const char *
 get_command_and_module(char *argv[], int *module, struct streamer *streamer)
 {
+int def_module = default_module;
+const char *first_arg = argv[0];
 *module = -1;
 
 if (!argv[0]) {
@@ -167,13 +169,18 @@ get_command_and_module(char *argv[], int *module, struct 
streamer *streamer)
 return NULL;
 }
 
-if (default_module == -1) {
+if (first_arg[0] == '/') {
+first_arg++;
+def_module = -1;
+}
+
+if (def_module == -1) {
 if (!argv[1] || argv[1][0] == '\0') {
 streamer_printf(streamer, "Unrecognized command: %s\n", argv[0]);
 return NULL;
 }
 
-*module = get_destination_module(argv[0], -1);
+*module = get_destination_module(first_arg, -1);
 if (*module == -1) {
 streamer_printf(streamer, "Illegal module %s\n", argv[0]);
 return NULL;
@@ -182,7 +189,7 @@ get_command_and_module(char *argv[], int *module, struct 
streamer *streamer)
 return argv[1];
 }
 
-*module = default_module;
+*module = def_module;
 return argv[0];
 }
 
@@ -358,6 +365,7 @@ shell_find_cmd(int argc, char *argv[], struct streamer 
*streamer)
 {
 const char *first_string = argv[0];
 int module = -1;
+int def_module = default_module;
 const struct shell_module *shell_module;
 const char *command;
 int i;
@@ -367,6 +375,11 @@ shell_find_cmd(int argc, char *argv[], struct streamer 
*streamer)
 return NULL;
 }
 
+if (first_string[0] == '/') {
+first_string++;
+def_module = -1;
+}
+
 if (!strcmp(first_string, "help")) {
 return &shell_cmd_help;
 }
@@ -375,7 +388,7 @@ shell_find_cmd(int argc, char *argv[], struct streamer 
*streamer)
 return &shell_cmd_select_module;
 }
 
-if ((argc == 1) && (default_module == -1)) {
+if ((argc == 1) && (def_module == -1)) {
 streamer_printf(streamer, "Missing parameter\n");
 return NULL;
 }
@@ -401,6 +414,7 @@ shell_exec(int argc, char **argv, struct streamer *streamer)
 const struct shell_cmd *cmd;
 size_t argc_offset = 0;
 int rc;
+int def_module = default_module;
 
 cmd = shell_find_cmd(argc, argv, streamer);
 if (!cmd) {
@@ -415,10 +429,13 @@ shell_exec(int argc, char **argv, struct streamer 
*streamer)
 }
 }
 
+if (argv[0][0] == '/') {
+def_module = -1;
+}
 /* Allow invoking a cmd with module name as a prefix; a command should
  * not know how it was invoked (with or without prefix)
  */
-if (default_module == -1 && cmd != &shell_cmd_select_module &&
+if (def_module == -1 && cmd != &shell_cmd_select_module &&
 cmd != &shell_cmd_help) {
 argc_offset = 1;
 }
@@ -811,6 +828,7 @@ completion(char *line, console_append_char_cb append_char)
 int tok_len;
 int module, command;
 int null_terminated = 0;
+int def_module = default_module;
 
 /*
  * line to completion is not ended by '\0' as the line that gets from
@@ -822,14 +840,19 @@ completion(char *line, console_append_char_cb append_char)
 
 cur = line;
 tok_len = get_token(&cur, &null_terminated);
+if (tok_len > 0 && cur[0] == '/') {
+def_module = -1;
+tok_len--;
+cur++;
+}
 
 /* empty token - print options */
 if (tok_len == 0) {
 console_out('\n');
-if (default_module == -1) {
+if (def_module == -1) {
 print_modules(streamer_console_get());
 } 

[GitHub] [mynewt-core] kasjer merged pull request #2063: sys/shell: Add full command path handling

2019-11-04 Thread GitBox
kasjer merged pull request #2063: sys/shell: Add full command path handling
URL: https://github.com/apache/mynewt-core/pull/2063
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] sjanc commented on a change in pull request #637: nimble/ll: Extended scanner optimizations and cleanup

2019-11-04 Thread GitBox
sjanc commented on a change in pull request #637: nimble/ll: Extended scanner 
optimizations and cleanup
URL: https://github.com/apache/mynewt-nimble/pull/637#discussion_r342402418
 
 

 ##
 File path: nimble/controller/include/controller/ble_ll_scan.h
 ##
 @@ -250,7 +250,7 @@ int ble_ll_scan_adv_decode_addr(uint8_t pdu_type, uint8_t 
*rxbuf,
 
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
 /* Get aux ptr from ext advertising */
 
 Review comment:
   I'd remove this comment too and leave only one next to definition


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[mynewt-mcumgr] branch master updated: img_mgmt/mynewt_img_mgmt: use g_img_mgmt_state instead of upload_state for lazy erase.

2019-11-04 Thread mlaz
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
 new 9cf3f58  img_mgmt/mynewt_img_mgmt: use g_img_mgmt_state instead of 
upload_state for lazy erase.
 new 8e20176  Merge pull request #47 from mlaz/mcumgr_changes
9cf3f58 is described below

commit 9cf3f58667469adb00ab31e02bbf5d7eaaafcab4
Author: Miguel Azevedo 
AuthorDate: Mon Nov 4 17:39:02 2019 +

img_mgmt/mynewt_img_mgmt: use g_img_mgmt_state instead of upload_state for 
lazy erase.
---
 cmd/img_mgmt/port/mynewt/src/mynewt_img_mgmt.c | 28 +-
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/cmd/img_mgmt/port/mynewt/src/mynewt_img_mgmt.c 
b/cmd/img_mgmt/port/mynewt/src/mynewt_img_mgmt.c
index 20b07e4..b021638 100644
--- a/cmd/img_mgmt/port/mynewt/src/mynewt_img_mgmt.c
+++ b/cmd/img_mgmt/port/mynewt/src/mynewt_img_mgmt.c
@@ -26,11 +26,6 @@
 #include "sysflash/sysflash.h"
 #include "img_mgmt/image.h"
 
-static struct {
-int sector_id;
-uint32_t sector_end;
-} upload_state;
-
 static int
 img_mgmt_find_best_area_id(void)
 {
@@ -407,8 +402,8 @@ img_mgmt_impl_write_image_data(unsigned int offset, const 
void *data,
 }
 
 /* Check if there any unerased target sectors, if not clean them. */
-while ((fa->fa_off + offset + num_bytes) > upload_state.sector_end) {
-rc = flash_area_getnext_sector(fa->fa_id, &upload_state.sector_id,
+while ((fa->fa_off + offset + num_bytes) > g_img_mgmt_state.sector_end) {
+rc = flash_area_getnext_sector(fa->fa_id, &g_img_mgmt_state.sector_id,
§or);
 if (rc) {
 goto err;
@@ -417,12 +412,12 @@ img_mgmt_impl_write_image_data(unsigned int offset, const 
void *data,
 if (rc) {
 goto err;
 }
-upload_state.sector_end = sector.fa_off + sector.fa_size;
+g_img_mgmt_state.sector_end = sector.fa_off + sector.fa_size;
 }
 
 if (last) {
-upload_state.sector_id = -1;
-upload_state.sector_end = 0;
+g_img_mgmt_state.sector_id = -1;
+g_img_mgmt_state.sector_end = 0;
 }
 
 rc = flash_area_write(fa, offset, data, num_bytes);
@@ -434,8 +429,8 @@ img_mgmt_impl_write_image_data(unsigned int offset, const 
void *data,
 return 0;
 
 err:
-upload_state.sector_id = -1;
-upload_state.sector_end = 0;
+g_img_mgmt_state.sector_id = -1;
+g_img_mgmt_state.sector_end = 0;
 return MGMT_ERR_EUNKNOWN;
 }
 
@@ -496,7 +491,8 @@ img_mgmt_impl_erase_if_needed(uint32_t off, uint32_t len)
 }
 
 while ((cfa->fa_off + off + len) > g_img_mgmt_state.sector_end) {
-rc = flash_area_getnext_sector(cfa->fa_id, 
&g_img_mgmt_state.sector_id, §or);
+rc = flash_area_getnext_sector(cfa->fa_id,
+   &g_img_mgmt_state.sector_id, §or);
 if (rc) {
 goto done;
 }
@@ -512,7 +508,7 @@ done:
 return rc;
 }
 #endif
-
+
 int
 img_mgmt_impl_swap_type(void)
 {
@@ -538,8 +534,4 @@ img_mgmt_module_init(void)
 SYSINIT_ASSERT_ACTIVE();
 
 img_mgmt_register_group();
-
-/* setup for lazy sector by sector erase */
-upload_state.sector_id = -1;
-upload_state.sector_end = 0;
 }



[GitHub] [mynewt-mcumgr] mlaz merged pull request #47: img_mgmt/mynewt_img_mgmt: use g_img_mgmt_state instead of upload_status

2019-11-04 Thread GitBox
mlaz merged pull request #47: img_mgmt/mynewt_img_mgmt: use g_img_mgmt_state 
instead of upload_status
URL: https://github.com/apache/mynewt-mcumgr/pull/47
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-mcumgr] mlaz opened a new pull request #47: img_mgmt/mynewt_img_mgmt: use g_img_mgmt_state instead of upload_status

2019-11-04 Thread GitBox
mlaz opened a new pull request #47: img_mgmt/mynewt_img_mgmt: use 
g_img_mgmt_state instead of upload_status
URL: https://github.com/apache/mynewt-mcumgr/pull/47
 
 
   g_img_mgmt_state has the sector_id and sector_end fields to be used on lazy 
erase uploads, this PR makes lazy erase use g_img_mgmt_state instead of 
upload_state which has the same fields for this purpose.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-newt] kazmer97 commented on issue #343: Mcuboot hack to prevent `newt upgrade` failure

2019-11-04 Thread GitBox
kazmer97 commented on issue #343: Mcuboot hack to prevent `newt upgrade` failure
URL: https://github.com/apache/mynewt-newt/pull/343#issuecomment-549479273
 
 
   > > I've installed Newt through brew following the native installation 
documentation from the website. (on a macbook pro 2015, running OSX catalina)
   > 
   > Try: `brew install --HEAD mynewt-newt`
   
   Thank you, this solved it. Appreciate the help.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-newt] utzig commented on issue #343: Mcuboot hack to prevent `newt upgrade` failure

2019-11-04 Thread GitBox
utzig commented on issue #343: Mcuboot hack to prevent `newt upgrade` failure
URL: https://github.com/apache/mynewt-newt/pull/343#issuecomment-549463206
 
 
   > I've installed Newt through brew following the native installation 
documentation from the website. (on a macbook pro 2015, running OSX catalina)
   
   Try: `brew install --HEAD mynewt-newt`


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-newt] kazmer97 commented on issue #343: Mcuboot hack to prevent `newt upgrade` failure

2019-11-04 Thread GitBox
kazmer97 commented on issue #343: Mcuboot hack to prevent `newt upgrade` failure
URL: https://github.com/apache/mynewt-newt/pull/343#issuecomment-549462609
 
 
   > @kazmer97 It might depend on how you installed `newt` before, but `go get 
-u github.com/apache/mynewt-newt/newt` should work.
   
   Thanks for the quick reply. 
   
   I've installed `Newt`  through `brew` following the native installation 
documentation from the website. (on a macbook pro 2015, running OSX catalina)
   
   I don't seem to find the repo mentioned by you.  Should I try installing 
Newt from the source?
   
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-newt] utzig commented on issue #343: Mcuboot hack to prevent `newt upgrade` failure

2019-11-04 Thread GitBox
utzig commented on issue #343: Mcuboot hack to prevent `newt upgrade` failure
URL: https://github.com/apache/mynewt-newt/pull/343#issuecomment-549453046
 
 
   @kazmer97 It might depend on how you installed `newt` before, but `go get -u 
github.com/apache/mynewt-newt/newt` should work.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-newt] kazmer97 commented on issue #343: Mcuboot hack to prevent `newt upgrade` failure

2019-11-04 Thread GitBox
kazmer97 commented on issue #343: Mcuboot hack to prevent `newt upgrade` failure
URL: https://github.com/apache/mynewt-newt/pull/343#issuecomment-549419521
 
 
   Hi,
   I am new to the newt environment. What should I do exactly to get the `newt 
upgrade` command working now?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] xumn3348 commented on issue #631: 修改开发板BLE的服务的UUID,只能重启手机系统后才能重新更新到最新的? 重启开发板和重启APP没用。

2019-11-04 Thread GitBox
xumn3348 commented on issue #631: 修改开发板BLE的服务的UUID,只能重启手机系统后才能重新更新到最新的? 
重启开发板和重启APP没用。
URL: https://github.com/apache/mynewt-nimble/issues/631#issuecomment-549384804
 
 
   @rymanluk ,  i am Sorry to use Chinese。It is exactly the use case you just 
said 。 i am not sure if this is a bug for the peripheral device which uses 
Nimble stack。more importantly, how to update my IPhone without rebooting  when  
the GATT DB changes?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] sjanc closed issue #632: BLE5.1 AOA_AOD的支持什么时候可以完成?

2019-11-04 Thread GitBox
sjanc closed issue #632: BLE5.1 AOA_AOD的支持什么时候可以完成?
URL: https://github.com/apache/mynewt-nimble/issues/632
 
 
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [mynewt-nimble] sjanc commented on issue #632: BLE5.1 AOA_AOD的支持什么时候可以完成?

2019-11-04 Thread GitBox
sjanc commented on issue #632: BLE5.1 AOA_AOD的支持什么时候可以完成?
URL: https://github.com/apache/mynewt-nimble/issues/632#issuecomment-549356542
 
 
   Please use English.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services