Skip to content
This repository was archived by the owner on Apr 24, 2019. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions source/m2mdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

#include <stdlib.h>
#include "mbed-client/m2mdevice.h"
#include "mbed-client/m2mconstants.h"
#include "mbed-client/m2mobject.h"
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions source/m2mnsdlinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down