Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: Allow empty multi instance resources #70

Closed
wants to merge 2 commits into from

Conversation

Alex-EEE
Copy link

@Alex-EEE Alex-EEE commented Aug 27, 2020

The client fails to register currently if a multi instance resource is created without any instances. This is allowed by the spec, in fact, it makes sense. The client may want to create a multi instance resource with no initial instances so that the server can PUT the resource instances later. (For example, our use case is just a simple place for our web team to store information specific to the IoT node in STRING format)

[x] I confirm this contribution is my own and I agree to license it with Apache 2.0.
[x] I confirm the moderators may change the PR before merging it in.
[x] I understand the release model prohibits detailed Git history and my contribution will be recorded to the list at the bottom of CONTRIBUTING.md.

Summary of changes

The client fails to register currently if a multi instance resource is created without any instances.  This is allowed by the spec, in fact, it makes sense.  The client may want to create a multi instance resource with no initial instances so that the server can PUT the resource instances later.  (For example, our use case is just a simple place for our web team to store information specific to the IoT node in STRING format)
@teetak01
Copy link
Contributor

Thanks, looks like a valid fix. Can you check the boxes in the template, and we will take a look how to patch this.

Allow creation of resource instances that didn't already exist.
@Alex-EEE
Copy link
Author

Ok, checked the boxes, and completed the fix with another commit.

@ristohuhtala
Copy link
Contributor

ristohuhtala commented Sep 27, 2020

Hi @Alex-EEE . @teetak01 assinged me to take this fix into our internal repository. After reviewing changes here are how those to methods will look like after this
M2MNsdlInterface::create_nsdl_resource_structure
if (res) { // if there are multiple instances supported if (multiple_instances) { const M2MResourceInstanceList &res_list = res->resource_instances(); if (!res_list.empty()) { M2MResourceInstanceList::const_iterator it; it = res_list.begin(); for ( ; it != res_list.end(); it++ ) { success = create_nsdl_resource((*it)); if (!success) { tr_error("M2MNsdlInterface::create_nsdl_resource_structure - instance creation failed"); return false; } } } } // Register the main Resource as well along with ResourceInstances success = create_nsdl_resource(res); }

M2MTLVDeserializer::deserialize_resource_instances
if(!found) { if(M2MTLVDeserializer::Post == operation) { error = M2MTLVDeserializer::NotAllowed; } else if(M2MTLVDeserializer::Put == operation) { // Create a new Resource Instance M2MResourceInstance *res_instance = resource.get_parent_object_instance().create_dynamic_resource_instance( resource.name(), "", resource.resource_instance_type(), true, til._id); if(res_instance) { res_instance->set_operation(M2MBase::PUT_ALLOWED); } } }

Edit: I am sorry, github seems to format code in comment to look really weird

@teetak01
Copy link
Contributor

I'll close this now. We fixed the reported issue #71 in 4.7.1 release version.

@teetak01 teetak01 closed this May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants