You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2017/11/15 17:11:48 UTC

[GitHub] mkiiskila closed pull request #658: Change iptest light resource to match bleprph_oic

mkiiskila closed pull request #658: Change iptest light resource to match bleprph_oic
URL: https://github.com/apache/mynewt-core/pull/658
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/apps/iptest/src/main.c b/apps/iptest/src/main.c
index 96820a207..8eb295842 100755
--- a/apps/iptest/src/main.c
+++ b/apps/iptest/src/main.c
@@ -321,19 +321,19 @@ net_cli(int argc, char **argv)
 static void
 app_get_light(oc_request_t *request, oc_interface_mask_t interface)
 {
-    bool state;
+    bool value;
 
     if (hal_gpio_read(LED_BLINK_PIN)) {
-        state = true;
+        value = true;
     } else {
-        state = false;
+        value = false;
     }
     oc_rep_start_root_object();
     switch (interface) {
     case OC_IF_BASELINE:
         oc_process_baseline_interface(request->resource);
-    case OC_IF_RW:
-        oc_rep_set_boolean(root, state, state);
+    case OC_IF_A:
+        oc_rep_set_boolean(root, value, value);
         break;
     default:
         break;
@@ -345,15 +345,15 @@ app_get_light(oc_request_t *request, oc_interface_mask_t interface)
 static void
 app_set_light(oc_request_t *request, oc_interface_mask_t interface)
 {
-    bool state;
+    bool value;
     int len;
     uint16_t data_off;
     struct os_mbuf *m;
     struct cbor_attr_t attrs[] = {
         [0] = {
-            .attribute = "state",
+            .attribute = "value",
             .type = CborAttrBooleanType,
-            .addr.boolean = &state,
+            .addr.boolean = &value,
             .dflt.boolean = false
         },
         [1] = {
@@ -364,7 +364,7 @@ app_set_light(oc_request_t *request, oc_interface_mask_t interface)
     if (cbor_read_mbuf_attrs(m, data_off, len, attrs)) {
         oc_send_response(request, OC_STATUS_BAD_REQUEST);
     } else {
-        hal_gpio_write(LED_BLINK_PIN, state == true);
+        hal_gpio_write(LED_BLINK_PIN, value == true);
         oc_send_response(request, OC_STATUS_CHANGED);
     }
 }
@@ -379,14 +379,15 @@ omgr_app_init(void)
                   NULL);
 
     res = oc_new_resource("/light/1", 1, 0);
-    oc_resource_bind_resource_type(res, "oic.r.light");
-    oc_resource_bind_resource_interface(res, OC_IF_RW);
-    oc_resource_set_default_interface(res, OC_IF_RW);
+    oc_resource_bind_resource_type(res, "oic.r.switch.binary");
+    oc_resource_bind_resource_interface(res, OC_IF_A);
+    oc_resource_set_default_interface(res, OC_IF_A);
 
     oc_resource_set_discoverable(res);
     oc_resource_set_periodic_observable(res, 1);
     oc_resource_set_request_handler(res, OC_GET, app_get_light);
     oc_resource_set_request_handler(res, OC_PUT, app_set_light);
+    oc_resource_set_request_handler(res, OC_POST, app_set_light);
     oc_add_resource(res);
 
     hal_gpio_init_out(LED_BLINK_PIN, 1);


 

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


With regards,
Apache Git Services