Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 12 months ago.
Mbed Client - M2MDevice registration
Hi All, I can't understand how to registrate a M2MDevice to my cloud (if you look in your dash board you have devices which should be some how registrate). In example we have next code: M2MDevice* create_device_object() { M2MDevice *device = M2MInterfaceFactory::create_device(); if (device) { device->create_resource(M2MDevice::Manufacturer, _device.Manufacturer); device->create_resource(M2MDevice::DeviceType, _device.Type); device->create_resource(M2MDevice::ModelNumber, _device.ModelNumber); device->create_resource(M2MDevice::SerialNumber, _device.SerialNumber); device->set_operation(M2MBase::POST_ALLOWED); device->set_register_uri(true); } return device; } How this code can registrate a device with Manufacture name ...? If you look to create_resource function this will registrate only device_id: _device_instance->create_dynamic_resource(device_id, OMA_RESOURCE_TYPE, M2MResourceInstance::STRING, true); but no info about manufacturea for example. In my opinion this code create only memory leaks and registrate device_id to server. BR
1 Answer
7 years, 11 months ago.
Hi Gindacul,
I think you may missed or get misunderstanding parts of the code.
Below line will only create dynamic resource with giving type ("Manufacturer", "HardwareVersion" etc.)
res = _device_instance->create_dynamic_resource(device_id, OMA_RESOURCE_TYPE, M2MResourceInstance::STRING, true);
While after that, the actual Manufacture name will be set into the resource by below lines:
if (value.empty()) { res->clear_value(); } else { res->set_value((const uint8_t*)value.c_str(), (uint32_t)value.length()); }
Hope this answered your question.