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/26 22:14:48 UTC
[3/6] incubator-mynewt-core git commit: working BLE COAP GATT server
side.
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 <pa...@yahoo.com>
Authored: Mon Sep 26 10:03:34 2016 -0700
Committer: Paul Dietrich <pa...@yahoo.com>
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 <console/prompt.h>
#include <shell/shell.h>
#include <log/log.h>
+#include <hal/hal_cputime.h>
#include <iotivity/oc_api.h>
#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 = &g_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 for server only system \n");
#endif
}
+
+#endif
\ No newline at end of file