简体   繁体   English

在mbed-os上使用mbed-client删除LWM2M对象时,应用程序崩溃

[英]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? 当mbed客户端连接到设备服务器时,如何删除对象及其实例?

Currently I have a class that creates an object in the constructor and I register it with mbed client. 目前我有一个类在构造函数中创建一个对象,我用mbed客户端注册它。 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. 我使用mbed-trace查看是否有任何错误消息,但找不到任何内容。 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. 我正在使用带有mbed-os 5.4.1的Nucleo-F401RE。

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; 但是,我已经看到mbed客户端接口由于某种原因在连续销毁后不能创建超过6次; one the 7th occasion client cannot connect to server and returns 'M2MIvaildParametersError'. 第7个客户端无法连接到服务器并返回'M2MIvaildParametersError'。 I will be grateful if someone can comment on this? 如果有人对此发表评论,我将不胜感激?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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