You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by pa...@apache.org on 2016/09/14 23:42:33 UTC

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

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 <pa...@yahoo.com>
Authored: Wed Sep 14 14:04:07 2016 -0700
Committer: Paul Dietrich <pa...@yahoo.com>
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 0000000..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 <assert.h>
+
+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 0000000..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 License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <stdint.h>
+#include <os/os.h>
+#include "../oc_clock.h"
+
+void oc_clock_init(void)
+{
+    /* in mynewt clock is initialized elsewhere */
+}
+oc_clock_time_t oc_clock_time(void)
+{
+    return os_time_get();
+}
+
+unsigned long oc_clock_seconds(void)
+{
+    return os_time_get()/OS_TICKS_PER_SEC;
+}
+
+void oc_clock_wait(oc_clock_time_t t)
+{
+    os_time_delay(t);
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/23b0a5ac/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 673ec1c..1889a70 100644
--- a/libs/iotivity/src/port/mynewt/config.h
+++ b/libs/iotivity/src/port/mynewt/config.h
@@ -8,6 +8,11 @@
 
 typedef os_time_t oc_clock_time_t;
 #define OC_CLOCK_CONF_TICKS_PER_SECOND (OS_TICKS_PER_SEC)
+#ifdef ARCH_sim
+#define OC_CLK_FMT  "%u"
+#else
+#define OC_CLK_FMT  "%lu"
+#endif
 
 /* Memory pool sizes */
 #define OC_BYTES_POOL_SIZE (2048)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/23b0a5ac/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
new file mode 100644
index 0000000..b32fc39
--- /dev/null
+++ b/libs/iotivity/src/port/mynewt/ip_adaptor.c
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "../oc_network_events_mutex.h"
+#include "../oc_connectivity.h"
+
+void oc_network_event_handler_mutex_init(void)
+{
+}
+
+void oc_network_event_handler_mutex_lock(void)
+{
+}
+
+void oc_network_event_handler_mutex_unlock(void)
+{
+}
+
+void oc_send_buffer(oc_message_t *message)
+{
+}
+
+#ifdef OC_SECURITY
+uint16_t oc_connectivity_get_dtls_port(void)
+{
+}
+#endif /* OC_SECURITY */
+
+int oc_connectivity_init(void)
+{
+    return -1;
+}
+
+void oc_connectivity_shutdown(void)
+{
+}
+
+void oc_send_multicast_message(oc_message_t *message)
+{
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/23b0a5ac/libs/iotivity/src/port/mynewt/oc_loop.c
----------------------------------------------------------------------
diff --git a/libs/iotivity/src/port/mynewt/oc_loop.c b/libs/iotivity/src/port/mynewt/oc_loop.c
new file mode 100644
index 0000000..ca91812
--- /dev/null
+++ b/libs/iotivity/src/port/mynewt/oc_loop.c
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT` WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "../oc_signal_main_loop.h"
+
+
+void oc_signal_main_loop(void)
+{
+    /* TODO */
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/23b0a5ac/libs/iotivity/src/port/mynewt/random.c
----------------------------------------------------------------------
diff --git a/libs/iotivity/src/port/mynewt/random.c b/libs/iotivity/src/port/mynewt/random.c
new file mode 100644
index 0000000..0fcddfb
--- /dev/null
+++ b/libs/iotivity/src/port/mynewt/random.c
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include "../oc_random.h"
+#include <stdlib.h>
+
+void oc_random_init(unsigned short seed) {
+    srand(seed);
+}
+
+unsigned short oc_random_rand(void) {
+    return rand();
+}
+
+void oc_random_destroy(void) {
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/23b0a5ac/libs/iotivity/src/port/mynewt/storage.c
----------------------------------------------------------------------
diff --git a/libs/iotivity/src/port/mynewt/storage.c b/libs/iotivity/src/port/mynewt/storage.c
new file mode 100644
index 0000000..3b77c1a
--- /dev/null
+++ b/libs/iotivity/src/port/mynewt/storage.c
@@ -0,0 +1,38 @@
+/**
+ * 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 <stddef.h>
+#include <stdint.h>
+
+/* we will not really use storage until after we get security working */
+int oc_storage_config(const char *store) {
+    return -1;
+}
+
+long oc_storage_read(const char *store, uint8_t *buf, size_t size)
+{
+    return -1;
+}
+
+
+long oc_storage_write(const char *store, uint8_t *buf, size_t size)
+{
+    return -1;
+}