terence zhang / Mbed OS mbed-os-example-wakaama

Dependencies:   C12832 LM75B

Revision:
15:d0f20339c1ad
Parent:
3:a280069151ac
--- a/wakaama/objects.c	Sat May 06 11:21:27 2017 +0000
+++ b/wakaama/objects.c	Sun May 07 03:00:16 2017 +0000
@@ -136,36 +136,43 @@
 {
     coap_status_t result;
     lwm2m_object_t * targetP;
+    LOG_URI(uriP);
 
-    LOG_URI(uriP);
     targetP = (lwm2m_object_t *)LWM2M_LIST_FIND(contextP->objectList, uriP->objectId);
     if (NULL == targetP) return COAP_404_NOT_FOUND;
     if (NULL == targetP->readFunc) return COAP_405_METHOD_NOT_ALLOWED;
-
+    
+    printf("TERENCE:%s, %d, flag = 0x%x\n",__FUNCTION__, __LINE__, uriP->flag);
     if (LWM2M_URI_IS_SET_INSTANCE(uriP))
     {
+        printf("TERENCE:%s, %d\n",__FUNCTION__, __LINE__);
         if (NULL == lwm2m_list_find(targetP->instanceList, uriP->instanceId)) return COAP_404_NOT_FOUND;
-
+        printf("TERENCE:%s, %d\n",__FUNCTION__, __LINE__);
         // single instance read
         if (LWM2M_URI_IS_SET_RESOURCE(uriP))
         {
+            printf("TERENCE:%s, %d\n",__FUNCTION__, __LINE__);
             *sizeP = 1;
             *dataP = lwm2m_data_new(*sizeP);
             if (*dataP == NULL) return COAP_500_INTERNAL_SERVER_ERROR;
 
             (*dataP)->id = uriP->resourceId;
         }
-
+        printf("TERENCE:%s, %d** result = %d\n",__FUNCTION__, __LINE__,result);
+        
         result = targetP->readFunc(uriP->instanceId, sizeP, dataP, targetP);
+        
+        printf("TERENCE:%s, %d** result = %d\n",__FUNCTION__, __LINE__,result);
     }
     else
     {
+        printf("TERENCE:%s, %d\n",__FUNCTION__, __LINE__);
         // multiple object instances read
         lwm2m_list_t * instanceP;
         int i;
 
         result = COAP_205_CONTENT;
-
+        printf("TERENCE:%s, %d\n",__FUNCTION__, __LINE__);
         *sizeP = 0;
         for (instanceP = targetP->instanceList; instanceP != NULL ; instanceP = instanceP->next)
         {
@@ -174,17 +181,22 @@
 
         if (*sizeP == 0)
         {
+            printf("TERENCE:%s, %d\n",__FUNCTION__, __LINE__);
             *dataP = NULL;
         }
         else
         {
+            printf("TERENCE:%s, %d\n",__FUNCTION__, __LINE__);
             *dataP = lwm2m_data_new(*sizeP);
             if (*dataP == NULL) return COAP_500_INTERNAL_SERVER_ERROR;
 
+            printf("TERENCE:%s, %d\n",__FUNCTION__, __LINE__);
             instanceP = targetP->instanceList;
             i = 0;
+            printf("TERENCE:%s, %d\n",__FUNCTION__, __LINE__);
             while (instanceP != NULL && result == COAP_205_CONTENT)
             {
+                printf("    TERENCE:%s, %d\n",__FUNCTION__, __LINE__);
                 result = targetP->readFunc(instanceP->id, (int*)&((*dataP)[i].value.asChildren.count), &((*dataP)[i].value.asChildren.array), targetP);
                 (*dataP)[i].type = LWM2M_TYPE_OBJECT_INSTANCE;
                 (*dataP)[i].id = instanceP->id;
@@ -193,6 +205,7 @@
             }
         }
     }
+    printf("TERENCE:%s, %d\n",__FUNCTION__, __LINE__);
 
     LOG_ARG("result: %u.%2u, size: %d", (result & 0xFF) >> 5, (result & 0x1F), *sizeP);
     return result;