bool M2MLWClient::create_object(const char *name, bool new_instance, uint8_t object_operation, uint8_t object_instance_operation, uint16_t object_instance_id, bool object_observable, bool object_instance_observable) { bool success = false; M2MObjectInstance *inst = NULL; if(!_object) { _object = M2MInterfaceFactory::create_object(name); if(_object) { _object->set_operation(int_to_operation(object_operation)); _object->set_observable(object_observable); inst = _object->create_object_instance(object_instance_id); if(inst) { success = true; inst->set_operation(int_to_operation(object_instance_operation)); inst->set_observable(object_instance_observable); } } } else { if(new_instance) { inst = _object->create_object_instance(object_instance_id); if(inst) { success = true; inst->set_operation(int_to_operation(object_instance_operation)); inst->set_observable(object_instance_observable); } } } return success; }
bool create_generic_object() { bool success = false; _object = M2MInterfaceFactory::create_object("10"); if(_object) { _object->set_operation(M2MBase::GET_PUT_POST_ALLOWED); M2MObjectInstance* inst = _object->create_object_instance(); if(inst) { inst->set_operation(M2MBase::GET_PUT_POST_ALLOWED); inst->set_observable(false); char buffer[20]; int size = sprintf(buffer,"%d",_value); inst->create_static_resource("0", "ResourceTest", M2MResourceInstance::INTEGER, STATIC_VALUE, sizeof(STATIC_VALUE)-1); M2MResourceInstance* instance = inst->create_dynamic_resource_instance("1", "ResourceTest", M2MResourceInstance::INTEGER, true,0); if(instance) { instance->set_operation(M2MBase::GET_PUT_POST_ALLOWED); instance->set_value((const uint8_t*)buffer, (const uint32_t)size); instance->set_execute_function(execute_callback(this,&MbedClient::execute_function)); _value++; } } } return success; }