[1/6] incubator-mynewt-core git commit: first cut at Host Privacy

2016-06-02 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 43143c902 -> d6bbacbd9


first cut at Host Privacy


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/6e95f444
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/6e95f444
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/6e95f444

Branch: refs/heads/develop
Commit: 6e95f4865cf1edf7c913ddacf26e5d4ab22d
Parents: 43143c9
Author: Paul Dietrich 
Authored: Fri May 13 10:07:44 2016 -0700
Committer: Paul Dietrich 
Committed: Thu Jun 2 12:51:42 2016 -0700

--
 apps/bletiny/src/bletiny.h  |   9 +-
 apps/bletiny/src/cmd.c  |  49 +++-
 apps/bletiny/src/main.c |  73 +-
 net/nimble/host/include/host/ble_gap.h  |  17 +-
 net/nimble/host/include/host/ble_hs.h   |   7 +-
 net/nimble/host/include/host/ble_keycache.h |  75 ++
 net/nimble/host/include/host/host_hci.h |  25 +-
 net/nimble/host/src/ble_gap.c   | 144 +++
 net/nimble/host/src/ble_hci_util.c  |  19 +-
 net/nimble/host/src/ble_hci_util_priv.h |   3 +-
 net/nimble/host/src/ble_hs.c|   3 +-
 net/nimble/host/src/ble_hs_cfg.c|   2 +
 net/nimble/host/src/ble_hs_priv.c   | 154 
 net/nimble/host/src/ble_hs_priv.h   |  14 +-
 net/nimble/host/src/ble_hs_startup.c|   4 +-
 net/nimble/host/src/ble_keycache.c  | 205 
 net/nimble/host/src/ble_l2cap_sm.c  |  77 +++---
 net/nimble/host/src/host_hci_cmd.c  | 293 +--
 net/nimble/host/src/test/ble_gap_test.c |   4 +-
 net/nimble/host/src/test/ble_hs_test_util.c |  12 +-
 net/nimble/host/src/test/ble_hs_test_util.h |   2 +-
 net/nimble/include/nimble/ble.h |   6 +-
 net/nimble/include/nimble/hci_common.h  |  23 +-
 net/nimble/src/hci_common.c |   3 +-
 24 files changed, 1055 insertions(+), 168 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6e95f444/apps/bletiny/src/bletiny.h
--
diff --git a/apps/bletiny/src/bletiny.h b/apps/bletiny/src/bletiny.h
index d3be8eb..f793550 100644
--- a/apps/bletiny/src/bletiny.h
+++ b/apps/bletiny/src/bletiny.h
@@ -35,6 +35,7 @@ struct ble_l2cap_sig_update_req;
 struct ble_l2cap_sig_update_params;
 union ble_store_value;
 union ble_store_key;
+struct ble_gap_adv_params;
 
 typedef int cmd_fn(int argc, char **argv);
 struct cmd_entry {
@@ -149,8 +150,9 @@ int bletiny_write_long(uint16_t conn_handle, uint16_t 
attr_handle,
 void *value, uint16_t value_len);
 int bletiny_write_reliable(uint16_t conn_handle, struct ble_gatt_attr *attrs,
 int num_attrs);
-int bletiny_adv_start(int disc, int conn, uint8_t *peer_addr, int addr_type,
-   struct hci_adv_params *params);
+int bletiny_adv_start(int disc, int conn, 
+ uint8_t *peer_addr, uint8_t peer_addr_type,
+ struct ble_gap_adv_params *params);
 int bletiny_adv_stop(void);
 int bletiny_conn_initiate(int addr_type, uint8_t *peer_addr,
struct ble_gap_crt_params *params);
@@ -159,7 +161,7 @@ int bletiny_term_conn(uint16_t conn_handle);
 int bletiny_wl_set(struct ble_gap_white_entry *white_list,
 int white_list_count);
 int bletiny_scan(uint32_t dur_ms, uint8_t disc_mode, uint8_t scan_type,
-  uint8_t filter_policy);
+  uint8_t filter_policy, uint8_t our_addr_mode);
 int bletiny_set_adv_data(struct ble_hs_adv_fields *adv_fields);
 int bletiny_update_conn(uint16_t conn_handle,
  struct ble_gap_upd_params *params);
@@ -169,7 +171,6 @@ int bletiny_l2cap_update(uint16_t conn_handle,
 int bletiny_sec_start(uint16_t conn_handle);
 int bletiny_sec_restart(uint16_t conn_handle, uint8_t *ltk, uint16_t ediv,
 uint64_t rand_val, int auth);
-
 #define BLETINY_LOG_MODULE  (LOG_MODULE_PERUSER + 0)
 #define BLETINY_LOG(lvl, ...) \
 LOG_ ## lvl(_log, BLETINY_LOG_MODULE, __VA_ARGS__)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6e95f444/apps/bletiny/src/cmd.c
--
diff --git a/apps/bletiny/src/cmd.c b/apps/bletiny/src/cmd.c
index 535637f..f44c6dd 100644
--- a/apps/bletiny/src/cmd.c
+++ b/apps/bletiny/src/cmd.c
@@ -243,6 +243,8 @@ static struct kv_pair cmd_adv_disc_modes[] = {
 static struct kv_pair cmd_adv_addr_types[] = {
 { "public", BLE_ADDR_TYPE_PUBLIC },
 { "random", 

[2/6] incubator-mynewt-core git commit: Initial cut of LL privacy

2016-06-02 Thread paulfdietrich
Initial cut of LL privacy


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/7327c542
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/7327c542
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/7327c542

Branch: refs/heads/develop
Commit: 7327c542d000b1323c669bba791da45fd87139b3
Parents: 6e95f44
Author: William San Filippo 
Authored: Wed May 18 14:06:01 2016 -0700
Committer: Paul Dietrich 
Committed: Thu Jun 2 12:53:52 2016 -0700

--
 .../controller/include/controller/ble_hw.h  |  35 +-
 .../controller/include/controller/ble_ll.h  |   1 +
 .../include/controller/ble_ll_resolv.h  |  79 
 .../controller/include/controller/ble_phy.h |   6 +
 net/nimble/controller/src/ble_ll.c  |  29 +-
 net/nimble/controller/src/ble_ll_adv.c  | 255 +++--
 net/nimble/controller/src/ble_ll_conn.c |  34 +-
 net/nimble/controller/src/ble_ll_conn_priv.h|   3 +-
 net/nimble/controller/src/ble_ll_ctrl.c |   2 +-
 net/nimble/controller/src/ble_ll_hci.c  |  27 ++
 net/nimble/controller/src/ble_ll_rand.c |  26 ++
 net/nimble/controller/src/ble_ll_resolv.c   | 378 +++
 net/nimble/controller/src/ble_ll_scan.c |   2 +
 net/nimble/drivers/nrf51/src/ble_hw.c   | 195 --
 net/nimble/drivers/nrf51/src/ble_phy.c  | 107 +-
 net/nimble/drivers/nrf52/src/ble_hw.c   | 116 +-
 net/nimble/drivers/nrf52/src/ble_phy.c  |  85 -
 net/nimble/host/src/host_hci_cmd.c  |   4 +-
 net/nimble/include/nimble/ble.h |   6 +-
 net/nimble/include/nimble/hci_common.h  |   2 +-
 net/nimble/include/nimble/nimble_opt.h  |   7 +-
 21 files changed, 1189 insertions(+), 210 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7327c542/net/nimble/controller/include/controller/ble_hw.h
--
diff --git a/net/nimble/controller/include/controller/ble_hw.h 
b/net/nimble/controller/include/controller/ble_hw.h
index 6166e58..da425de 100644
--- a/net/nimble/controller/include/controller/ble_hw.h
+++ b/net/nimble/controller/include/controller/ble_hw.h
@@ -6,7 +6,7 @@
  * 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,
@@ -57,23 +57,44 @@ int ble_hw_rng_init(ble_rng_isr_cb_t cb, int bias);
 
 /**
  * Start the random number generator
- * 
- * @return int 
+ *
+ * @return int
  */
 int ble_hw_rng_start(void);
 
 /**
  * Stop the random generator
- * 
- * @return int 
+ *
+ * @return int
  */
 int ble_hw_rng_stop(void);
 
 /**
  * Read the random number generator.
- * 
- * @return uint8_t 
+ *
+ * @return uint8_t
  */
 uint8_t ble_hw_rng_read(void);
 
+/*  Clear the resolving list*/
+void ble_hw_resolv_list_clear(void);
+
+/* Add a device to the hw resolving list */
+int ble_hw_resolv_list_add(uint8_t *irk);
+
+/* Remove a device from the hw resolving list */
+void ble_hw_resolv_list_rmv(int index);
+
+/* Returns the size of the whitelist in HW */
+uint8_t ble_hw_resolv_list_size(void);
+
+/* Enable the resolving list */
+void ble_hw_resolv_list_enable(void);
+
+/* Disables resolving list devices */
+void ble_hw_resolv_list_disable(void);
+
+/* Returns index of resolved address; -1 if not resolved */
+int ble_hw_resolv_list_match(void);
+
 #endif /* H_BLE_HW_ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7327c542/net/nimble/controller/include/controller/ble_ll.h
--
diff --git a/net/nimble/controller/include/controller/ble_ll.h 
b/net/nimble/controller/include/controller/ble_ll.h
index 8c8cb54..9a4014c 100644
--- a/net/nimble/controller/include/controller/ble_ll.h
+++ b/net/nimble/controller/include/controller/ble_ll.h
@@ -354,6 +354,7 @@ int ble_ll_chk_txrx_time(uint16_t time);
 int ble_ll_rand_init(void);
 void ble_ll_rand_sample(uint8_t rnum);
 int ble_ll_rand_data_get(uint8_t *buf, uint8_t len);
+void ble_ll_rand_prand_get(uint8_t *prand);
 int ble_ll_rand_start(void);
 
 /*

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7327c542/net/nimble/controller/include/controller/ble_ll_resolv.h
--
diff --git a/net/nimble/controller/include/controller/ble_ll_resolv.h 
b/net/nimble/controller/include/controller/ble_ll_resolv.h
new file mode 

[4/6] incubator-mynewt-core git commit: second cut at host privacy

2016-06-02 Thread paulfdietrich
second cut at host privacy


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/34e4509a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/34e4509a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/34e4509a

Branch: refs/heads/develop
Commit: 34e4509af1f497c6b85cf16f1f43755a998f8e4b
Parents: a8c1718
Author: Paul Dietrich 
Authored: Wed May 18 14:25:17 2016 -0700
Committer: Paul Dietrich 
Committed: Thu Jun 2 14:12:05 2016 -0700

--
 apps/bletiny/pkg.yml|   2 +-
 apps/bletiny/src/bletiny.h  |   2 +
 apps/bletiny/src/cmd.c  | 306 ---
 apps/bletiny/src/main.c |  92 ++-
 apps/bletiny/src/parse.c|  24 +-
 net/nimble/controller/src/ble_ll_hci.c  |   4 +-
 net/nimble/controller/src/ble_ll_rand.c |   2 +-
 net/nimble/host/include/host/ble_gap.h  |   7 +
 net/nimble/host/include/host/ble_keycache.h |  75 --
 net/nimble/host/include/host/ble_store.h|   7 +
 net/nimble/host/src/ble_gap.c   |  61 +++--
 net/nimble/host/src/ble_hs_priv.c   | 161 +---
 net/nimble/host/src/ble_hs_priv.h   |   5 +-
 net/nimble/host/src/ble_hs_startup.c|   5 +-
 net/nimble/host/src/ble_keycache.c  | 205 ---
 net/nimble/host/src/ble_l2cap_sm.c  |  11 +-
 net/nimble/host/src/ble_store.c |  72 ++
 net/nimble/host/src/host_hci.c  |  30 ++-
 net/nimble/host/src/host_hci_cmd.c  |   4 +-
 net/nimble/host/src/test/ble_hs_test_util.c |  20 +-
 net/nimble/include/nimble/hci_common.h  |   2 +
 21 files changed, 631 insertions(+), 466 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34e4509a/apps/bletiny/pkg.yml
--
diff --git a/apps/bletiny/pkg.yml b/apps/bletiny/pkg.yml
index 614f76f..90e2286 100644
--- a/apps/bletiny/pkg.yml
+++ b/apps/bletiny/pkg.yml
@@ -33,4 +33,4 @@ pkg.deps:
 pkg.cflags:
 # Reduce the log level from DEBUG to INFO.  This is necessary to fit
 # bletiny on the nRF51dk.
-- "-DLOG_LEVEL=1"
+- "-DLOG_LEVEL=0"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34e4509a/apps/bletiny/src/bletiny.h
--
diff --git a/apps/bletiny/src/bletiny.h b/apps/bletiny/src/bletiny.h
index f793550..0e3cae6 100644
--- a/apps/bletiny/src/bletiny.h
+++ b/apps/bletiny/src/bletiny.h
@@ -96,6 +96,7 @@ extern struct log bletiny_log;
 
 void print_addr(void *addr);
 void print_uuid(void *uuid128);
+void print_bytes(uint8_t *bytes, int len);
 const struct cmd_entry *parse_cmd_find(const struct cmd_entry *cmds,
char *name);
 struct kv_pair *parse_kv_find(struct kv_pair *kvs, char *name);
@@ -111,6 +112,7 @@ uint16_t parse_arg_uint16_dflt(char *name, uint16_t dflt, 
int *out_status);
 uint32_t parse_arg_uint32(char *name, int *out_status);
 uint64_t parse_arg_uint64(char *name, int *out_status);
 int parse_arg_kv(char *name, struct kv_pair *kvs);
+int parse_arg_kv_default(char *name, struct kv_pair *kvs, int def_val);
 int parse_arg_byte_stream(char *name, int max_len, uint8_t *dst, int *out_len);
 int parse_arg_byte_stream_exact_length(char *name, uint8_t *dst, int len);
 int parse_arg_mac(char *name, uint8_t *dst);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34e4509a/apps/bletiny/src/cmd.c
--
diff --git a/apps/bletiny/src/cmd.c b/apps/bletiny/src/cmd.c
index f44c6dd..e0a361b 100644
--- a/apps/bletiny/src/cmd.c
+++ b/apps/bletiny/src/cmd.c
@@ -285,19 +285,20 @@ cmd_adv(int argc, char **argv)
 }
 
 conn = parse_arg_kv("conn", cmd_adv_conn_modes);
-if (conn == -1) {
+if (conn <  0) {
 console_printf("invalid 'conn' parameter\n");
 return -1;
 }
 
 disc = parse_arg_kv("disc", cmd_adv_disc_modes);
-if (disc == -1) {
+if (conn <  0) {
 console_printf("missing 'disc' parameter\n");
 return -1;
 }
 
 if (conn == BLE_GAP_CONN_MODE_DIR) {
-addr_type = parse_arg_kv("peer_addr_type", cmd_adv_addr_types);
+addr_type = parse_arg_kv_default
+("peer_addr_type", cmd_adv_addr_types, BLE_ADDR_TYPE_PUBLIC);
 if (addr_type == -1) {
 return -1;
 }
@@ -313,13 +314,13 @@ cmd_adv(int argc, char **argv)
 
 peer_addr_type = addr_type;
 
-addr_type = parse_arg_kv("own_addr_type", cmd_adv_addr_types);
-if (addr_type == -1) {
-return -1;

[3/6] incubator-mynewt-core git commit: BLE Host - Separate secure-read from secure-write

2016-06-02 Thread paulfdietrich
BLE Host - Separate secure-read from secure-write

Prior to this change, attributes required encryption, authentication,
and / or authorization; these were applied to both reads and writes.
Now security requirements can be different for reads vs. writes.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/a8c17182
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/a8c17182
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/a8c17182

Branch: refs/heads/develop
Commit: a8c1718281f2cb925a215d508074aaa849443348
Parents: 7327c54
Author: Christopher Collins 
Authored: Tue May 17 20:23:36 2016 -0700
Committer: Paul Dietrich 
Committed: Thu Jun 2 12:53:58 2016 -0700

--
 net/nimble/host/src/ble_att_svr.c | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a8c17182/net/nimble/host/src/ble_att_svr.c
--
diff --git a/net/nimble/host/src/ble_att_svr.c 
b/net/nimble/host/src/ble_att_svr.c
index 7f064db..ce6aa7d 100644
--- a/net/nimble/host/src/ble_att_svr.c
+++ b/net/nimble/host/src/ble_att_svr.c
@@ -357,15 +357,8 @@ ble_att_svr_write(uint16_t conn_handle, struct 
ble_att_svr_entry *entry,
 
 BLE_HS_DBG_ASSERT(!ble_hs_locked_by_cur_task());
 
-/* Bypass permissions and security checks if we are writing our own
- * attribute.
- */
-if (conn_handle != BLE_HS_CONN_HANDLE_NONE) {
-if (!(entry->ha_flags & BLE_ATT_F_WRITE)) {
-att_err = BLE_ATT_ERR_WRITE_NOT_PERMITTED;
-rc = BLE_HS_ENOTSUP;
-goto err;
-}
+if (conn_handle != BLE_HS_CONN_HANDLE_NONE &&
+!(entry->ha_flags & BLE_ATT_F_WRITE)) {
 
 rc = ble_att_svr_check_security(conn_handle, 0, entry, _err);
 if (rc != 0) {
@@ -373,6 +366,11 @@ ble_att_svr_write(uint16_t conn_handle, struct 
ble_att_svr_entry *entry,
 }
 }
 
+rc = ble_att_svr_check_security(conn_handle, 0, entry, _err);
+if (rc != 0) {
+goto err;
+}
+
 BLE_HS_DBG_ASSERT(entry->ha_cb != NULL);
 rc = entry->ha_cb(conn_handle, entry->ha_handle_id,
   entry->ha_uuid, BLE_ATT_ACCESS_OP_WRITE, ctxt,



[6/6] incubator-mynewt-core git commit: first cut at LL privacy

2016-06-02 Thread paulfdietrich
first cut at LL privacy


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/d6bbacbd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/d6bbacbd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/d6bbacbd

Branch: refs/heads/develop
Commit: d6bbacbd95693af7bfdefef6ccdc4863dd6c53c9
Parents: 34e4509
Author: William San Filippo 
Authored: Wed May 18 15:59:54 2016 -0700
Committer: Paul Dietrich 
Committed: Thu Jun 2 14:12:15 2016 -0700

--
 apps/bletest/src/bletest_hci.c  |  32 ++
 apps/bletest/src/bletest_priv.h |   4 +
 apps/bletest/src/main.c | 125 ++--
 apps/bletiny/src/main.c |   2 +-
 .../controller/include/controller/ble_ll.h  |   2 +-
 .../controller/include/controller/ble_ll_adv.h  |   6 +
 .../controller/include/controller/ble_ll_conn.h |   3 +
 .../include/controller/ble_ll_resolv.h  |  27 +-
 .../controller/include/controller/ble_ll_scan.h |  14 +-
 .../include/controller/ble_ll_whitelist.h   |   2 +-
 net/nimble/controller/src/ble_ll.c  |  16 +-
 net/nimble/controller/src/ble_ll_adv.c  | 227 +-
 net/nimble/controller/src/ble_ll_conn.c | 247 
 net/nimble/controller/src/ble_ll_conn_hci.c | 100 ---
 net/nimble/controller/src/ble_ll_conn_priv.h|   3 +-
 net/nimble/controller/src/ble_ll_hci.c  |   2 +-
 net/nimble/controller/src/ble_ll_resolv.c   | 148 --
 net/nimble/controller/src/ble_ll_scan.c | 296 ++-
 net/nimble/controller/src/ble_ll_whitelist.c| 105 ---
 net/nimble/drivers/nrf51/include/ble/xcvr.h |   6 +
 net/nimble/drivers/nrf51/src/ble_hw.c   |   9 +-
 net/nimble/drivers/nrf51/src/ble_phy.c  |   3 +-
 net/nimble/drivers/nrf52/include/ble/xcvr.h |   8 +-
 net/nimble/drivers/nrf52/src/ble_hw.c   |   9 +-
 net/nimble/drivers/nrf52/src/ble_phy.c  |   2 +
 net/nimble/host/src/host_dbg.c  |  23 +-
 net/nimble/include/nimble/ble.h |   2 +-
 net/nimble/include/nimble/hci_common.h  |   4 +
 28 files changed, 1054 insertions(+), 373 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d6bbacbd/apps/bletest/src/bletest_hci.c
--
diff --git a/apps/bletest/src/bletest_hci.c b/apps/bletest/src/bletest_hci.c
index 1eee29c..c227cc0 100755
--- a/apps/bletest/src/bletest_hci.c
+++ b/apps/bletest/src/bletest_hci.c
@@ -580,4 +580,36 @@ bletest_hci_le_create_connection(struct hci_create_conn 
*hcc)
 return rc;
 }
 
+int
+bletest_hci_le_add_resolv_list(uint8_t *local_irk, uint8_t *peer_irk,
+   uint8_t *peer_ident_addr, uint8_t addr_type)
+{
+int rc;
+struct hci_add_dev_to_resolving_list padd;
+uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_ADD_TO_RESOLV_LIST_LEN];
+
+padd.addr_type = addr_type;
+memcpy(padd.addr, peer_ident_addr, BLE_DEV_ADDR_LEN);
+swap_buf(padd.local_irk, local_irk, 16);
+swap_buf(padd.peer_irk, peer_irk, 16);
+rc = host_hci_cmd_add_device_to_resolving_list(, buf, sizeof buf);
+if (!rc) {
+rc = ble_hci_cmd_tx_empty_ack(buf);
+}
+return rc;
+}
+
+int
+bletest_hci_le_enable_resolv_list(uint8_t enable)
+{
+int rc;
+uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_ADDR_RESOL_ENA_LEN];
+
+
+rc = host_hci_cmd_set_addr_resolution_enable(enable, buf, sizeof buf);
+if (!rc) {
+rc = ble_hci_cmd_tx_empty_ack(buf);
+}
+return rc;
+}
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d6bbacbd/apps/bletest/src/bletest_priv.h
--
diff --git a/apps/bletest/src/bletest_priv.h b/apps/bletest/src/bletest_priv.h
index 4a00aef..28f3074 100644
--- a/apps/bletest/src/bletest_priv.h
+++ b/apps/bletest/src/bletest_priv.h
@@ -58,5 +58,9 @@ int bletest_hci_le_create_connection(struct hci_create_conn 
*hcc);
 int bletest_hci_le_set_scan_params(uint8_t scan_type, uint16_t scan_itvl,
uint16_t scan_window, uint8_t own_addr_type,
uint8_t filter_policy);
+int bletest_hci_le_add_resolv_list(uint8_t *local_irk, uint8_t *peer_irk,
+   uint8_t *peer_ident_addr, uint8_t 
addr_type);
+int bletest_hci_le_enable_resolv_list(uint8_t enable);
+
 
 #endif  /* H_BLETEST_PRIV_*/

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d6bbacbd/apps/bletest/src/main.c

[5/6] incubator-mynewt-core git commit: first cut at LL privacy

2016-06-02 Thread paulfdietrich
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d6bbacbd/net/nimble/controller/src/ble_ll_whitelist.c
--
diff --git a/net/nimble/controller/src/ble_ll_whitelist.c 
b/net/nimble/controller/src/ble_ll_whitelist.c
index 5ee3e84..f3af569 100644
--- a/net/nimble/controller/src/ble_ll_whitelist.c
+++ b/net/nimble/controller/src/ble_ll_whitelist.c
@@ -21,13 +21,21 @@
 #include 
 #include "os/os.h"
 #include "nimble/ble.h"
+#include "nimble/nimble_opt.h"
+#include "ble/xcvr.h"
 #include "controller/ble_ll_whitelist.h"
 #include "controller/ble_ll_hci.h"
 #include "controller/ble_ll_adv.h"
 #include "controller/ble_ll_scan.h"
 #include "controller/ble_hw.h"
+#include "hal/hal_cputime.h"
+
+#if (NIMBLE_OPT_LL_WHITELIST_SIZE < BLE_HW_WHITE_LIST_SIZE)
+#define BLE_LL_WHITELIST_SIZE   NIMBLE_OPT_LL_WHITELIST_SIZE
+#else
+#define BLE_LL_WHITELIST_SIZE   BLE_HW_WHITE_LIST_SIZE
+#endif
 
-#ifndef BLE_USES_HW_WHITELIST
 struct ble_ll_whitelist_entry
 {
 uint8_t wl_valid;
@@ -35,8 +43,7 @@ struct ble_ll_whitelist_entry
 uint8_t wl_dev_addr[BLE_DEV_ADDR_LEN];
 };
 
-struct ble_ll_whitelist_entry g_ble_ll_whitelist[NIMBLE_OPT_LL_WHITELIST_SIZE];
-#endif
+struct ble_ll_whitelist_entry g_ble_ll_whitelist[BLE_LL_WHITELIST_SIZE];
 
 static int
 ble_ll_whitelist_chg_allowed(void)
@@ -65,24 +72,23 @@ ble_ll_whitelist_chg_allowed(void)
 int
 ble_ll_whitelist_clear(void)
 {
+int i;
+struct ble_ll_whitelist_entry *wl;
 
 /* Check proper state */
 if (!ble_ll_whitelist_chg_allowed()) {
 return BLE_ERR_CMD_DISALLOWED;
 }
 
-#ifdef BLE_USES_HW_WHITELIST
-ble_hw_whitelist_clear();
-#else
-int i;
-struct ble_ll_whitelist_entry *wl;
-
 /* Set the number of entries to 0 */
 wl = _ble_ll_whitelist[0];
-for (i = 0; i < NIMBLE_OPT_LL_WHITELIST_SIZE; ++i) {
+for (i = 0; i < BLE_LL_WHITELIST_SIZE; ++i) {
 wl->wl_valid = 0;
 ++wl;
 }
+
+#if (BLE_USES_HW_WHITELIST == 1)
+ble_hw_whitelist_clear();
 #endif
 
 return BLE_ERR_SUCCESS;
@@ -99,20 +105,17 @@ ble_ll_whitelist_clear(void)
 int
 ble_ll_whitelist_read_size(uint8_t *rspbuf, uint8_t *rsplen)
 {
-#ifdef BLE_USES_HW_WHITELIST
-rspbuf[0] = ble_hw_whitelist_size();
-#else
-rspbuf[0] = NIMBLE_OPT_LL_WHITELIST_SIZE;
-#endif
+rspbuf[0] = BLE_LL_WHITELIST_SIZE;
 *rsplen = 1;
 return BLE_ERR_SUCCESS;
 }
 
-#ifndef BLE_USES_HW_WHITELIST
 /**
- * Used to determine if the device is on the whitelist.
+ * Searches the whitelist to determine if the address is present in the
+ * whitelist. This is an internal API that only searches the link layer
+ * whitelist and does not care about the hardware whitelist
  *
- * @param addr
+ * @param addr  Device or identity address to check.
  * @param addr_type Public address (0) or random address (1)
  *
  * @return int 0: device is not on whitelist; otherwise the return value
@@ -120,13 +123,13 @@ ble_ll_whitelist_read_size(uint8_t *rspbuf, uint8_t 
*rsplen)
  * plus 1).
  */
 static int
-ble_ll_is_on_whitelist(uint8_t *addr, uint8_t addr_type)
+ble_ll_whitelist_search(uint8_t *addr, uint8_t addr_type)
 {
 int i;
 struct ble_ll_whitelist_entry *wl;
 
 wl = _ble_ll_whitelist[0];
-for (i = 0; i < NIMBLE_OPT_LL_WHITELIST_SIZE; ++i) {
+for (i = 0; i < BLE_LL_WHITELIST_SIZE; ++i) {
 if ((wl->wl_valid) && (wl->wl_addr_type == addr_type) &&
 (!memcmp(>wl_dev_addr[0], addr, BLE_DEV_ADDR_LEN))) {
 return i + 1;
@@ -136,24 +139,37 @@ ble_ll_is_on_whitelist(uint8_t *addr, uint8_t addr_type)
 
 return 0;
 }
-#endif
 
 /**
- * Is there a match between the device and a device on the whitelist
+ * Is there a match between the device and a device on the whitelist.
+ *
+ * NOTE: This API uses the HW, if present, to determine if there was a match
+ * between a received address and an address in the whitelist. If the HW does
+ * not support whitelisting this API is the same as the whitelist search API
  *
  * @param addr
  * @param addr_type Public address (0) or random address (1)
+ * @param is_ident  True if addr is an identity address; false otherwise
  *
  * @return int
  */
 int
-ble_ll_whitelist_match(uint8_t *addr, uint8_t addr_type)
+ble_ll_whitelist_match(uint8_t *addr, uint8_t addr_type, int is_ident)
 {
 int rc;
-#ifdef BLE_USES_HW_WHITELIST
-rc = ble_hw_whitelist_match();
+#if (BLE_USES_HW_WHITELIST == 1)
+/*
+ * XXX: This should be changed. This is HW specific: some HW may be able
+ * to both resolve a private address and perform a whitelist check. The
+ * current BLE hw cannot support this.
+ */
+if (is_ident) {
+rc = ble_ll_whitelist_search(addr, addr_type);
+} else {
+rc = ble_hw_whitelist_match();
+}
 #else
-rc = ble_ll_is_on_whitelist(addr, addr_type);
+rc = ble_ll_whitelist_search(addr, addr_type);
 #endif
 return rc;
 }
@@ -166,7 +182,9 @@ 

incubator-mynewt-core git commit: when we do a key exchange and get an identity address from the peer make sure we use that address and not the device address in the key store

2016-06-02 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop d6bbacbd9 -> 6a72c5452


when we do a key exchange and get an identity address from the peer
make sure we use that address and not the device address in the
key store


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/6a72c545
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/6a72c545
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/6a72c545

Branch: refs/heads/develop
Commit: 6a72c5452f0375d5ffcc2bee5ddf59a16a149512
Parents: d6bbacb
Author: Paul Dietrich 
Authored: Thu Jun 2 17:11:09 2016 -0700
Committer: Paul Dietrich 
Committed: Thu Jun 2 17:11:09 2016 -0700

--
 net/nimble/host/src/ble_l2cap_sm.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6a72c545/net/nimble/host/src/ble_l2cap_sm.c
--
diff --git a/net/nimble/host/src/ble_l2cap_sm.c 
b/net/nimble/host/src/ble_l2cap_sm.c
index fb89877..dd944f6 100644
--- a/net/nimble/host/src/ble_l2cap_sm.c
+++ b/net/nimble/host/src/ble_l2cap_sm.c
@@ -517,9 +517,14 @@ ble_l2cap_sm_key_exchange_events(struct ble_l2cap_sm_proc 
*proc)
 conn = ble_hs_conn_find(proc->conn_handle);
 BLE_HS_DBG_ASSERT(conn != NULL);
 
-peer_addr_type = conn->bhc_addr_type;
-memcpy(peer_addr, conn->bhc_addr, sizeof peer_addr);
-
+/* if we got an identity address, use that for key storage */
+if(proc->peer_keys.addr_valid) {
+peer_addr_type = proc->peer_keys.addr_type;
+memcpy(peer_addr, proc->peer_keys.addr, sizeof peer_addr);
+} else {
+peer_addr_type = conn->bhc_addr_type;
+memcpy(peer_addr, conn->bhc_addr, sizeof peer_addr);
+}
 ble_hs_unlock();
 
 authenticated = !!(proc->flags & BLE_L2CAP_SM_PROC_F_AUTHENTICATED);



incubator-mynewt-core git commit: ensure that we do security pairing with the correct address type and address for our device and theirs.

2016-06-03 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 8b9c08139 -> 8c891bed0


ensure that we do security pairing with the correct address type
and address for our device and theirs.

The security legacy pairing algorithm uses 1-bit address type but
the new enhanced connection command uses 2 bit address types.  This
code serves to map between them for pairing.

With this code I tested

public addr adv and connect to iphone and then pair
random addr adv and connect to iphone and then pair
rpa adv and connect to iphone and then pair

In all cases, I re-advertised and ensure that I coud reconnect (except random)


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/8c891bed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/8c891bed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/8c891bed

Branch: refs/heads/develop
Commit: 8c891bed0850b84665722c58a0ced8da491ef6c7
Parents: 8b9c081
Author: Paul Dietrich 
Authored: Fri Jun 3 14:09:27 2016 -0700
Committer: Paul Dietrich 
Committed: Fri Jun 3 14:09:27 2016 -0700

--
 net/nimble/host/src/ble_gap.c  |  7 +
 net/nimble/host/src/ble_hs_conn_priv.h |  2 ++
 net/nimble/host/src/ble_hs_priv.c  | 11 +++-
 net/nimble/host/src/ble_hs_priv.h  |  1 +
 net/nimble/host/src/ble_l2cap_sm.c | 44 ++---
 5 files changed, 60 insertions(+), 5 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8c891bed/net/nimble/host/src/ble_gap.c
--
diff --git a/net/nimble/host/src/ble_gap.c b/net/nimble/host/src/ble_gap.c
index 4ec25d4..fc12d79 100644
--- a/net/nimble/host/src/ble_gap.c
+++ b/net/nimble/host/src/ble_gap.c
@@ -110,6 +110,7 @@ static bssnz_t struct {
 void *cb_arg;
 
 unsigned using_wl:1;
+unsigned our_addr_type:2;
 } conn;
 
 struct {
@@ -129,6 +130,7 @@ static bssnz_t struct {
 
 uint8_t conn_mode;
 uint8_t disc_mode;
+unsigned our_addr_type:2;
 ble_gap_event_fn *cb;
 void *cb_arg;
 
@@ -896,17 +898,20 @@ ble_gap_rx_conn_complete(struct hci_le_conn_complete *evt)
 conn->bhc_handle = evt->connection_handle;
 memcpy(conn->bhc_addr, evt->peer_addr, sizeof conn->bhc_addr);
 conn->bhc_addr_type = evt->peer_addr_type;
+memcpy(conn->our_rpa_addr, evt->local_rpa, sizeof(conn->our_rpa_addr));
 conn->bhc_itvl = evt->conn_itvl;
 conn->bhc_latency = evt->conn_latency;
 conn->bhc_supervision_timeout = evt->supervision_timeout;
 if (evt->role == BLE_HCI_LE_CONN_COMPLETE_ROLE_MASTER) {
 conn->bhc_flags |= BLE_HS_CONN_F_MASTER;
 conn->bhc_cb = ble_gap_master.conn.cb;
+conn->our_addr_type = ble_gap_master.conn.our_addr_type;
 conn->bhc_cb_arg = ble_gap_master.conn.cb_arg;
 ble_gap_master.op = BLE_GAP_OP_NULL;
 } else {
 conn->bhc_cb = ble_gap_slave.cb;
 conn->bhc_cb_arg = ble_gap_slave.cb_arg;
+conn->our_addr_type = ble_gap_slave.our_addr_type;
 ble_gap_slave.op = BLE_GAP_OP_NULL;
 }
 
@@ -1420,6 +1425,7 @@ ble_gap_adv_start(uint8_t discoverable_mode, uint8_t 
connectable_mode,
 ble_gap_slave.cb_arg = cb_arg;
 ble_gap_slave.conn_mode = connectable_mode;
 ble_gap_slave.disc_mode = discoverable_mode;
+ble_gap_slave.our_addr_type = gap_adv_params.own_addr_type;
 
 ble_gap_adv_itvls(discoverable_mode, connectable_mode,
   _adv_params.adv_itvl_min,
@@ -1806,6 +1812,7 @@ ble_gap_conn_initiate(int addr_type, uint8_t *addr,
 ble_gap_master.conn.cb = cb;
 ble_gap_master.conn.cb_arg = cb_arg;
 ble_gap_master.conn.using_wl = addr_type == BLE_GAP_ADDR_TYPE_WL;
+ble_gap_master.conn.our_addr_type = params->our_addr_type;
 
 rc = ble_gap_conn_create_tx(addr_type, addr, params);
 if (rc != 0) {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8c891bed/net/nimble/host/src/ble_hs_conn_priv.h
--
diff --git a/net/nimble/host/src/ble_hs_conn_priv.h 
b/net/nimble/host/src/ble_hs_conn_priv.h
index a77428e..90c32e5 100644
--- a/net/nimble/host/src/ble_hs_conn_priv.h
+++ b/net/nimble/host/src/ble_hs_conn_priv.h
@@ -37,7 +37,9 @@ struct ble_hs_conn {
 SLIST_ENTRY(ble_hs_conn) bhc_next;
 uint16_t bhc_handle;
 uint8_t bhc_addr_type;
+uint8_t our_addr_type;
 uint8_t bhc_addr[6];
+uint8_t our_rpa_addr[6];
 
 uint16_t bhc_itvl;
 uint16_t bhc_latency;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8c891bed/net/nimble/host/src/ble_hs_priv.c

incubator-mynewt-core git commit: we also need to keep the peers RPA in case we do a pairing with that address while using resolvable private addresses

2016-06-03 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 8c891bed0 -> b256be023


we also need to keep the peers RPA in case we do a pairing with that address 
while
using resolvable private addresses


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/b256be02
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/b256be02
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/b256be02

Branch: refs/heads/develop
Commit: b256be023b94dab2dfaee0ae3eeba674e6b24321
Parents: 8c891be
Author: Paul Dietrich 
Authored: Fri Jun 3 14:49:54 2016 -0700
Committer: Paul Dietrich 
Committed: Fri Jun 3 14:49:54 2016 -0700

--
 net/nimble/host/src/ble_gap.c  |  1 +
 net/nimble/host/src/ble_hs_conn_priv.h |  1 +
 net/nimble/host/src/ble_l2cap_sm.c | 25 +
 3 files changed, 23 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b256be02/net/nimble/host/src/ble_gap.c
--
diff --git a/net/nimble/host/src/ble_gap.c b/net/nimble/host/src/ble_gap.c
index fc12d79..3834346 100644
--- a/net/nimble/host/src/ble_gap.c
+++ b/net/nimble/host/src/ble_gap.c
@@ -899,6 +899,7 @@ ble_gap_rx_conn_complete(struct hci_le_conn_complete *evt)
 memcpy(conn->bhc_addr, evt->peer_addr, sizeof conn->bhc_addr);
 conn->bhc_addr_type = evt->peer_addr_type;
 memcpy(conn->our_rpa_addr, evt->local_rpa, sizeof(conn->our_rpa_addr));
+memcpy(conn->peer_rpa_addr, evt->peer_rpa, sizeof(conn->peer_rpa_addr));
 conn->bhc_itvl = evt->conn_itvl;
 conn->bhc_latency = evt->conn_latency;
 conn->bhc_supervision_timeout = evt->supervision_timeout;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b256be02/net/nimble/host/src/ble_hs_conn_priv.h
--
diff --git a/net/nimble/host/src/ble_hs_conn_priv.h 
b/net/nimble/host/src/ble_hs_conn_priv.h
index 90c32e5..963b200 100644
--- a/net/nimble/host/src/ble_hs_conn_priv.h
+++ b/net/nimble/host/src/ble_hs_conn_priv.h
@@ -40,6 +40,7 @@ struct ble_hs_conn {
 uint8_t our_addr_type;
 uint8_t bhc_addr[6];
 uint8_t our_rpa_addr[6];
+uint8_t peer_rpa_addr[6];
 
 uint16_t bhc_itvl;
 uint16_t bhc_latency;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b256be02/net/nimble/host/src/ble_l2cap_sm.c
--
diff --git a/net/nimble/host/src/ble_l2cap_sm.c 
b/net/nimble/host/src/ble_l2cap_sm.c
index fa9e2e3..5aba968 100644
--- a/net/nimble/host/src/ble_l2cap_sm.c
+++ b/net/nimble/host/src/ble_l2cap_sm.c
@@ -973,6 +973,8 @@ ble_l2cap_sm_confirm_prepare_args(struct ble_l2cap_sm_proc 
*proc,
 struct ble_hs_conn *conn;
 uint8_t our_addr[6];
 uint8_t our_addr_type;
+uint8_t peer_addr[6];
+uint8_t peer_addr_type;
 
 BLE_HS_DBG_ASSERT(ble_hs_thread_safe());
 
@@ -1010,16 +1012,31 @@ ble_l2cap_sm_confirm_prepare_args(struct 
ble_l2cap_sm_proc *proc,
 break;
 }
 
+peer_addr_type = (conn->bhc_addr_type ? 1 : 0);
+switch(conn->bhc_addr_type) {
+case BLE_ADDR_TYPE_PUBLIC:
+memcpy(peer_addr, conn->bhc_addr, 6);
+break;
+case BLE_ADDR_TYPE_RANDOM:
+memcpy(peer_addr, conn->bhc_addr, 6);
+break;
+case BLE_ADDR_TYPE_RPA_RND_DEFAULT:
+case BLE_ADDR_TYPE_RPA_PUB_DEFAULT:
+memcpy(peer_addr, conn->peer_rpa_addr, 6);
+break;
+
+}
+
 if (proc->flags & BLE_L2CAP_SM_PROC_F_INITIATOR) {
 memcpy(ia, our_addr, 6);
 *iat = our_addr_type;
-*rat = (conn->bhc_addr_type ? 1 : 0);
-memcpy(ra, conn->bhc_addr, 6);
+*rat = peer_addr_type;
+memcpy(ra, peer_addr, 6);
 } else {
 memcpy(ra, our_addr, 6);
 *rat = our_addr_type;
-*iat = (conn->bhc_addr_type ? 1 : 0);
-memcpy(ia, conn->bhc_addr, 6);
+*iat = peer_addr_type;
+memcpy(ia, peer_addr, 6);
 }
 }
 



[GitHub] incubator-mynewt-site pull request: MYNEWT-145

2016-02-26 Thread paulfdietrich
GitHub user paulfdietrich opened a pull request:

https://github.com/apache/incubator-mynewt-site/pull/13

MYNEWT-145

added documentation for os_time.  Also moved the time.md file to os_time.md 
to be consistent with the nomenclature

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/paulfdietrich/incubator-mynewt-site MYNEWT-145

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-mynewt-site/pull/13.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #13


commit 04d242e23703e9345a5d68690f844221ffa2c95a
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-02-26T21:51:07Z

MYNEWT-145

added documentation for os_time.  Also moved the time.md file to os_time.md 
to be consistent with the nomenclature




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-mynewt-site pull request: Mynewt 255

2016-03-18 Thread paulfdietrich
GitHub user paulfdietrich opened a pull request:

https://github.com/apache/incubator-mynewt-site/pull/63

Mynewt 255

Basic documentation. I did not document all the APIs because I thought it 
was more productive to document use case and usage.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/paulfdietrich/incubator-mynewt-site MYNEWT-255

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-mynewt-site/pull/63.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #63


commit 354e4b9b34d3870dc53f41307b36643c1cfd1073
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-03-18T21:06:13Z

stat documentaiton example

commit ceed65f6f807557395cd5283502b57e9eb07640e
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-03-18T22:45:00Z

finish stats document

commit e0b4e854864267f24cf7f7ed87b8626018edeedb
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-03-19T00:10:15Z

log description




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-mynewt-site pull request: Mynewt 247

2016-03-11 Thread paulfdietrich
GitHub user paulfdietrich opened a pull request:

https://github.com/apache/incubator-mynewt-site/pull/50

Mynewt 247

a tutorial on how to create a project

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/paulfdietrich/incubator-mynewt-site MYNEWT-247

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-mynewt-site/pull/50.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #50


commit b17522a7b41dca1d71ac3674755158a7437b9f5a
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-03-11T23:43:28Z

added a new tutorial for project create

commit 7ff04eddae8ac46514ab90ba8dd31b69b5a8d828
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-03-11T23:43:48Z

a new file to create a project




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-mynewt-site pull request: Mynewt 182

2016-03-08 Thread paulfdietrich
GitHub user paulfdietrich opened a pull request:

https://github.com/apache/incubator-mynewt-site/pull/42

Mynewt 182

A document for the hal_GPIO

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/paulfdietrich/incubator-mynewt-site MYNEWT-182

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-mynewt-site/pull/42.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #42


commit 6acbc0aa9dc8c91d249b5342d7bd7951ae7ec9f3
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-03-08T23:19:20Z

document hal_gpio interface

commit 0762d138da95410e066c5cdad321b8ab9f64fd86
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-03-08T23:26:02Z

minor revisions to the gpio page to address unclear section




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-mynewt-site pull request: Mynewt 250

2016-03-19 Thread paulfdietrich
GitHub user paulfdietrich opened a pull request:

https://github.com/apache/incubator-mynewt-site/pull/53

Mynewt 250



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/paulfdietrich/incubator-mynewt-site MYNEWT-250

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-mynewt-site/pull/53.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #53


commit 591e06201a020209d2cb97819e898e88d83f150c
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-03-16T17:55:22Z

changes so Olimex tutorial builds with new newt

also fixed a few typos and formmatting issues

NOTE: the bootloader would not build, so I am not done with the
tutorial

commit 585c6dd296fb7f1ec645eef37f377ae4ec46c6e9
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-03-16T18:10:20Z

resize pictures to the render better
more minor edits to match new newt format

commit 2add15da415c4c5ff2a3288b7b793a23b4ef0cda
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-03-16T19:17:59Z

more modifications for final build process




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-mynewt-site pull request: MYNEWT-252

2016-03-19 Thread paulfdietrich
GitHub user paulfdietrich opened a pull request:

https://github.com/apache/incubator-mynewt-site/pull/58

MYNEWT-252

documentation for nrf52 with new newt commands

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/paulfdietrich/incubator-mynewt-site MYNEWT-252

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-mynewt-site/pull/58.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #58


commit b8ded39977c83baecc32911f4c89cbf791924a8a
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-03-17T20:05:06Z

MYNEWT-252

documentation for nrf52 with new newt commands




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-mynewt-site pull request: MYNEWT-251

2016-03-19 Thread paulfdietrich
GitHub user paulfdietrich opened a pull request:

https://github.com/apache/incubator-mynewt-site/pull/56

MYNEWT-251

rewrite the STMF3Discovery tutorial for new newt commands

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/paulfdietrich/incubator-mynewt-site MYNEWT-251

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-mynewt-site/pull/56.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #56


commit 7da8ae5bf124e3edea03eda195c6b1c6b7482eac
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-03-17T19:15:34Z

MYNEWT-251

rewrite the STMF3Discovery tutorial for new newt commands




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-mynewt-site pull request: Mynewt 215

2016-03-03 Thread paulfdietrich
GitHub user paulfdietrich opened a pull request:

https://github.com/apache/incubator-mynewt-site/pull/28

Mynewt 215

This includes the documentation for arduino blinky and also include two 
small fixes for the porting work.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/paulfdietrich/incubator-mynewt-site MYNEWT-215

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-mynewt-site/pull/28.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #28


commit 652a89dc3f7ce06ac62d1d3a50938c38dc75b006
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-03-01T21:54:05Z

basic changes to support structure for porting sections

commit 8b5b99dfdf36f8bcdf367969f59c25dfdaa178ef
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-03-01T21:58:19Z

fixed a type in the file which caused mkdocs build error

commit c2bd198bffdab7b9f279622bc9ea230ff17d4910
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-03-03T20:29:19Z

documentation for arduino blinky tutorial




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-mynewt-site pull request: Mynewt 178

2016-03-03 Thread paulfdietrich
GitHub user paulfdietrich opened a pull request:

https://github.com/apache/incubator-mynewt-site/pull/26

Mynewt 178

Documentation for porting to a new BSP, CPU and MCU.  When doing this it 
highlight the difficulties one might find.  I filed a few tickets to try to 
resolve this soon.  

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/paulfdietrich/incubator-mynewt-site MYNEWT-178

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-mynewt-site/pull/26.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #26


commit 652a89dc3f7ce06ac62d1d3a50938c38dc75b006
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-03-01T21:54:05Z

basic changes to support structure for porting sections

commit 8b5b99dfdf36f8bcdf367969f59c25dfdaa178ef
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-03-01T21:58:19Z

fixed a type in the file which caused mkdocs build error

commit 5f20995b8dc1cb7c7ee3facf132e870690b5bad8
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-03-03T20:29:19Z

documents for porting to new platform

commit ef1a1a0340576b3aca9a4f4e88da77654e6e0368
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-03-03T20:30:25Z

fix a few typos

commit 6c3d803966b05d234b9e3cba080cd7ceab67d934
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-03-03T20:44:31Z

fix broken link to HAL section since it moved




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


incubator-mynewt-core git commit: changes to support APi review by Greg. Also changed the start/stop API to begin/end to differentiate from the i2c bus start/stop conditions

2016-04-21 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 4d0a38707 -> 0892fd98e


changes to support APi review by Greg.  Also changed the start/stop API
to begin/end to differentiate from the i2c bus start/stop conditions


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/0892fd98
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/0892fd98
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/0892fd98

Branch: refs/heads/develop
Commit: 0892fd98e40a9cdf295fa99b1041822cc9a89519
Parents: 4d0a387
Author: Paul Dietrich 
Authored: Thu Apr 21 10:30:31 2016 -0700
Committer: Paul Dietrich 
Committed: Thu Apr 21 10:32:32 2016 -0700

--
 hw/hal/include/hal/hal_i2c.h | 86 ++-
 hw/hal/src/hal_i2c.c |  5 +--
 2 files changed, 59 insertions(+), 32 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0892fd98/hw/hal/include/hal/hal_i2c.h
--
diff --git a/hw/hal/include/hal/hal_i2c.h b/hw/hal/include/hal/hal_i2c.h
index 82546d4..20b697d 100644
--- a/hw/hal/include/hal/hal_i2c.h
+++ b/hw/hal/include/hal/hal_i2c.h
@@ -20,64 +20,92 @@
 #ifndef HAL_I2C_H
 #define HAL_I2C_H
 
+#include 
+#include 
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include 
-#include 
-
-/* This is the API for an i2c bus.  I tried to make this a simple API */
+/* This is the API for an i2c bus.  Currently, this is a master API
+ * allowing the mynewt device to function as an I2C master.
+ *
+ * A slave API is pending for future release
+ * 
+ * Typical usage of this API is as follows:
+ * 
+ * Initialize an i2c device with 
+ *  hal_i2c_init()
+ * 
+ * When you with to perform an i2c transaction, issue
+ *  hal_i2c_master_begin()l
+ * followed by the transaction.  For example, in an I2C memory access access
+ * you might write and address and then read back data
+ *  hal_i2c_write(); -- write amemory ddress to device
+ *  hal_i2c_read(); --- read back data
+ * then end the transaction 
+ *  hal_i2c_end();
+ */
 
 struct hal_i2c;
 
 /* when sending a packet, use this structure to pass the arguments */
 struct hal_i2c_master_data {
 uint8_t  address;   /* destination address */
-/* NOTE: Write addresses are even and read addresses are odd
- * but in this API, you must enter a single address that is the
- * write address divide by 2.  For example, for address 
- * 80, you would enter a 40 */
+/* a I2C address has 7 bits. In the protocol these 
+ * 7 bits are combined with a 1 bit R/W bit to specify read
+ * or write operation in an 8-bit address field sent to 
+ * the remote device .  This API accepts the 7-bit
+ * address as its argument in the 7 LSBs of the 
+ * address field above.  For example if I2C was 
+ * writing a 0x81 in its protocol, you would pass
+ * only the top 7-bits to this function as 0x40 */
+uint16_t len;   /* number of buffer bytes to transmit or receive */
 uint8_t *buffer;/* buffer space to hold the transmit or receive */
-uint16_t len;   /* length of buffer to transmit or receive */
 };
 
 /* Initialize a new i2c device with the given system id.
- * Returns negative on error, 0 on success. */
+ * Returns a pointer to the i2c device or NULL on error  */
 struct hal_i2c*
 hal_i2c_init(enum system_device_id sysid);
 
-/* Sends  bytes of data on the i2c.  This API assumes that you 
- * issued a successful start condition.  It will fail if you
- * have not. This API does NOT issue a stop condition.  You must stop the 
- * bus after successful or unsuccessful write attempts.  Returns 0 on 
- * success, negative on failure */
+/* Sends a start condition and writes  bytes of data on the i2c.  
+ * This API assumes that you have already called hal_i2c_master_begin
+ *  It will fail if you have not. This API does NOT issue a stop condition.  
+ * You must stop the bus after successful or unsuccessful write attempts.  
+ * This API is blocking until an error or NaK occurs. Timeout is platform
+ * dependent
+ * Returns 0 on success, negative on failure */
 int
 hal_i2c_master_write(struct hal_i2c*, struct hal_i2c_master_data *pdata);
 
-/* Reads  bytes of data on the i2c.  This API assumes that you 
- * issued a successful start condition.  It will fail if you
- * have not. This API does NOT issue a stop condition.  You must stop the 
- * bus after successful or unsuccessful write attempts.  Returns 0 on 
- * success, negative on failure */
+/* Sends a start condition and 

incubator-mynewt-core git commit: we should return success down here as the command worked

2016-05-09 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop d4d5d75fb -> b288e8b69


we should return success down here as the command worked


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/b288e8b6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/b288e8b6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/b288e8b6

Branch: refs/heads/develop
Commit: b288e8b69c11a8af8359a2dc1aa7b9311f5ef668
Parents: d4d5d75
Author: Paul Dietrich 
Authored: Mon May 9 10:41:54 2016 -0700
Committer: Paul Dietrich 
Committed: Mon May 9 17:58:58 2016 -0700

--
 apps/bletiny/src/cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b288e8b6/apps/bletiny/src/cmd.c
--
diff --git a/apps/bletiny/src/cmd.c b/apps/bletiny/src/cmd.c
index 420ed6a..8c96bd1 100644
--- a/apps/bletiny/src/cmd.c
+++ b/apps/bletiny/src/cmd.c
@@ -1023,7 +1023,7 @@ cmd_sec_restart(int argc, char **argv)
 return rc;
 }
 
-return -1;
+return 0;
 }
 
 static int



incubator-mynewt-core git commit: I2C interface supporting blocking read and write

2016-04-19 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 9131d1e4c -> 598b91010


I2C interface supporting blocking read and write

changes to support start and stop conditions


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/598b9101
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/598b9101
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/598b9101

Branch: refs/heads/develop
Commit: 598b91010431f175394c03f34b7cd2429b66248e
Parents: 9131d1e
Author: Paul Dietrich 
Authored: Thu Apr 14 16:55:12 2016 -0700
Committer: Paul Dietrich 
Committed: Tue Apr 19 20:48:12 2016 -0700

--
 hw/hal/include/hal/hal_i2c.h | 89 +++
 hw/hal/include/hal/hal_i2c_int.h | 54 +
 hw/hal/src/hal_i2c.c | 78 ++
 3 files changed, 221 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/598b9101/hw/hal/include/hal/hal_i2c.h
--
diff --git a/hw/hal/include/hal/hal_i2c.h b/hw/hal/include/hal/hal_i2c.h
new file mode 100644
index 000..82546d4
--- /dev/null
+++ b/hw/hal/include/hal/hal_i2c.h
@@ -0,0 +1,89 @@
+/**
+ * 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 HAL_I2C_H
+#define HAL_I2C_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+#include 
+
+/* This is the API for an i2c bus.  I tried to make this a simple API */
+
+struct hal_i2c;
+
+/* when sending a packet, use this structure to pass the arguments */
+struct hal_i2c_master_data {
+uint8_t  address;   /* destination address */
+/* NOTE: Write addresses are even and read addresses are odd
+ * but in this API, you must enter a single address that is the
+ * write address divide by 2.  For example, for address 
+ * 80, you would enter a 40 */
+uint8_t *buffer;/* buffer space to hold the transmit or receive */
+uint16_t len;   /* length of buffer to transmit or receive */
+};
+
+/* Initialize a new i2c device with the given system id.
+ * Returns negative on error, 0 on success. */
+struct hal_i2c*
+hal_i2c_init(enum system_device_id sysid);
+
+/* Sends  bytes of data on the i2c.  This API assumes that you 
+ * issued a successful start condition.  It will fail if you
+ * have not. This API does NOT issue a stop condition.  You must stop the 
+ * bus after successful or unsuccessful write attempts.  Returns 0 on 
+ * success, negative on failure */
+int
+hal_i2c_master_write(struct hal_i2c*, struct hal_i2c_master_data *pdata);
+
+/* Reads  bytes of data on the i2c.  This API assumes that you 
+ * issued a successful start condition.  It will fail if you
+ * have not. This API does NOT issue a stop condition.  You must stop the 
+ * bus after successful or unsuccessful write attempts.  Returns 0 on 
+ * success, negative on failure */
+int
+hal_i2c_master_read(struct hal_i2c*, struct hal_i2c_master_data *pdata);
+
+/* issues a start condition and address on the SPI bus. Returns 0 
+ * on success, negative on error.
+ */
+int 
+hal_i2c_master_start(struct hal_i2c*);
+
+/* issues a stop condition on the bus.  You must issue a stop condition for
+ * every successful start condition on the bus */
+int 
+hal_i2c_master_stop(struct hal_i2c*);
+
+
+/* Probes the i2c bus for a device with this address.  THIS API 
+ * issues a start condition, probes the address and issues a stop
+ * condition.  
+ */
+int 
+hal_i2c_master_probe(struct hal_i2c*, uint8_t address);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HAL_I2C_H */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/598b9101/hw/hal/include/hal/hal_i2c_int.h
--
diff --git a/hw/hal/include/hal/hal_i2c_int.h b/hw/hal/include/hal/hal_i2c_int.h
new file mode 100644
index 

incubator-mynewt-newt git commit: add a split image command to newtmgr

2016-08-24 Thread paulfdietrich
Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop d255509e9 -> d82d6bfaa


add a split image command to newtmgr


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/d82d6bfa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/d82d6bfa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/d82d6bfa

Branch: refs/heads/develop
Commit: d82d6bfaa4dd8b257c43b9c2a68448b5aad4074c
Parents: d255509
Author: Paul Dietrich 
Authored: Mon Aug 8 16:58:55 2016 -0700
Committer: Paul Dietrich 
Committed: Mon Aug 8 16:58:55 2016 -0700

--
 newtmgr/cli/image.go   |  62 ++
 newtmgr/protocol/imagelist.go  |   1 +
 newtmgr/protocol/imagesplit.go | 102 
 3 files changed, 165 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/d82d6bfa/newtmgr/cli/image.go
--
diff --git a/newtmgr/cli/image.go b/newtmgr/cli/image.go
index 69fa922..9565a96 100644
--- a/newtmgr/cli/image.go
+++ b/newtmgr/cli/image.go
@@ -25,6 +25,7 @@ import (
"io"
"io/ioutil"
"os"
+   "strconv"
"time"
 
"mynewt.apache.org/newt/newtmgr/config"
@@ -628,6 +629,55 @@ func coreEraseCmd(cmd *cobra.Command, args []string) {
}
 }
 
+func splitCmd(cmd *cobra.Command, args []string) {
+   runner, err := getTargetCmdRunner()
+   if err != nil {
+   nmUsage(cmd, err)
+   }
+   defer runner.Conn.Close()
+
+   split, err := protocol.NewSplit()
+   if err != nil {
+   nmUsage(cmd, err)
+   }
+   var nmr *protocol.NmgrReq
+   if len(args) == 0 {
+   nmr, err = split.EncoderReadRequest()
+   } else if len(args) == 1 {
+   b, err := strconv.ParseBool(args[0])
+
+   if err != nil {
+   nmUsage(cmd, util.NewNewtError("Invalid Boolean 
Argument"))
+   }
+   split.Split = b
+   nmr, err = split.EncoderWriteRequest()
+   } else {
+   nmUsage(cmd, nil)
+   return
+   }
+
+   if err := runner.WriteReq(nmr); err != nil {
+   nmUsage(cmd, err)
+   }
+
+   rsp, err := runner.ReadResp()
+   if err != nil {
+   nmUsage(cmd, err)
+   }
+
+   srsp, err := protocol.DecodeSplitReadResponse(rsp.Data)
+   if err != nil {
+   nmUsage(cmd, err)
+   }
+
+   if len(args) == 0 {
+   fmt.Printf("Split value is %v\n", srsp.Split)
+   }
+   if srsp.ReturnCode != 0 {
+   fmt.Printf("Error executing split command: rc=%d\n", 
srsp.ReturnCode)
+   }
+}
+
 func imageCmd() *cobra.Command {
imageCmd := {
Use:   "image",
@@ -738,5 +788,17 @@ func imageCmd() *cobra.Command {
}
imageCmd.AddCommand(coreEraseCmd)
 
+   splitEx := "  newtmgr -c olimex image split 1\n"
+   splitEx += "  newtmgr -c olimex image split 0\n"
+   splitEx += "  newtmgr -c olimex image split\n"
+
+   splitCmd := {
+   Use: "split",
+   Short:   "Erase core on target",
+   Example: splitEx,
+   Run: splitCmd,
+   }
+   imageCmd.AddCommand(splitCmd)
+
return imageCmd
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/d82d6bfa/newtmgr/protocol/imagelist.go
--
diff --git a/newtmgr/protocol/imagelist.go b/newtmgr/protocol/imagelist.go
index 8f4fe8b..18b5f03 100644
--- a/newtmgr/protocol/imagelist.go
+++ b/newtmgr/protocol/imagelist.go
@@ -41,6 +41,7 @@ const (
IMGMGR_NMGR_OP_BOOT2= 5
IMGMGR_NMGR_OP_CORELIST = 6
IMGMGR_NMGR_OP_CORELOAD = 7
+   IMGMGR_NMGR_OP_SPLITAPP = 8
 )
 
 func HashDecode(src string) (string, error) {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/d82d6bfa/newtmgr/protocol/imagesplit.go
--
diff --git a/newtmgr/protocol/imagesplit.go b/newtmgr/protocol/imagesplit.go
new file mode 100644
index 000..0386b2a
--- /dev/null
+++ b/newtmgr/protocol/imagesplit.go
@@ -0,0 +1,102 @@
+/**
+ * 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 

[2/2] incubator-mynewt-newt git commit: MYNEWT-317

2016-08-24 Thread paulfdietrich
MYNEWT-317

newt changes to support split images.  This basically builds the split image as 
follows.

1) builds the two apps (loader and app). A new tag "loader" was defined for the 
target
2) looks at common symbols between then
3) Collects them by package
4) rebuilds the loader with all of the common symbols in the common packages
5) builds a special linkable ROM from the loader image using the common symbols
5) rebuilds the app linking against the special loader elf and the non-common 
libraries
6) Builds two elfs and two image files


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/8c06bb68
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/8c06bb68
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/8c06bb68

Branch: refs/heads/develop
Commit: 8c06bb681dee7ee78bc8d9b33d761ac2e9a23455
Parents: 428b16e
Author: Paul Dietrich 
Authored: Wed Jul 6 11:18:18 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Aug 24 16:02:58 2016 -0700

--
 newt/builder/build.go  | 305 +++-
 newt/builder/buildpackage.go   |  10 +-
 newt/builder/buildutil.go  |  30 +--
 newt/builder/library.go| 218 ++
 newt/builder/load.go   |  78 +--
 newt/builder/size.go   |  27 ++-
 newt/builder/targetbuild.go| 445 
 newt/cli/build_cmds.go |  18 +-
 newt/cli/image_cmds.go |  99 +---
 newt/cli/run_cmds.go   |  45 ++--
 newt/image/image.go|  95 +---
 newt/newtutil/newtutil.go  |  24 ++
 newt/pkg/bsp_package.go|  13 +-
 newt/project/project.go|  13 ++
 newt/symbol/symbol.go  | 322 ++
 newt/target/target.go  |   7 +
 newt/toolchain/compiler.go | 217 +-
 newt/toolchain/deps.go |  89 +++-
 newtmgr/cli/commands.go|   1 +
 newtmgr/cli/image.go   |  19 +-
 newtmgr/cli/split.go   | 102 +
 newtmgr/protocol/defs.go   |   1 +
 newtmgr/protocol/imagelist2.go |  30 +--
 newtmgr/protocol/imagesplit.go | 181 +++
 24 files changed, 2117 insertions(+), 272 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/8c06bb68/newt/builder/build.go
--
diff --git a/newt/builder/build.go b/newt/builder/build.go
index 383bb95..b8cbd39 100644
--- a/newt/builder/build.go
+++ b/newt/builder/build.go
@@ -29,43 +29,44 @@ import (
log "github.com/Sirupsen/logrus"
 
"mynewt.apache.org/newt/newt/pkg"
+   "mynewt.apache.org/newt/newt/symbol"
"mynewt.apache.org/newt/newt/target"
"mynewt.apache.org/newt/newt/toolchain"
"mynewt.apache.org/newt/util"
 )
 
 type Builder struct {
-   Packages map[*pkg.LocalPackage]*BuildPackage
-   features map[string]bool
-   apis map[string]*BuildPackage
-
-   appPkg   *BuildPackage
-   Bsp  *pkg.BspPackage
-   compilerPkg  *pkg.LocalPackage
-   compilerInfo *toolchain.CompilerInfo
-
+   Packages map[*pkg.LocalPackage]*BuildPackage
+   features map[string]bool
+   apis map[string]*BuildPackage
+   appPkg   *BuildPackage
+   BspPkg   *pkg.LocalPackage
+   compilerInfo *toolchain.CompilerInfo
featureWhiteList []map[string]interface{}
featureBlackList []map[string]interface{}
-
-   target *target.Target
+   target   *TargetBuilder
+   linkerScript string
+   buildNamestring
+   LinkElf  string
 }
 
-func NewBuilder(target *target.Target) (*Builder, error) {
+func NewBuilder(t *TargetBuilder, buildName string) (*Builder, error) {
b := {}
 
-   if err := b.Init(target); err != nil {
-   return nil, err
-   }
+   b.buildName = buildName
+   /* TODO */
+   b.Init(t)
 
return b, nil
 }
 
-func (b *Builder) Init(target *target.Target) error {
-   b.target = target
+func (b *Builder) Init(t *TargetBuilder) error {
 
+   b.target = t
b.Packages = map[*pkg.LocalPackage]*BuildPackage{}
b.features = map[string]bool{}
b.apis = map[string]*BuildPackage{}
+   b.LinkElf = ""
 
return nil
 }
@@ -133,9 +134,10 @@ func (b *Builder) loadDeps() error {
}
 
if newFeatures {
-   // A new supported feature was discovered.  It 
is impossible to
-   // determine what new dependency and API 
requirements are
-   // 

[1/2] incubator-mynewt-newt git commit: MYNEWT-317

2016-08-24 Thread paulfdietrich
Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop 428b16e06 -> 8c06bb681


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/8c06bb68/newtmgr/protocol/imagesplit.go
--
diff --git a/newtmgr/protocol/imagesplit.go b/newtmgr/protocol/imagesplit.go
new file mode 100644
index 000..a3c28fc
--- /dev/null
+++ b/newtmgr/protocol/imagesplit.go
@@ -0,0 +1,181 @@
+/**
+ * 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.
+ */
+
+package protocol
+
+import (
+   "encoding/json"
+   "fmt"
+   "strings"
+
+   "mynewt.apache.org/newt/util"
+)
+
+const (
+   SPLIT_NMGR_OP_SPLIT = 0
+)
+
+type SplitMode int
+
+const (
+   NONE SplitMode = iota
+   TEST
+   RUN
+)
+
+var splitMode = [...]string{NONE: "none", TEST: "test", RUN: "run"}
+
+/* is the enum valid */
+func (sm SplitMode) Valid() bool {
+   for val, _ := range splitMode {
+   if int(sm) == val {
+   return true
+   }
+   }
+   return false
+}
+
+/* returns the enum as a string */
+func (sm SplitMode) String() string {
+   if sm > RUN || sm < 0 {
+   return "Invalid!"
+   }
+   return splitMode[sm]
+}
+
+type SplitStatus int
+
+const (
+   NOT_APPLICABLE SplitStatus = iota
+   NOT_MATCHING
+   MATCHING
+)
+
+/* parses the enum from a string */
+func ParseSplitMode(str string) (SplitMode, error) {
+   for val, key := range splitMode {
+   if strings.EqualFold(key, str) {
+   return SplitMode(val), nil
+   }
+   }
+   return NONE, util.NewNewtError("Invalid value for Split Mode %v" + str)
+}
+
+var splitStatus = [...]string{NOT_APPLICABLE: "N/A", NOT_MATCHING: 
"Non-matching", MATCHING: "matching"}
+
+/* is the enum valid */
+func (sm SplitStatus) Valid() bool {
+   for val, _ := range splitStatus {
+   if int(sm) == val {
+   return true
+   }
+   }
+   return false
+}
+
+/* returns the enum as a string */
+func (sm SplitStatus) String() string {
+   if sm > MATCHING || sm < 0 {
+   return "Unknown!"
+   }
+   return splitStatus[sm]
+}
+
+/* parses the enum from a string */
+func ParseSplitStatus(str string) (SplitStatus, error) {
+   for val, key := range splitStatus {
+   if strings.EqualFold(key, str) {
+   return SplitStatus(val), nil
+   }
+   }
+   return NOT_APPLICABLE, util.NewNewtError("Invalid value for Split 
Status %v" + str)
+}
+
+type Split struct {
+   Split  SplitMode   `json:"splitMode"`
+   Status SplitStatus `json:"splitStatus"`
+   ReturnCode int `json:"rc"`
+}
+
+func NewSplit() (*Split, error) {
+   s := {}
+   return s, nil
+}
+
+func (s *Split) EncoderReadRequest() (*NmgrReq, error) {
+   msg := "{}"
+
+   data := []byte(msg)
+
+   nmr, err := NewNmgrReq()
+   if err != nil {
+   return nil, err
+   }
+
+   nmr.Op = NMGR_OP_READ
+   nmr.Flags = 0
+   nmr.Group = NMGR_GROUP_ID_SPLIT
+   nmr.Id = SPLIT_NMGR_OP_SPLIT
+   nmr.Len = uint16(len(data))
+   nmr.Data = data
+
+   return nmr, nil
+}
+
+func (s *Split) EncoderWriteRequest() (*NmgrReq, error) {
+
+   data, err := json.Marshal(s)
+
+   if err != nil {
+   return nil, err
+   }
+
+   nmr, err := NewNmgrReq()
+   if err != nil {
+   return nil, err
+   }
+
+   nmr.Op = NMGR_OP_WRITE
+   nmr.Flags = 0
+   nmr.Group = NMGR_GROUP_ID_SPLIT
+   nmr.Id = SPLIT_NMGR_OP_SPLIT
+   nmr.Len = uint16(len(data))
+   nmr.Data = data
+
+   return nmr, nil
+}
+
+func DecodeSplitReadResponse(data []byte) (*Split, error) {
+   i := {}
+
+   if len(data) == 0 {
+   return i, nil
+   }
+
+   err := json.Unmarshal(data, )
+   if err != nil {
+   return nil, util.NewNewtError(fmt.Sprintf("Invalid incoming 
json: %s",
+   err.Error()))
+   }
+   if i.ReturnCode != 0 {
+   return nil, 

incubator-mynewt-newt git commit: Revert "add a split image command to newtmgr"

2016-08-24 Thread paulfdietrich
Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop d82d6bfaa -> 428b16e06


Revert "add a split image command to newtmgr"

This reverts commit d82d6bfaa4dd8b257c43b9c2a68448b5aad4074c.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/428b16e0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/428b16e0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/428b16e0

Branch: refs/heads/develop
Commit: 428b16e0686403946711ca769c8beb7c69d1d228
Parents: d82d6bf
Author: Paul Dietrich 
Authored: Wed Aug 24 16:02:08 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Aug 24 16:02:08 2016 -0700

--
 newtmgr/cli/image.go   |  62 --
 newtmgr/protocol/imagelist.go  |   1 -
 newtmgr/protocol/imagesplit.go | 102 
 3 files changed, 165 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/428b16e0/newtmgr/cli/image.go
--
diff --git a/newtmgr/cli/image.go b/newtmgr/cli/image.go
index 9565a96..69fa922 100644
--- a/newtmgr/cli/image.go
+++ b/newtmgr/cli/image.go
@@ -25,7 +25,6 @@ import (
"io"
"io/ioutil"
"os"
-   "strconv"
"time"
 
"mynewt.apache.org/newt/newtmgr/config"
@@ -629,55 +628,6 @@ func coreEraseCmd(cmd *cobra.Command, args []string) {
}
 }
 
-func splitCmd(cmd *cobra.Command, args []string) {
-   runner, err := getTargetCmdRunner()
-   if err != nil {
-   nmUsage(cmd, err)
-   }
-   defer runner.Conn.Close()
-
-   split, err := protocol.NewSplit()
-   if err != nil {
-   nmUsage(cmd, err)
-   }
-   var nmr *protocol.NmgrReq
-   if len(args) == 0 {
-   nmr, err = split.EncoderReadRequest()
-   } else if len(args) == 1 {
-   b, err := strconv.ParseBool(args[0])
-
-   if err != nil {
-   nmUsage(cmd, util.NewNewtError("Invalid Boolean 
Argument"))
-   }
-   split.Split = b
-   nmr, err = split.EncoderWriteRequest()
-   } else {
-   nmUsage(cmd, nil)
-   return
-   }
-
-   if err := runner.WriteReq(nmr); err != nil {
-   nmUsage(cmd, err)
-   }
-
-   rsp, err := runner.ReadResp()
-   if err != nil {
-   nmUsage(cmd, err)
-   }
-
-   srsp, err := protocol.DecodeSplitReadResponse(rsp.Data)
-   if err != nil {
-   nmUsage(cmd, err)
-   }
-
-   if len(args) == 0 {
-   fmt.Printf("Split value is %v\n", srsp.Split)
-   }
-   if srsp.ReturnCode != 0 {
-   fmt.Printf("Error executing split command: rc=%d\n", 
srsp.ReturnCode)
-   }
-}
-
 func imageCmd() *cobra.Command {
imageCmd := {
Use:   "image",
@@ -788,17 +738,5 @@ func imageCmd() *cobra.Command {
}
imageCmd.AddCommand(coreEraseCmd)
 
-   splitEx := "  newtmgr -c olimex image split 1\n"
-   splitEx += "  newtmgr -c olimex image split 0\n"
-   splitEx += "  newtmgr -c olimex image split\n"
-
-   splitCmd := {
-   Use: "split",
-   Short:   "Erase core on target",
-   Example: splitEx,
-   Run: splitCmd,
-   }
-   imageCmd.AddCommand(splitCmd)
-
return imageCmd
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/428b16e0/newtmgr/protocol/imagelist.go
--
diff --git a/newtmgr/protocol/imagelist.go b/newtmgr/protocol/imagelist.go
index 18b5f03..8f4fe8b 100644
--- a/newtmgr/protocol/imagelist.go
+++ b/newtmgr/protocol/imagelist.go
@@ -41,7 +41,6 @@ const (
IMGMGR_NMGR_OP_BOOT2= 5
IMGMGR_NMGR_OP_CORELIST = 6
IMGMGR_NMGR_OP_CORELOAD = 7
-   IMGMGR_NMGR_OP_SPLITAPP = 8
 )
 
 func HashDecode(src string) (string, error) {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/428b16e0/newtmgr/protocol/imagesplit.go
--
diff --git a/newtmgr/protocol/imagesplit.go b/newtmgr/protocol/imagesplit.go
deleted file mode 100644
index 0386b2a..000
--- a/newtmgr/protocol/imagesplit.go
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * 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
- * 

incubator-mynewt-core git commit: MYNEWT-317

2016-08-24 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 665e22f57 -> 5fa1a912e


MYNEWT-317

changes to the code tree to support split applications
Create a new split library that does the split image functionality for loader, 
app including config and newtmgr
fix miscellanous global appearing in header files
remove unused duplicate bluetooth code
rework bootutil to add functionality for split images
format new imagemgr commands for list2 and boot


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/5fa1a912
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/5fa1a912
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/5fa1a912

Branch: refs/heads/develop
Commit: 5fa1a912e8cacda4609027999ced53d330aa73e0
Parents: 665e22f
Author: Paul Dietrich 
Authored: Mon Jun 27 09:43:03 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Aug 24 15:46:06 2016 -0700

--
 apps/boot/src/boot.c|  34 +-
 apps/slinky/pkg.yml |   2 +
 apps/slinky/src/main.c  |  70 ++--
 apps/splitty/pkg.yml|  49 +++
 apps/splitty/src/main.c | 377 +++
 fs/nffs/src/nffs.c  |   4 +
 fs/nffs/src/nffs_priv.h |   6 +-
 hw/bsp/nrf52dk/nrf52dk_debug.sh |  14 +
 hw/bsp/nrf52dk/nrf52dk_download.sh  |  17 +-
 hw/bsp/nrf52dk/pkg.yml  |   1 +
 hw/bsp/nrf52dk/split-nrf52dk.ld | 208 ++
 .../src/arch/cortex_m4/gcc_startup_nrf52.s  |  10 +
 .../arch/cortex_m4/gcc_startup_nrf52_split.s| 152 
 hw/bsp/nrf52dk/src/os_bsp.c |  12 +-
 hw/bsp/nrf52dk/src/sbrk.c   |  17 +-
 libs/boot_serial/src/boot_serial.c  |   2 +-
 libs/bootutil/include/bootutil/image.h  |  21 +-
 libs/bootutil/include/bootutil/loader.h |  10 +-
 libs/bootutil/src/bootutil_misc.c   |   1 +
 libs/bootutil/src/bootutil_priv.h   |   6 +-
 libs/bootutil/src/image_validate.c  |  16 +-
 libs/bootutil/src/loader.c  | 136 ++-
 libs/imgmgr/include/imgmgr/imgmgr.h |   2 +-
 libs/imgmgr/src/imgmgr.c|  45 ++-
 libs/imgmgr/src/imgmgr_boot.c   |  12 +-
 libs/imgmgr/src/imgmgr_priv.h   |   3 +-
 libs/json/src/json_decode.c |   2 +
 libs/newtmgr/include/newtmgr/newtmgr.h  |   1 +
 libs/split/include/split/split.h|  45 +++
 libs/split/include/split/split_priv.h   |  39 ++
 libs/split/pkg.yml  |  30 ++
 libs/split/src/split.c  |  74 
 libs/split/src/split_config.c   |  92 +
 libs/split/src/split_netmgr.c   | 150 
 libs/tinycrypt/include/tinycrypt/constants.h|   4 -
 net/nimble/controller/src/ble_ll_rng.c  |  60 ---
 sys/config/include/config/config.h  |   3 +-
 sys/config/src/config.c |  13 +-
 sys/coredump/src/coredump.c |   2 +-
 sys/log/include/log/log.h   |   4 +-
 sys/log/src/log.c   |   2 +
 41 files changed, 1574 insertions(+), 174 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5fa1a912/apps/boot/src/boot.c
--
diff --git a/apps/boot/src/boot.c b/apps/boot/src/boot.c
index 7323701..fb2b6b8 100755
--- a/apps/boot/src/boot.c
+++ b/apps/boot/src/boot.c
@@ -55,18 +55,17 @@ int
 main(void)
 {
 struct flash_area descs[AREA_DESC_MAX];
-const struct flash_area *fap;
 /** Areas representing the beginning of image slots. */
 uint8_t img_starts[2];
-int cnt;
-int total;
-struct boot_rsp rsp;
-int rc;
 struct boot_req req = {
 .br_area_descs = descs,
 .br_slot_areas = img_starts,
 };
 
+struct boot_rsp rsp;
+int rc;
+
+
 #ifdef BOOT_SERIAL
 os_init();
 #else
@@ -76,30 +75,9 @@ main(void)
 rc = hal_flash_init();
 assert(rc == 0);
 
-cnt = BOOT_AREA_DESC_MAX;
-rc = flash_area_to_sectors(FLASH_AREA_IMAGE_0, , descs);
-img_starts[0] = 0;
-total = cnt;
-
-flash_area_open(FLASH_AREA_IMAGE_0, );
-req.br_img_sz = fap->fa_size;
-
-cnt = BOOT_AREA_DESC_MAX - total;
-assert(cnt >= 0);
-rc = flash_area_to_sectors(FLASH_AREA_IMAGE_1, , [total]);
-assert(rc == 0);
-img_starts[1] = total;
-total += cnt;
-
-cnt = 

incubator-mynewt-newt git commit: MYNEWT-264

2016-08-31 Thread paulfdietrich
Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop 0ca269a01 -> 2c44ae5f4


MYNEWT-264

We check that within the same repo,  there are not two packages with the same 
name


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/2c44ae5f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/2c44ae5f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/2c44ae5f

Branch: refs/heads/develop
Commit: 2c44ae5f4cc491afaf3e3bb8d6ff979c315c494e
Parents: 0ca269a
Author: Paul Dietrich 
Authored: Wed Aug 31 14:26:37 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Aug 31 14:26:37 2016 -0700

--
 newt/pkg/localpackage.go | 7 +++
 newt/project/project.go  | 4 
 2 files changed, 7 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/2c44ae5f/newt/pkg/localpackage.go
--
diff --git a/newt/pkg/localpackage.go b/newt/pkg/localpackage.go
index 78207b5..b7f5b9c 100644
--- a/newt/pkg/localpackage.go
+++ b/newt/pkg/localpackage.go
@@ -400,6 +400,13 @@ func ReadLocalPackageRecursive(repo *repo.Repo,
if err != nil {
return err
}
+
+   if oldPkg, ok := pkgList[pkg.Name()]; ok {
+   errStr := fmt.Sprintf("Multiple packages with same pkg.name=%s 
in repo %s\n",
+   oldPkg.FullName(), repo.Name())
+   return util.NewNewtError(errStr)
+   }
+
pkgList[pkg.Name()] = pkg
 
return nil

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/2c44ae5f/newt/project/project.go
--
diff --git a/newt/project/project.go b/newt/project/project.go
index 5368d32..a5575d1 100644
--- a/newt/project/project.go
+++ b/newt/project/project.go
@@ -47,10 +47,6 @@ var PackageSearchDirs []string = []string{
"fs/",
"libs/",
"net/",
-   "hw/bsp/",
-   "hw/mcu/",
-   "hw/mcu/stm",
-   "hw/drivers/",
"hw/",
"project/",
"targets/",



incubator-mynewt-newt git commit: MYNEWT-377

2016-08-31 Thread paulfdietrich
Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop 319e51082 -> 0ca269a01


MYNEWT-377

still pass 0 based index to download script, but adjust for printout in newt.  
Also, check bootloader feature and print more relevant message when downloading 
a bootloader


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/0ca269a0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/0ca269a0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/0ca269a0

Branch: refs/heads/develop
Commit: 0ca269a015ea3cd63cfd6bf409eb69f398bb6c3e
Parents: 319e510
Author: Paul Dietrich 
Authored: Wed Aug 31 12:55:42 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Aug 31 12:56:45 2016 -0700

--
 newt/builder/load.go | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0ca269a0/newt/builder/load.go
--
diff --git a/newt/builder/load.go b/newt/builder/load.go
index cdb0074..7c92400 100644
--- a/newt/builder/load.go
+++ b/newt/builder/load.go
@@ -78,8 +78,16 @@ func (b *Builder) Load(image_slot int) error {
downloadCmd := fmt.Sprintf("%s %s %s %d %s",
downloadScript, bspPath, binBaseName, image_slot, featureString)
 
-   util.StatusMessage(util.VERBOSITY_DEFAULT,
-   "Loading %s image int slot %d\n", b.buildName, image_slot)
+   features := b.Features(nil)
+
+   if _, ok := features["bootloader"]; ok {
+   util.StatusMessage(util.VERBOSITY_DEFAULT,
+   "Loading bootloader\n")
+   } else {
+   util.StatusMessage(util.VERBOSITY_DEFAULT,
+   "Loading %s image into slot %d\n", b.buildName, 
image_slot+1)
+   }
+
util.StatusMessage(util.VERBOSITY_VERBOSE, "Load command: %s\n",
downloadCmd)
rsp, err := util.ShellCommand(downloadCmd)



incubator-mynewt-core git commit: MYNEWT-317

2016-09-01 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 1e3a96db4 -> 0f85cf5a9


MYNEWT-317

add a comment to why we have this function in the startup code for the loader.
Its a weird artifact of an error in the linking that will be addressed in 
another bug


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/0f85cf5a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/0f85cf5a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/0f85cf5a

Branch: refs/heads/develop
Commit: 0f85cf5a9beb733ed7feb0def36dbfa1f0d6c312
Parents: 1e3a96d
Author: Paul Dietrich 
Authored: Thu Sep 1 12:13:05 2016 -0700
Committer: Paul Dietrich 
Committed: Thu Sep 1 12:14:07 2016 -0700

--
 .../arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52.s  | 5 +++--
 hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52.s| 5 +++--
 hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51.s | 3 +++
 hw/bsp/nrf51dk-16kbram/src/arch/cortex_m0/gcc_startup_nrf51.s   | 3 +++
 hw/bsp/nrf51dk/src/arch/cortex_m0/gcc_startup_nrf51.s   | 3 +++
 hw/bsp/nrf52dk/src/arch/cortex_m4/gcc_startup_nrf52.s   | 5 +++--
 6 files changed, 18 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0f85cf5a/hw/bsp/arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52.s
--
diff --git a/hw/bsp/arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52.s 
b/hw/bsp/arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52.s
index 6848ae3..033f227 100755
--- a/hw/bsp/arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52.s
+++ b/hw/bsp/arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52.s
@@ -168,9 +168,10 @@ Reset_Handler:
 LDR R0, =SystemInit
 BLX R0
 
-#ifdef SPLIT_APPLICATION
+/* This is called but current_slot is in the data section so it is
+ * overwritten. its only called here to ensure that the global and this
+ * function are linked into the loader */
 BL  bsp_slot_init_split_application
-#endif
 
 LDR R0, =_start
 BX  R0

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0f85cf5a/hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52.s
--
diff --git a/hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52.s 
b/hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52.s
index 6848ae3..033f227 100755
--- a/hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52.s
+++ b/hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52.s
@@ -168,9 +168,10 @@ Reset_Handler:
 LDR R0, =SystemInit
 BLX R0
 
-#ifdef SPLIT_APPLICATION
+/* This is called but current_slot is in the data section so it is
+ * overwritten. its only called here to ensure that the global and this
+ * function are linked into the loader */
 BL  bsp_slot_init_split_application
-#endif
 
 LDR R0, =_start
 BX  R0

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0f85cf5a/hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51.s
--
diff --git a/hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51.s 
b/hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51.s
index 515e30f..19ff3d8 100755
--- a/hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51.s
+++ b/hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51.s
@@ -173,6 +173,9 @@ Reset_Handler:
 LDR R1, =__HeapLimit
 BL  _sbrkInit
 
+/* This is called but current_slot is in the data section so it is
+ * overwritten. its only called here to ensure that the global and this
+ * function are linked into the loader */
 BL  bsp_slot_init_split_application
 
 LDR R0, =SystemInit

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0f85cf5a/hw/bsp/nrf51dk-16kbram/src/arch/cortex_m0/gcc_startup_nrf51.s
--
diff --git a/hw/bsp/nrf51dk-16kbram/src/arch/cortex_m0/gcc_startup_nrf51.s 
b/hw/bsp/nrf51dk-16kbram/src/arch/cortex_m0/gcc_startup_nrf51.s
index 0a88c21..89cee05 100755
--- a/hw/bsp/nrf51dk-16kbram/src/arch/cortex_m0/gcc_startup_nrf51.s
+++ b/hw/bsp/nrf51dk-16kbram/src/arch/cortex_m0/gcc_startup_nrf51.s
@@ -173,6 +173,9 @@ Reset_Handler:
 LDR R1, =__HeapLimit
 BL  _sbrkInit
 
+/* This is called but current_slot is in the data section so it is
+ * overwritten. its only called here to ensure that the global and this
+ * function are linked into the 

[GitHub] incubator-mynewt-site pull request #113: changes to add more detail on bsp p...

2016-09-01 Thread paulfdietrich
GitHub user paulfdietrich opened a pull request:

https://github.com/apache/incubator-mynewt-site/pull/113

changes to add more detail on bsp porting

also removed whitespace at end of lines

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/paulfdietrich/incubator-mynewt-site develop

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-mynewt-site/pull/113.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #113


commit 41d2526f8c1cd980f07e426bcba3572d76013184
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-09-01T19:17:19Z

changes to add more detail on bsp porting




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


incubator-mynewt-core git commit: MYNEWT-317

2016-08-29 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 4a850f55c -> 273fbc208


MYNEWT-317

add bsp support for split image to ble nano


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/273fbc20
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/273fbc20
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/273fbc20

Branch: refs/heads/develop
Commit: 273fbc2083a1f37362392a02f795125e85dc3747
Parents: 4a850f5
Author: Paul Dietrich 
Authored: Mon Aug 29 15:58:41 2016 -0700
Committer: Paul Dietrich 
Committed: Mon Aug 29 16:16:24 2016 -0700

--
 hw/bsp/nrf51-blenano/nrf51dk_download.sh|  14 +-
 hw/bsp/nrf51-blenano/pkg.yml|   1 +
 hw/bsp/nrf51-blenano/split-nrf51dk.ld   | 185 +++
 .../src/arch/cortex_m0/gcc_startup_nrf51.s  |   5 +
 .../arch/cortex_m0/gcc_startup_nrf51_split.s| 168 +
 hw/bsp/nrf51-blenano/src/os_bsp.c   |   8 +-
 hw/bsp/nrf51-blenano/src/sbrk.c |  18 +-
 7 files changed, 392 insertions(+), 7 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/273fbc20/hw/bsp/nrf51-blenano/nrf51dk_download.sh
--
diff --git a/hw/bsp/nrf51-blenano/nrf51dk_download.sh 
b/hw/bsp/nrf51-blenano/nrf51dk_download.sh
index 7ba69f2..f5b178f 100755
--- a/hw/bsp/nrf51-blenano/nrf51dk_download.sh
+++ b/hw/bsp/nrf51-blenano/nrf51dk_download.sh
@@ -29,9 +29,15 @@ if [ $# -lt 2 ]; then
 exit 1
 fi
 
+if [ $# -lt 3 ]; then
+echo "Need image slot to download"
+exit 1
+fi
+
 IS_BOOTLOADER=0
 MYPAH=$1
 BASENAME=$2
+IMAGE_SLOT=$3
 #JLINK_SCRIPT=.download.jlink
 GDB_CMD_FILE=.gdb_cmds
 
@@ -48,9 +54,15 @@ done
 if [ $IS_BOOTLOADER -eq 1 ]; then
 FLASH_OFFSET=0x0
 FILE_NAME=$BASENAME.elf.bin
-else
+elif [ $IMAGE_SLOT -eq 0 ]; then
 FLASH_OFFSET=0x8000
 FILE_NAME=$BASENAME.img
+elif [ $IMAGE_SLOT -eq 1 ]; then
+FLASH_OFFSET=0x23800
+FILE_NAME=$BASENAME.img
+else
+echo "Invalid Image Slot Number: $IMAGE_SLOT"
+exit 1
 fi
 
 echo "Downloading" $FILE_NAME "to" $FLASH_OFFSET

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/273fbc20/hw/bsp/nrf51-blenano/pkg.yml
--
diff --git a/hw/bsp/nrf51-blenano/pkg.yml b/hw/bsp/nrf51-blenano/pkg.yml
index ea41d92..6b45854 100644
--- a/hw/bsp/nrf51-blenano/pkg.yml
+++ b/hw/bsp/nrf51-blenano/pkg.yml
@@ -31,6 +31,7 @@ pkg.arch: cortex_m0
 pkg.compiler: compiler/arm-none-eabi-m0
 pkg.linkerscript: "nrf51dk.ld"
 pkg.linkerscript.bootloader.OVERWRITE: "boot-nrf51dk.ld"
+pkg.part2linkerscript: "split-nrf51dk.ld"
 pkg.downloadscript: nrf51dk_download.sh
 pkg.debugscript: nrf51dk_debug.sh
 pkg.cflags: -DNRF51

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/273fbc20/hw/bsp/nrf51-blenano/split-nrf51dk.ld
--
diff --git a/hw/bsp/nrf51-blenano/split-nrf51dk.ld 
b/hw/bsp/nrf51-blenano/split-nrf51dk.ld
new file mode 100755
index 000..bd8c2be
--- /dev/null
+++ b/hw/bsp/nrf51-blenano/split-nrf51dk.ld
@@ -0,0 +1,185 @@
+/* Linker script for Nordic Semiconductor nRF5 devices
+ *
+ * Version: Sourcery G++ 4.5-1
+ * Support: https://support.codesourcery.com/GNUToolchain/
+ *
+ * Copyright (c) 2007, 2008, 2009, 2010 CodeSourcery, Inc.
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions.  No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
+
+MEMORY
+{
+  FLASH (rx) : ORIGIN = 0x00023800, LENGTH = 0x1b800
+  RAM (rwx) :  ORIGIN = 0x2000, LENGTH = 0x8000
+}
+
+/* Linker script to place sections and symbol values. Should be used together
+ * with other linker script that defines memory regions FLASH and RAM.
+ * It references following symbols, which must be defined in code:
+ *   Reset_Handler_split : Entry of reset handler
+ *
+ * It defines following symbols, which code can use without definition:
+ *   __exidx_start
+ *   __exidx_end
+ *   __etext
+ *   __data_start__
+ *   

[2/3] incubator-mynewt-newt git commit: MYNEWT-126

2016-09-07 Thread paulfdietrich
MYNEWT-126

add autocompletion to newt.

To get autocompletion working in your shell you have to tell bash

complete -C "newt complete" newt

which tells the mac autocomplete code to use newt (sub command newt complete) 
to get autocompletions.

If you execute newt complete from the command line it just prints out a message 
saying its for bash


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/bcff03dd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/bcff03dd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/bcff03dd

Branch: refs/heads/develop
Commit: bcff03ddc971723094c0a8e1eda7049134ab6c39
Parents: e287dae
Author: Paul Dietrich 
Authored: Wed Sep 7 14:22:51 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Sep 7 14:39:36 2016 -0700

--
 newt/cli/build_cmds.go   |  11 ++-
 newt/cli/complete_cmd.go | 210 ++
 newt/cli/image_cmds.go   |   2 +
 newt/cli/run_cmds.go |   1 +
 newt/newt.go |  26 ++
 5 files changed, 249 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/bcff03dd/newt/cli/build_cmds.go
--
diff --git a/newt/cli/build_cmds.go b/newt/cli/build_cmds.go
index bc83c8d..d6d7034 100644
--- a/newt/cli/build_cmds.go
+++ b/newt/cli/build_cmds.go
@@ -309,6 +309,7 @@ func AddBuildCommands(cmd *cobra.Command) {
Run:   buildRunCmd,
}
 
+   buildCmd.ValidArgs = targetList()
cmd.AddCommand(buildCmd)
 
cleanCmd := {
@@ -317,6 +318,7 @@ func AddBuildCommands(cmd *cobra.Command) {
Run:   cleanRunCmd,
}
 
+   cleanCmd.ValidArgs = append(targetList(), "all")
cmd.AddCommand(cleanCmd)
 
testCmd := {
@@ -324,7 +326,7 @@ func AddBuildCommands(cmd *cobra.Command) {
Short: "Executes unit tests for one or more packages",
Run:   testRunCmd,
}
-
+   testCmd.ValidArgs = append(packageList(), "all")
cmd.AddCommand(testCmd)
 
loadHelpText := "Load app image to target for ."
@@ -335,6 +337,8 @@ func AddBuildCommands(cmd *cobra.Command) {
Long:  loadHelpText,
Run:   loadRunCmd,
}
+
+   loadCmd.ValidArgs = targetList()
cmd.AddCommand(loadCmd)
 
debugHelpText := "Open debugger session for ."
@@ -345,6 +349,8 @@ func AddBuildCommands(cmd *cobra.Command) {
Long:  debugHelpText,
Run:   debugRunCmd,
}
+
+   debugCmd.ValidArgs = targetList()
cmd.AddCommand(debugCmd)
 
sizeHelpText := "Calculate the size of target components specified by " 
+
@@ -356,5 +362,8 @@ func AddBuildCommands(cmd *cobra.Command) {
Long:  sizeHelpText,
Run:   sizeRunCmd,
}
+
+   sizeCmd.ValidArgs = targetList()
cmd.AddCommand(sizeCmd)
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/bcff03dd/newt/cli/complete_cmd.go
--
diff --git a/newt/cli/complete_cmd.go b/newt/cli/complete_cmd.go
new file mode 100644
index 000..957ee4c
--- /dev/null
+++ b/newt/cli/complete_cmd.go
@@ -0,0 +1,210 @@
+/**
+ * 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.
+ */
+
+package cli
+
+import (
+   "fmt"
+   "os"
+   "regexp"
+   "strings"
+
+   "mynewt.apache.org/newt/newt/pkg"
+   "mynewt.apache.org/newt/newt/project"
+   "mynewt.apache.org/newt/newt/target"
+
+   "github.com/spf13/cobra"
+   "github.com/spf13/pflag"
+)
+
+func targetList() []string {
+   _ = project.Initialize()
+   targetNames := []string{}
+   for name, _ := range target.GetTargets() {
+   // Don't display the special unittest target; this is used
+   // internally by newt, so the user 

[1/3] incubator-mynewt-newt git commit: MYNEWT-128

2016-09-07 Thread paulfdietrich
Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop e287dae75 -> 40c8f6811


MYNEWT-128

fix the autocomplete when we have a short flag without a space


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/8634519a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/8634519a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/8634519a

Branch: refs/heads/develop
Commit: 8634519aafc65892304c888cf3f7f4c4032e28de
Parents: bcff03d
Author: Paul Dietrich 
Authored: Wed Sep 7 14:37:29 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Sep 7 14:39:36 2016 -0700

--
 newt/cli/complete_cmd.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/8634519a/newt/cli/complete_cmd.go
--
diff --git a/newt/cli/complete_cmd.go b/newt/cli/complete_cmd.go
index 957ee4c..dd113da 100644
--- a/newt/cli/complete_cmd.go
+++ b/newt/cli/complete_cmd.go
@@ -149,7 +149,7 @@ func completeRunCmd(cmd *cobra.Command, args []string) {
!strings.HasPrefix(extra_str, "--")
 
showLong := strings.HasPrefix(extra_str, "--") ||
-   strings.HasPrefix(extra_str, "-")
+   extra_str == "-"
 
if showLong {
r := regexp.MustCompile("^--[^\\W]+")



[GitHub] incubator-mynewt-site pull request #114: MYNEWT-126

2016-09-07 Thread paulfdietrich
GitHub user paulfdietrich opened a pull request:

https://github.com/apache/incubator-mynewt-site/pull/114

MYNEWT-126

docs for autocomplete

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/paulfdietrich/incubator-mynewt-site MYNEWT-126

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-mynewt-site/pull/114.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #114


commit a67738a41275476ef2e50e287a7ecf3358b38e50
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-09-07T21:54:59Z

MYNEWT-126
docs for autocomplete




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


incubator-mynewt-core git commit: I had put these in the wrong place. I have to put them in a place where calling them doesn; t do anything. Instead I had put them after the data init so that they wer

2016-09-07 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 90a567cab -> 260a90ebb


I had put these in the wrong place. I have to put them in a place where calling 
them doesn;t
do anything.  Instead I had put them after the data init so that they were 
overwriting the
important stuff.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/260a90eb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/260a90eb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/260a90eb

Branch: refs/heads/develop
Commit: 260a90ebb75609de35225ca6fab75bb308edb182
Parents: 90a567c
Author: Paul Dietrich 
Authored: Wed Sep 7 15:26:33 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Sep 7 15:26:33 2016 -0700

--
 .../src/arch/cortex_m4/gcc_startup_nrf52.s|  9 -
 hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52.s  | 10 +-
 .../nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51.s  | 10 +-
 .../src/arch/cortex_m0/gcc_startup_nrf51.s| 10 +-
 hw/bsp/nrf51dk/src/arch/cortex_m0/gcc_startup_nrf51.s | 10 +-
 hw/bsp/nrf52dk/src/arch/cortex_m4/gcc_startup_nrf52.s |  9 -
 6 files changed, 28 insertions(+), 30 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/260a90eb/hw/bsp/arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52.s
--
diff --git a/hw/bsp/arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52.s 
b/hw/bsp/arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52.s
index 033f227..de2a2fa 100755
--- a/hw/bsp/arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52.s
+++ b/hw/bsp/arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52.s
@@ -138,6 +138,10 @@ __isr_vector:
 Reset_Handler:
 .fnstart
 
+/* This is called but current_slot is in the data section so it is
+ * overwritten. its only called here to ensure that the global and this
+ * function are linked into the loader */
+BL  bsp_slot_init_split_application
 
 /* Loop to copy data from read only memory to RAM. The ranges
  *  of copy from/to are specified by following symbols evaluated in
@@ -168,11 +172,6 @@ Reset_Handler:
 LDR R0, =SystemInit
 BLX R0
 
-/* This is called but current_slot is in the data section so it is
- * overwritten. its only called here to ensure that the global and this
- * function are linked into the loader */
-BL  bsp_slot_init_split_application
-
 LDR R0, =_start
 BX  R0
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/260a90eb/hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52.s
--
diff --git a/hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52.s 
b/hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52.s
index 033f227..8c667f9 100755
--- a/hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52.s
+++ b/hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52.s
@@ -138,6 +138,11 @@ __isr_vector:
 Reset_Handler:
 .fnstart
 
+/* This is called but current_slot is in the data section so it is
+ * overwritten. its only called here to ensure that the global and this
+ * function are linked into the loader */
+BL  bsp_slot_init_split_application
+
 
 /* Loop to copy data from read only memory to RAM. The ranges
  *  of copy from/to are specified by following symbols evaluated in
@@ -168,11 +173,6 @@ Reset_Handler:
 LDR R0, =SystemInit
 BLX R0
 
-/* This is called but current_slot is in the data section so it is
- * overwritten. its only called here to ensure that the global and this
- * function are linked into the loader */
-BL  bsp_slot_init_split_application
-
 LDR R0, =_start
 BX  R0
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/260a90eb/hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51.s
--
diff --git a/hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51.s 
b/hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51.s
index 19ff3d8..0773621 100755
--- a/hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51.s
+++ b/hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51.s
@@ -149,6 +149,11 @@ Reset_Handler:
 ORRSR2, R1
 STR R2, [R0]
 
+/* This is called but current_slot is in the data section so it is
+ * overwritten. its only called here to ensure that the global and this
+ * function are linked into the loader */
+BL  

[2/2] incubator-mynewt-core git commit: MYNEWT-373

2016-08-31 Thread paulfdietrich
MYNEWT-373

Return better status when we fail to validate the split image. It can happen 
for two reasons.
1) we have an invalid image
2) we can't get RAM to validate (malloc)


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/e803fa2b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/e803fa2b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/e803fa2b

Branch: refs/heads/develop
Commit: e803fa2b48c55c1dc5d37771ca739e78824d3e6d
Parents: 1149339
Author: Paul Dietrich 
Authored: Wed Aug 31 11:27:22 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Aug 31 11:27:22 2016 -0700

--
 libs/bootutil/include/bootutil/loader.h |  4 
 libs/bootutil/src/loader.c  | 30 
 libs/split/include/split/split.h|  4 +++-
 libs/split/src/split.c  | 12 +--
 libs/split/src/split_config.c   |  2 --
 5 files changed, 30 insertions(+), 22 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e803fa2b/libs/bootutil/include/bootutil/loader.h
--
diff --git a/libs/bootutil/include/bootutil/loader.h 
b/libs/bootutil/include/bootutil/loader.h
index 76da0dd..75e0d01 100644
--- a/libs/bootutil/include/bootutil/loader.h
+++ b/libs/bootutil/include/bootutil/loader.h
@@ -74,6 +74,10 @@ boot_build_request(struct boot_req *preq, int 
area_descriptor_max);
 int
 boot_go(const struct boot_req *req, struct boot_rsp *rsp);
 
+
+#define SPLIT_GO_OK (0)
+#define SPLIT_GO_NON_MATCHING   (-1)
+#define SPLIT_GO_ERR(-2)
 int
 split_go(int loader_slot, int split_slot, void **entry);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e803fa2b/libs/bootutil/src/loader.c
--
diff --git a/libs/bootutil/src/loader.c b/libs/bootutil/src/loader.c
index 43635a0..e2d4cfa 100644
--- a/libs/bootutil/src/loader.c
+++ b/libs/bootutil/src/loader.c
@@ -607,40 +607,44 @@ split_go(int loader_slot, int split_slot, void **entry)
 /** Areas representing the beginning of image slots. */
 uint8_t img_starts[2];
 struct flash_area *descs;
+uint32_t entry_val;
 struct boot_req req = {
 .br_slot_areas = img_starts,
 };
 
 descs = calloc(SPLIT_AREA_DESC_MAX, sizeof(struct flash_area));
 if (descs == NULL) {
-return BOOT_ENOMEM;
+return SPLIT_GO_ERR;
 }
 
 req.br_area_descs = descs;
 
 rc = boot_build_request(, SPLIT_AREA_DESC_MAX);
 if (rc != 0) {
-return rc;
+rc = SPLIT_GO_ERR;
+goto split_app_go_end;
 }
 
 boot_req = 
 
 boot_image_info();
 
-/* if this is not a bootable image and it validates, boot it
- * TODO check flash config state */
-if (!boot_image_bootable(_img[split_slot].hdr) &&
- split_image_check(_img[split_slot].hdr,
+/* Don't check the bootable image flag because we could really
+  * call a bootable or non-bootable image.  Just validate that
+  * the image check passes which is distinct from the normal check */
+rc = split_image_check(_img[split_slot].hdr,
_img[split_slot].loc,
_img[loader_slot].hdr,
-   _img[loader_slot].loc) == 0) {
-uint32_t entry_val = (uint32_t) boot_img[split_slot].loc.bil_address +
- (uint32_t)  boot_img[split_slot].hdr.ih_hdr_size;
-*entry = (void*) entry_val;
-rc = 0;
-goto split_app_go_end;
+   _img[loader_slot].loc);
+if (rc != 0) {
+rc = SPLIT_GO_NON_MATCHING;
+goto split_app_go_end;
 }
-rc =BOOT_EBADIMAGE;
+
+entry_val = (uint32_t) boot_img[split_slot].loc.bil_address +
+ (uint32_t)  boot_img[split_slot].hdr.ih_hdr_size;
+*entry = (void*) entry_val;
+rc = SPLIT_GO_OK;
 
 split_app_go_end:
 free(descs);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e803fa2b/libs/split/include/split/split.h
--
diff --git a/libs/split/include/split/split.h b/libs/split/include/split/split.h
index 9396a9c..fa31369 100644
--- a/libs/split/include/split/split.h
+++ b/libs/split/include/split/split.h
@@ -50,7 +50,9 @@ split_app_init(void);
   * If toBoot is true, also performs the necessary steps
   * to prepare to boot.  An application may set toBoot to
   * false and call this function to check whether the split
-  * application is bootable */
+  * application is 

incubator-mynewt-newt git commit: MYNEWT-317

2016-08-31 Thread paulfdietrich
Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop 05cc70132 -> faee1f4c6


MYNEWT-317

ensure that we can still run things like sim that don't create images or 
manifests


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/faee1f4c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/faee1f4c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/faee1f4c

Branch: refs/heads/develop
Commit: faee1f4c6f6f387b9505d2eede41a99474663b67
Parents: 05cc701
Author: Paul Dietrich 
Authored: Wed Aug 31 11:11:45 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Aug 31 11:12:39 2016 -0700

--
 newt/cli/run_cmds.go | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/faee1f4c/newt/cli/run_cmds.go
--
diff --git a/newt/cli/run_cmds.go b/newt/cli/run_cmds.go
index 57309a1..c8a1078 100644
--- a/newt/cli/run_cmds.go
+++ b/newt/cli/run_cmds.go
@@ -79,14 +79,18 @@ func runRunCmd(cmd *cobra.Command, args []string) {
}
} else {
os.Remove(b.App.AppImgPath())
-   os.Remove(b.Loader.AppImgPath())
-   }
 
-   build_id := image.CreateBuildId(app_img, loader_img)
+   if b.Loader != nil {
+   os.Remove(b.Loader.AppImgPath())
+   }
+   }
+   if app_img != nil {
+   build_id := image.CreateBuildId(app_img, loader_img)
 
-   err = image.CreateManifest(b, app_img, loader_img, build_id)
-   if err != nil {
-   NewtUsage(cmd, err)
+   err = image.CreateManifest(b, app_img, loader_img, build_id)
+   if err != nil {
+   NewtUsage(cmd, err)
+   }
}
 
err = b.Load()



incubator-mynewt-core git commit: MYNEWT-317

2016-08-31 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop d05e51e49 -> cf9ec6374


MYNEWT-317

split image support for Rigado bmd300 eval board.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/cf9ec637
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/cf9ec637
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/cf9ec637

Branch: refs/heads/develop
Commit: cf9ec6374f507a589b591eddc073bdb5a2fceac4
Parents: d05e51e
Author: Paul Dietrich 
Authored: Wed Aug 31 09:18:51 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Aug 31 09:18:51 2016 -0700

--
 hw/bsp/bmd300eval/bmd300eval_download.sh|  17 +-
 hw/bsp/bmd300eval/pkg.yml   |   1 +
 hw/bsp/bmd300eval/split-bmd300eval.ld   | 208 +++
 .../src/arch/cortex_m4/gcc_startup_nrf52.s  |  10 +
 .../arch/cortex_m4/gcc_startup_nrf52_split.s| 152 ++
 hw/bsp/bmd300eval/src/os_bsp.c  |  12 +-
 hw/bsp/bmd300eval/src/sbrk.c|  17 +-
 7 files changed, 409 insertions(+), 8 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cf9ec637/hw/bsp/bmd300eval/bmd300eval_download.sh
--
diff --git a/hw/bsp/bmd300eval/bmd300eval_download.sh 
b/hw/bsp/bmd300eval/bmd300eval_download.sh
index 028a5aa..6e16440 100755
--- a/hw/bsp/bmd300eval/bmd300eval_download.sh
+++ b/hw/bsp/bmd300eval/bmd300eval_download.sh
@@ -30,11 +30,18 @@ if [ $# -lt 2 ]; then
 exit 1
 fi
 
+if [ $# -lt 3 ]; then
+echo "Need image slot to download"
+exit 1
+fi
+
 IS_BOOTLOADER=0
 BASENAME=$2
+IMAGE_SLOT=$3
 GDB_CMD_FILE=.gdb_cmds
 
-# Look for 'bootloader' from 3rd arg onwards
+# Look for 'bootloader' from 4th arg onwards
+shift
 shift
 shift
 while [ $# -gt 0 ]; do
@@ -47,9 +54,15 @@ done
 if [ $IS_BOOTLOADER -eq 1 ]; then
 FLASH_OFFSET=0x0
 FILE_NAME=$BASENAME.elf.bin
-else
+elif [ $IMAGE_SLOT -eq 0 ]; then
 FLASH_OFFSET=0x8000
 FILE_NAME=$BASENAME.img
+elif [ $IMAGE_SLOT -eq 1 ]; then
+FLASH_OFFSET=0x42000
+FILE_NAME=$BASENAME.img
+else 
+echo "Invalid Image Slot Number: $IMAGE_SLOT"
+exit 1
 fi
 
 echo "Downloading" $FILE_NAME "to" $FLASH_OFFSET

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cf9ec637/hw/bsp/bmd300eval/pkg.yml
--
diff --git a/hw/bsp/bmd300eval/pkg.yml b/hw/bsp/bmd300eval/pkg.yml
index 60d88ff..9b906ca 100644
--- a/hw/bsp/bmd300eval/pkg.yml
+++ b/hw/bsp/bmd300eval/pkg.yml
@@ -30,6 +30,7 @@ pkg.arch: cortex_m4
 pkg.compiler: compiler/arm-none-eabi-m4
 pkg.linkerscript: "bmd300eval.ld"
 pkg.linkerscript.bootloader.OVERWRITE: "boot-bmd300eval.ld"
+pkg.part2linkerscript: "split-bmd300eval.ld"
 pkg.downloadscript: bmd300eval_download.sh
 pkg.debugscript: bmd300eval_debug.sh
 pkg.cflags: -DNRF52 -DBSP_HAS_32768_XTAL

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/cf9ec637/hw/bsp/bmd300eval/split-bmd300eval.ld
--
diff --git a/hw/bsp/bmd300eval/split-bmd300eval.ld 
b/hw/bsp/bmd300eval/split-bmd300eval.ld
new file mode 100755
index 000..ebfac21
--- /dev/null
+++ b/hw/bsp/bmd300eval/split-bmd300eval.ld
@@ -0,0 +1,208 @@
+/* Linker script for Nordic Semiconductor nRF5 devices
+ *
+ * Version: Sourcery G++ 4.5-1
+ * Support: https://support.codesourcery.com/GNUToolchain/
+ *
+ * Copyright (c) 2007, 2008, 2009, 2010 CodeSourcery, Inc.
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions.  No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
+
+MEMORY
+{
+  FLASH (rx) : ORIGIN =  0x00042000, LENGTH = 0x3a000
+  RAM  (rwx) : ORIGIN =  0x2000, LENGTH = 0x1
+}
+
+/* Linker script to place sections and symbol values. Should be used together
+ * with other linker script that defines memory regions FLASH and RAM.
+ * It references following symbols, which must be defined in code:
+ *   Reset_Handler : Entry of reset handler
+ *
+ * It defines following symbols, which 

[09/10] incubator-mynewt-core git commit: Add tinycbor and iotivity constrained to the repo.

2016-09-14 Thread paulfdietrich
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ece29bb3/libs/iotivity/src/api/oc_network_events.c
--
diff --git a/libs/iotivity/src/api/oc_network_events.c 
b/libs/iotivity/src/api/oc_network_events.c
new file mode 100644
index 000..2149bd3
--- /dev/null
+++ b/libs/iotivity/src/api/oc_network_events.c
@@ -0,0 +1,57 @@
+/*
+// Copyright (c) 2016 Intel Corporation
+//
+// Licensed 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 "oc_network_events.h"
+#include "oc_buffer.h"
+#include "port/oc_connectivity.h"
+#include "port/oc_signal_main_loop.h"
+#include "util/oc_list.h"
+
+OC_LIST(network_events);
+
+static void
+oc_process_network_event(void)
+{
+  oc_network_event_handler_mutex_lock();
+  oc_message_t *head = (oc_message_t *)oc_list_pop(network_events);
+  while (head != NULL) {
+oc_recv_message(head);
+head = oc_list_pop(network_events);
+  }
+  oc_network_event_handler_mutex_unlock();
+}
+
+OC_PROCESS(oc_network_events, "");
+OC_PROCESS_THREAD(oc_network_events, ev, data)
+{
+  OC_PROCESS_POLLHANDLER(oc_process_network_event());
+  OC_PROCESS_BEGIN();
+  while (oc_process_is_running(&(oc_network_events))) {
+OC_PROCESS_YIELD();
+  }
+  OC_PROCESS_END();
+}
+
+void
+oc_network_event(oc_message_t *message)
+{
+  oc_network_event_handler_mutex_lock();
+  oc_list_add(network_events, message);
+  oc_network_event_handler_mutex_unlock();
+
+  oc_process_poll(&(oc_network_events));
+  oc_signal_main_loop();
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ece29bb3/libs/iotivity/src/api/oc_rep.c
--
diff --git a/libs/iotivity/src/api/oc_rep.c b/libs/iotivity/src/api/oc_rep.c
new file mode 100644
index 000..b922e1e
--- /dev/null
+++ b/libs/iotivity/src/api/oc_rep.c
@@ -0,0 +1,301 @@
+/*
+// Copyright (c) 2016 Intel Corporation
+//
+// Licensed 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 "oc_rep.h"
+#include "config.h"
+#include "port/oc_assert.h"
+#include "port/oc_log.h"
+#include "util/oc_memb.h"
+
+OC_MEMB(rep_objects, oc_rep_t, EST_NUM_REP_OBJECTS);
+static const CborEncoder g_empty;
+static uint8_t *g_buf;
+CborEncoder g_encoder, root_map, links_array;
+CborError g_err;
+
+void
+oc_rep_new(uint8_t *out_payload, int size)
+{
+  g_err = CborNoError;
+  g_buf = out_payload;
+  cbor_encoder_init(_encoder, out_payload, size, 0);
+}
+
+int
+oc_rep_finalize(void)
+{
+  int size = cbor_encoder_get_buffer_size(_encoder, g_buf);
+  oc_rep_reset();
+  if (g_err != CborNoError)
+return -1;
+  return size;
+}
+
+void
+oc_rep_reset(void)
+{
+  g_encoder = g_empty;
+}
+
+static oc_rep_t *
+_alloc_rep(void)
+{
+  oc_rep_t *rep = oc_memb_alloc(_objects);
+#ifdef DEBUG
+  oc_assert(rep != NULL);
+#endif
+  return rep;
+}
+
+static void
+_free_rep(oc_rep_t *rep_value)
+{
+  oc_memb_free(_objects, rep_value);
+}
+
+void
+oc_free_rep(oc_rep_t *rep)
+{
+  if (rep == 0)
+return;
+  oc_free_rep(rep->next);
+  switch (rep->type) {
+  case BYTE_STRING_ARRAY:
+  case STRING_ARRAY:
+oc_free_string_array(>value_array);
+break;
+  case BOOL_ARRAY:
+oc_free_bool_array(>value_array);
+break;
+  case DOUBLE_ARRAY:
+oc_free_double_array(>value_array);
+break;
+  case INT_ARRAY:
+oc_free_int_array(>value_array);
+break;
+  case BYTE_STRING:
+  case STRING:
+oc_free_string(>value_string);
+break;
+  case OBJECT:
+oc_free_rep(rep->value_object);
+break;
+  case OBJECT_ARRAY:
+oc_free_rep(rep->value_object_array);
+break;
+  default:
+break;
+  }
+  oc_free_string(>name);
+  _free_rep(rep);
+}
+
+/*
+  An Object is a collection of key-value pairs.
+  A value_object value points to the first key-value pair,
+  and subsequent items are accessed via the next pointer.
+
+  An Object Array is a collection of objects, where each object
+  is a collection of 

[04/10] incubator-mynewt-core git commit: Add tinycbor and iotivity constrained to the repo.

2016-09-14 Thread paulfdietrich
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ece29bb3/libs/tinycbor/include/tinycbor/extract_number_p.h
--
diff --git a/libs/tinycbor/include/tinycbor/extract_number_p.h 
b/libs/tinycbor/include/tinycbor/extract_number_p.h
new file mode 100644
index 000..b65ca44
--- /dev/null
+++ b/libs/tinycbor/include/tinycbor/extract_number_p.h
@@ -0,0 +1,78 @@
+/
+**
+** Copyright (C) 2015 Intel Corporation
+**
+** Permission is hereby granted, free of charge, to any person obtaining a copy
+** of this software and associated documentation files (the "Software"), to 
deal
+** in the Software without restriction, including without limitation the rights
+** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+** copies of the Software, and to permit persons to whom the Software is
+** furnished to do so, subject to the following conditions:
+**
+** The above copyright notice and this permission notice shall be included in
+** all copies or substantial portions of the Software.
+**
+** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+** THE SOFTWARE.
+**
+/
+
+#define _BSD_SOURCE 1
+#define _DEFAULT_SOURCE 1
+#include "cbor.h"
+#include "cborconstants_p.h"
+#include "compilersupport_p.h"
+#include 
+
+static inline uint16_t get16(const uint8_t *ptr)
+{
+uint16_t result;
+memcpy(, ptr, sizeof(result));
+return cbor_ntohs(result);
+}
+
+static inline uint32_t get32(const uint8_t *ptr)
+{
+uint32_t result;
+memcpy(, ptr, sizeof(result));
+return cbor_ntohl(result);
+}
+
+static inline uint64_t get64(const uint8_t *ptr)
+{
+uint64_t result;
+memcpy(, ptr, sizeof(result));
+return cbor_ntohll(result);
+}
+
+static CborError extract_number(const uint8_t **ptr, const uint8_t *end, 
uint64_t *len)
+{
+uint8_t additional_information = **ptr & SmallValueMask;
+++*ptr;
+if (additional_information < Value8Bit) {
+*len = additional_information;
+return CborNoError;
+}
+if (unlikely(additional_information > Value64Bit))
+return CborErrorIllegalNumber;
+
+size_t bytesNeeded = (size_t)(1 << (additional_information - Value8Bit));
+if (unlikely(bytesNeeded > (size_t)(end - *ptr))) {
+return CborErrorUnexpectedEOF;
+} else if (bytesNeeded == 1) {
+*len = (uint8_t)(*ptr)[0];
+} else if (bytesNeeded == 2) {
+*len = get16(*ptr);
+} else if (bytesNeeded == 4) {
+*len = get32(*ptr);
+} else {
+*len = get64(*ptr);
+}
+*ptr += bytesNeeded;
+return CborNoError;
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ece29bb3/libs/tinycbor/include/tinycbor/math_support_p.h
--
diff --git a/libs/tinycbor/include/tinycbor/math_support_p.h 
b/libs/tinycbor/include/tinycbor/math_support_p.h
new file mode 100644
index 000..676f781
--- /dev/null
+++ b/libs/tinycbor/include/tinycbor/math_support_p.h
@@ -0,0 +1,47 @@
+/
+**
+** Copyright (C) 2016 Intel Corporation
+**
+** Permission is hereby granted, free of charge, to any person obtaining a copy
+** of this software and associated documentation files (the "Software"), to 
deal
+** in the Software without restriction, including without limitation the rights
+** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+** copies of the Software, and to permit persons to whom the Software is
+** furnished to do so, subject to the following conditions:
+**
+** The above copyright notice and this permission notice shall be included in
+** all copies or substantial portions of the Software.
+**
+** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+** THE SOFTWARE.
+**
+/
+
+#ifndef MATH_SUPPORT_H
+#define MATH_SUPPORT_H
+

[02/10] incubator-mynewt-core git commit: Add tinycbor and iotivity constrained to the repo.

2016-09-14 Thread paulfdietrich
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ece29bb3/libs/tinycbor/src/cbortojson.c
--
diff --git a/libs/tinycbor/src/cbortojson.c b/libs/tinycbor/src/cbortojson.c
new file mode 100644
index 000..953f2aa
--- /dev/null
+++ b/libs/tinycbor/src/cbortojson.c
@@ -0,0 +1,686 @@
+/
+**
+** Copyright (C) 2016 Intel Corporation
+**
+** Permission is hereby granted, free of charge, to any person obtaining a copy
+** of this software and associated documentation files (the "Software"), to 
deal
+** in the Software without restriction, including without limitation the rights
+** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+** copies of the Software, and to permit persons to whom the Software is
+** furnished to do so, subject to the following conditions:
+**
+** The above copyright notice and this permission notice shall be included in
+** all copies or substantial portions of the Software.
+**
+** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+** THE SOFTWARE.
+**
+/
+
+#define _BSD_SOURCE 1
+#define _DEFAULT_SOURCE 1
+#define _GNU_SOURCE 1
+#define _POSIX_C_SOURCE 200809L
+#ifndef __STDC_LIMIT_MACROS
+#  define __STDC_LIMIT_MACROS 1
+#endif
+
+#include "cbor.h"
+#include "cborjson.h"
+#include "compilersupport_p.h"
+#include "math_support_p.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+
+/**
+ * \defgroup CborToJson Converting CBOR to JSON
+ * \brief Group of functions used to convert CBOR to JSON.
+ *
+ * This group contains two functions that are can be used to convert one
+ * CborValue object to an equivalent JSON representation. This module attempts
+ * to follow the recommendations from RFC 7049 section 4.1 "Converting from
+ * CBOR to JSON", though it has a few differences. They are noted below.
+ *
+ * These functions produce a "minified" JSON output, with no spacing,
+ * indentation or line breaks. If those are necessary, they need to be applied
+ * in a post-processing phase.
+ *
+ * Note that JSON cannot support all CBOR types with fidelity, so the
+ * conversion is usually lossy. For that reason, TinyCBOR supports adding a set
+ * of metadata JSON values that can be used by a JSON-to-CBOR converter to
+ * restore the original data types.
+ *
+ * The TinyCBOR library does not provide a way to convert from JSON
+ * representation back to encoded form. However, it provides a tool called
+ * \c json2cbor which can be used for that purpose. That tool supports the
+ * metadata format that these functions may produce.
+ *
+ * Either of the functions in this section will attempt to convert exactly one
+ * CborValue object to JSON. Those functions may return any error documented
+ * for the functions for CborParsing. In addition, if the C standard library
+ * stream functions return with error, the text conversion will return with
+ * error CborErrorIO.
+ *
+ * These functions also perform UTF-8 validation in CBOR text strings. If they
+ * encounter a sequence of bytes that not permitted in UTF-8, they will return
+ * CborErrorInvalidUtf8TextString. That includes encoding of surrogate points
+ * in UTF-8.
+ *
+ * \warning The metadata produced by these functions is not guaranteed to
+ * remain stable. A future update of TinyCBOR may produce different output for
+ * the same input and parsers may be unable to handle them.
+ *
+ * \sa CborParsing, CborPretty, cbor_parser_init()
+ */
+
+/**
+ * \addtogroup CborToJson
+ * @{
+ * Conversion limitations
+ *
+ * When converting from CBOR to JSON, there may be information loss. This
+ * section lists the possible scenarios.
+ *
+ * \par Number precision:
+ * ALL JSON numbers, due to its JavaScript heritage, are IEEE 754
+ * double-precision floating point. This means JSON is not capable of
+ * representing integers numbers outside the range [-(253)+1,
+ * 253-1] and is not capable of representing NaN or infinite. If the
+ * CBOR data contains a number outside the valid range, the conversion will
+ * lose precision. If the input was NaN or infinite, the result of the
+ * conversion will be "null". In addition, the distinction between half-,
+ * single- and double-precision is lost.
+ *
+ * \par
+ * If enabled, the original value and original type are stored in the metadata.
+ *
+ * \par Non-native types:
+ * CBOR's type system is richer than JSON's, which 

[01/10] incubator-mynewt-core git commit: some changes to support printing with different size intergers.

2016-09-14 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 0b82d070c -> 1693f95a3


some changes to support printing with different size intergers.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/1693f95a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/1693f95a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/1693f95a

Branch: refs/heads/develop
Commit: 1693f95a3c4698792798ac4c2612e9fe90cc5723
Parents: ece29bb
Author: Paul Dietrich 
Authored: Wed Sep 14 13:30:42 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Sep 14 13:32:32 2016 -0700

--
 libs/baselibc/include/inttypes.h| 7 +--
 libs/iotivity/src/messaging/coap/coap.c | 2 +-
 libs/iotivity/src/messaging/coap/engine.c   | 8 
 libs/iotivity/src/messaging/coap/transactions.c | 2 +-
 4 files changed, 11 insertions(+), 8 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1693f95a/libs/baselibc/include/inttypes.h
--
diff --git a/libs/baselibc/include/inttypes.h b/libs/baselibc/include/inttypes.h
index 29311fe..e9ee426 100644
--- a/libs/baselibc/include/inttypes.h
+++ b/libs/baselibc/include/inttypes.h
@@ -23,6 +23,9 @@ __extern uintmax_t strntoumax(const char *, char **, int, 
size_t);
 
 #if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)
 
+#define __PRI64_RANK "ll"
+#define __PRI32_RANK "l"
+
 #define PRId8  "d"
 #define PRId16 "d"
 #define PRId32 "d"
@@ -97,7 +100,7 @@ __extern uintmax_t strntoumax(const char *, char **, int, 
size_t);
 
 #define PRIx8  "x"
 #define PRIx16 "x"
-#define PRIx32 "x"
+#define PRIx32 __PRI32_RANK "x"
 #define PRIx64 __PRI64_RANK "x"
 
 #define PRIxLEAST8 "x"
@@ -115,7 +118,7 @@ __extern uintmax_t strntoumax(const char *, char **, int, 
size_t);
 
 #define PRIX8  "X"
 #define PRIX16 "X"
-#define PRIX32 "X"
+#define PRIX32 __PRI32_RANK "X"
 #define PRIX64 __PRI64_RANK "X"
 
 #define PRIXLEAST8 "X"

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1693f95a/libs/iotivity/src/messaging/coap/coap.c
--
diff --git a/libs/iotivity/src/messaging/coap/coap.c 
b/libs/iotivity/src/messaging/coap/coap.c
index e8d8608..d77fbbb 100644
--- a/libs/iotivity/src/messaging/coap/coap.c
+++ b/libs/iotivity/src/messaging/coap/coap.c
@@ -405,7 +405,7 @@ coap_serialize_message(void *packet, uint8_t *buffer)
 void
 coap_send_message(oc_message_t *message)
 {
-  LOG("-sending OCF message (%lu)-\n", message->length);
+  LOG("-sending OCF message (%u)-\n", (unsigned int) message->length);
 
   oc_send_message(message);
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1693f95a/libs/iotivity/src/messaging/coap/engine.c
--
diff --git a/libs/iotivity/src/messaging/coap/engine.c 
b/libs/iotivity/src/messaging/coap/engine.c
index 638541e..0eecabf 100644
--- a/libs/iotivity/src/messaging/coap/engine.c
+++ b/libs/iotivity/src/messaging/coap/engine.c
@@ -61,7 +61,7 @@ coap_receive(oc_message_t *msg)
 {
   erbium_status_code = NO_ERROR;
 
-  LOG("\n\nCoAP Engine: received datalen=%lu \n", msg->length);
+  LOG("\n\nCoAP Engine: received datalen=%u \n", (unsigned int) msg->length);
 
   /* static declaration reduces stack peaks and program code size */
   static coap_packet_t
@@ -141,8 +141,8 @@ coap_receive(oc_message_t *msg)
 }
 if (coap_get_header_block2(message, _num, NULL, _size,
_offset)) {
-  LOG("\tBlockwise: block request %u (%u/%u) @ %u bytes\n", block_num,
-  block_size, COAP_MAX_BLOCK_SIZE, block_offset);
+  LOG("\tBlockwise: block request %u (%u/%u) @ %u bytes\n", (unsigned 
int) block_num,
+  block_size, COAP_MAX_BLOCK_SIZE, (unsigned int) block_offset);
   block_size = MIN(block_size, COAP_MAX_BLOCK_SIZE);
   new_offset = block_offset;
 }
@@ -195,7 +195,7 @@ coap_receive(oc_message_t *msg)
 /* resource provides chunk-wise data */
   } else {
 LOG("\tBlockwise: blockwise resource, new offset %d\n",
-new_offset);
+(int) new_offset);
 coap_set_header_block2(response, block_num,
new_offset != -1 ||
  response->payload_len > block_size,

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1693f95a/libs/iotivity/src/messaging/coap/transactions.c

[2/3] incubator-mynewt-core git commit: add stubs for mynewt

2016-09-14 Thread paulfdietrich
add stubs for mynewt

abort, clock, random are implemented but untested
storage -- we will probbably not need until we do security
loop, ip are still TBD


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/23b0a5ac
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/23b0a5ac
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/23b0a5ac

Branch: refs/heads/develop
Commit: 23b0a5ac4d5632cecdb77b9e08edae6a10e69e6c
Parents: aa0f259
Author: Paul Dietrich 
Authored: Wed Sep 14 14:04:07 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Sep 14 16:42:22 2016 -0700

--
 libs/iotivity/src/messaging/coap/transactions.c |  4 +-
 libs/iotivity/src/port/mynewt/abort.c   | 25 +
 libs/iotivity/src/port/mynewt/clock.c   | 41 ++
 libs/iotivity/src/port/mynewt/config.h  |  5 ++
 libs/iotivity/src/port/mynewt/ip_adaptor.c  | 56 
 libs/iotivity/src/port/mynewt/oc_loop.c | 26 +
 libs/iotivity/src/port/mynewt/random.c  | 31 +++
 libs/iotivity/src/port/mynewt/storage.c | 38 +
 8 files changed, 224 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/23b0a5ac/libs/iotivity/src/messaging/coap/transactions.c
--
diff --git a/libs/iotivity/src/messaging/coap/transactions.c 
b/libs/iotivity/src/messaging/coap/transactions.c
index e52362a..8feaa7c 100644
--- a/libs/iotivity/src/messaging/coap/transactions.c
+++ b/libs/iotivity/src/messaging/coap/transactions.c
@@ -112,10 +112,10 @@ coap_send_transaction(coap_transaction_t *t)
   COAP_RESPONSE_TIMEOUT_TICKS +
   (oc_random_rand() %
(oc_clock_time_t)COAP_RESPONSE_TIMEOUT_BACKOFF_MASK);
-LOG("Initial interval %lu\n", t->retrans_timer.timer.interval);
+LOG("Initial interval " OC_CLK_FMT "\n", 
t->retrans_timer.timer.interval);
   } else {
 t->retrans_timer.timer.interval <<= 1; /* double */
-LOG("Doubled %lu\n", t->retrans_timer.timer.interval);
+LOG("Doubled " OC_CLK_FMT "\n", t->retrans_timer.timer.interval);
   }
 
   OC_PROCESS_CONTEXT_BEGIN(transaction_handler_process);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/23b0a5ac/libs/iotivity/src/port/mynewt/abort.c
--
diff --git a/libs/iotivity/src/port/mynewt/abort.c 
b/libs/iotivity/src/port/mynewt/abort.c
new file mode 100644
index 000..0ca5329
--- /dev/null
+++ b/libs/iotivity/src/port/mynewt/abort.c
@@ -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.
+ */
+
+#include "../oc_assert.h"
+#include 
+
+void abort_impl(void) {
+assert(0);
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/23b0a5ac/libs/iotivity/src/port/mynewt/clock.c
--
diff --git a/libs/iotivity/src/port/mynewt/clock.c 
b/libs/iotivity/src/port/mynewt/clock.c
new file mode 100644
index 000..51def9a
--- /dev/null
+++ b/libs/iotivity/src/port/mynewt/clock.c
@@ -0,0 +1,41 @@
+/**
+ * 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 

[1/3] incubator-mynewt-core git commit: add an untested socket interface for the ocf stack

2016-09-14 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 3204c603b -> 1cb7f3577


add an untested socket interface for the ocf stack


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/1cb7f357
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/1cb7f357
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/1cb7f357

Branch: refs/heads/develop
Commit: 1cb7f35772158a7376d9ab1236c16809939eb817
Parents: 23b0a5a
Author: Paul Dietrich 
Authored: Wed Sep 14 16:42:04 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Sep 14 16:42:22 2016 -0700

--
 libs/iotivity/pkg.yml   |   2 +
 libs/iotivity/src/port/mynewt/ip_adaptor.c  | 323 ++-
 sys/log/include/log/log.h   |   2 +
 sys/mn_socket/include/mn_socket/mn_socket.h |   2 +
 4 files changed, 319 insertions(+), 10 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1cb7f357/libs/iotivity/pkg.yml
--
diff --git a/libs/iotivity/pkg.yml b/libs/iotivity/pkg.yml
index f8f9f03..c4bf8b2 100644
--- a/libs/iotivity/pkg.yml
+++ b/libs/iotivity/pkg.yml
@@ -26,6 +26,8 @@ pkg.keywords:
 pkg.deps:
 - "@apache-mynewt-core/libs/tinycbor"
 - "@apache-mynewt-core/libs/os"
+- "@apache-mynewt-core/sys/mn_socket"
+- "@apache-mynewt-core/sys/log"
 
 pkg.cflags: -DDEBUG=1
 -DSECURE=0

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1cb7f357/libs/iotivity/src/port/mynewt/ip_adaptor.c
--
diff --git a/libs/iotivity/src/port/mynewt/ip_adaptor.c 
b/libs/iotivity/src/port/mynewt/ip_adaptor.c
index b32fc39..11a7981 100644
--- a/libs/iotivity/src/port/mynewt/ip_adaptor.c
+++ b/libs/iotivity/src/port/mynewt/ip_adaptor.c
@@ -17,40 +17,343 @@
  * under the License.
  */
 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
 #include "../oc_network_events_mutex.h"
 #include "../oc_connectivity.h"
+#include "oc_buffer.h"
+
+#ifdef OC_SECURITY
+#error This implementation does not yet support security
+#endif
+
+#define COAP_PORT_UNSECURED (5683)
+#define ALL_COAP_NODES_V6 "FF02::FD"
+
+/* TODO these should be defined elsewhere but they are here as stubs */
+#define MN_SOL_SOCKET (0)
+#define MN_SO_REUSEPORT (1)
+#define MN_SO_REUSEADDR (2)
+
+/* need a task to process OCF messages */
+#define OC_NET_TASK_STACK_SIZE  OS_STACK_ALIGN(300)
+#define OC_NET_TASK_PRIORITY(4)
+struct os_task oc_task;
+os_stack_t *oc_stack;
+
+/* sockets to use for coap unicast and multicast */
+struct mn_socket *mcast;
+struct mn_socket *ucast;
+
+/* to wake our task when stuff is ready */
+struct os_sem oc_read_sem;
+struct os_sem oc_write_sem;
 
-void oc_network_event_handler_mutex_init(void)
+/* logging data for this module. TODO, the application should
+ * define the logging strategy for this module */
+#define MAX_CBMEM_BUF   (600)
+static uint32_t *cbmem_buf;
+static struct cbmem cbmem;
+static struct log oc_log;
+
+/* not sure if these semaphores are necessary yet.  If we are running
+ * all of this from one task, we may not need these */
+static struct os_mutex oc_net_mutex;
+
+void
+oc_network_event_handler_mutex_init(void)
 {
+os_error_t rc;
+rc = os_mutex_init(_net_mutex);
+assert(rc == 0);
 }
 
-void oc_network_event_handler_mutex_lock(void)
+void
+oc_network_event_handler_mutex_lock(void)
 {
+os_mutex_pend(_net_mutex, OS_TIMEOUT_NEVER);
 }
 
-void oc_network_event_handler_mutex_unlock(void)
+void
+oc_network_event_handler_mutex_unlock(void)
 {
+os_mutex_release(_net_mutex);
 }
 
-void oc_send_buffer(oc_message_t *message)
+void
+oc_send_buffer(oc_message_t *message)
 {
+struct mn_sockaddr_in6 to;
+struct mn_socket * send_sock;
+struct os_mbuf m;
+int rc;
+
+while (1) {
+LOG_INFO(_log, LOG_MODULE_DEFAULT,
+ "attempt send buffer %u\n", message->length);
+
+to.msin6_len = sizeof(to);
+to.msin6_family = MN_AF_INET6;
+to.msin6_port = htons(message->endpoint.ipv6_addr.port);
+memcpy(to.msin6_addr, message->endpoint.ipv6_addr.address,
+   sizeof(to.msin6_addr));
+send_sock = ucast;
+
+/* put on an mbuf header to make the socket happy */
+memset(,0, sizeof(m));
+m.om_data = message->data;
+m.om_len = message->length;
+
+rc = mn_sendto(send_sock, , (struct mn_sockaddr *) );
+/* TODO what to do if this fails, we can't keep the buffer */
+if (rc != 0) {
+LOG_ERROR(_log, LOG_MODULE_DEFAULT,
+  

[3/3] incubator-mynewt-core git commit: add stubs for mynewt implememtations for iotivity

2016-09-14 Thread paulfdietrich
add stubs for mynewt implememtations for iotivity

abort,clock, random are complete but untested
storage -- stub that we probably won't need until we turn on security
oc_loop, ip_adator -- need to fill these out with mynewt content


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/aa0f2596
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/aa0f2596
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/aa0f2596

Branch: refs/heads/develop
Commit: aa0f2596fb9d9cd959fe27abbc0af3d984228d55
Parents: 3204c60
Author: Paul Dietrich 
Authored: Wed Sep 14 13:58:36 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Sep 14 16:42:22 2016 -0700

--
 libs/iotivity/src/messaging/coap/transactions.c | 4 ++--
 libs/iotivity/src/port/mynewt/config.h  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/aa0f2596/libs/iotivity/src/messaging/coap/transactions.c
--
diff --git a/libs/iotivity/src/messaging/coap/transactions.c 
b/libs/iotivity/src/messaging/coap/transactions.c
index facd95f..e52362a 100644
--- a/libs/iotivity/src/messaging/coap/transactions.c
+++ b/libs/iotivity/src/messaging/coap/transactions.c
@@ -112,10 +112,10 @@ coap_send_transaction(coap_transaction_t *t)
   COAP_RESPONSE_TIMEOUT_TICKS +
   (oc_random_rand() %
(oc_clock_time_t)COAP_RESPONSE_TIMEOUT_BACKOFF_MASK);
-LOG("Initial interval %llu\n", t->retrans_timer.timer.interval);
+LOG("Initial interval %lu\n", t->retrans_timer.timer.interval);
   } else {
 t->retrans_timer.timer.interval <<= 1; /* double */
-LOG("Doubled %llu\n", t->retrans_timer.timer.interval);
+LOG("Doubled %lu\n", t->retrans_timer.timer.interval);
   }
 
   OC_PROCESS_CONTEXT_BEGIN(transaction_handler_process);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/aa0f2596/libs/iotivity/src/port/mynewt/config.h
--
diff --git a/libs/iotivity/src/port/mynewt/config.h 
b/libs/iotivity/src/port/mynewt/config.h
index 803a99d..673ec1c 100644
--- a/libs/iotivity/src/port/mynewt/config.h
+++ b/libs/iotivity/src/port/mynewt/config.h
@@ -6,7 +6,7 @@
 #include 
 #include 
 
-typedef uint64_t oc_clock_time_t;
+typedef os_time_t oc_clock_time_t;
 #define OC_CLOCK_CONF_TICKS_PER_SECOND (OS_TICKS_PER_SEC)
 
 /* Memory pool sizes */



[03/10] incubator-mynewt-core git commit: Add tinycbor and iotivity constrained to the repo.

2016-09-14 Thread paulfdietrich
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ece29bb3/libs/tinycbor/src/cborparser.c
--
diff --git a/libs/tinycbor/src/cborparser.c b/libs/tinycbor/src/cborparser.c
new file mode 100644
index 000..1d81091
--- /dev/null
+++ b/libs/tinycbor/src/cborparser.c
@@ -0,0 +1,1293 @@
+/
+**
+** Copyright (C) 2016 Intel Corporation
+**
+** Permission is hereby granted, free of charge, to any person obtaining a copy
+** of this software and associated documentation files (the "Software"), to 
deal
+** in the Software without restriction, including without limitation the rights
+** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+** copies of the Software, and to permit persons to whom the Software is
+** furnished to do so, subject to the following conditions:
+**
+** The above copyright notice and this permission notice shall be included in
+** all copies or substantial portions of the Software.
+**
+** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+** THE SOFTWARE.
+**
+/
+
+#define _BSD_SOURCE 1
+#define _DEFAULT_SOURCE 1
+#ifndef __STDC_LIMIT_MACROS
+#  define __STDC_LIMIT_MACROS 1
+#endif
+
+#include "cbor.h"
+#include "cborconstants_p.h"
+#include "compilersupport_p.h"
+#include "extract_number_p.h"
+
+#include 
+#include 
+
+#include "assert_p.h"   /* Always include last */
+
+#ifndef CBOR_PARSER_MAX_RECURSIONS
+#  define CBOR_PARSER_MAX_RECURSIONS 1024
+#endif
+
+/**
+ * \defgroup CborParsing Parsing CBOR streams
+ * \brief Group of functions used to parse CBOR streams.
+ *
+ * TinyCBOR provides functions for pull-based stream parsing of a CBOR-encoded
+ * payload. The main data type for the parsing is a CborValue, which behaves
+ * like an iterator and can be used to extract the encoded data. It is first
+ * initialized with a call to cbor_parser_init() and is usually used to extract
+ * exactly one item, most often an array or map.
+ *
+ * Nested CborValue objects can be parsed using cbor_value_enter_container().
+ * Each call to cbor_value_enter_container() must be matched by a call to
+ * cbor_value_leave_container(), with the exact same parameters.
+ *
+ * The example below initializes a CborParser object, begins the parsing with a
+ * CborValue and decodes a single integer:
+ *
+ * \code
+ * int extract_int(const uint8_t *buffer, size_t len)
+ * {
+ * CborParser parser;
+ * CborValue value;
+ * int result;
+ * cbor_parser_init(buffer, len, 0, , );
+ * cbor_value_get_int(, );
+ * return result;
+ * }
+ * \endcode
+ *
+ * The code above does no error checking, which means it assumes the data comes
+ * from a source trusted to send one properly-encoded integer. The following
+ * example does the exact same operation, but includes error parsing and
+ * returns 0 on parsing failure:
+ *
+ * \code
+ * int extract_int(const uint8_t *buffer, size_t len)
+ * {
+ * CborParser parser;
+ * CborValue value;
+ * int result;
+ * if (cbor_parser_init(buffer, len, 0, , ) != CborNoError)
+ * return 0;
+ * if (!cbor_value_is_integer() ||
+ * cbor_value_get_int(, ) != CborNoError)
+ * return 0;
+ * return result;
+ * }
+ * \endcode
+ *
+ * Note, in the example above, that one can't distinguish a parsing failure
+ * from an encoded value of zero. Reporting a parsing error is left as an
+ * exercise to the reader.
+ *
+ * The code above does not execute a range-check either: it is possible that
+ * the value decoded from the CBOR stream encodes a number larger than what can
+ * be represented in a variable of type \c{int}. If detecting that case is
+ * important, the code should call cbor_value_get_int_checked() instead.
+ *
+ * Memory and parsing constraints
+ *
+ * TinyCBOR is designed to run with little memory and with minimal overhead.
+ * Except where otherwise noted, the parser functions always run on constant
+ * time (O(1)), do not recurse and never allocate memory (thus, stack usage is
+ * bounded and is O(1)).
+ *
+ * Error handling and preconditions
+ *
+ * All functions operating on a CborValue return a CborError condition, with
+ * CborNoError standing for the normal situation in which no parsing error
+ * occurred. All functions may return parsing errors in case the stream cannot
+ * be decoded properly, be it due to corrupted data or due to reaching 

[10/10] incubator-mynewt-core git commit: Add tinycbor and iotivity constrained to the repo.

2016-09-14 Thread paulfdietrich
Add tinycbor and iotivity constrained to the repo.

These are not working yet.  Need to add basic test cases for cbor
Need to add the OS support for iotivity


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/ece29bb3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/ece29bb3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/ece29bb3

Branch: refs/heads/develop
Commit: ece29bb340b4ec83b635e3a13cdca8c21d458d19
Parents: 0b82d07
Author: Paul Dietrich 
Authored: Wed Sep 14 13:18:31 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Sep 14 13:32:32 2016 -0700

--
 libs/iotivity/include/iotivity/oc_api.h |  165 +++
 libs/iotivity/include/iotivity/oc_buffer.h  |   32 +
 .../iotivity/include/iotivity/oc_client_state.h |   88 ++
 libs/iotivity/include/iotivity/oc_constants.h   |   43 +
 libs/iotivity/include/iotivity/oc_core_res.h|   52 +
 libs/iotivity/include/iotivity/oc_discovery.h   |   22 +
 libs/iotivity/include/iotivity/oc_helpers.h |   78 ++
 .../include/iotivity/oc_network_events.h|   29 +
 libs/iotivity/include/iotivity/oc_rep.h |  228 +++
 libs/iotivity/include/iotivity/oc_ri.h  |  176 +++
 libs/iotivity/include/iotivity/oc_uuid.h|   31 +
 libs/iotivity/pkg.yml   |   37 +
 libs/iotivity/src/api/oc_buffer.c   |  138 ++
 libs/iotivity/src/api/oc_client_api.c   |  287 
 libs/iotivity/src/api/oc_core_res.c |  280 
 libs/iotivity/src/api/oc_discovery.c|  298 
 libs/iotivity/src/api/oc_events.h   |   34 +
 libs/iotivity/src/api/oc_helpers.c  |  164 +++
 libs/iotivity/src/api/oc_main.c |  119 ++
 libs/iotivity/src/api/oc_network_events.c   |   57 +
 libs/iotivity/src/api/oc_rep.c  |  301 
 libs/iotivity/src/api/oc_ri.c   | 1016 ++
 libs/iotivity/src/api/oc_server_api.c   |  291 
 libs/iotivity/src/api/oc_uuid.c |  119 ++
 libs/iotivity/src/messaging/coap/coap.c | 1186 
 libs/iotivity/src/messaging/coap/coap.h |  297 
 libs/iotivity/src/messaging/coap/conf.h |   71 +
 libs/iotivity/src/messaging/coap/constants.h|  158 +++
 libs/iotivity/src/messaging/coap/engine.c   |  333 +
 libs/iotivity/src/messaging/coap/engine.h   |   48 +
 libs/iotivity/src/messaging/coap/observe.c  |  319 +
 libs/iotivity/src/messaging/coap/observe.h  |   80 ++
 libs/iotivity/src/messaging/coap/oc_coap.h  |   39 +
 libs/iotivity/src/messaging/coap/separate.c |  152 ++
 libs/iotivity/src/messaging/coap/separate.h |   71 +
 libs/iotivity/src/messaging/coap/transactions.c |  202 +++
 libs/iotivity/src/messaging/coap/transactions.h |   75 +
 libs/iotivity/src/port/mynewt/config.h  |   50 +
 libs/iotivity/src/port/oc_assert.h  |   42 +
 libs/iotivity/src/port/oc_clock.h   |  102 ++
 libs/iotivity/src/port/oc_connectivity.h|   83 ++
 libs/iotivity/src/port/oc_log.h |   46 +
 .../iotivity/src/port/oc_network_events_mutex.h |   26 +
 libs/iotivity/src/port/oc_random.h  |   56 +
 libs/iotivity/src/port/oc_signal_main_loop.h|   22 +
 libs/iotivity/src/port/oc_storage.h |   27 +
 libs/iotivity/src/security/oc_acl.c |  412 ++
 libs/iotivity/src/security/oc_acl.h |   63 +
 libs/iotivity/src/security/oc_cred.c|  200 +++
 libs/iotivity/src/security/oc_cred.h|   40 +
 libs/iotivity/src/security/oc_doxm.c|  128 ++
 libs/iotivity/src/security/oc_doxm.h|   45 +
 libs/iotivity/src/security/oc_dtls.c|  372 +
 libs/iotivity/src/security/oc_dtls.h|   50 +
 libs/iotivity/src/security/oc_pstat.c   |  119 ++
 libs/iotivity/src/security/oc_pstat.h   |   39 +
 libs/iotivity/src/security/oc_store.c   |  158 +++
 libs/iotivity/src/security/oc_store.h   |   26 +
 libs/iotivity/src/security/oc_svr.c |   51 +
 libs/iotivity/src/security/oc_svr.h |   22 +
 libs/iotivity/src/util/oc_etimer.c  |  263 
 libs/iotivity/src/util/oc_etimer.h  |  247 
 libs/iotivity/src/util/oc_list.c|  317 +
 libs/iotivity/src/util/oc_list.h|  144 ++
 libs/iotivity/src/util/oc_memb.c|  111 ++
 libs/iotivity/src/util/oc_memb.h|  127 ++
 libs/iotivity/src/util/oc_mmem.c|  154 +++
 libs/iotivity/src/util/oc_mmem.h|   53 +
 libs/iotivity/src/util/oc_process.c |  346 +
 libs/iotivity/src/util/oc_process.h |  527 

[07/10] incubator-mynewt-core git commit: Add tinycbor and iotivity constrained to the repo.

2016-09-14 Thread paulfdietrich
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ece29bb3/libs/iotivity/src/messaging/coap/observe.c
--
diff --git a/libs/iotivity/src/messaging/coap/observe.c 
b/libs/iotivity/src/messaging/coap/observe.c
new file mode 100644
index 000..4bd1d96
--- /dev/null
+++ b/libs/iotivity/src/messaging/coap/observe.c
@@ -0,0 +1,319 @@
+/*
+ * Copyright (c) 2016 Intel Corporation
+ *
+ * Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *may be used to endorse or promote products derived from this software
+ *without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ */
+
+#include "config.h"
+
+#ifdef OC_SERVER
+
+#include "observe.h"
+#include "util/oc_memb.h"
+#include 
+#include 
+
+#include "oc_coap.h"
+#include "oc_rep.h"
+#include "oc_ri.h"
+/*---*/
+uint64_t observe_counter = 3;
+/*---*/
+OC_LIST(observers_list);
+OC_MEMB(observers_memb, coap_observer_t, COAP_MAX_OBSERVERS);
+
+/*---*/
+/*- Internal API */
+/*---*/
+static int
+add_observer(oc_resource_t *resource, oc_endpoint_t *endpoint,
+ const uint8_t *token, size_t token_len, const char *uri,
+ int uri_len)
+{
+  /* Remove existing observe relationship, if any. */
+  int dup = coap_remove_observer_by_uri(endpoint, uri);
+
+  coap_observer_t *o = oc_memb_alloc(_memb);
+
+  if (o) {
+int max = sizeof(o->url) - 1;
+if (max > uri_len) {
+  max = uri_len;
+}
+memcpy(o->url, uri, max);
+o->url[max] = 0;
+memcpy(>endpoint, endpoint, sizeof(oc_endpoint_t));
+o->token_len = token_len;
+memcpy(o->token, token, token_len);
+o->last_mid = 0;
+o->obs_counter = observe_counter;
+o->resource = resource;
+resource->num_observers++;
+LOG("Adding observer (%u/%u) for /%s [0x%02X%02X]\n",
+oc_list_length(observers_list) + 1, COAP_MAX_OBSERVERS, o->url,
+o->token[0], o->token[1]);
+oc_list_add(observers_list, o);
+return dup;
+  }
+  return -1;
+}
+/*---*/
+/*- Removal -*/
+/*---*/
+void
+coap_remove_observer(coap_observer_t *o)
+{
+  LOG("Removing observer for /%s [0x%02X%02X]\n", o->url, o->token[0],
+  o->token[1]);
+  oc_memb_free(_memb, o);
+  oc_list_remove(observers_list, o);
+}
+/*---*/
+int
+coap_remove_observer_by_client(oc_endpoint_t *endpoint)
+{
+  int removed = 0;
+  coap_observer_t *obs = (coap_observer_t *)oc_list_head(observers_list), 
*next;
+
+  LOG("Unregistering observers for client at: ");
+  LOGipaddr(*endpoint);
+
+  while (obs) {
+next = obs->next;
+if (memcmp(>endpoint, endpoint, sizeof(oc_endpoint_t)) == 0) {
+  obs->resource->num_observers--;
+  coap_remove_observer(obs);
+  removed++;
+}
+obs = next;
+  }
+  LOG("Removed %d observers\n", removed);
+  return removed;
+}
+/*---*/
+int
+coap_remove_observer_by_token(oc_endpoint_t 

[08/10] incubator-mynewt-core git commit: Add tinycbor and iotivity constrained to the repo.

2016-09-14 Thread paulfdietrich
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ece29bb3/libs/iotivity/src/messaging/coap/coap.c
--
diff --git a/libs/iotivity/src/messaging/coap/coap.c 
b/libs/iotivity/src/messaging/coap/coap.c
new file mode 100644
index 000..e8d8608
--- /dev/null
+++ b/libs/iotivity/src/messaging/coap/coap.c
@@ -0,0 +1,1186 @@
+/*
+ * Copyright (c) 2016 Intel Corporation
+ *
+ * Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *may be used to endorse or promote products derived from this software
+ *without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ */
+
+#include 
+#include 
+
+#include "coap.h"
+#include "transactions.h"
+
+#ifdef OC_SECURITY
+#include "security/oc_dtls.h"
+#endif
+
+/*---*/
+/*- Variables ---*/
+/*---*/
+static uint16_t current_mid = 0;
+
+coap_status_t erbium_status_code = NO_ERROR;
+char *coap_error_message = "";
+/*---*/
+/*- Local helper functions --*/
+/*---*/
+static uint16_t
+coap_log_2(uint16_t value)
+{
+  uint16_t result = 0;
+
+  do {
+value = value >> 1;
+result++;
+  } while (value);
+
+  return (result - 1);
+}
+/*---*/
+static uint32_t
+coap_parse_int_option(uint8_t *bytes, size_t length)
+{
+  uint32_t var = 0;
+  int i = 0;
+
+  while (i < length) {
+var <<= 8;
+var |= bytes[i++];
+  }
+  return var;
+}
+/*---*/
+static uint8_t
+coap_option_nibble(unsigned int value)
+{
+  if (value < 13) {
+return value;
+  } else if (value <= 0xFF + 13) {
+return 13;
+  } else {
+return 14;
+  }
+}
+/*---*/
+static size_t
+coap_set_option_header(unsigned int delta, size_t length, uint8_t *buffer)
+{
+  size_t written = 0;
+
+  buffer[0] = coap_option_nibble(delta) << 4 | coap_option_nibble(length);
+
+  if (delta > 268) {
+buffer[++written] = ((delta - 269) >> 8) & 0xff;
+buffer[++written] = (delta - 269) & 0xff;
+  } else if (delta > 12) {
+buffer[++written] = (delta - 13);
+  }
+
+  if (length > 268) {
+buffer[++written] = ((length - 269) >> 8) & 0xff;
+buffer[++written] = (length - 269) & 0xff;
+  } else if (length > 12) {
+buffer[++written] = (length - 13);
+  }
+
+  LOG("WRITTEN %zu B opt header\n", 1 + written);
+
+  return ++written;
+}
+/*---*/
+static size_t
+coap_serialize_int_option(unsigned int number, unsigned int current_number,
+  uint8_t *buffer, uint32_t value)
+{
+  size_t i = 0;
+
+  if (0xFF00 & value) {
+++i;
+  }
+  if (0x & value) {
+++i;
+  }
+  if (0xFF00 & value) {
+++i;
+  }
+  if (0x & value) {
+++i;
+  }
+  LOG("OPTION %u (delta %u, len %zu)\n", number, number - current_number, i);
+
+  i = coap_set_option_header(number - current_number, i, buffer);
+
+  if (0xFF00 & value) {
+buffer[i++] = (uint8_t)(value >> 24);
+  }
+  

incubator-mynewt-newt git commit: MYNEWT-126

2016-09-12 Thread paulfdietrich
Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop 7a57c73b5 -> 0baf3a369


MYNEWT-126

newt new command broke because we were not heeding the error from these 
functions.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/0baf3a36
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/0baf3a36
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/0baf3a36

Branch: refs/heads/develop
Commit: 0baf3a3696b5fa072ceea95433b867cf564f0561
Parents: 7a57c73
Author: Paul Dietrich 
Authored: Mon Sep 12 10:39:57 2016 -0700
Committer: Paul Dietrich 
Committed: Mon Sep 12 10:40:48 2016 -0700

--
 newt/cli/complete_cmd.go | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0baf3a36/newt/cli/complete_cmd.go
--
diff --git a/newt/cli/complete_cmd.go b/newt/cli/complete_cmd.go
index dd113da..c01410c 100644
--- a/newt/cli/complete_cmd.go
+++ b/newt/cli/complete_cmd.go
@@ -34,8 +34,14 @@ import (
 )
 
 func targetList() []string {
-   _ = project.Initialize()
+   err := project.Initialize()
+
targetNames := []string{}
+
+   if err != nil {
+   return targetNames
+   }
+
for name, _ := range target.GetTargets() {
// Don't display the special unittest target; this is used
// internally by newt, so the user doesn't need to know about 
it.
@@ -50,7 +56,14 @@ func targetList() []string {
 
 /* return a list of all packages */
 func packageList() []string {
+
+   err := project.Initialize()
+
var list []string
+
+   if err != nil {
+   return list
+   }
for _, repoHash := range project.GetProject().PackageList() {
for _, pack := range *repoHash {
lclPack := pack.(*pkg.LocalPackage)



[2/3] incubator-mynewt-core git commit: finish refactoring tinycbor to allow mbuf decoding or flat buf decoding

2016-10-07 Thread paulfdietrich
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 CBOR_BUF_READER_H
+#define CBOR_BUF_READER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+
+struct cbor_buf_reader {
+struct cbor_decoder_reader r;
+const uint8_t *buffer;
+};
+
+void
+cbor_buf_reader_init(struct cbor_buf_reader *cb, const uint8_t *buffer, size_t 
data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CBOR_BUF_READER_H */
+

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d49b9ab5/encoding/tinycbor/include/tinycbor/cbor_buf_writer.h
--
diff --git a/encoding/tinycbor/include/tinycbor/cbor_buf_writer.h 
b/encoding/tinycbor/include/tinycbor/cbor_buf_writer.h
index 9dbf4da..2f98154 100644
--- a/encoding/tinycbor/include/tinycbor/cbor_buf_writer.h
+++ b/encoding/tinycbor/include/tinycbor/cbor_buf_writer.h
@@ -1,14 +1,20 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/* 
- * File:   cbor_buf_writer.h
- * Author: paulfdietrich
+/**
+ * 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
  *
- * Created on September 30, 2016, 4:38 PM
+ * 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 CBOR_BUF_WRITER_H

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d49b9ab5/encoding/tinycbor/include/tinycbor/cbor_cnt_writer.h
--
diff --git a/encoding/tinycbor/include/tinycbor/cbor_cnt_writer.h 
b/encoding/tinycbor/include/tinycbor/cbor_cnt_writer.h
index e5c4485..1db57e6 100644
--- a/encoding/tinycbor/include/tinycbor/cbor_cnt_writer.h
+++ b/encoding/tinycbor/include/tinycbor/cbor_cnt_writer.h
@@ -1,14 +1,20 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/* 
- * File:   cbor_cnt_writer.h
- * Author: paulfdietrich
+/**
+ * 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
  *
- * Created on September 30, 2016, 4:50 PM
+ * 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 CBOR_CNT_WRITER_H

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d49b9ab5/encoding/tinycbor/include/tinycbor/cbor_mbuf_reader.h
--
diff --git a/encoding/tinycbor/include/tinycbor/cbor_mbuf_reader.h 
b/encoding/tinycbor/include/tinycbor/cbor_mbuf_reader.h
new file mode 100644
index 000..128fda9
--- /dev/null
+++ b/encoding/tinycbor/include/tinycbor/cbor_mbuf_reader.h
@@ -0,0 +1,40 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/* 
+ * File:   cbor_mbuf_reader.h
+ * Author: paulfdietrich
+ *
+ * Created on October 5, 2016, 1:19 PM
+ */
+
+#ifndef CBOR_MBUF_READER_H
+#define CBOR_MBUF_READER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#i

[1/3] incubator-mynewt-core git commit: forgot to account for offset in one spot

2016-10-07 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop a6a2c878e -> 9164e65c0


forgot to account for offset in one spot


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/9164e65c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/9164e65c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/9164e65c

Branch: refs/heads/develop
Commit: 9164e65c080a07a9310fe306df61ba30ae098508
Parents: d49b9ab
Author: Paul Dietrich 
Authored: Fri Oct 7 12:07:55 2016 -0700
Committer: Paul Dietrich 
Committed: Fri Oct 7 12:08:33 2016 -0700

--
 encoding/tinycbor/src/cbor_mbuf_reader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9164e65c/encoding/tinycbor/src/cbor_mbuf_reader.c
--
diff --git a/encoding/tinycbor/src/cbor_mbuf_reader.c 
b/encoding/tinycbor/src/cbor_mbuf_reader.c
index e272487..f37908b 100644
--- a/encoding/tinycbor/src/cbor_mbuf_reader.c
+++ b/encoding/tinycbor/src/cbor_mbuf_reader.c
@@ -25,7 +25,7 @@ static uint8_t
 cbuf_mbuf_reader_get8(struct cbor_decoder_reader *d, int offset) {
 uint8_t val;
 struct CborMbufReader *cb = (struct CborMbufReader *) d;
-os_mbuf_copydata(cb->m, offset, sizeof(val), );
+os_mbuf_copydata(cb->m, offset + cb->init_off, sizeof(val), );
 return val;
 }
 



[3/3] incubator-mynewt-core git commit: refactor the encoder for tinycbor to use mbufs, flat bufs, or just count size (to replace existing functionality). This had the detrimental affect of making the

2016-10-07 Thread paulfdietrich
refactor the encoder for tinycbor to use mbufs, flat bufs, or just count size 
(to replace existing functionality).
This had the detrimental affect of making the checked container close difficult 
so that is left our for now.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/4246a503
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/4246a503
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/4246a503

Branch: refs/heads/develop
Commit: 4246a5030f194f171fd33fa5a1fe4d4ff6239e9c
Parents: a6a2c87
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Authored: Fri Sep 30 17:35:29 2016 -0700
Committer: Paul Dietrich <paulfdietr...@yahoo.com>
Committed: Fri Oct 7 12:08:33 2016 -0700

--
 encoding/tinycbor/include/tinycbor/cbor.h   | 23 +++--
 .../tinycbor/include/tinycbor/cbor_buf_writer.h | 39 ++
 .../tinycbor/include/tinycbor/cbor_cnt_writer.h | 53 
 .../include/tinycbor/cbor_mbuf_writer.h | 42 
 .../include/tinycbor/extract_number_p.h |  3 +-
 encoding/tinycbor/src/cbor_buf_writer.c | 53 
 encoding/tinycbor/src/cbor_mbuf_writer.c| 47 +
 encoding/tinycbor/src/cborencoder.c | 49 --
 .../src/cborencoder_close_container_checked.c   | 36 -
 net/oic/src/api/oc_rep.c|  7 ++-
 10 files changed, 257 insertions(+), 95 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4246a503/encoding/tinycbor/include/tinycbor/cbor.h
--
diff --git a/encoding/tinycbor/include/tinycbor/cbor.h 
b/encoding/tinycbor/include/tinycbor/cbor.h
index f78e4af..7b8e861 100644
--- a/encoding/tinycbor/include/tinycbor/cbor.h
+++ b/encoding/tinycbor/include/tinycbor/cbor.h
@@ -157,14 +157,14 @@ typedef enum CborError {
 
 CBOR_API const char *cbor_error_string(CborError error);
 
+
+typedef int (cbor_encoder_writer)(void *arg, const char *data, int len);
+
 /* Encoder API */
 struct CborEncoder
 {
-union {
-uint8_t *ptr;
-ptrdiff_t bytes_needed;
-};
-const uint8_t *end;
+cbor_encoder_writer *writer;
+void *writer_arg;
 size_t added;
 int flags;
 };
@@ -172,7 +172,8 @@ typedef struct CborEncoder CborEncoder;
 
 static const size_t CborIndefiniteLength = SIZE_MAX;
 
-CBOR_API void cbor_encoder_init(CborEncoder *encoder, uint8_t *buffer, size_t 
size, int flags);
+
+CBOR_API void cbor_encoder_init(CborEncoder *encoder, cbor_encoder_writer 
*pwriter, void *writer_arg, int flags);
 CBOR_API CborError cbor_encode_uint(CborEncoder *encoder, uint64_t value);
 CBOR_API CborError cbor_encode_int(CborEncoder *encoder, int64_t value);
 CBOR_API CborError cbor_encode_negative_int(CborEncoder *encoder, uint64_t 
absolute_value);
@@ -203,16 +204,6 @@ CBOR_API CborError cbor_encoder_create_map(CborEncoder 
*encoder, CborEncoder *ma
 CBOR_API CborError cbor_encoder_close_container(CborEncoder *encoder, const 
CborEncoder *containerEncoder);
 CBOR_API CborError cbor_encoder_close_container_checked(CborEncoder *encoder, 
const CborEncoder *containerEncoder);
 
-CBOR_INLINE_API size_t cbor_encoder_get_buffer_size(const CborEncoder 
*encoder, const uint8_t *buffer)
-{
-return (size_t)(encoder->ptr - buffer);
-}
-
-CBOR_INLINE_API size_t cbor_encoder_get_extra_bytes_needed(const CborEncoder 
*encoder)
-{
-return encoder->end ? 0 : (size_t)encoder->bytes_needed;
-}
-
 /* Parser API */
 
 enum CborParserIteratorFlags

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4246a503/encoding/tinycbor/include/tinycbor/cbor_buf_writer.h
--
diff --git a/encoding/tinycbor/include/tinycbor/cbor_buf_writer.h 
b/encoding/tinycbor/include/tinycbor/cbor_buf_writer.h
new file mode 100644
index 000..9dbf4da
--- /dev/null
+++ b/encoding/tinycbor/include/tinycbor/cbor_buf_writer.h
@@ -0,0 +1,39 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/* 
+ * File:   cbor_buf_writer.h
+ * Author: paulfdietrich
+ *
+ * Created on September 30, 2016, 4:38 PM
+ */
+
+#ifndef CBOR_BUF_WRITER_H
+#define CBOR_BUF_WRITER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct CborBufWriter {
+uint8_t *ptr;
+const uint8_t *end;
+};
+
+void
+cbor_buf_writer_init(struct CborBufWriter *cb, uint8_t *buffer, size_t data);
+
+int
+cbor_buf_writer(void *arg, const char *data, int len);
+
+size_t
+cbor_buf_writer_buffer_size(struct CborBufWr

[1/3] incubator-mynewt-core git commit: working client and server after refactoring the adaptor to allow for serial and gatt interfaces

2016-09-21 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop b402017f5 -> 12ef82c64


working client and server after refactoring the adaptor to allow
for serial and gatt interfaces


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/12ef82c6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/12ef82c6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/12ef82c6

Branch: refs/heads/develop
Commit: 12ef82c64f072d79bcffd417ad803b503dac6431
Parents: 29a11be
Author: Paul Dietrich 
Authored: Wed Sep 21 10:47:56 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Sep 21 10:48:28 2016 -0700

--
 apps/ocf_sample/pkg.yml|   8 +-
 apps/ocf_sample/src/main.c | 141 ++--
 libs/iotivity/pkg.yml  |   2 +-
 libs/iotivity/src/api/oc_ri.c  |   2 +-
 libs/iotivity/src/port/mynewt/adaptor.c| 223 +++
 libs/iotivity/src/port/mynewt/adaptor.h|  61 +
 libs/iotivity/src/port/mynewt/ble_adaptor.c|  18 ++
 libs/iotivity/src/port/mynewt/config.h |   2 +
 libs/iotivity/src/port/mynewt/ip_adaptor.c | 234 
 libs/iotivity/src/port/mynewt/serial_adaptor.c | 153 +
 libs/iotivity/src/port/oc_connectivity.h   |   3 +-
 libs/os/include/os/os_eventq.h |   2 +-
 12 files changed, 685 insertions(+), 164 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/12ef82c6/apps/ocf_sample/pkg.yml
--
diff --git a/apps/ocf_sample/pkg.yml b/apps/ocf_sample/pkg.yml
index 32c96f2..52858b5 100644
--- a/apps/ocf_sample/pkg.yml
+++ b/apps/ocf_sample/pkg.yml
@@ -33,4 +33,10 @@ pkg.deps:
 - libs/iotivity
 
 # this tells the library that you intend to suppor the server functionality
-pkg.cflags: -DOC_SERVER
\ No newline at end of file
+pkg.cflags:
+
+#-DOC_SERVER -- build the server examples 
+#-DOC_CLIENT -- build the client examples
+#-DOC_TRANSPORT_GATT -- to send COAP over GATT
+#-DOC_TRANSPORT_SERIAL -- to send COAP over serial
+#-DOC_TRANSPORT_IP -- to send COAP over IP ßß
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/12ef82c6/apps/ocf_sample/src/main.c
--
diff --git a/apps/ocf_sample/src/main.c b/apps/ocf_sample/src/main.c
index 4d90495..78846d2 100644
--- a/apps/ocf_sample/src/main.c
+++ b/apps/ocf_sample/src/main.c
@@ -28,7 +28,7 @@
 #include "mn_socket/arch/sim/native_sock.h"
 
 /* Shell */
-#define SHELL_TASK_PRIO  (8)
+#define SHELL_TASK_PRIO (8)
 #define SHELL_MAX_INPUT_LEN (256)
 #define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(2048))
 static os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
@@ -38,8 +38,6 @@ static os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
 static os_stack_t ocf_stack[OCF_TASK_STACK_SIZE];
 struct os_task ocf_task;
 
-static bool light_state = false;
-
 #define DEFAULT_MBUF_MPOOL_BUF_LEN (256)
 #define DEFAULT_MBUF_MPOOL_NBUFS (10)
 
@@ -49,6 +47,13 @@ static uint8_t 
default_mbuf_mpool_data[DEFAULT_MBUF_MPOOL_BUF_LEN *
 static struct os_mbuf_pool default_mbuf_pool;
 static struct os_mempool default_mbuf_mpool;
 
+#ifdef OC_CLIENT
+static void issue_requests(void);
+#endif
+
+#ifdef OC_SERVER
+static bool light_state = false;
+
 static void
 get_light(oc_request_t *request, oc_interface_mask_t interface)
 {
@@ -93,13 +98,6 @@ put_light(oc_request_t *request, oc_interface_mask_t 
interface)
 }
 
 static void
-app_init(void)
-{
-  oc_init_platform("Mynewt", NULL, NULL);
-  oc_add_device("/oic/d", "oic.d.light", "MynewtLED", "1.0", "1.0", NULL, 
NULL);
-}
-
-static void
 register_resources(void)
 {
   oc_resource_t *res = oc_new_resource("/light/1", 1, 0);
@@ -107,22 +105,131 @@ register_resources(void)
   oc_resource_bind_resource_interface(res, OC_IF_RW);
   oc_resource_set_default_interface(res, OC_IF_RW);
 
-#ifdef OC_SECURITY
-  oc_resource_make_secure(res);
-#endif
-
   oc_resource_set_discoverable(res);
   oc_resource_set_periodic_observable(res, 1);
   oc_resource_set_request_handler(res, OC_GET, get_light);
   oc_resource_set_request_handler(res, OC_PUT, put_light);
   oc_add_resource(res);
 }
+#endif
 
-struct os_sem ocf_main_loop_sem;
+#ifdef OC_CLIENT
+#define MAX_URI_LENGTH (30)
+static char light_1[MAX_URI_LENGTH];
+static oc_server_handle_t light_server;
+static bool light_state = false;
+
+static void
+set_device_custom_property(void *data)
+{
+  oc_set_custom_device_property(purpose, "operate mynewt-light");
+}
+
+static oc_event_callback_retval_t

[3/3] incubator-mynewt-core git commit: format logging so the library logs to mynewt logging system

2016-09-21 Thread paulfdietrich
format logging so the library logs to mynewt logging system


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/7f682f64
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/7f682f64
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/7f682f64

Branch: refs/heads/develop
Commit: 7f682f6483d1efd4d638ebb8972bdb4b0eebf299
Parents: b402017
Author: Paul Dietrich 
Authored: Fri Sep 16 15:32:27 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Sep 21 10:48:28 2016 -0700

--
 libs/iotivity/src/port/mynewt/config.h |  2 +
 libs/iotivity/src/port/mynewt/ip_adaptor.c | 66 ++---
 libs/iotivity/src/port/oc_log.h| 11 +++--
 3 files changed, 48 insertions(+), 31 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7f682f64/libs/iotivity/src/port/mynewt/config.h
--
diff --git a/libs/iotivity/src/port/mynewt/config.h 
b/libs/iotivity/src/port/mynewt/config.h
index c2602c4..10b4f95 100644
--- a/libs/iotivity/src/port/mynewt/config.h
+++ b/libs/iotivity/src/port/mynewt/config.h
@@ -5,6 +5,8 @@
 /* Time resolution */
 #include 
 #include 
+#include 
+extern struct log oc_log;
 
 typedef os_time_t oc_clock_time_t;
 #define OC_CLOCK_CONF_TICKS_PER_SECOND (OS_TICKS_PER_SEC)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7f682f64/libs/iotivity/src/port/mynewt/ip_adaptor.c
--
diff --git a/libs/iotivity/src/port/mynewt/ip_adaptor.c 
b/libs/iotivity/src/port/mynewt/ip_adaptor.c
index 0b6fd1a..dfb1f9c 100644
--- a/libs/iotivity/src/port/mynewt/ip_adaptor.c
+++ b/libs/iotivity/src/port/mynewt/ip_adaptor.c
@@ -58,7 +58,23 @@ struct os_sem oc_write_sem;
 #define MAX_CBMEM_BUF   (600)
 static uint32_t *cbmem_buf;
 static struct cbmem cbmem;
-static struct log oc_log;
+struct log oc_log;
+
+static int oc_log_init(void) {
+
+log_init();
+
+cbmem_buf = malloc(sizeof(uint32_t) * MAX_CBMEM_BUF);
+if (cbmem_buf == NULL) {
+return -1;
+}
+
+cbmem_init(, cbmem_buf, MAX_CBMEM_BUF);
+log_register("iot", _log, _cbmem_handler, );
+
+LOG_INFO(_log, LOG_MODULE_IOTIVITY, "OC Init");
+return 0;
+}
 
 /* not sure if these semaphores are necessary yet.  If we are running
  * all of this from one task, we may not need these */
@@ -93,7 +109,7 @@ oc_send_buffer(oc_message_t *message)
 int rc;
 
 while (1) {
-LOG_INFO(_log, LOG_MODULE_DEFAULT,
+LOG_INFO(_log, LOG_MODULE_IOTIVITY,
  "attempt send buffer %u\n", message->length);
 
 to.msin6_len = sizeof(to);
@@ -112,7 +128,7 @@ oc_send_buffer(oc_message_t *message)
 rc = mn_sendto(send_sock, , (struct mn_sockaddr *) );
 /* TODO what to do if this fails, we can't keep the buffer */
 if (rc != 0) {
-LOG_ERROR(_log, LOG_MODULE_DEFAULT,
+LOG_ERROR(_log, LOG_MODULE_IOTIVITY,
   "Failed sending buffer %u\n", message->length);
 } else {
 break;
@@ -130,7 +146,7 @@ oc_attempt_rx(struct mn_socket * rxsock) {
 oc_message_t *message = NULL;
 struct mn_sockaddr_in6 from;
 
-LOG_DEBUG(_log, LOG_MODULE_DEFAULT, "attempt rx from %u\n", rxsock);
+LOG_DEBUG(_log, LOG_MODULE_IOTIVITY, "attempt rx from %u\n", rxsock);
 
 rc= mn_recvfrom(rxsock, , (struct mn_sockaddr *) );
 
@@ -144,7 +160,7 @@ oc_attempt_rx(struct mn_socket * rxsock) {
 
 pkt = OS_MBUF_PKTHDR(m);
 
-LOG_DEBUG(_log, LOG_MODULE_DEFAULT,
+LOG_DEBUG(_log, LOG_MODULE_IOTIVITY,
   "rx from %u %p-%u\n", rxsock, pkt, pkt->omp_len);
 
 message = oc_allocate_message();
@@ -173,7 +189,7 @@ oc_attempt_rx(struct mn_socket * rxsock) {
 message->endpoint.ipv6_addr.scope = from.msin6_scope_id;
 message->endpoint.ipv6_addr.port = ntohs(from.msin6_port);
 
-LOG_INFO(_log, LOG_MODULE_DEFAULT, "rx from %u len %u\n",
+LOG_INFO(_log, LOG_MODULE_IOTIVITY, "rx from %u len %u\n",
  rxsock, message->length);
 
 return message;
@@ -245,21 +261,21 @@ oc_init_net_task(void) {
 /* start this thing running to check right away */
 rc = os_sem_init(_read_sem, 1);
 if (0 != rc) {
-LOG_ERROR(_log, LOG_MODULE_DEFAULT,
+LOG_ERROR(_log, LOG_MODULE_IOTIVITY,
   "Could not initialize oc read sem\n");
 return rc;
 }
 
 rc = os_sem_init(_write_sem, 1);
 if (0 != rc) {
-LOG_ERROR(_log, LOG_MODULE_DEFAULT,
+LOG_ERROR(_log, LOG_MODULE_IOTIVITY,
   "Could not initialize oc write sem\n");
 return rc;
 }
 

[2/3] incubator-mynewt-core git commit: fix logging so that we use printf during sim, and use logs when debug is defined

2016-09-21 Thread paulfdietrich
fix logging so that we use printf during sim, and use logs when debug is defined


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/29a11be7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/29a11be7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/29a11be7

Branch: refs/heads/develop
Commit: 29a11be746551e3c2b8c8f17407274669d739b5b
Parents: 7f682f6
Author: Paul Dietrich 
Authored: Fri Sep 16 15:54:27 2016 -0700
Committer: Paul Dietrich 
Committed: Wed Sep 21 10:48:28 2016 -0700

--
 libs/iotivity/pkg.yml  |  1 +
 libs/iotivity/src/port/mynewt/ip_adaptor.c | 79 +++--
 libs/iotivity/src/port/mynewt/log.c| 43 ++
 libs/iotivity/src/port/oc_log.h| 27 -
 4 files changed, 90 insertions(+), 60 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/29a11be7/libs/iotivity/pkg.yml
--
diff --git a/libs/iotivity/pkg.yml b/libs/iotivity/pkg.yml
index e5c95fb..87b4b45 100644
--- a/libs/iotivity/pkg.yml
+++ b/libs/iotivity/pkg.yml
@@ -29,6 +29,7 @@ pkg.deps:
 - "@apache-mynewt-core/sys/mn_socket"
 - "@apache-mynewt-core/sys/log"
 
+# remove debug option to save logging 
 pkg.cflags: -std=c99
 -DDEBUG=1
 -DSECURE=0

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/29a11be7/libs/iotivity/src/port/mynewt/ip_adaptor.c
--
diff --git a/libs/iotivity/src/port/mynewt/ip_adaptor.c 
b/libs/iotivity/src/port/mynewt/ip_adaptor.c
index dfb1f9c..9b8bbff 100644
--- a/libs/iotivity/src/port/mynewt/ip_adaptor.c
+++ b/libs/iotivity/src/port/mynewt/ip_adaptor.c
@@ -27,6 +27,7 @@
 #include "../oc_network_events_mutex.h"
 #include "../oc_connectivity.h"
 #include "oc_buffer.h"
+#include "../oc_log.h"
 
 #ifdef OC_SECURITY
 #error This implementation does not yet support security
@@ -53,29 +54,6 @@ struct mn_socket *ucast;
 struct os_sem oc_read_sem;
 struct os_sem oc_write_sem;
 
-/* logging data for this module. TODO, the application should
- * define the logging strategy for this module */
-#define MAX_CBMEM_BUF   (600)
-static uint32_t *cbmem_buf;
-static struct cbmem cbmem;
-struct log oc_log;
-
-static int oc_log_init(void) {
-
-log_init();
-
-cbmem_buf = malloc(sizeof(uint32_t) * MAX_CBMEM_BUF);
-if (cbmem_buf == NULL) {
-return -1;
-}
-
-cbmem_init(, cbmem_buf, MAX_CBMEM_BUF);
-log_register("iot", _log, _cbmem_handler, );
-
-LOG_INFO(_log, LOG_MODULE_IOTIVITY, "OC Init");
-return 0;
-}
-
 /* not sure if these semaphores are necessary yet.  If we are running
  * all of this from one task, we may not need these */
 static struct os_mutex oc_net_mutex;
@@ -109,8 +87,7 @@ oc_send_buffer(oc_message_t *message)
 int rc;
 
 while (1) {
-LOG_INFO(_log, LOG_MODULE_IOTIVITY,
- "attempt send buffer %u\n", message->length);
+LOG("attempt send buffer %lu\n", message->length);
 
 to.msin6_len = sizeof(to);
 to.msin6_family = MN_AF_INET6;
@@ -128,8 +105,7 @@ oc_send_buffer(oc_message_t *message)
 rc = mn_sendto(send_sock, , (struct mn_sockaddr *) );
 /* TODO what to do if this fails, we can't keep the buffer */
 if (rc != 0) {
-LOG_ERROR(_log, LOG_MODULE_IOTIVITY,
-  "Failed sending buffer %u\n", message->length);
+ERROR("Failed sending buffer %lu\n", message->length);
 } else {
 break;
 }
@@ -146,7 +122,7 @@ oc_attempt_rx(struct mn_socket * rxsock) {
 oc_message_t *message = NULL;
 struct mn_sockaddr_in6 from;
 
-LOG_DEBUG(_log, LOG_MODULE_IOTIVITY, "attempt rx from %u\n", rxsock);
+LOG("attempt rx from %p\n", rxsock);
 
 rc= mn_recvfrom(rxsock, , (struct mn_sockaddr *) );
 
@@ -160,23 +136,22 @@ oc_attempt_rx(struct mn_socket * rxsock) {
 
 pkt = OS_MBUF_PKTHDR(m);
 
-LOG_DEBUG(_log, LOG_MODULE_IOTIVITY,
-  "rx from %u %p-%u\n", rxsock, pkt, pkt->omp_len);
+LOG("rx from %p %p-%u\n", rxsock, pkt, pkt->omp_len);
 
 message = oc_allocate_message();
 if (NULL == message) {
-/* TODO log an error that we dropped a frame */
+ERROR("Could not allocate OC message buffer\n");
 goto rx_attempt_err;
 }
 
 if (pkt->omp_len > MAX_PAYLOAD_SIZE) {
-/* TODO what do we do with this */
+ERROR("Message to large for OC message buffer\n");
 goto rx_attempt_err;
 }
 /* copy to message from mbuf chain */
 rc = os_mbuf_copydata(m, 0, pkt->omp_len, 

incubator-mynewt-core git commit: basic test app working with the iotivity client that builds with their constrained github repo

2016-09-16 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop b359382d5 -> d27f1f309


basic test app working with the iotivity client that builds with their 
constrained github repo


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/d27f1f30
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/d27f1f30
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/d27f1f30

Branch: refs/heads/develop
Commit: d27f1f3095f34bb1b9261ea425db4e87c0e548af
Parents: b359382
Author: Paul Dietrich 
Authored: Fri Sep 16 10:36:53 2016 -0700
Committer: Paul Dietrich 
Committed: Fri Sep 16 13:41:36 2016 -0700

--
 apps/ocf_sample/pkg.yml |  36 
 apps/ocf_sample/src/main.c  | 198 +++
 libs/iotivity/include/iotivity/oc_api.h |   6 +-
 libs/iotivity/include/iotivity/oc_buffer.h  |   4 +-
 .../iotivity/include/iotivity/oc_client_state.h |   2 +-
 libs/iotivity/include/iotivity/oc_helpers.h |   4 +-
 .../include/iotivity/oc_network_events.h|   4 +-
 libs/iotivity/include/iotivity/oc_rep.h |   2 +-
 libs/iotivity/include/iotivity/oc_ri.h  |   6 +-
 libs/iotivity/src/messaging/coap/coap.h |  10 +-
 libs/iotivity/src/messaging/coap/conf.h |   2 +-
 libs/iotivity/src/messaging/coap/observe.h  |   4 +-
 libs/iotivity/src/messaging/coap/oc_coap.h  |   2 +-
 libs/iotivity/src/messaging/coap/separate.h |   2 +-
 libs/iotivity/src/messaging/coap/transactions.h |   2 +-
 libs/iotivity/src/port/mynewt/ip_adaptor.c  |  87 +---
 libs/iotivity/src/port/oc_assert.h  |   2 +-
 libs/iotivity/src/port/oc_clock.h   |   2 +-
 libs/iotivity/src/port/oc_connectivity.h|   8 +-
 libs/iotivity/src/util/oc_process.h |   2 +-
 libs/iotivity/src/util/oc_timer.h   |   2 +-
 21 files changed, 329 insertions(+), 58 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d27f1f30/apps/ocf_sample/pkg.yml
--
diff --git a/apps/ocf_sample/pkg.yml b/apps/ocf_sample/pkg.yml
new file mode 100644
index 000..32c96f2
--- /dev/null
+++ b/apps/ocf_sample/pkg.yml
@@ -0,0 +1,36 @@
+#
+# 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/ocf_sample
+pkg.type: app
+pkg.description: Example application which uses OCF iotivity.
+pkg.author: "Apache Mynewt "
+pkg.homepage: "http://mynewt.apache.org/;
+pkg.keywords:
+
+pkg.deps:
+- libs/console/full
+- libs/os
+- libs/shell
+- libs/util
+- sys/log
+- libs/iotivity
+
+# this tells the library that you intend to suppor the server functionality
+pkg.cflags: -DOC_SERVER
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d27f1f30/apps/ocf_sample/src/main.c
--
diff --git a/apps/ocf_sample/src/main.c b/apps/ocf_sample/src/main.c
new file mode 100644
index 000..4d90495
--- /dev/null
+++ b/apps/ocf_sample/src/main.c
@@ -0,0 +1,198 @@
+/**
+ * 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 

incubator-mynewt-core git commit: need to turn on c99 for iotivity

2016-09-16 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 0ae2adf14 -> 7541bded5


need to turn on c99 for iotivity


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/7541bded
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/7541bded
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/7541bded

Branch: refs/heads/develop
Commit: 7541bded5722d82e99594ac89a8e314b78870037
Parents: 0ae2adf
Author: Paul Dietrich 
Authored: Fri Sep 16 14:49:28 2016 -0700
Committer: Paul Dietrich 
Committed: Fri Sep 16 14:49:28 2016 -0700

--
 libs/iotivity/pkg.yml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7541bded/libs/iotivity/pkg.yml
--
diff --git a/libs/iotivity/pkg.yml b/libs/iotivity/pkg.yml
index c4bf8b2..e5c95fb 100644
--- a/libs/iotivity/pkg.yml
+++ b/libs/iotivity/pkg.yml
@@ -29,7 +29,8 @@ pkg.deps:
 - "@apache-mynewt-core/sys/mn_socket"
 - "@apache-mynewt-core/sys/log"
 
-pkg.cflags: -DDEBUG=1
+pkg.cflags: -std=c99
+-DDEBUG=1
 -DSECURE=0
 -I./port/mynewt
 -I../port/mynewt



incubator-mynewt-core git commit: fix codeing standards register for multicast on all interfaces `

2016-09-16 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop d27f1f309 -> 0ae2adf14


fix codeing standards
register for multicast on all interfaces
`


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/0ae2adf1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/0ae2adf1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/0ae2adf1

Branch: refs/heads/develop
Commit: 0ae2adf148456e98c162a98b320ff35edd2faf88
Parents: d27f1f3
Author: Paul Dietrich 
Authored: Fri Sep 16 14:14:04 2016 -0700
Committer: Paul Dietrich 
Committed: Fri Sep 16 14:14:04 2016 -0700

--
 libs/iotivity/src/port/mynewt/ip_adaptor.c | 54 -
 1 file changed, 26 insertions(+), 28 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0ae2adf1/libs/iotivity/src/port/mynewt/ip_adaptor.c
--
diff --git a/libs/iotivity/src/port/mynewt/ip_adaptor.c 
b/libs/iotivity/src/port/mynewt/ip_adaptor.c
index 494ae82..0b6fd1a 100644
--- a/libs/iotivity/src/port/mynewt/ip_adaptor.c
+++ b/libs/iotivity/src/port/mynewt/ip_adaptor.c
@@ -33,16 +33,12 @@
 #endif
 
 #define COAP_PORT_UNSECURED (5683)
+/* TODO use inet_pton when its available */
 const struct mn_in6_addr coap_all_nodes_v6 = {
 .s_addr = {0xFF,0x02,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFD}
 };
 
-/* TODO these should be defined elsewhere but they are here as stubs */
-#define MN_SOL_SOCKET (0)
-#define MN_SO_REUSEPORT (1)
-#define MN_SO_REUSEADDR (2)
-
 /* need a task to process OCF messages */
 #define OC_NET_TASK_STACK_SIZE  OS_STACK_ALIGN(300)
 #define OC_NET_TASK_PRIORITY(4)
@@ -131,7 +127,7 @@ oc_attempt_rx(struct mn_socket * rxsock) {
 int rc;
 struct os_mbuf *m = NULL;
 struct os_mbuf_pkthdr *pkt;
-oc_message_t *message;
+oc_message_t *message = NULL;
 struct mn_sockaddr_in6 from;
 
 LOG_DEBUG(_log, LOG_MODULE_DEFAULT, "attempt rx from %u\n", rxsock);
@@ -142,7 +138,7 @@ oc_attempt_rx(struct mn_socket * rxsock) {
 return NULL;
 }
 
-if(!OS_MBUF_IS_PKTHDR(m)) {
+if (!OS_MBUF_IS_PKTHDR(m)) {
 goto rx_attempt_err;
 }
 
@@ -184,7 +180,7 @@ oc_attempt_rx(struct mn_socket * rxsock) {
 
 /* add the addr info to the message */
 rx_attempt_err:
-if(m) {
+if (m) {
 os_mbuf_free_chain(m);
 }
 
@@ -225,10 +221,9 @@ oc_socks_writable(void *cb_arg, int err)
 os_sem_release(_write_sem);
 }
 
-
 void
 oc_task_handler(void *arg) {
-while(1) {
+while (1) {
 oc_message_t *pmsg;
 os_sem_pend(_read_sem, OS_TIMEOUT_NEVER);
 pmsg = oc_attempt_rx_ucast();
@@ -295,17 +290,19 @@ oc_connectivity_shutdown(void)
 }
 }
 
-
 int
 oc_connectivity_init(void)
 {
 int rc;
 struct mn_sockaddr_in6 sin;
+struct mn_itf itf;
+
+memset(, 0, sizeof(itf));
 
 log_init();
 
 cbmem_buf = malloc(sizeof(uint32_t) * MAX_CBMEM_BUF);
-if(cbmem_buf == NULL) {
+if (cbmem_buf == NULL) {
 return -1;
 }
 
@@ -343,32 +340,33 @@ oc_connectivity_init(void)
 goto oc_connectivity_init_err;
 }
 
-/* Set socket option to join multicast group */
-{
+/* Set socket option to join multicast group on all valid interfaces */
+while (1) {
 struct mn_mreq join;
 
+rc = mn_itf_getnext();
+if (rc) {
+break;
+}
+
+if (0 == (itf.mif_flags & MN_ITF_F_UP)) {
+continue;
+}
+
 join.mm_addr.v6 = coap_all_nodes_v6;
-join.mm_idx = 1;
+join.mm_idx = itf.mif_idx;
 join.mm_family = MN_AF_INET6;
 
 rc = mn_setsockopt(mcast, MN_SO_LEVEL, MN_MCAST_JOIN_GROUP, );
 if (rc != 0) {
-goto oc_connectivity_init_err;
+LOG_ERROR(_log, LOG_MODULE_DEFAULT,
+ "Could not join multicast group on %s\n", itf.mif_name);
+continue;
 }
-}
-
-#if 0
-int reuse = 1;
-rc = mn_setsockopt(mcast, MN_SOL_SOCKET, MN_SO_REUSEADDR, );
-if (rc != 0) {
-goto oc_connectivity_init_err;
-}
 
-rc = mn_setsockopt(mcast, MN_SOL_SOCKET, MN_SO_REUSEPORT, );
-if (rc != 0) {
-goto oc_connectivity_init_err;
+LOG_INFO(_log, LOG_MODULE_DEFAULT,
+  "Joined Coap multicast grop on %s\n", itf.mif_name);
 }
-#endif
 
 sin.msin6_port = htons(COAP_PORT_UNSECURED);
 rc = mn_bind(mcast, (struct mn_sockaddr *));



incubator-mynewt-core git commit: changes to support split images on nrf51dk

2016-08-26 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 079026143 -> 6d6d3210b


changes to support split images on nrf51dk

This is a good example of what you need to do to support split images.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/6d6d3210
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/6d6d3210
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/6d6d3210

Branch: refs/heads/develop
Commit: 6d6d3210ba5628702fd50315e896b6c53ecb1aa8
Parents: 0790261
Author: Paul Dietrich 
Authored: Fri Aug 26 17:09:25 2016 -0700
Committer: Paul Dietrich 
Committed: Fri Aug 26 17:10:22 2016 -0700

--
 apps/splitty/src/main.c |   2 +-
 hw/bsp/nrf51dk/nrf51dk_download.sh  |  17 +-
 hw/bsp/nrf51dk/pkg.yml  |   1 +
 hw/bsp/nrf51dk/split-nrf51dk.ld | 185 +++
 .../src/arch/cortex_m0/gcc_startup_nrf51.s  |   5 +
 .../arch/cortex_m0/gcc_startup_nrf51_split.s| 168 +
 hw/bsp/nrf51dk/src/os_bsp.c |   8 +-
 hw/bsp/nrf51dk/src/sbrk.c   |  18 +-
 8 files changed, 395 insertions(+), 9 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d6d3210/apps/splitty/src/main.c
--
diff --git a/apps/splitty/src/main.c b/apps/splitty/src/main.c
index 838a4a7..682acfe 100755
--- a/apps/splitty/src/main.c
+++ b/apps/splitty/src/main.c
@@ -119,7 +119,7 @@ static struct conf_fcb my_conf = {
 #endif
 
 #define DEFAULT_MBUF_MPOOL_BUF_LEN (256)
-#define DEFAULT_MBUF_MPOOL_NBUFS (10)
+#define DEFAULT_MBUF_MPOOL_NBUFS (9)
 
 static uint8_t default_mbuf_mpool_data[DEFAULT_MBUF_MPOOL_BUF_LEN *
 DEFAULT_MBUF_MPOOL_NBUFS];

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d6d3210/hw/bsp/nrf51dk/nrf51dk_download.sh
--
diff --git a/hw/bsp/nrf51dk/nrf51dk_download.sh 
b/hw/bsp/nrf51dk/nrf51dk_download.sh
index 2ee17e9..249cb55 100755
--- a/hw/bsp/nrf51dk/nrf51dk_download.sh
+++ b/hw/bsp/nrf51dk/nrf51dk_download.sh
@@ -29,8 +29,14 @@ if [ $# -lt 2 ]; then
 exit 1
 fi
 
+if [ $# -lt 3 ]; then
+echo "Need image slot to download"
+exit 1
+fi
+
 IS_BOOTLOADER=0
 BASENAME=$2
+IMAGE_SLOT=$3
 #JLINK_SCRIPT=.download.jlink
 GDB_CMD_FILE=.gdb_cmds
 
@@ -47,17 +53,24 @@ done
 if [ $IS_BOOTLOADER -eq 1 ]; then
 FLASH_OFFSET=0x0
 FILE_NAME=$BASENAME.elf.bin
-else
+elif [ $IMAGE_SLOT -eq 0 ]; then
 FLASH_OFFSET=0x8000
 FILE_NAME=$BASENAME.img
+elif [ $IMAGE_SLOT -eq 1 ]; then
+FLASH_OFFSET=0x23800
+FILE_NAME=$BASENAME.img
+else
+echo "Invalid Image Slot Number: $IMAGE_SLOT"
+exit 1
 fi
 
+
 echo "Downloading" $FILE_NAME "to" $FLASH_OFFSET
 
 # XXX for some reason JLinkExe overwrites flash at offset 0 when
 # downloading somewhere in the flash. So need to figure out how to tell it
 # not to do that, or report failure if gdb fails to write this file
-# 
+#
 echo "shell /bin/sh -c 'trap \"\" 2;JLinkGDBServer -device nRF51422_xxAC 
-speed 4000 -if SWD -port  -singlerun' & " > $GDB_CMD_FILE
 echo "target remote localhost:" >> $GDB_CMD_FILE
 echo "restore $FILE_NAME binary $FLASH_OFFSET" >> $GDB_CMD_FILE

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d6d3210/hw/bsp/nrf51dk/pkg.yml
--
diff --git a/hw/bsp/nrf51dk/pkg.yml b/hw/bsp/nrf51dk/pkg.yml
index 4a1a93b..56de75a 100644
--- a/hw/bsp/nrf51dk/pkg.yml
+++ b/hw/bsp/nrf51dk/pkg.yml
@@ -30,6 +30,7 @@ pkg.arch: cortex_m0
 pkg.compiler: compiler/arm-none-eabi-m0
 pkg.linkerscript: "nrf51dk.ld"
 pkg.linkerscript.bootloader.OVERWRITE: "boot-nrf51dk.ld"
+pkg.part2linkerscript: "split-nrf51dk.ld"
 pkg.downloadscript: nrf51dk_download.sh
 pkg.debugscript: nrf51dk_debug.sh
 pkg.cflags: -DNRF51 -DBSP_HAS_32768_XTAL

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6d6d3210/hw/bsp/nrf51dk/split-nrf51dk.ld
--
diff --git a/hw/bsp/nrf51dk/split-nrf51dk.ld b/hw/bsp/nrf51dk/split-nrf51dk.ld
new file mode 100755
index 000..bd8c2be
--- /dev/null
+++ b/hw/bsp/nrf51dk/split-nrf51dk.ld
@@ -0,0 +1,185 @@
+/* Linker script for Nordic Semiconductor nRF5 devices
+ *
+ * Version: Sourcery G++ 4.5-1
+ * Support: https://support.codesourcery.com/GNUToolchain/
+ *
+ * Copyright (c) 2007, 2008, 2009, 2010 CodeSourcery, Inc.
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its 

[GitHub] incubator-mynewt-site pull request #112: add documentation for split images

2016-08-26 Thread paulfdietrich
GitHub user paulfdietrich opened a pull request:

https://github.com/apache/incubator-mynewt-site/pull/112

add documentation for split images

Here is documentation for the split image design and usage

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/paulfdietrich/incubator-mynewt-site MYNEWT-317

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-mynewt-site/pull/112.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #112


commit d8bcd01735b5b5f48f99591b68b805014266a438
Author: Paul Dietrich <paulfdietr...@yahoo.com>
Date:   2016-08-26T21:04:16Z

add documentation for split images




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[4/6] incubator-mynewt-core git commit: this file needs to be consistent with the one in full. They had different names

2016-09-26 Thread paulfdietrich
this file needs to be consistent with the one in full.  They had different names


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/6aea7128
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/6aea7128
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/6aea7128

Branch: refs/heads/develop
Commit: 6aea7128449ec463ee80d0740a9a572bc8439c4a
Parents: f5df33c
Author: Paul Dietrich 
Authored: Wed Sep 21 17:07:41 2016 -0700
Committer: Paul Dietrich 
Committed: Mon Sep 26 10:41:37 2016 -0700

--
 libs/console/stub/include/console/prompt.h | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6aea7128/libs/console/stub/include/console/prompt.h
--
diff --git a/libs/console/stub/include/console/prompt.h 
b/libs/console/stub/include/console/prompt.h
index 9d7f622..a1d72c9 100644
--- a/libs/console/stub/include/console/prompt.h
+++ b/libs/console/stub/include/console/prompt.h
@@ -17,8 +17,9 @@
  * under the License.
  */
 
-#ifndef H_CONSOLE_PROMPT_
-#define H_CONSOLE_PROMPT_
+#ifndef __CONSOLE_PROMPT_H__
+#define __CONSOLE_PROMPT_H__
+nclude/console/prompt.h
 
 #include 
 
@@ -31,4 +32,4 @@ void console_set_prompt(char);
 extern char console_prompt[2];
 
 
-#endif /* __CONSOLE_H__ */
+#endif /* __CONSOLE_PROMPT_H__ */



[2/6] incubator-mynewt-core git commit: get the client gatt to compile (not tested yet)

2016-09-26 Thread paulfdietrich
get the client gatt to compile (not tested yet)


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/5b51d6b1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/5b51d6b1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/5b51d6b1

Branch: refs/heads/develop
Commit: 5b51d6b1c31dc1e36ffd0fe2b4d535a2282ad8dc
Parents: afeca1a
Author: Paul Dietrich 
Authored: Mon Sep 26 10:39:06 2016 -0700
Committer: Paul Dietrich 
Committed: Mon Sep 26 10:41:37 2016 -0700

--
 apps/ocf_sample/src/main.c  |  4 +++
 libs/iotivity/src/port/mynewt/ble_adaptor.c | 31 +---
 2 files changed, 26 insertions(+), 9 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5b51d6b1/apps/ocf_sample/src/main.c
--
diff --git a/apps/ocf_sample/src/main.c b/apps/ocf_sample/src/main.c
index 9c5ccb2..e767dce 100644
--- a/apps/ocf_sample/src/main.c
+++ b/apps/ocf_sample/src/main.c
@@ -395,6 +395,10 @@ main(int argc, char **argv)
 rc = ble_coap_gatt_srv_init(, );
 assert(rc == 0);
 
+#ifdef OC_CLIENT
+/* TODO INIT CLIENT */
+#endif
+
 rc = ble_hs_init(ev, );
 assert(rc == 0);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5b51d6b1/libs/iotivity/src/port/mynewt/ble_adaptor.c
--
diff --git a/libs/iotivity/src/port/mynewt/ble_adaptor.c 
b/libs/iotivity/src/port/mynewt/ble_adaptor.c
index 0328940..f6a2925 100644
--- a/libs/iotivity/src/port/mynewt/ble_adaptor.c
+++ b/libs/iotivity/src/port/mynewt/ble_adaptor.c
@@ -168,6 +168,20 @@ oc_gatt_advertise(void)
 #endif
 
 #ifdef OC_CLIENT
+static char *
+addr_str(const void *addr)
+{
+static char buf[6 * 2 + 5 + 1];
+const uint8_t *u8p;
+
+u8p = addr;
+sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
+u8p[5], u8p[4], u8p[3], u8p[2], u8p[1], u8p[0]);
+
+return buf;
+}
+
+
 /**
  * Indicates whether we should tre to connect to the sender of the specified
  * advertisement.  The function returns a positive result if the device
@@ -187,9 +201,9 @@ oc_gatt_should_connect(const struct ble_gap_disc_desc *disc)
 
 /* The device has to advertise support for the COAP service
  */
-for
 for (i = 0; i < disc->fields->num_uuids128; i++) {
-if (disc->fields->uuids128[i] == gatt_svr_svc_coap) {
+char *ptr = ((char*) disc->fields->uuids128) + 16 * i;
+if (memcmp(ptr, gatt_svr_svc_coap, sizeof(gatt_svr_svc_coap)) == 0) {
 return 1;
 }
 }
@@ -259,7 +273,7 @@ oc_gatt_scan(void)
 disc_params.limited = 0;
 
 rc = ble_gap_disc(BLE_ADDR_TYPE_PUBLIC, BLE_HS_FOREVER, _params,
-  blecent_gap_event, NULL);
+  blecoap_gap_event, NULL);
 if (rc != 0) {
 ERROR("Error initiating GAP discovery procedure; rc=%d\n",
 rc);
@@ -347,7 +361,7 @@ blecoap_gap_event(struct ble_gap_event *event, void *arg)
 #ifdef OC_CLIENT
 case BLE_GAP_EVENT_DISC:
 /* Try to connect to the advertiser if it looks interesting. */
-blecent_connect_if_interesting(>disc);
+oc_gatt_connect_if_interesting(>disc);
 return 0;
 #endif
 case BLE_GAP_EVENT_CONNECT:
@@ -389,14 +403,11 @@ blecoap_gap_event(struct ble_gap_event *event, void *arg)
 return 0;
 }
 
-#ifdef OC_SERVER
 int
 ble_coap_gatt_srv_init(struct ble_hs_cfg *cfg, struct os_eventq **out)
 {
+#ifdef OC_SERVER
 int rc;
-
-*out = _event_q;
-
 rc = ble_gatts_count_cfg(gatt_svr_svcs, cfg);
 if (rc != 0) {
 return rc;
@@ -406,9 +417,11 @@ ble_coap_gatt_srv_init(struct ble_hs_cfg *cfg, struct 
os_eventq **out)
 if (rc != 0) {
 return rc;
 }
+#endif
+
+*out = _event_q;
 return 0;
 }
-#endif
 
 int oc_connectivity_init_gatt(void) {
 os_mqueue_init(_coap_mq, NULL);



[3/6] incubator-mynewt-core git commit: working BLE COAP GATT server side.

2016-09-26 Thread paulfdietrich
working BLE COAP GATT server side.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/afeca1aa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/afeca1aa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/afeca1aa

Branch: refs/heads/develop
Commit: afeca1aaecab156dc69fc96782cef9ff5dea0d18
Parents: 7c30b04
Author: Paul Dietrich 
Authored: Mon Sep 26 10:03:34 2016 -0700
Committer: Paul Dietrich 
Committed: Mon Sep 26 10:41:37 2016 -0700

--
 apps/ocf_sample/src/main.c  | 11 +--
 libs/iotivity/src/port/mynewt/adaptor.c |  2 +-
 libs/iotivity/src/port/mynewt/ble_adaptor.c | 14 +++---
 3 files changed, 21 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/afeca1aa/apps/ocf_sample/src/main.c
--
diff --git a/apps/ocf_sample/src/main.c b/apps/ocf_sample/src/main.c
index 17d0f6a..9c5ccb2 100644
--- a/apps/ocf_sample/src/main.c
+++ b/apps/ocf_sample/src/main.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include "mn_socket/mn_socket.h"
 #include "mn_socket/arch/sim/native_sock.h"
@@ -74,7 +75,13 @@ static os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
 static os_stack_t ocf_stack[OCF_TASK_STACK_SIZE];
 struct os_task ocf_task;
 
-#define DEFAULT_MBUF_MPOOL_BUF_LEN OS_ALIGN(BLE_MBUF_PAYLOAD_SIZE, 4)
+#ifdef OC_TRANSPORT_GATT
+#define MBUF_PAYLOAD_SIZE BLE_MBUF_PAYLOAD_SIZE
+#else
+#define MBUF_PAYLOAD_SIZE 128
+#endif
+
+#define DEFAULT_MBUF_MPOOL_BUF_LEN OS_ALIGN(MBUF_PAYLOAD_SIZE, 4)
 #define DEFAULT_MBUF_MPOOL_NBUFS (12)
 
 static uint8_t default_mbuf_mpool_data[DEFAULT_MBUF_MPOOL_BUF_LEN *
@@ -306,8 +313,8 @@ int
 main(int argc, char **argv)
 {
 int rc;
-struct os_eventq *ev;
 #ifdef OC_TRANSPORT_GATT
+struct os_eventq *ev;
 struct ble_hci_ram_cfg hci_cfg;
 struct ble_hs_cfg cfg;
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/afeca1aa/libs/iotivity/src/port/mynewt/adaptor.c
--
diff --git a/libs/iotivity/src/port/mynewt/adaptor.c 
b/libs/iotivity/src/port/mynewt/adaptor.c
index 7c2925b..144ef9b 100644
--- a/libs/iotivity/src/port/mynewt/adaptor.c
+++ b/libs/iotivity/src/port/mynewt/adaptor.c
@@ -143,12 +143,12 @@ oc_task_handler(void *arg) {
 oc_network_event(pmsg);
 }
 break;
+#endif
 case OS_EVENT_T_TIMER:
 cf = (struct os_callout_func *)evt;
 assert(cf->cf_func);
 cf->cf_func(CF_ARG(cf));
 break;
-#endif
 default:
 ERROR("oc_task_handler: Unidentified event %d\n", 
evt->ev_type);
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/afeca1aa/libs/iotivity/src/port/mynewt/ble_adaptor.c
--
diff --git a/libs/iotivity/src/port/mynewt/ble_adaptor.c 
b/libs/iotivity/src/port/mynewt/ble_adaptor.c
index edca8a0..0328940 100644
--- a/libs/iotivity/src/port/mynewt/ble_adaptor.c
+++ b/libs/iotivity/src/port/mynewt/ble_adaptor.c
@@ -26,6 +26,8 @@
 #include "services/gap/ble_svc_gap.h"
 #include "services/gatt/ble_svc_gatt.h"
 
+#ifdef OC_TRANSPORT_GATT
+
 /* a custom service for COAP over GATT */
 /* {e3f9f9c4-8a83-4055-b647-728b769745d6} */
 const uint8_t gatt_svr_svc_coap[16] = {
@@ -62,7 +64,7 @@ static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
 /* Characteristic: Write No Rsp */
 .uuid128 = (void *)gatt_svr_chr_coap,
 .access_cb = gatt_svr_chr_access_coap,
-.flags = BLE_GATT_CHR_F_WRITE_NO_RSP,
+.flags = BLE_GATT_CHR_F_WRITE_NO_RSP | BLE_GATT_CHR_F_NOTIFY,
 .val_handle = _ble_coap_attr_handle,
 }, {
 0, /* No more characteristics in this service */
@@ -459,13 +461,17 @@ void oc_send_buffer_gatt(oc_message_t *message)
 ERROR("oc_transport_gatt: could not append data \n");
 goto err;
 }
+
 #ifdef OC_CLIENT
-/* TODO */
+ERROR("send not supported on client");
 #endif
+
 #ifdef OC_SERVER
 ble_gattc_notify_custom(message->endpoint.bt_addr.conn_handle,
 g_ble_coap_attr_handle, m);
+m = NULL;
 #endif
+
 err:
 if (m) {
 os_mbuf_free_chain(m);
@@ -478,9 +484,11 @@ void
 oc_send_buffer_gatt_mcast(oc_message_t *message)
 {
 #ifdef OC_CLIENT
-/* TODO */
+ERROR("send not supported on client");
 #elif defined(OC_SERVER)
 oc_message_unref(message);
 ERROR("oc_transport_gatt: no multicast support 

[5/6] incubator-mynewt-core git commit: partially working gatt coap service

2016-09-26 Thread paulfdietrich
partially working gatt coap service


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/7c30b040
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/7c30b040
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/7c30b040

Branch: refs/heads/develop
Commit: 7c30b040bc6a3de9a7a97ab1557f3e366a69f8b0
Parents: 6aea712
Author: Paul Dietrich 
Authored: Fri Sep 23 16:08:44 2016 -0700
Committer: Paul Dietrich 
Committed: Mon Sep 26 10:41:37 2016 -0700

--
 apps/ocf_sample/pkg.yml |   9 +-
 apps/ocf_sample/src/main.c  | 109 -
 libs/console/full/src/cons_tty.c|   2 +-
 libs/iotivity/include/iotivity/oc_gatt.h|  38 ++
 libs/iotivity/pkg.yml   |   5 +-
 libs/iotivity/src/port/mynewt/adaptor.c |  15 +-
 libs/iotivity/src/port/mynewt/adaptor.h |   3 +
 libs/iotivity/src/port/mynewt/ble_adaptor.c | 468 +++
 libs/iotivity/src/port/mynewt/serial_adaptor.c  |   1 +
 libs/iotivity/src/port/oc_connectivity.h|   1 +
 .../transport/ble/include/nmgrble/newtmgr_ble.h |   1 +
 11 files changed, 636 insertions(+), 16 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7c30b040/apps/ocf_sample/pkg.yml
--
diff --git a/apps/ocf_sample/pkg.yml b/apps/ocf_sample/pkg.yml
index 52858b5..bf9b362 100644
--- a/apps/ocf_sample/pkg.yml
+++ b/apps/ocf_sample/pkg.yml
@@ -31,11 +31,16 @@ pkg.deps:
 - libs/util
 - sys/log
 - libs/iotivity
-
+- "@apache-mynewt-core/net/nimble/host"
+- "@apache-mynewt-core/net/nimble/controller"
+- "@apache-mynewt-core/net/nimble/transport/ram"
+- "@apache-mynewt-core/net/nimble/host/store/ram"
+- "@apache-mynewt-core/net/nimble/host/services/gap"
+- "@apache-mynewt-core/net/nimble/host/services/gatt"
 # this tells the library that you intend to suppor the server functionality
 pkg.cflags:
 
-#-DOC_SERVER -- build the server examples 
+#-DOC_SERVER -- build the server examples
 #-DOC_CLIENT -- build the client examples
 #-DOC_TRANSPORT_GATT -- to send COAP over GATT
 #-DOC_TRANSPORT_SERIAL -- to send COAP over serial

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7c30b040/apps/ocf_sample/src/main.c
--
diff --git a/apps/ocf_sample/src/main.c b/apps/ocf_sample/src/main.c
index ebe9988..17d0f6a 100644
--- a/apps/ocf_sample/src/main.c
+++ b/apps/ocf_sample/src/main.c
@@ -23,24 +23,59 @@
 #include 
 #include 
 #include 
-
 #include 
 #include "mn_socket/mn_socket.h"
 #include "mn_socket/arch/sim/native_sock.h"
 
+#ifdef OC_TRANSPORT_GATT
+
+#include 
+
+/* BLE */
+#include "nimble/ble.h"
+#include "host/ble_hs.h"
+#include "host/ble_hs_adv.h"
+#include "host/ble_uuid.h"
+#include "host/ble_att.h"
+#include "host/ble_gap.h"
+#include "host/ble_gatt.h"
+#include "host/ble_l2cap.h"
+#include "host/ble_sm.h"
+#include "controller/ble_ll.h"
+
+/* RAM HCI transport. */
+#include "transport/ram/ble_hci_ram.h"
+
+/* RAM persistence layer. */
+#include "store/ram/ble_store_ram.h"
+
+/* Mandatory services. */
+#include "services/gap/ble_svc_gap.h"
+#include "services/gatt/ble_svc_gatt.h"
+
+uint8_t g_random_addr[6] = {6,5,4,3,2,1};
+uint8_t g_dev_addr[6] = {1,2,3,4,5,6};
+
+/** Priority of the nimble host and controller tasks. */
+#define BLE_LL_TASK_PRI (OS_TASK_PRI_HIGHEST)
+
+#endif
+
 /* Shell */
+#ifdef OC_TRANSPORT_SERIAL
 #define SHELL_TASK_PRIO (8)
 #define SHELL_MAX_INPUT_LEN (512)
 #define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(2048))
 static os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
+#endif
 
 #define OCF_TASK_PRIO  (8)
 #define OCF_TASK_STACK_SIZE (OS_STACK_ALIGN(2048))
 static os_stack_t ocf_stack[OCF_TASK_STACK_SIZE];
 struct os_task ocf_task;
 
-#define DEFAULT_MBUF_MPOOL_BUF_LEN (256)
-#define DEFAULT_MBUF_MPOOL_NBUFS (10)
+#define DEFAULT_MBUF_MPOOL_BUF_LEN OS_ALIGN(BLE_MBUF_PAYLOAD_SIZE, 4)
+#define DEFAULT_MBUF_MPOOL_NBUFS (12)
 
 static uint8_t default_mbuf_mpool_data[DEFAULT_MBUF_MPOOL_BUF_LEN *
 DEFAULT_MBUF_MPOOL_NBUFS];
@@ -238,8 +273,6 @@ oc_signal_main_loop(void) {
 }
 
 void ocf_task_handler(void *arg) {
-/* TODO */
-oc_main_init(_handler);
 
 os_sem_init(_main_loop_sem, 1);
 
@@ -265,16 +298,27 @@ ocf_task_init(void) {
 rc = os_task_init(_task, "ocf", ocf_task_handler, NULL,
 OCF_TASK_PRIO, OS_WAIT_FOREVER, ocf_stack, OCF_TASK_STACK_SIZE);
 assert(rc == 0);
+
+oc_main_init(_handler);
 }
 
 int
 main(int argc, char **argv)
 {
 int rc;
-
+struct 

[1/6] incubator-mynewt-core git commit: finished serial server example for ocf

2016-09-26 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 8999db3dc -> b98fe7095


finished serial server example for ocf

To replicate, create two targets

targets/ocf_server_ser
app=@apache-mynewt-core/apps/ocf_sample
bsp=@apache-mynewt-core/hw/bsp/native
build_profile=debug
cflags=-DOC_SERVER -DOC_TRANSPORT_SERIAL

targets/ocf_client_ser
app=@apache-mynewt-core/apps/ocf_sample
bsp=@apache-mynewt-core/hw/bsp/native
build_profile=debug
cflags=-DOC_CLIENT -DOC_TRANSPORT_SERIAL

Run them (via the debugger) and use socat to connect their serial ports

socat -x /dev/ttys004,raw,echo=0 /dev/ttys006,raw,echo=0

You should see the client discover the server and then request obsevations on 
the client.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/f5df33ce
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f5df33ce
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f5df33ce

Branch: refs/heads/develop
Commit: f5df33ce1bd069c72431342ed096a6415ad06f1a
Parents: 8999db3
Author: Paul Dietrich 
Authored: Wed Sep 21 16:56:45 2016 -0700
Committer: Paul Dietrich 
Committed: Mon Sep 26 10:40:17 2016 -0700

--
 apps/ocf_sample/src/main.c |  8 +++-
 libs/console/full/include/console/prompt.h |  2 ++
 libs/console/full/src/cons_tty.c   |  1 +
 libs/console/full/src/prompt.c | 10 +-
 libs/iotivity/src/port/mynewt/serial_adaptor.c | 16 
 5 files changed, 31 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f5df33ce/apps/ocf_sample/src/main.c
--
diff --git a/apps/ocf_sample/src/main.c b/apps/ocf_sample/src/main.c
index 78846d2..ebe9988 100644
--- a/apps/ocf_sample/src/main.c
+++ b/apps/ocf_sample/src/main.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -29,7 +30,7 @@
 
 /* Shell */
 #define SHELL_TASK_PRIO (8)
-#define SHELL_MAX_INPUT_LEN (256)
+#define SHELL_MAX_INPUT_LEN (512)
 #define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(2048))
 static os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
 
@@ -286,6 +287,11 @@ main(int argc, char **argv)
 rc = os_msys_register(_mbuf_pool);
 assert(rc == 0);
 
+#ifdef OC_TRANSPORT_SERIAL
+console_echo(0);
+console_no_prompt();
+#endif
+
 /* Init tasks */
 rc = shell_task_init(SHELL_TASK_PRIO, shell_stack, SHELL_TASK_STACK_SIZE,
  SHELL_MAX_INPUT_LEN);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f5df33ce/libs/console/full/include/console/prompt.h
--
diff --git a/libs/console/full/include/console/prompt.h 
b/libs/console/full/include/console/prompt.h
index f930879..849ec7e 100644
--- a/libs/console/full/include/console/prompt.h
+++ b/libs/console/full/include/console/prompt.h
@@ -28,4 +28,6 @@ void console_print_prompt();
 /* set the console prompt character */
 void console_set_prompt(char);
 
+void console_no_prompt(void);
+
 #endif /* __CONSOLE_PROMPT_H__ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f5df33ce/libs/console/full/src/cons_tty.c
--
diff --git a/libs/console/full/src/cons_tty.c b/libs/console/full/src/cons_tty.c
index db8c88e..412f93c 100644
--- a/libs/console/full/src/cons_tty.c
+++ b/libs/console/full/src/cons_tty.c
@@ -282,6 +282,7 @@ console_rx_char(void *arg, uint8_t data)
 /* echo */
 switch (data) {
 case '\r':
+break;
 case '\n':
 /*
  * linefeed

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f5df33ce/libs/console/full/src/prompt.c
--
diff --git a/libs/console/full/src/prompt.c b/libs/console/full/src/prompt.c
index 5a811bf..3806310 100644
--- a/libs/console/full/src/prompt.c
+++ b/libs/console/full/src/prompt.c
@@ -23,18 +23,26 @@
 
 /* console prompt, always followed by a space */
 static char console_prompt[] = " > ";
+static char do_prompt = 1;
 
 
 /* set the prompt character, leave the space */
 void
 console_set_prompt(char p)
 {
+do_prompt = 1;
 console_prompt[1] = p;
 }
 
+void console_no_prompt(void) {
+do_prompt = 0;
+}
+
 /* print the prompt to the console */
 void
 console_print_prompt(void)
 {
-console_printf("%s", console_prompt);
+if (do_prompt) {
+console_printf("%s", console_prompt);
+}
 }


[6/6] incubator-mynewt-core git commit: refactor iotivity to match new sysconfig interfaces. retested serial, IP, and gatt server. gat client is still not working

2016-09-26 Thread paulfdietrich
refactor iotivity to match new sysconfig interfaces.
retested serial, IP, and gatt server.  gat client is still not working


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/b98fe709
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/b98fe709
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/b98fe709

Branch: refs/heads/develop
Commit: b98fe70953d6fc68d06da8c861d17d2ff720b578
Parents: 5b51d6b
Author: Paul Dietrich 
Authored: Mon Sep 26 15:13:47 2016 -0700
Committer: Paul Dietrich 
Committed: Mon Sep 26 15:13:47 2016 -0700

--
 apps/ocf_sample/pkg.yml|  23 +--
 apps/ocf_sample/src/main.c | 163 
 libs/console/full/pkg.yml  |   8 +
 libs/console/full/src/cons_tty.c   |   2 +
 libs/console/full/src/prompt.c |   3 +-
 libs/iotivity/include/iotivity/oc_api.h|   1 +
 libs/iotivity/include/iotivity/oc_gatt.h   |   2 +-
 libs/iotivity/pkg.yml  |  40 -
 libs/iotivity/src/port/mynewt/adaptor.c|  39 ++---
 libs/iotivity/src/port/mynewt/adaptor.h|   6 +-
 libs/iotivity/src/port/mynewt/ble_adaptor.c|  38 ++---
 libs/iotivity/src/port/mynewt/config.h |  18 ++-
 libs/iotivity/src/port/mynewt/ip_adaptor.c |  14 +-
 libs/iotivity/src/port/mynewt/serial_adaptor.c |   4 +-
 14 files changed, 157 insertions(+), 204 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b98fe709/apps/ocf_sample/pkg.yml
--
diff --git a/apps/ocf_sample/pkg.yml b/apps/ocf_sample/pkg.yml
index bf9b362..3abca7e 100644
--- a/apps/ocf_sample/pkg.yml
+++ b/apps/ocf_sample/pkg.yml
@@ -25,23 +25,16 @@ pkg.homepage: "http://mynewt.apache.org/;
 pkg.keywords:
 
 pkg.deps:
-- libs/console/full
 - libs/os
-- libs/shell
 - libs/util
 - sys/log
 - libs/iotivity
-- "@apache-mynewt-core/net/nimble/host"
-- "@apache-mynewt-core/net/nimble/controller"
-- "@apache-mynewt-core/net/nimble/transport/ram"
-- "@apache-mynewt-core/net/nimble/host/store/ram"
-- "@apache-mynewt-core/net/nimble/host/services/gap"
-- "@apache-mynewt-core/net/nimble/host/services/gatt"
-# this tells the library that you intend to suppor the server functionality
-pkg.cflags:
 
-#-DOC_SERVER -- build the server examples
-#-DOC_CLIENT -- build the client examples
-#-DOC_TRANSPORT_GATT -- to send COAP over GATT
-#-DOC_TRANSPORT_SERIAL -- to send COAP over serial
-#-DOC_TRANSPORT_IP -- to send COAP over IP ßß
\ No newline at end of file
+pkg.deps.OC_TRANSPORT_SERIAL:
+- libs/shell
+- libs/console/full
+
+pkg.deps.OC_TRANSPORT_GATT:
+- net/nimble/controller
+- net/nimble/transport/ram
+- net/nimble/host/store/ram

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b98fe709/apps/ocf_sample/src/main.c
--
diff --git a/apps/ocf_sample/src/main.c b/apps/ocf_sample/src/main.c
index e767dce..948408b 100644
--- a/apps/ocf_sample/src/main.c
+++ b/apps/ocf_sample/src/main.c
@@ -19,82 +19,40 @@
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
 #include 
 #include 
 #include 
+
+#if (MYNEWT_VAL(OC_TRANSPORT_SERIAL) == 1)
+#include 
+#include 
+#include 
+#endif
+
+#if (MYNEWT_VAL(OC_TRANSPORT_IP) == 1)
 #include "mn_socket/mn_socket.h"
 #include "mn_socket/arch/sim/native_sock.h"
+#endif
 
-#ifdef OC_TRANSPORT_GATT
-
+#if (MYNEWT_VAL(OC_TRANSPORT_GATT) == 1)
 #include 
-
-/* BLE */
 #include "nimble/ble.h"
 #include "host/ble_hs.h"
-#include "host/ble_hs_adv.h"
-#include "host/ble_uuid.h"
-#include "host/ble_att.h"
-#include "host/ble_gap.h"
-#include "host/ble_gatt.h"
-#include "host/ble_l2cap.h"
-#include "host/ble_sm.h"
 #include "controller/ble_ll.h"
-
-/* RAM HCI transport. */
-#include "transport/ram/ble_hci_ram.h"
-
-/* RAM persistence layer. */
-#include "store/ram/ble_store_ram.h"
-
-/* Mandatory services. */
 #include "services/gap/ble_svc_gap.h"
 #include "services/gatt/ble_svc_gatt.h"
-
-uint8_t g_random_addr[6] = {6,5,4,3,2,1};
-uint8_t g_dev_addr[6] = {1,2,3,4,5,6};
-
-/** Priority of the nimble host and controller tasks. */
-#define BLE_LL_TASK_PRI (OS_TASK_PRI_HIGHEST)
-
-#endif
-
-/* Shell */
-#ifdef OC_TRANSPORT_SERIAL
-#define SHELL_TASK_PRIO (8)
-#define SHELL_MAX_INPUT_LEN (512)
-#define SHELL_TASK_STACK_SIZE (OS_STACK_ALIGN(2048))
-static os_stack_t shell_stack[SHELL_TASK_STACK_SIZE];
 #endif
 
 #define OCF_TASK_PRIO  (8)
-#define OCF_TASK_STACK_SIZE (OS_STACK_ALIGN(2048))
+#define 

[1/2] incubator-mynewt-core git commit: allows console buffers larger than 128 bytes. Also check to ensure that console buffers are a power of 2 because the code requires them to be since it uses mask

2016-10-26 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 062d3ab39 -> bc9a74c44


allows console buffers larger than 128 bytes.  Also check to ensure that 
console buffers
are a power of 2 because the code requires them to be since it uses masks 
instead of mods


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/bc9a74c4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/bc9a74c4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/bc9a74c4

Branch: refs/heads/develop
Commit: bc9a74c443c512d584d4f038439b12ae7894b7c0
Parents: 4b17d72
Author: paulfdietrich <paulfdietr...@yahoo.com>
Authored: Wed Oct 26 09:10:45 2016 -0700
Committer: paulfdietrich <paulfdietr...@yahoo.com>
Committed: Wed Oct 26 09:11:35 2016 -0700

--
 sys/console/full/src/cons_tty.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bc9a74c4/sys/console/full/src/cons_tty.c
--
diff --git a/sys/console/full/src/cons_tty.c b/sys/console/full/src/cons_tty.c
index 2ac0a1a..3563c89 100644
--- a/sys/console/full/src/cons_tty.c
+++ b/sys/console/full/src/cons_tty.c
@@ -53,8 +53,7 @@ void console_print_prompt(void);
 struct console_ring {
 uint8_t cr_head;
 uint8_t cr_tail;
-uint8_t cr_size;
-uint8_t _pad;
+uint16_t cr_size;
 uint8_t *cr_buf;
 };
 
@@ -516,6 +515,11 @@ console_is_init(void)
 return (ct->ct_dev != NULL);
 }
 
+static int is_power_of_two (unsigned int x)
+{
+  return ((x != 0) && !(x & (x - 1)));
+}
+
 int
 console_init(console_rx_cb rx_cb)
 {
@@ -547,6 +551,9 @@ console_init(console_rx_cb rx_cb)
 ct->ct_echo_off = ! MYNEWT_VAL(CONSOLE_ECHO);
 }
 
+/* must be a power of 2 */
+assert(is_power_of_two(MYNEWT_VAL(CONSOLE_RX_BUF_SIZE)));
+
 #if MYNEWT_VAL(CONSOLE_HIST_ENABLE)
 console_hist_init();
 #endif



incubator-mynewt-newt git commit: add a bit of extra time for these multi-segment frames for the slow platforms to extract them from their receive buffer and continue processing.

2016-10-26 Thread paulfdietrich
Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop 611d95bd6 -> 09bd4f97a


add a bit of extra time for these multi-segment frames for the slow platforms 
to extract them
from their receive buffer and continue processing.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/09bd4f97
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/09bd4f97
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/09bd4f97

Branch: refs/heads/develop
Commit: 09bd4f97a3b0431528b608f7f833972b430e315f
Parents: 611d95b
Author: paulfdietrich <paulfdietr...@yahoo.com>
Authored: Wed Oct 26 09:10:13 2016 -0700
Committer: paulfdietrich <paulfdietr...@yahoo.com>
Committed: Wed Oct 26 09:11:45 2016 -0700

--
 newtmgr/transport/connserial.go | 4 
 1 file changed, 4 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/09bd4f97/newtmgr/transport/connserial.go
--
diff --git a/newtmgr/transport/connserial.go b/newtmgr/transport/connserial.go
index 37514a0..b97dd07 100644
--- a/newtmgr/transport/connserial.go
+++ b/newtmgr/transport/connserial.go
@@ -217,6 +217,10 @@ func (cs *ConnSerial) WritePacket(pkt *Packet) error {
if written == 0 {
cs.writeData([]byte{6, 9})
} else {
+   /* slower platforms take some time to process each 
segment
+* and have very small receive buffers.  Give them a 
bit of
+* time here */
+   time.Sleep(20 * time.Millisecond)
cs.writeData([]byte{4, 20})
}
 



[1/2] incubator-mynewt-newt git commit: write notes on the magic number here and test long images (> 64k)

2016-10-18 Thread paulfdietrich
Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop 0558d537a -> f544ec6fb


write notes on the magic number here and test long images (> 64k)


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/dba476ce
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/dba476ce
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/dba476ce

Branch: refs/heads/develop
Commit: dba476ce79f3041c62f72cbf6cb744fe24349c64
Parents: 0558d53
Author: paulfdietrich <paulfdietr...@yahoo.com>
Authored: Tue Oct 18 15:38:28 2016 -0700
Committer: paulfdietrich <paulfdietr...@yahoo.com>
Committed: Tue Oct 18 15:39:20 2016 -0700

--
 newtmgr/cli/image.go| 26 ++
 newtmgr/transport/connserial.go | 11 ++-
 2 files changed, 36 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/dba476ce/newtmgr/cli/image.go
--
diff --git a/newtmgr/cli/image.go b/newtmgr/cli/image.go
index c8ca761..c2e94ed 100644
--- a/newtmgr/cli/image.go
+++ b/newtmgr/cli/image.go
@@ -253,6 +253,32 @@ func imageUploadCmd(cmd *cobra.Command, args []string) {
if profile.Type() == "ble" {
mtu = uint32((transport.BleMTU - 33) * 3 / 4)
} else {
+   /* since this possibly gets base 64 encoded, we want
+* to ensure that the payload leaving this layer is 91
+* bytes or less (91 bytes plus 2 byte crc will encode
+* to 124 with 4 bytes of header
+* left over */
+
+   /*   02 00 00 4f 00 01 00 01  a2 64 64 61 74 61 58 40  
|...O.ddataX@|
+* 0010  00 f0 5a f8 0e 4b 1c 70  0e 4b 5a 88 12 05 10 0f  
|..Z..K.p.KZ.|
+* 0020  59 88 0d 4a 0a 40 5a 80  59 88 0c 4a 0a 40 5a 80  
|Y..J.@Z.Y..J.@Z.|
+* 0030  19 1c 80 22 d2 01 4b 88  13 42 fc d1 05 49 02 02  
|..."..K..B...I..|
+* 0040  48 88 05 4b 03 40 13 43  4b 80 00 f0 5d f8 10 bd  
|H..K.@.CK...]...|
+* 0050  63 6f 66 66 1a 00 01 5d  b8   
|coff..x|
+*/
+
+   /* from this dump we can see the following
+   * 1) newtmgr hdr 8 bytes
+   * 2) cbor wrapper up to data (and length) 8 bytes
+   * 3) cbor data 64 bytes
+   * 4) offset tag 4 bytes
+   * 5) offsert value 3 (safely say 5 bytes since it could be 
bigger
+   *  than uint16_t
+   * That makes 25 bytes plus the data needs to fit in 91 bytes
+*/
+
+   /* however, something is not calcualated properly as we
+* can only do 66 bytes here.  Use 64 for power of 2 */
mtu = 64
}
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/dba476ce/newtmgr/transport/connserial.go
--
diff --git a/newtmgr/transport/connserial.go b/newtmgr/transport/connserial.go
index b7aaf4f..37514a0 100644
--- a/newtmgr/transport/connserial.go
+++ b/newtmgr/transport/connserial.go
@@ -212,13 +212,22 @@ func (cs *ConnSerial) WritePacket(pkt *Packet) error {
totlen := len(base64Data)
 
for written < totlen {
+   /* write the packet stat designators. They are
+   * different whether we are starting a new packet or continuing 
one */
if written == 0 {
cs.writeData([]byte{6, 9})
} else {
cs.writeData([]byte{4, 20})
}
 
-   writeLen := util.Min(120, totlen-written)
+   /* ensure that the total frame fits into 128 bytes.
+* base 64 is 3 ascii to 4 base 64 byte encoding.  so
+* the number below should be a multiple of 4.  Also,
+* we need to save room for the header (2 byte) and
+* carriage return (and possibly LF 2 bytes), */
+
+   /* all totaled, 124 bytes should work */
+   writeLen := util.Min(124, totlen-written)
 
writeBytes := base64Data[written : written+writeLen]
cs.writeData(writeBytes)



[2/2] incubator-mynewt-newt git commit: more documentation for the first packet

2016-10-18 Thread paulfdietrich
more documentation for the first packet


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/f544ec6f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/f544ec6f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/f544ec6f

Branch: refs/heads/develop
Commit: f544ec6fb3d45e0a685541952c70eabf949c26ff
Parents: dba476c
Author: paulfdietrich <paulfdietr...@yahoo.com>
Authored: Tue Oct 18 15:48:35 2016 -0700
Committer: paulfdietrich <paulfdietr...@yahoo.com>
Committed: Tue Oct 18 15:48:35 2016 -0700

--
 newtmgr/cli/image.go | 11 +++
 1 file changed, 11 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/f544ec6f/newtmgr/cli/image.go
--
diff --git a/newtmgr/cli/image.go b/newtmgr/cli/image.go
index c2e94ed..7bcb879 100644
--- a/newtmgr/cli/image.go
+++ b/newtmgr/cli/image.go
@@ -295,6 +295,17 @@ func imageUploadCmd(cmd *cobra.Command, args []string) {
if currOff == 0 {
/* we need extra space to encode the image size */
if blockSz > (mtu - 8) {
+   /*
+* to encode the image size, we write clen=val 
in CBOR.
+* From below (for up to 2G images, you can see 
that it
+* will take up to 9 bytes.  (starts at 63.. 
ends at e8)
+* 0040  7d c4 00 00 7d c4 00 00  63 6c 65 
6e 1a 00 01 5d  |}...}...clen...]|
+* 0050  e8 63 6f 66 66 00  
   |.coff.|
+* However, since the offset is zero, we will 
use less
+* bytes (we budgeted for 5 bytes but will only 
use 1
+*/
+
+   /* to make these powers of 2, just go with 8 
bytes */
blockSz = mtu - 8
}
}



incubator-mynewt-core git commit: disable console history by default since it uses tons of RAM and interrupt time

2016-10-28 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 087532bb0 -> 96b3f5ffa


disable console history by default since it uses tons of RAM and interrupt time


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/96b3f5ff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/96b3f5ff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/96b3f5ff

Branch: refs/heads/develop
Commit: 96b3f5ffa594df47359f130d3a3cd070b79aa5ad
Parents: 087532b
Author: paulfdietrich <paulfdietr...@yahoo.com>
Authored: Fri Oct 28 15:14:51 2016 -0700
Committer: paulfdietrich <paulfdietr...@yahoo.com>
Committed: Fri Oct 28 15:15:26 2016 -0700

--
 sys/console/full/syscfg.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/96b3f5ff/sys/console/full/syscfg.yml
--
diff --git a/sys/console/full/syscfg.yml b/sys/console/full/syscfg.yml
index cd58944..e90402f 100644
--- a/sys/console/full/syscfg.yml
+++ b/sys/console/full/syscfg.yml
@@ -22,4 +22,4 @@ syscfg.defs:
 value: '1'
 CONSOLE_HIST_ENABLE:
 description: 'Console history '
-value: 1
+value: 0



[3/3] incubator-mynewt-newt git commit: missing autocomplete for set command

2016-10-13 Thread paulfdietrich
missing autocomplete for set command


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/a47565d2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/a47565d2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/a47565d2

Branch: refs/heads/develop
Commit: a47565d22869186ea8eb0bfb646e66ca3123488e
Parents: 8d09f13
Author: Paul Dietrich 
Authored: Fri Sep 16 15:19:31 2016 -0700
Committer: Paul Dietrich 
Committed: Thu Oct 13 11:10:47 2016 -0700

--
 newt/cli/target_cmds.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/a47565d2/newt/cli/target_cmds.go
--
diff --git a/newt/cli/target_cmds.go b/newt/cli/target_cmds.go
index ff284f7..e325713 100644
--- a/newt/cli/target_cmds.go
+++ b/newt/cli/target_cmds.go
@@ -495,7 +495,7 @@ func AddTargetCommands(cmd *cobra.Command) {
Example: setHelpEx,
Run: targetSetCmd,
}
-
+   setCmd.ValidArgs = targetList()
targetCmd.AddCommand(setCmd)
 
createHelpText := "Create a target specified by ."



[2/3] incubator-mynewt-newt git commit: refactor newtmgr to use cbor instead of json

2016-10-13 Thread paulfdietrich
refactor newtmgr to use cbor instead of json


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/ade80cfc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/ade80cfc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/ade80cfc

Branch: refs/heads/develop
Commit: ade80cfc0576be75b837507ef6b0761d89ffb39b
Parents: a47565d
Author: Paul Dietrich 
Authored: Tue Oct 11 16:51:33 2016 -0700
Committer: Paul Dietrich 
Committed: Thu Oct 13 11:10:47 2016 -0700

--
 newtmgr/cli/image.go  | 25 +++---
 newtmgr/protocol/config.go|  6 ++--
 newtmgr/protocol/coreerase.go |  4 +--
 newtmgr/protocol/corelist.go  |  4 +--
 newtmgr/protocol/coreload.go  | 11 +++
 newtmgr/protocol/crash.go |  4 +--
 newtmgr/protocol/datetime.go  |  8 ++---
 newtmgr/protocol/echo.go  | 10 +++---
 newtmgr/protocol/imageboot2.go| 53 +-
 newtmgr/protocol/imagefiledownload.go | 13 
 newtmgr/protocol/imagefileupload.go   | 17 +-
 newtmgr/protocol/imagelist2.go|  6 ++--
 newtmgr/protocol/imagesplit.go|  6 ++--
 newtmgr/protocol/imageupload.go   | 17 +-
 newtmgr/protocol/logs.go  | 36 ++--
 newtmgr/protocol/mpstats.go   |  4 +--
 newtmgr/protocol/stats.go | 12 +++
 newtmgr/protocol/taskstats.go |  4 +--
 18 files changed, 106 insertions(+), 134 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/ade80cfc/newtmgr/cli/image.go
--
diff --git a/newtmgr/cli/image.go b/newtmgr/cli/image.go
index 445d8fe..087d57c 100644
--- a/newtmgr/cli/image.go
+++ b/newtmgr/cli/image.go
@@ -20,7 +20,6 @@
 package cli
 
 import (
-   "encoding/base64"
"encoding/hex"
"errors"
"fmt"
@@ -81,15 +80,10 @@ func imageListCmd(cmd *cobra.Command, args []string) {
fmt.Printf(" slot=%d\n", img.Slot)
fmt.Printf("version=%s\n", img.Version)
fmt.Printf("bootable=%v\n", img.Bootable)
-   if img.Hash == "" {
+   if len(img.Hash) == 0 {
fmt.Printf("hash=Unavailable\n")
} else {
-   dec, err := base64.StdEncoding.DecodeString(img.Hash)
-   if err != nil {
-   fmt.Printf("hash=Unable to Decode")
-   } else {
-   fmt.Printf("hash=%s\n", 
hex.EncodeToString(dec[:]))
-   }
+   fmt.Printf("hash=%x\n", img.Hash)
}
}
 }
@@ -245,7 +239,7 @@ func imageUploadCmd(cmd *cobra.Command, args []string) {
if profile.Type() == "ble" {
mtu = uint32((transport.BleMTU - 33) * 3 / 4)
} else {
-   mtu = 36
+   mtu = 64
}
 
for currOff < imageSz {
@@ -259,7 +253,10 @@ func imageUploadCmd(cmd *cobra.Command, args []string) {
blockSz = mtu
}
if currOff == 0 {
-   blockSz = 33
+   /* we need extra space to encode the image size */
+   if blockSz > (mtu - 8) {
+   blockSz = mtu - 8
+   }
}
 
imageUpload.Offset = currOff
@@ -332,7 +329,7 @@ func imageBootCmd(cmd *cobra.Command, args []string) {
}
 
if len(args) >= 1 {
-   imageBoot.BootTarget = args[0]
+   imageBoot.BootTarget, _ = hex.DecodeString(args[0])
}
nmr, err := imageBoot.EncodeWriteRequest()
if err != nil {
@@ -353,9 +350,9 @@ func imageBootCmd(cmd *cobra.Command, args []string) {
nmUsage(cmd, err)
}
if len(args) == 0 {
-   fmt.Println("   Test image:", iRsp.Test)
-   fmt.Println("   Main image:", iRsp.Main)
-   fmt.Println("   Active img:", iRsp.Active)
+   fmt.Printf("   Test image: %x\n", iRsp.Test)
+   fmt.Printf("   Main image: %x\n", iRsp.Main)
+   fmt.Printf("   Active img: %x\n", iRsp.Active)
}
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/ade80cfc/newtmgr/protocol/config.go
--
diff --git a/newtmgr/protocol/config.go b/newtmgr/protocol/config.go
index 1e18ffe..9406665 100644
--- a/newtmgr/protocol/config.go
+++ 

[1/3] incubator-mynewt-newt git commit: changes to allow the image state command to use cbor instead of json

2016-10-13 Thread paulfdietrich
Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop 8d09f1306 -> f936c989e


changes to allow the image state command to use cbor instead of json


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/f936c989
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/f936c989
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/f936c989

Branch: refs/heads/develop
Commit: f936c989e94f5ce32313035a09d2d6a7035f6a34
Parents: ade80cf
Author: Paul Dietrich 
Authored: Thu Oct 13 11:06:41 2016 -0700
Committer: Paul Dietrich 
Committed: Thu Oct 13 11:10:47 2016 -0700

--
 newtmgr/cli/image.go   | 26 ++
 newtmgr/protocol/imagelist.go  | 26 --
 newtmgr/protocol/imagestate.go | 14 +++---
 3 files changed, 21 insertions(+), 45 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/f936c989/newtmgr/cli/image.go
--
diff --git a/newtmgr/cli/image.go b/newtmgr/cli/image.go
index 087d57c..48090f9 100644
--- a/newtmgr/cli/image.go
+++ b/newtmgr/cli/image.go
@@ -128,8 +128,10 @@ func imageStateCmd(cmd *cobra.Command, args []string) {
nmUsage(cmd, nil)
}
 
+   hex_bytes, _ := hex.DecodeString(args[1])
+
req := protocol.ImageStateWriteReq{
-   Hash:args[1],
+   Hash:hex_bytes,
Confirm: false,
}
nmr, err = req.Encode()
@@ -138,7 +140,7 @@ func imageStateCmd(cmd *cobra.Command, args []string) {
}
} else if args[0] == "confirm" {
req := protocol.ImageStateWriteReq{
-   Hash:"",
+   Hash:make([]byte, 0),
Confirm: true,
}
nmr, err = req.Encode()
@@ -172,15 +174,10 @@ func imageStateCmd(cmd *cobra.Command, args []string) {
fmt.Printf("version: %s\n", img.Version)
fmt.Printf("bootable: %v\n", img.Bootable)
fmt.Printf("flags: %s\n", imageFlagsStr(img))
-   if img.Hash == "" {
+   if len(img.Hash) == 0 {
fmt.Printf("hash: Unavailable\n")
} else {
-   dec, err := base64.StdEncoding.DecodeString(img.Hash)
-   if err != nil {
-   fmt.Printf("hash: Unable to Decode")
-   } else {
-   fmt.Printf("hash: %s\n", 
hex.EncodeToString(dec[:]))
-   }
+   fmt.Printf("hash: %x\n", img.Hash)
}
}
 
@@ -672,10 +669,15 @@ func imageCmd() *cobra.Command {
}
imageCmd.AddCommand(listCmd)
 
+   stateEx := "  newtmgr -c olimex image state show\n"
+   stateEx += "  newtmgr -c olimex image state test \n"
+   stateEx += "  newtmgr -c olimex image state confirm"
+
stateCmd := {
-   Use:   "state",
-   Short: "Show target images",
-   Run:   imageStateCmd,
+   Use: "state",
+   Short:   "Show target images",
+   Example: stateEx,
+   Run: imageStateCmd,
}
imageCmd.AddCommand(stateCmd)
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/f936c989/newtmgr/protocol/imagelist.go
--
diff --git a/newtmgr/protocol/imagelist.go b/newtmgr/protocol/imagelist.go
index 67def59..1c31bf8 100644
--- a/newtmgr/protocol/imagelist.go
+++ b/newtmgr/protocol/imagelist.go
@@ -19,14 +19,6 @@
 
 package protocol
 
-import (
-   "encoding/base64"
-   "encoding/hex"
-   "fmt"
-
-   "mynewt.apache.org/newt/util"
-)
-
 const (
IMGMGR_NMGR_OP_LIST = 0
IMGMGR_NMGR_OP_UPLOAD   = 1
@@ -38,21 +30,3 @@ const (
IMGMGR_NMGR_OP_CORELOAD = 7
IMGMGR_NMGR_OP_STATE= 8
 )
-
-func HashDecode(src string) (string, error) {
-   imgHex, err := base64.StdEncoding.DecodeString(src)
-   if err != nil {
-   return "", util.NewNewtError(fmt.Sprintf("Hash decode error: 
%s",
-   err.Error()))
-   }
-   return hex.EncodeToString(imgHex), nil
-}
-
-func HashEncode(src string) (string, error) {
-   imgHex, err := hex.DecodeString(src)
-   if err != nil {
-   return "", util.NewNewtError(fmt.Sprintf("Hash encode error: 
%s",
-   

[3/3] incubator-mynewt-core git commit: refactor newtmgr to use cbor instead of json

2016-10-13 Thread paulfdietrich
refactor newtmgr to use cbor instead of json


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/7f299efb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/7f299efb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/7f299efb

Branch: refs/heads/develop
Commit: 7f299efb657dccedbebe7254fbd495ae80409cb0
Parents: adbb00e
Author: Paul Dietrich 
Authored: Tue Oct 11 16:51:50 2016 -0700
Committer: Paul Dietrich 
Committed: Thu Oct 13 11:08:40 2016 -0700

--
 boot/split/src/split_netmgr.c   |  60 ++--
 encoding/cborattr/include/cborattr/cborattr.h   | 130 
 encoding/cborattr/pkg.yml   |  27 ++
 encoding/cborattr/src/cborattr.c| 257 
 encoding/tinycbor/include/tinycbor/cbor.h   |  20 +-
 .../tinycbor/include/tinycbor/cbor_buf_writer.h |   4 +-
 .../tinycbor/include/tinycbor/cbor_cnt_writer.h |  21 +-
 .../include/tinycbor/cbor_mbuf_writer.h |   9 +-
 encoding/tinycbor/src/cbor_buf_writer.c |  17 +-
 encoding/tinycbor/src/cbor_mbuf_reader.c|  10 +-
 encoding/tinycbor/src/cbor_mbuf_writer.c|  21 +-
 encoding/tinycbor/src/cborencoder.c |   7 +-
 encoding/tinycbor/src/cborparser.c  |  13 +-
 mgmt/imgmgr/src/imgmgr.c| 129 
 mgmt/imgmgr/src/imgmgr_boot.c   |  71 ++---
 mgmt/imgmgr/src/imgmgr_coredump.c   |  59 ++--
 mgmt/imgmgr/src/imgmgr_fs.c | 129 
 mgmt/imgmgr/src/imgmgr_priv.h   |  24 +-
 mgmt/imgmgr/src/imgmgr_state.c  |  91 +++---
 mgmt/mgmt/include/mgmt/mgmt.h   |  13 +-
 mgmt/mgmt/src/mgmt.c|  17 +-
 mgmt/newtmgr/include/newtmgr/newtmgr.h  |   4 +-
 mgmt/newtmgr/nmgr_os/src/newtmgr_os.c   | 214 ++---
 mgmt/newtmgr/pkg.yml|   2 +-
 mgmt/newtmgr/src/newtmgr.c  | 168 +++---
 sys/config/src/config_json_line.c   |  14 +-
 sys/config/src/config_nmgr.c|  32 +-
 sys/config/src/config_priv.h|   6 +-
 sys/log/src/log_nmgr.c  | 303 ++-
 sys/stats/src/stats_nmgr.c  | 113 ---
 test/crash_test/src/crash_nmgr.c|  14 +-
 31 files changed, 1124 insertions(+), 875 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7f299efb/boot/split/src/split_netmgr.c
--
diff --git a/boot/split/src/split_netmgr.c b/boot/split/src/split_netmgr.c
index 50c21f5..ae22554 100644
--- a/boot/split/src/split_netmgr.c
+++ b/boot/split/src/split_netmgr.c
@@ -17,7 +17,8 @@
  * under the License.
  */
 
-#include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -25,8 +26,8 @@
 #include 
 
 
-static int imgr_splitapp_read(struct mgmt_jbuf *njb);
-static int imgr_splitapp_write(struct mgmt_jbuf *njb);
+static int imgr_splitapp_read(struct mgmt_cbuf *cb);
+static int imgr_splitapp_write(struct mgmt_cbuf *cb);
 
 static const struct mgmt_handler split_nmgr_handlers[] = {
 [SPLIT_NMGR_OP_SPLIT] = {
@@ -51,56 +52,56 @@ split_nmgr_register(void)
 }
 
 int
-imgr_splitapp_read(struct mgmt_jbuf *njb)
+imgr_splitapp_read(struct mgmt_cbuf *cb)
 {
 int x;
-struct json_encoder *enc;
-struct json_value jv;
+CborError g_err = CborNoError;
+CborEncoder *penc = >encoder;
+CborEncoder rsp;
 
-enc = >mjb_enc;
-
-json_encode_object_start(enc);
+g_err |= cbor_encoder_create_map(penc, , CborIndefiniteLength);
 
 x = split_mode_get();
-JSON_VALUE_INT(, x)
-json_encode_object_entry(enc, "splitMode", );
+g_err |= cbor_encode_text_stringz(, "splitMode");
+g_err |= cbor_encode_int(, x);
 
-JSON_VALUE_INT(, split_check_status())
-json_encode_object_entry(enc, "splitStatus", );
+x = split_check_status();
+g_err |= cbor_encode_text_stringz(, "splitStatus");
+g_err |= cbor_encode_int(, x);
 
-JSON_VALUE_INT(, MGMT_ERR_EOK);
-json_encode_object_entry(enc, "rc", );
+g_err |= cbor_encode_text_stringz(, "rc");
+g_err |= cbor_encode_int(, MGMT_ERR_EOK);
 
-json_encode_object_finish(enc);
+g_err |= cbor_encoder_close_container(penc, );
 
 return 0;
 }
 
 int
-imgr_splitapp_write(struct mgmt_jbuf *njb)
+imgr_splitapp_write(struct mgmt_cbuf *cb)
 {
 long long int split_mode;
 long long int send_split_status;  /* ignored */
 long long int sent_rc; /* ignored */
-const struct json_attr_t split_write_attr[4] = {
+const struct cbor_attr_t 

[2/3] incubator-mynewt-core git commit: refactor newtmgr to use cbor instead of json

2016-10-13 Thread paulfdietrich
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7f299efb/mgmt/newtmgr/src/newtmgr.c
--
diff --git a/mgmt/newtmgr/src/newtmgr.c b/mgmt/newtmgr/src/newtmgr.c
index 6621b9b..ffecd4f 100644
--- a/mgmt/newtmgr/src/newtmgr.c
+++ b/mgmt/newtmgr/src/newtmgr.c
@@ -30,6 +30,10 @@
 #include "newtmgr/newtmgr.h"
 #include "nmgr_os/nmgr_os.h"
 
+#include 
+#include 
+#include 
+
 os_stack_t newtmgr_stack[OS_STACK_ALIGN(MYNEWT_VAL(NEWTMGR_STACK_SIZE))];
 
 static struct os_eventq nmgr_evq;
@@ -37,17 +41,23 @@ struct os_eventq *g_mgmt_evq = _evq;
 static struct os_task g_nmgr_task;
 
 /*
- * JSON buffer for newtmgr
+ * cbor buffer for newtmgr
  */
-static struct nmgr_jbuf {
-struct mgmt_jbuf n_b;
-struct os_mbuf *n_in_m;
+static struct nmgr_cbuf {
+struct mgmt_cbuf n_b;
+struct CborMbufWriter writer;
+struct CborMbufReader reader;
 struct os_mbuf *n_out_m;
+
+#if 0
+struct os_mbuf *n_in_m;
 struct nmgr_hdr *n_hdr;
 uint16_t n_off;
 uint16_t n_end;
-} nmgr_task_jbuf;
+#endif
+} nmgr_task_cbuf;
 
+#if 0
 static int
 nmgr_rsp_extend(struct nmgr_hdr *hdr, struct os_mbuf *rsp, void *data,
 uint16_t len)
@@ -64,128 +74,15 @@ nmgr_rsp_extend(struct nmgr_hdr *hdr, struct os_mbuf *rsp, 
void *data,
 err:
 return (rc);
 }
-
-static char
-nmgr_jbuf_read_next(struct json_buffer *jb)
-{
-struct nmgr_jbuf *njb;
-char c;
-int rc;
-
-njb = (struct nmgr_jbuf *) jb;
-
-if (njb->n_off + 1 > njb->n_end) {
-return '\0';
-}
-
-rc = os_mbuf_copydata(njb->n_in_m, njb->n_off, 1, );
-if (rc == -1) {
-c = '\0';
-}
-++njb->n_off;
-
-return (c);
-}
-
-static char
-nmgr_jbuf_read_prev(struct json_buffer *jb)
-{
-struct nmgr_jbuf *njb;
-char c;
-int rc;
-
-njb = (struct nmgr_jbuf *) jb;
-
-if (njb->n_off == 0) {
-return '\0';
-}
-
---njb->n_off;
-rc = os_mbuf_copydata(njb->n_in_m, njb->n_off, 1, );
-if (rc == -1) {
-c = '\0';
-}
-
-return (c);
-}
+#endif
 
 static int
-nmgr_jbuf_readn(struct json_buffer *jb, char *buf, int size)
+nmgr_cbuf_init(struct nmgr_cbuf *njb)
 {
-struct nmgr_jbuf *njb;
-int read;
-int left;
-int rc;
-
-njb = (struct nmgr_jbuf *) jb;
-
-left = njb->n_end - njb->n_off;
-read = size > left ? left : size;
-
-rc = os_mbuf_copydata(njb->n_in_m, njb->n_off, read, buf);
-if (rc != 0) {
-goto err;
-}
-
-return (read);
-err:
-return (rc);
-}
-
-int
-nmgr_jbuf_write(void *arg, char *data, int len)
-{
-struct nmgr_jbuf *njb;
-int rc;
-
-njb = (struct nmgr_jbuf *) arg;
-
-rc = nmgr_rsp_extend(njb->n_hdr, njb->n_out_m, data, len);
-if (rc != 0) {
-assert(0);
-goto err;
-}
-
-return (0);
-err:
-return (rc);
-}
-
-static int
-nmgr_jbuf_init(struct nmgr_jbuf *njb)
-{
-struct mgmt_jbuf *mj;
-
 memset(njb, 0, sizeof(*njb));
-
-mj = >n_b;
-mj->mjb_buf.jb_read_next = nmgr_jbuf_read_next;
-mj->mjb_buf.jb_read_prev = nmgr_jbuf_read_prev;
-mj->mjb_buf.jb_readn = nmgr_jbuf_readn;
-mj->mjb_enc.je_write = nmgr_jbuf_write;
-mj->mjb_enc.je_arg = njb;
-
 return (0);
 }
 
-static void
-nmgr_jbuf_setibuf(struct nmgr_jbuf *njb, struct os_mbuf *m,
-uint16_t off, uint16_t len)
-{
-njb->n_in_m = m;
-njb->n_off = off;
-njb->n_end = off + len;
-}
-
-static void
-nmgr_jbuf_setobuf(struct nmgr_jbuf *njb, struct nmgr_hdr *hdr,
-struct os_mbuf *m)
-{
-njb->n_b.mjb_enc.je_wr_commas = 0;
-njb->n_out_m = m;
-njb->n_hdr = hdr;
-}
-
 static struct nmgr_hdr*
 nmgr_init_rsp(struct os_mbuf *m, struct nmgr_hdr *src)
 {
@@ -204,8 +101,10 @@ nmgr_init_rsp(struct os_mbuf *m, struct nmgr_hdr *src)
 hdr->nh_seq = src->nh_seq;
 hdr->nh_id = src->nh_id;
 
-nmgr_jbuf_setobuf(_task_jbuf, hdr, m);
-
+/* setup state for cbor encoding */
+cbor_mbuf_writer_init(_task_cbuf.writer, m);
+cbor_encoder_init(_task_cbuf.n_b.encoder, _task_cbuf.writer.enc, 
0);
+nmgr_task_cbuf.n_out_m = m;
 return hdr;
 }
 
@@ -217,10 +116,12 @@ nmgr_send_err_rsp(struct nmgr_transport *nt, struct 
os_mbuf *m,
 if (!hdr) {
 return;
 }
+#if 0
 mgmt_jbuf_setoerr(_task_jbuf.n_b, rc);
+#endif
 hdr->nh_len = htons(hdr->nh_len);
-hdr->nh_flags = NMGR_F_JSON_RSP_COMPLETE;
-nt->nt_output(nt, nmgr_task_jbuf.n_out_m);
+hdr->nh_flags = NMGR_F_CBOR_RSP_COMPLETE;
+nt->nt_output(nt, nmgr_task_cbuf.n_out_m);
 }
 
 static int
@@ -287,7 +188,7 @@ nmgr_rsp_fragment(struct nmgr_transport *nt, struct 
nmgr_hdr *rsp_hdr,
 
 do {
 if (len <= mtu) {
-rsp_hdr->nh_flags |= NMGR_F_JSON_RSP_COMPLETE;
+rsp_hdr->nh_flags |= NMGR_F_CBOR_RSP_COMPLETE;
 } else {
 len = mtu;
 }
@@ -299,8 +200,8 @@ nmgr_rsp_fragment(struct nmgr_transport *nt, struct 
nmgr_hdr *rsp_hdr,
 
 len = 

[1/3] incubator-mynewt-core git commit: minor bug fixes to state command. Also fix reboot to ensure we don't call functions that are not enabled by sysconfig

2016-10-13 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop adbb00e93 -> 82c6b75c4


minor bug fixes to state command.  Also fix reboot to ensure we don't
call functions that are not enabled by sysconfig


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/82c6b75c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/82c6b75c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/82c6b75c

Branch: refs/heads/develop
Commit: 82c6b75c498b3870bb4701fc63e9b0422af250ff
Parents: 7f299ef
Author: Paul Dietrich 
Authored: Thu Oct 13 11:07:38 2016 -0700
Committer: Paul Dietrich 
Committed: Thu Oct 13 11:08:40 2016 -0700

--
 mgmt/imgmgr/src/imgmgr_state.c |  1 +
 mgmt/newtmgr/nmgr_os/pkg.yml   |  5 +
 sys/reboot/src/log_reboot.c| 10 +++---
 3 files changed, 13 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/82c6b75c/mgmt/imgmgr/src/imgmgr_state.c
--
diff --git a/mgmt/imgmgr/src/imgmgr_state.c b/mgmt/imgmgr/src/imgmgr_state.c
index ac62d71..67551d7 100644
--- a/mgmt/imgmgr/src/imgmgr_state.c
+++ b/mgmt/imgmgr/src/imgmgr_state.c
@@ -234,6 +234,7 @@ imgmgr_state_read(struct mgmt_cbuf *cb)
 g_err |= cbor_encode_int(, i);
 
 g_err |= cbor_encode_text_stringz(, "version");
+imgr_ver_str(, vers_str);
 g_err |= cbor_encode_text_stringz(, vers_str);
 
 g_err |= cbor_encode_text_stringz(, "hash");

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/82c6b75c/mgmt/newtmgr/nmgr_os/pkg.yml
--
diff --git a/mgmt/newtmgr/nmgr_os/pkg.yml b/mgmt/newtmgr/nmgr_os/pkg.yml
index 2812f60..c0ee6c7 100644
--- a/mgmt/newtmgr/nmgr_os/pkg.yml
+++ b/mgmt/newtmgr/nmgr_os/pkg.yml
@@ -30,3 +30,8 @@ pkg.deps:
 - encoding/json
 - sys/reboot
 - mgmt/mgmt
+- encoding/tinycbor
+- encoding/cborattr
+
+pkg.req_apis:
+- newtmgr

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/82c6b75c/sys/reboot/src/log_reboot.c
--
diff --git a/sys/reboot/src/log_reboot.c b/sys/reboot/src/log_reboot.c
index 89ef589..9869a08 100644
--- a/sys/reboot/src/log_reboot.c
+++ b/sys/reboot/src/log_reboot.c
@@ -136,12 +136,16 @@ log_reboot(int reason)
 char str[12] = {0};
 struct image_version ver;
 int16_t reboot_tmp_cnt;
-const struct flash_area *ptr;
 
 rc = 0;
-if (flash_area_open(MYNEWT_VAL(REBOOT_LOG_FLASH_AREA), )) {
-goto err;
+#if MYNEWT_VAL(REBOOT_LOG_FCB)
+{
+const struct flash_area *ptr;
+if (flash_area_open(MYNEWT_VAL(REBOOT_LOG_FLASH_AREA), )) {
+goto err;
+}
 }
+#endif
 
 reboot_tmp_cnt = reboot_cnt;
 



incubator-mynewt-core git commit: refactor oicmgr to use cbor encoding without encapsulation

2016-10-13 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 566a80030 -> 53a2ce067


refactor oicmgr to use cbor encoding without encapsulation


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/53a2ce06
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/53a2ce06
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/53a2ce06

Branch: refs/heads/develop
Commit: 53a2ce067cd2ed5e40cc7ccfe580f3c2d0306236
Parents: 566a800
Author: Paul Dietrich 
Authored: Thu Oct 13 15:42:04 2016 -0700
Committer: Paul Dietrich 
Committed: Thu Oct 13 15:42:27 2016 -0700

--
 .../tinycbor/include/tinycbor/cbor_cnt_writer.h |   4 +-
 mgmt/imgmgr/src/imgmgr_priv.h   |   1 -
 mgmt/newtmgr/src/newtmgr.c  |  30 +--
 mgmt/oicmgr/src/oicmgr.c| 189 +--
 net/oic/src/api/oc_rep.c|   2 +-
 5 files changed, 46 insertions(+), 180 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/53a2ce06/encoding/tinycbor/include/tinycbor/cbor_cnt_writer.h
--
diff --git a/encoding/tinycbor/include/tinycbor/cbor_cnt_writer.h 
b/encoding/tinycbor/include/tinycbor/cbor_cnt_writer.h
index deb8f89..9c84eb4 100644
--- a/encoding/tinycbor/include/tinycbor/cbor_cnt_writer.h
+++ b/encoding/tinycbor/include/tinycbor/cbor_cnt_writer.h
@@ -37,14 +37,14 @@ struct CborCntWriter {
 struct cbor_encoder_writer enc;
 };
 
-inline int
+static inline int
 cbor_cnt_writer(struct cbor_encoder_writer *arg, const char *data, int len) {
 struct CborCntWriter *cb = (struct CborCntWriter *) arg;
 cb->enc.bytes_written += len;
 return CborNoError;
 }
 
-inline void
+static inline void
 cbor_cnt_writer_init(struct CborCntWriter *cb) {
 cb->enc.bytes_written = 0;
 cb->enc.write = _cnt_writer;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/53a2ce06/mgmt/imgmgr/src/imgmgr_priv.h
--
diff --git a/mgmt/imgmgr/src/imgmgr_priv.h b/mgmt/imgmgr/src/imgmgr_priv.h
index 1c31ad5..d7f39ff 100644
--- a/mgmt/imgmgr/src/imgmgr_priv.h
+++ b/mgmt/imgmgr/src/imgmgr_priv.h
@@ -83,7 +83,6 @@ struct imgmgr_upload_cmd {
  * }
  */
 
-struct mgmt_jbuf;
 struct nmgr_hdr;
 struct os_mbuf;
 struct fs_file;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/53a2ce06/mgmt/newtmgr/src/newtmgr.c
--
diff --git a/mgmt/newtmgr/src/newtmgr.c b/mgmt/newtmgr/src/newtmgr.c
index ffecd4f..c248c77 100644
--- a/mgmt/newtmgr/src/newtmgr.c
+++ b/mgmt/newtmgr/src/newtmgr.c
@@ -48,34 +48,8 @@ static struct nmgr_cbuf {
 struct CborMbufWriter writer;
 struct CborMbufReader reader;
 struct os_mbuf *n_out_m;
-
-#if 0
-struct os_mbuf *n_in_m;
-struct nmgr_hdr *n_hdr;
-uint16_t n_off;
-uint16_t n_end;
-#endif
 } nmgr_task_cbuf;
 
-#if 0
-static int
-nmgr_rsp_extend(struct nmgr_hdr *hdr, struct os_mbuf *rsp, void *data,
-uint16_t len)
-{
-int rc;
-
-rc = os_mbuf_append(rsp, data, len);
-if (rc != 0) {
-goto err;
-}
-hdr->nh_len += len;
-
-return (0);
-err:
-return (rc);
-}
-#endif
-
 static int
 nmgr_cbuf_init(struct nmgr_cbuf *njb)
 {
@@ -116,9 +90,7 @@ nmgr_send_err_rsp(struct nmgr_transport *nt, struct os_mbuf 
*m,
 if (!hdr) {
 return;
 }
-#if 0
-mgmt_jbuf_setoerr(_task_jbuf.n_b, rc);
-#endif
+mgmt_cbuf_setoerr(_task_cbuf.n_b, rc);
 hdr->nh_len = htons(hdr->nh_len);
 hdr->nh_flags = NMGR_F_CBOR_RSP_COMPLETE;
 nt->nt_output(nt, nmgr_task_cbuf.n_out_m);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/53a2ce06/mgmt/oicmgr/src/oicmgr.c
--
diff --git a/mgmt/oicmgr/src/oicmgr.c b/mgmt/oicmgr/src/oicmgr.c
index 4fde423..8d10ce1 100644
--- a/mgmt/oicmgr/src/oicmgr.c
+++ b/mgmt/oicmgr/src/oicmgr.c
@@ -29,20 +29,19 @@
 #include 
 #include 
 
+#include 
+#include 
+#include 
+#include 
 #include 
 
 #define OMGR_OC_EVENT  (OS_EVENT_T_PERUSER)
 #define OMGR_OC_TIMER  (OS_EVENT_T_PERUSER + 1)
 #define OICMGR_STACK_SZOS_STACK_ALIGN(MYNEWT_VAL(OICMGR_STACK_SIZE))
 
-struct omgr_jbuf {
-struct mgmt_jbuf ob_mj;
-char *ob_in;
-uint16_t ob_in_off;
-uint16_t ob_in_end;
-char *ob_out;
-uint16_t ob_out_off;
-uint16_t ob_out_end;
+struct omgr_cbuf {
+struct mgmt_cbuf ob_mj;
+struct cbor_buf_reader ob_reader;
 };
 
 struct omgr_state {
@@ -50,8 +49,7 @@ struct omgr_state {
 struct os_event 

incubator-mynewt-core git commit: fix echo command type and cleanup attribute array

2016-10-14 Thread paulfdietrich
Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 7bedd6c51 -> f9bf3836c


fix echo command type and cleanup attribute array


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/f9bf3836
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f9bf3836
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f9bf3836

Branch: refs/heads/develop
Commit: f9bf3836c9fedd62ab98d60192cbe61d426003a4
Parents: 7bedd6c
Author: Paul Dietrich 
Authored: Fri Oct 14 12:17:02 2016 -0700
Committer: Paul Dietrich 
Committed: Fri Oct 14 12:17:46 2016 -0700

--
 mgmt/newtmgr/nmgr_os/src/newtmgr_os.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f9bf3836/mgmt/newtmgr/nmgr_os/src/newtmgr_os.c
--
diff --git a/mgmt/newtmgr/nmgr_os/src/newtmgr_os.c 
b/mgmt/newtmgr/nmgr_os/src/newtmgr_os.c
index 9fbc294..d0d70e8 100644
--- a/mgmt/newtmgr/nmgr_os/src/newtmgr_os.c
+++ b/mgmt/newtmgr/nmgr_os/src/newtmgr_os.c
@@ -111,17 +111,14 @@ nmgr_def_console_echo(struct mgmt_cbuf *cb)
 {
 long long int echo_on = 1;
 int rc;
-struct cbor_attr_t attrs[3] = {
+struct cbor_attr_t attrs[2] = {
 [0] = {
 .attribute = "echo",
-.type = CborAttrTextStringType,
+.type = CborAttrIntegerType,
 .addr.integer = _on,
 .nodefault = 1
 },
-[1] = {
-.attribute = NULL
-},
-[2] = { 0 },
+[1] = { 0 },
 };
 
 rc = cbor_read_object(>it, attrs);