{"action":"created","comment":{"url":"https://api.github.com/repos/solettaproject/soletta/pulls/comments/69325156","id":69325156,"diff_hunk":"@@ -3085,6 +3163,127 @@ handle_create(struct sol_lwm2m_client *client,\n     return SOL_COAP_RESPONSE_CODE_BAD_REQUEST;\n }\n \n+static uint8_t\n+handle_write(struct sol_lwm2m_client *client,\n+    struct obj_ctx *obj_ctx, struct obj_instance *obj_instance,\n+    uint16_t *path, uint16_t path_size,\n+    struct sol_lwm2m_payload payload)\n+{\n+    int r;\n+\n+    if (client->is_bootstrapping) {\n+        clear_bootstrap_ctx(client);\n+    }\n+\n+    if (path_size < 2 && client->is_bootstrapping) {\n+        //Bootstrap Write on Object (e.g.: PUT /1)\n+        //In this case the payload is composed of <multiple TLVs> of type OBJECT_INSTANCE,\n+        // <each one containing multiple TLVs> of type MULTIPLE_RESOURCES or RESOURCE_WITH_VALUE\n+        // and each TLV of type MULTIPLE_RESOURCES can contain multiple TLVs of type\n+        // RESOURCE_INSTANCE\n+        struct sol_lwm2m_tlv *instance_tlvs;\n+        uint16_t i;\n+\n+        if (payload.type == SOL_LWM2M_CONTENT_TYPE_TLV) {\n+            SOL_VECTOR_FOREACH_IDX (&payload.payload.tlv_content, instance_tlvs, i) {\n+                struct sol_lwm2m_payload instance_payload = { .type = SOL_LWM2M_CONTENT_TYPE_TLV };\n+\n+                if (instance_tlvs->type != SOL_LWM2M_TLV_TYPE_OBJECT_INSTANCE) {\n+                    SOL_WRN(\"Only TLV is supported for writing an individual Object Instance.\"\n+                        \" Received: %\" PRIu16 \". Skipping this instance.\", instance_tlvs->type);\n+                    continue;\n+                }\n+\n+                sol_vector_init(&instance_payload.payload.tlv_content,\n+                    sizeof(struct sol_lwm2m_tlv));\n+\n+                instance_payload.payload.tlv_content.data =\n+                    (unsigned char *)payload.payload.tlv_content.data +\n+                    (payload.payload.tlv_content.elem_size * (i + 1));\n+                SOL_NULL_CHECK_GOTO(instance_payload.payload.tlv_content.data, err_build_tlvs);\n+                instance_payload.payload.tlv_content.len = instance_tlvs->content.used;\n+\n+                i += instance_tlvs->content.used;\n+\n+                obj_instance = find_object_instance_by_instance_id(obj_ctx, instance_tlvs->id);\n+\n+                //Instance already exists?\n+                if (obj_instance) {\n+                    r = write_instance_tlv_or_resource(client, obj_ctx, obj_instance, -1,\n+                        instance_payload);\n+                } else {\n+                    r = handle_create(client, obj_ctx, instance_tlvs->id, instance_payload);\n+                }\n+\n+                if (r == SOL_COAP_RESPONSE_CODE_CHANGED || r == SOL_COAP_RESPONSE_CODE_CREATED) {\n+                    SOL_DBG(\"Bootstrap Write on Object Instance /%\"\n+                        PRIu16 \"/%\" PRIu16 \" succeeded!\", obj_ctx->obj->id, instance_tlvs->id);\n+                } else {\n+                    SOL_WRN(\"Bootstrap Write on Object Instance /%\"\n+                        PRIu16 \"/%\" PRIu16 \" failed!\", obj_ctx->obj->id, instance_tlvs->id);","path":"src/lib/comms/sol-lwm2m.c","position":880,"original_position":327,"commit_id":"1760210e9a455fb73720e76278a6eb68ad785f43","original_commit_id":"6e9b16ad8f648bd5b44f212cf3e95d9388d87f10","user":{"login":"cabelitos","id":984610,"avatar_url":"https://avatars.githubusercontent.com/u/984610?v=3","gravatar_id":"","url":"https://api.github.com/users/cabelitos","html_url":"https://github.com/cabelitos","followers_url":"https://api.github.com/users/cabelitos/followers","following_url":"https://api.github.com/users/cabelitos/following{/other_user}","gists_url":"https://api.github.com/users/cabelitos/gists{/gist_id}","starred_url":"https://api.github.com/users/cabelitos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cabelitos/subscriptions","organizations_url":"https://api.github.com/users/cabelitos/orgs","repos_url":"https://api.github.com/users/cabelitos/repos","events_url":"https://api.github.com/users/cabelitos/events{/privacy}","received_events_url":"https://api.github.com/users/cabelitos/received_events","type":"User","site_admin":false},"body":"yeah","created_at":"2016-07-01T16:30:50Z","updated_at":"2016-07-01T16:30:50Z","html_url":"https://github.com/solettaproject/soletta/pull/2217#discussion_r69325156","pull_request_url":"https://api.github.com/repos/solettaproject/soletta/pulls/2217","_links":{"self":{"href":"https://api.github.com/repos/solettaproject/soletta/pulls/comments/69325156"},"html":{"href":"https://github.com/solettaproject/soletta/pull/2217#discussion_r69325156"},"pull_request":{"href":"https://api.github.com/repos/solettaproject/soletta/pulls/2217"}}},"pull_request":{"url":"https://api.github.com/repos/solettaproject/soletta/pulls/2217","id":75900432,"html_url":"https://github.com/solettaproject/soletta/pull/2217","diff_url":"https://github.com/solettaproject/soletta/pull/2217.diff","patch_url":"https://github.com/solettaproject/soletta/pull/2217.patch","issue_url":"https://api.github.com/repos/solettaproject/soletta/issues/2217","number":2217,"state":"open","locked":false,"title":"lwm2m: adding the Bootstrap Interface [v3]","user":{"login":"bsmelo","id":15204241,"avatar_url":"https://avatars.githubusercontent.com/u/15204241?v=3","gravatar_id":"","url":"https://api.github.com/users/bsmelo","html_url":"https://github.com/bsmelo","followers_url":"https://api.github.com/users/bsmelo/followers","following_url":"https://api.github.com/users/bsmelo/following{/other_user}","gists_url":"https://api.github.com/users/bsmelo/gists{/gist_id}","starred_url":"https://api.github.com/users/bsmelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsmelo/subscriptions","organizations_url":"https://api.github.com/users/bsmelo/orgs","repos_url":"https://api.github.com/users/bsmelo/repos","events_url":"https://api.github.com/users/bsmelo/events{/privacy}","received_events_url":"https://api.github.com/users/bsmelo/received_events","type":"User","site_admin":false},"body":"- Main changes from v2 (#2183):\r\n - Refactored Write/Delete operations' handling.\r\n - Better callback chaining and checking return code in the samples.\r\n - Bootstrap Write on Object (with multiple Instances) now works, thanks to #2212 as well.\r\n - Samples are nicer now, testing Bootstrap Write for Resource, Object Instance and Object, as well as Bootstrap Delete for '/'.\r\n- Future Improvements\r\n - Use the `SOL_MAIN_DEFAULT()`\r\n - Add an API to add and remove known clients on the fly\r\n - Add tests to `test-lwm2m.c`\r\n\r\nSigned-off-by: Bruno Melo bsilva.melo@gmail.com","created_at":"2016-06-30T22:22:38Z","updated_at":"2016-07-01T16:30:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"49c2716faec3254418d653ec6dbd81fddfcbf765","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/solettaproject/soletta/pulls/2217/commits","review_comments_url":"https://api.github.com/repos/solettaproject/soletta/pulls/2217/comments","review_comment_url":"https://api.github.com/repos/solettaproject/soletta/pulls/comments{/number}","comments_url":"https://api.github.com/repos/solettaproject/soletta/issues/2217/comments","statuses_url":"https://api.github.com/repos/solettaproject/soletta/statuses/1760210e9a455fb73720e76278a6eb68ad785f43","head":{"label":"bsmelo:lwm2m-bootstrap-v3","ref":"lwm2m-bootstrap-v3","sha":"1760210e9a455fb73720e76278a6eb68ad785f43","user":{"login":"bsmelo","id":15204241,"avatar_url":"https://avatars.githubusercontent.com/u/15204241?v=3","gravatar_id":"","url":"https://api.github.com/users/bsmelo","html_url":"https://github.com/bsmelo","followers_url":"https://api.github.com/users/bsmelo/followers","following_url":"https://api.github.com/users/bsmelo/following{/other_user}","gists_url":"https://api.github.com/users/bsmelo/gists{/gist_id}","starred_url":"https://api.github.com/users/bsmelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsmelo/subscriptions","organizations_url":"https://api.github.com/users/bsmelo/orgs","repos_url":"https://api.github.com/users/bsmelo/repos","events_url":"https://api.github.com/users/bsmelo/events{/privacy}","received_events_url":"https://api.github.com/users/bsmelo/received_events","type":"User","site_admin":false},"repo":{"id":54440906,"name":"soletta","full_name":"bsmelo/soletta","owner":{"login":"bsmelo","id":15204241,"avatar_url":"https://avatars.githubusercontent.com/u/15204241?v=3","gravatar_id":"","url":"https://api.github.com/users/bsmelo","html_url":"https://github.com/bsmelo","followers_url":"https://api.github.com/users/bsmelo/followers","following_url":"https://api.github.com/users/bsmelo/following{/other_user}","gists_url":"https://api.github.com/users/bsmelo/gists{/gist_id}","starred_url":"https://api.github.com/users/bsmelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsmelo/subscriptions","organizations_url":"https://api.github.com/users/bsmelo/orgs","repos_url":"https://api.github.com/users/bsmelo/repos","events_url":"https://api.github.com/users/bsmelo/events{/privacy}","received_events_url":"https://api.github.com/users/bsmelo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bsmelo/soletta","description":"Soletta Project is a framework for making IoT devices.  With Soletta Project's libraries developers can easily write software for devices that control actuators/sensors and communicate using standard technologies. It enables adding smartness even on the smallest edge devices.  ","fork":true,"url":"https://api.github.com/repos/bsmelo/soletta","forks_url":"https://api.github.com/repos/bsmelo/soletta/forks","keys_url":"https://api.github.com/repos/bsmelo/soletta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bsmelo/soletta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bsmelo/soletta/teams","hooks_url":"https://api.github.com/repos/bsmelo/soletta/hooks","issue_events_url":"https://api.github.com/repos/bsmelo/soletta/issues/events{/number}","events_url":"https://api.github.com/repos/bsmelo/soletta/events","assignees_url":"https://api.github.com/repos/bsmelo/soletta/assignees{/user}","branches_url":"https://api.github.com/repos/bsmelo/soletta/branches{/branch}","tags_url":"https://api.github.com/repos/bsmelo/soletta/tags","blobs_url":"https://api.github.com/repos/bsmelo/soletta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bsmelo/soletta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bsmelo/soletta/git/refs{/sha}","trees_url":"https://api.github.com/repos/bsmelo/soletta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bsmelo/soletta/statuses/{sha}","languages_url":"https://api.github.com/repos/bsmelo/soletta/languages","stargazers_url":"https://api.github.com/repos/bsmelo/soletta/stargazers","contributors_url":"https://api.github.com/repos/bsmelo/soletta/contributors","subscribers_url":"https://api.github.com/repos/bsmelo/soletta/subscribers","subscription_url":"https://api.github.com/repos/bsmelo/soletta/subscription","commits_url":"https://api.github.com/repos/bsmelo/soletta/commits{/sha}","git_commits_url":"https://api.github.com/repos/bsmelo/soletta/git/commits{/sha}","comments_url":"https://api.github.com/repos/bsmelo/soletta/comments{/number}","issue_comment_url":"https://api.github.com/repos/bsmelo/soletta/issues/comments{/number}","contents_url":"https://api.github.com/repos/bsmelo/soletta/contents/{+path}","compare_url":"https://api.github.com/repos/bsmelo/soletta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bsmelo/soletta/merges","archive_url":"https://api.github.com/repos/bsmelo/soletta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bsmelo/soletta/downloads","issues_url":"https://api.github.com/repos/bsmelo/soletta/issues{/number}","pulls_url":"https://api.github.com/repos/bsmelo/soletta/pulls{/number}","milestones_url":"https://api.github.com/repos/bsmelo/soletta/milestones{/number}","notifications_url":"https://api.github.com/repos/bsmelo/soletta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bsmelo/soletta/labels{/name}","releases_url":"https://api.github.com/repos/bsmelo/soletta/releases{/id}","deployments_url":"https://api.github.com/repos/bsmelo/soletta/deployments","created_at":"2016-03-22T03:04:07Z","updated_at":"2016-03-22T03:04:11Z","pushed_at":"2016-06-30T22:58:42Z","git_url":"git://github.com/bsmelo/soletta.git","ssh_url":"git@github.com:bsmelo/soletta.git","clone_url":"https://github.com/bsmelo/soletta.git","svn_url":"https://github.com/bsmelo/soletta","homepage":"http://solettaproject.org","size":21584,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"solettaproject:master","ref":"master","sha":"7e306544aaa33b1f2f19f34a4fac69852dfb1b55","user":{"login":"solettaproject","id":12736897,"avatar_url":"https://avatars.githubusercontent.com/u/12736897?v=3","gravatar_id":"","url":"https://api.github.com/users/solettaproject","html_url":"https://github.com/solettaproject","followers_url":"https://api.github.com/users/solettaproject/followers","following_url":"https://api.github.com/users/solettaproject/following{/other_user}","gists_url":"https://api.github.com/users/solettaproject/gists{/gist_id}","starred_url":"https://api.github.com/users/solettaproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solettaproject/subscriptions","organizations_url":"https://api.github.com/users/solettaproject/orgs","repos_url":"https://api.github.com/users/solettaproject/repos","events_url":"https://api.github.com/users/solettaproject/events{/privacy}","received_events_url":"https://api.github.com/users/solettaproject/received_events","type":"Organization","site_admin":false},"repo":{"id":37087063,"name":"soletta","full_name":"solettaproject/soletta","owner":{"login":"solettaproject","id":12736897,"avatar_url":"https://avatars.githubusercontent.com/u/12736897?v=3","gravatar_id":"","url":"https://api.github.com/users/solettaproject","html_url":"https://github.com/solettaproject","followers_url":"https://api.github.com/users/solettaproject/followers","following_url":"https://api.github.com/users/solettaproject/following{/other_user}","gists_url":"https://api.github.com/users/solettaproject/gists{/gist_id}","starred_url":"https://api.github.com/users/solettaproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solettaproject/subscriptions","organizations_url":"https://api.github.com/users/solettaproject/orgs","repos_url":"https://api.github.com/users/solettaproject/repos","events_url":"https://api.github.com/users/solettaproject/events{/privacy}","received_events_url":"https://api.github.com/users/solettaproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/solettaproject/soletta","description":"Soletta Project is a framework for making IoT devices.  With Soletta Project's libraries developers can easily write software for devices that control actuators/sensors and communicate using standard technologies. It enables adding smartness even on the smallest edge devices.  ","fork":false,"url":"https://api.github.com/repos/solettaproject/soletta","forks_url":"https://api.github.com/repos/solettaproject/soletta/forks","keys_url":"https://api.github.com/repos/solettaproject/soletta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/solettaproject/soletta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/solettaproject/soletta/teams","hooks_url":"https://api.github.com/repos/solettaproject/soletta/hooks","issue_events_url":"https://api.github.com/repos/solettaproject/soletta/issues/events{/number}","events_url":"https://api.github.com/repos/solettaproject/soletta/events","assignees_url":"https://api.github.com/repos/solettaproject/soletta/assignees{/user}","branches_url":"https://api.github.com/repos/solettaproject/soletta/branches{/branch}","tags_url":"https://api.github.com/repos/solettaproject/soletta/tags","blobs_url":"https://api.github.com/repos/solettaproject/soletta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/solettaproject/soletta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/solettaproject/soletta/git/refs{/sha}","trees_url":"https://api.github.com/repos/solettaproject/soletta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/solettaproject/soletta/statuses/{sha}","languages_url":"https://api.github.com/repos/solettaproject/soletta/languages","stargazers_url":"https://api.github.com/repos/solettaproject/soletta/stargazers","contributors_url":"https://api.github.com/repos/solettaproject/soletta/contributors","subscribers_url":"https://api.github.com/repos/solettaproject/soletta/subscribers","subscription_url":"https://api.github.com/repos/solettaproject/soletta/subscription","commits_url":"https://api.github.com/repos/solettaproject/soletta/commits{/sha}","git_commits_url":"https://api.github.com/repos/solettaproject/soletta/git/commits{/sha}","comments_url":"https://api.github.com/repos/solettaproject/soletta/comments{/number}","issue_comment_url":"https://api.github.com/repos/solettaproject/soletta/issues/comments{/number}","contents_url":"https://api.github.com/repos/solettaproject/soletta/contents/{+path}","compare_url":"https://api.github.com/repos/solettaproject/soletta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/solettaproject/soletta/merges","archive_url":"https://api.github.com/repos/solettaproject/soletta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/solettaproject/soletta/downloads","issues_url":"https://api.github.com/repos/solettaproject/soletta/issues{/number}","pulls_url":"https://api.github.com/repos/solettaproject/soletta/pulls{/number}","milestones_url":"https://api.github.com/repos/solettaproject/soletta/milestones{/number}","notifications_url":"https://api.github.com/repos/solettaproject/soletta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/solettaproject/soletta/labels{/name}","releases_url":"https://api.github.com/repos/solettaproject/soletta/releases{/id}","deployments_url":"https://api.github.com/repos/solettaproject/soletta/deployments","created_at":"2015-06-08T19:13:18Z","updated_at":"2016-06-28T17:50:23Z","pushed_at":"2016-07-01T06:55:10Z","git_url":"git://github.com/solettaproject/soletta.git","ssh_url":"git@github.com:solettaproject/soletta.git","clone_url":"https://github.com/solettaproject/soletta.git","svn_url":"https://github.com/solettaproject/soletta","homepage":"http://solettaproject.org","size":30401,"stargazers_count":107,"watchers_count":107,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":86,"mirror_url":null,"open_issues_count":119,"forks":86,"open_issues":119,"watchers":107,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/solettaproject/soletta/pulls/2217"},"html":{"href":"https://github.com/solettaproject/soletta/pull/2217"},"issue":{"href":"https://api.github.com/repos/solettaproject/soletta/issues/2217"},"comments":{"href":"https://api.github.com/repos/solettaproject/soletta/issues/2217/comments"},"review_comments":{"href":"https://api.github.com/repos/solettaproject/soletta/pulls/2217/comments"},"review_comment":{"href":"https://api.github.com/repos/solettaproject/soletta/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/solettaproject/soletta/pulls/2217/commits"},"statuses":{"href":"https://api.github.com/repos/solettaproject/soletta/statuses/1760210e9a455fb73720e76278a6eb68ad785f43"}}}}
{"actor":{"display_login":"cabelitos"}}