简体   繁体   中英

App crashes when deleting an LWM2M object using mbed-client on mbed-os

How do can I delete an object and its instance while mbed client is connected to the device server?

Currently I have a class that creates an object in the constructor and I register it with mbed client. I would also like to delete this object when the destructor is called. I'm trying the following:

In the constructor:

object = M2MInterfaceFactory::create_object(name);
instance = object->create_object_instance();

In the destructor:

object->remove_object_instance(instance->instance_id());
// delete object;

The above code works but the object is never removed from memory.

If I uncomment the line to call the object's destructor then my application crashes. I used mbed-trace to see if there are any error messages, but couldn't find anything. Here is the output of the log from the call to the destructor until the app crashes.

I'm using a Nucleo-F401RE with mbed-os 5.4.1.

As per my observation, you have to de-register first and then delete the interface/resources.

However, I have seen that mbed client interface for some reason cannot be created more than 6 times after successive destruction; one the 7th occasion client cannot connect to server and returns 'M2MIvaildParametersError'. I will be grateful if someone can comment on this?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM