diff --git a/source/m2mdevice.cpp b/source/m2mdevice.cpp index 7e662871..5a9360c4 100644 --- a/source/m2mdevice.cpp +++ b/source/m2mdevice.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include "mbed-client/m2mdevice.h" #include "mbed-client/m2mconstants.h" #include "mbed-client/m2mobject.h" @@ -203,11 +204,11 @@ M2MResource* M2MDevice::create_resource(DeviceResource resource, int64_t value) true); if(res) { - - res->set_operation(operation); - res->set_value(value); - + uint8_t size = 0; + uint8_t *buffer = String::convert_integer_to_array(value, size); + res->set_value(buffer,size); + free(buffer); res->set_register_uri(false); } } @@ -361,8 +362,10 @@ bool M2MDevice::set_resource_value(DeviceResource resource, // If it is any of the above resource // set the value of the resource. if (check_value_range(resource, value)) { - - success = res->set_value(value); + uint8_t size = 0; + uint8_t *buffer = String::convert_integer_to_array(value, size); + success = res->set_value(buffer,size); + free(buffer); } } } @@ -407,9 +410,11 @@ int64_t M2MDevice::resource_value_int(DeviceResource resource, M2MDevice::AvailablePowerSources == resource || M2MDevice::PowerSourceVoltage == resource || M2MDevice::PowerSourceCurrent == resource) { - - // note: the value may be 32bit int on 32b archs. - value = res->get_value_int(); + uint8_t* buffer = NULL; + uint32_t length; + res->get_value(buffer, length); + value = String::convert_array_to_integer(buffer, length); + free(buffer); } } return value; diff --git a/source/m2mnsdlinterface.cpp b/source/m2mnsdlinterface.cpp index a7235b7e..44690b0b 100644 --- a/source/m2mnsdlinterface.cpp +++ b/source/m2mnsdlinterface.cpp @@ -1668,12 +1668,15 @@ bool M2MNsdlInterface::validate_security_object() uint32_t public_key_size = _security->get_resource(M2MSecurity::PublicKey)->value_length(); uint32_t server_key_size = _security->get_resource(M2MSecurity::ServerPublicKey)->value_length(); uint32_t pkey_size = _security->get_resource(M2MSecurity::Secretkey)->value_length(); + M2MDevice* dev = M2MInterfaceFactory::create_device(); + uint32_t time = dev->resource_value_int(M2MDevice::CurrentTime); tr_debug("M2MNsdlInterface::validate_security_object - Server URI /0/0: %s", address.c_str()); tr_debug("M2MNsdlInterface::validate_security_object - is bs server /0/1: %d", is_bs_server); tr_debug("M2MNsdlInterface::validate_security_object - Security Mode /0/2: %" PRIu32, sec_mode); tr_debug("M2MNsdlInterface::validate_security_object - Public key size /0/3: %" PRIu32, public_key_size); tr_debug("M2MNsdlInterface::validate_security_object - Server Public key size /0/4: %" PRIu32, server_key_size); tr_debug("M2MNsdlInterface::validate_security_object - Secret key size /0/5: %" PRIu32, pkey_size); + tr_debug("M2MNsdlInterface::validate_security_object - Current time: %" PRIu32, time); // Only NoSec and Certificate modes are supported if (!address.empty() && !is_bs_server) { if (M2MSecurity::Certificate == sec_mode) {