MYNEWT-729 SensorAPI: Send sensor data over OIC - Cleaning up
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/be12bfb2 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/be12bfb2 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/be12bfb2 Branch: refs/heads/master Commit: be12bfb26d4cccf286d45491ce3ae5706d4cd3f9 Parents: 686b92d Author: Vipul Rahane <vipulrah...@apache.org> Authored: Tue Apr 11 18:33:09 2017 -0700 Committer: Vipul Rahane <vipulrah...@apache.org> Committed: Mon Apr 17 16:14:20 2017 -0700 ---------------------------------------------------------------------- apps/sensors_test/syscfg.yml | 2 ++ hw/sensor/src/sensor_oic.c | 12 ++++++++++-- kernel/os/syscfg.yml | 2 +- net/oic/syscfg.yml | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/be12bfb2/apps/sensors_test/syscfg.yml ---------------------------------------------------------------------- diff --git a/apps/sensors_test/syscfg.yml b/apps/sensors_test/syscfg.yml index 1d650b1..04adddc 100644 --- a/apps/sensors_test/syscfg.yml +++ b/apps/sensors_test/syscfg.yml @@ -52,6 +52,8 @@ syscfg.vals: OC_TRANSPORT_GATT: 1 OC_APP_RESOURCES : 20 + FLOAT_USER: 1 + syscfg.defs: TSL2561_PRESENT: description: 'TSL2561 is present' http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/be12bfb2/hw/sensor/src/sensor_oic.c ---------------------------------------------------------------------- diff --git a/hw/sensor/src/sensor_oic.c b/hw/sensor/src/sensor_oic.c index 132b940..987e2a7 100644 --- a/hw/sensor/src/sensor_oic.c +++ b/hw/sensor/src/sensor_oic.c @@ -460,9 +460,15 @@ sensor_oic_get_data(oc_request_t *request, oc_interface_mask_t interface) char *typename; sensor_type_t type; const char s[2] = "/"; + char *tmpstr; + + tmpstr = calloc(request->resource->uri.os_sz, request->resource->uri.os_sz); + + memcpy(tmpstr, (char *)&(request->resource->uri.os_str[1]), + request->resource->uri.os_sz - 1); /* Parse the sensor device name from the uri */ - devname = strtok((char *)&(request->resource->uri.os_str[1]), s); + devname = strtok(tmpstr, s); typename = strtok(NULL, s); /* Look up sensor by name */ @@ -511,11 +517,13 @@ sensor_oic_get_data(oc_request_t *request, oc_interface_mask_t interface) break; } + free(tmpstr); sensor_unregister_listener(sensor, &listener); oc_rep_end_root_object(); oc_send_response(request, OC_STATUS_OK); return; err: + free(tmpstr); sensor_unregister_listener(sensor, &listener); oc_send_response(request, OC_STATUS_NOT_FOUND); } @@ -562,7 +570,7 @@ sensor_oic_init(void) res = oc_new_resource(tmpstr, 1, 0); free(tmpstr); - bufsize = strlen(sensor->s_dev->od_name) + strlen("sensors.r."); + bufsize = strlen(sensor->s_dev->od_name) + sizeof("sensors.r."); tmpstr = (char *)calloc(bufsize, bufsize); sprintf(tmpstr, "sensors.r.%s", sensor->s_dev->od_name); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/be12bfb2/kernel/os/syscfg.yml ---------------------------------------------------------------------- diff --git a/kernel/os/syscfg.yml b/kernel/os/syscfg.yml index d56c283..66eae3f 100644 --- a/kernel/os/syscfg.yml +++ b/kernel/os/syscfg.yml @@ -80,4 +80,4 @@ syscfg.defs: value: 0 FLOAT_USER: descriptiong: 'Enable float support for users' - value: 1 + value: 0 http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/be12bfb2/net/oic/syscfg.yml ---------------------------------------------------------------------- diff --git a/net/oic/syscfg.yml b/net/oic/syscfg.yml index 08eb9b9..51d86e2 100644 --- a/net/oic/syscfg.yml +++ b/net/oic/syscfg.yml @@ -58,7 +58,7 @@ syscfg.defs: OC_APP_RESOURCES: description: 'Maximum number of server resources' - value: 7 + value: 3 OC_NUM_DEVICES: description: 'Number of devices on the OCF platform'