Skip to content
This repository has been archived by the owner on Apr 24, 2019. It is now read-only.

Commit

Permalink
Revert "Make code compatible with path change in nsdl-c"
Browse files Browse the repository at this point in the history
This reverts commit 953cfd1.

We need to revert the pathlen removal as that version of
mbed-client-c is not yet pushed and published at mbed-os.

Conflicts:
	source/m2mbase.cpp
  • Loading branch information
TeroJaasko committed Jan 10, 2017
1 parent 15c300b commit 5567aff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
6 changes: 2 additions & 4 deletions source/m2mbase.cpp
Expand Up @@ -79,11 +79,9 @@ M2MBase::M2MBase(const String& resource_name,
params->resource_type_ptr = (char*)
alloc_string_copy((uint8_t*) resource_type.c_str(), len);
}
params->path = (uint8_t*)path;
params->pathlen = strlen(path);

// The ownership of path parameter given is transferred to here, and no copy here is needed.
// This is a bit awkward, but the caller is the only one who actually knows yet the
// path and it can not be constructed here.
params->path = path;

params->mode = (const uint8_t)mode;
params->free_on_delete = true;
Expand Down
15 changes: 10 additions & 5 deletions source/m2mfirmware.cpp
Expand Up @@ -71,8 +71,9 @@ STATIC_PARAM_TYPE
static sn_nsdl_static_resource_parameters_s firmware_package_params_static = {
(char*)OMA_RESOURCE_TYPE, // resource_type_ptr
(char*)"", // interface_description_ptr
(char*)PACKAGE_PATH, // path
(uint8_t*)PACKAGE_PATH, // path
(uint8_t*)"", // resource
5, // strlen("5/0/0")
0, // resourcelen
false, // external_memory_block
SN_GRS_DYNAMIC, // mode
Expand All @@ -85,8 +86,9 @@ STATIC_PARAM_TYPE
static sn_nsdl_static_resource_parameters_s firmware_package_uri_params_static = {
(char*)OMA_RESOURCE_TYPE, // resource_type_ptr
(char*)"", // interface_description_ptr
(char*)PACKAGE_URI_PATH, // path
(uint8_t*)PACKAGE_URI_PATH, // path
(uint8_t*)"", // resource
5, // strlen("5/0/1")
0, // resourcelen
false, // external_memory_block
SN_GRS_DYNAMIC, // mode
Expand All @@ -99,8 +101,9 @@ STATIC_PARAM_TYPE
static sn_nsdl_static_resource_parameters_s firmware_update_params_static = {
(char*)OMA_RESOURCE_TYPE, // resource_type_ptr
(char*)"", // interface_description_ptr
(char*)UPDATE_PATH, // path
(uint8_t*)UPDATE_PATH, // path
(uint8_t*)"", // resource
5, // strlen(5/0/2)
0, // resourcelen
false, // external_memory_block
SN_GRS_DYNAMIC, // mode
Expand All @@ -113,8 +116,9 @@ STATIC_PARAM_TYPE
static sn_nsdl_static_resource_parameters_s firmware_state_params_static = {
(char*)OMA_RESOURCE_TYPE, // resource_type_ptr
(char*)"", // interface_description_ptr
(char*)STATE_URI_PATH, // path
(uint8_t*)STATE_URI_PATH, // path
(uint8_t*)"0", // resource
5, // strlen("5/0/3")
1, // resourcelen
false, // external_memory_block
SN_GRS_DYNAMIC, // mode
Expand All @@ -127,8 +131,9 @@ STATIC_PARAM_TYPE
static sn_nsdl_static_resource_parameters_s firmware_update_result_params_static = {
(char*)OMA_RESOURCE_TYPE, // resource_type_ptr
(char*)"", // interface_description_ptr
(char*)UPDATE_RESULT_PATH, // path
(uint8_t*)UPDATE_RESULT_PATH, // path
(uint8_t*)"0", // resource
5, // strlen(5/0/5)
1, // resourcelen
false, // external_memory_block
SN_GRS_DYNAMIC, // mode
Expand Down
7 changes: 4 additions & 3 deletions source/m2mnsdlinterface.cpp
Expand Up @@ -907,15 +907,16 @@ bool M2MNsdlInterface::create_nsdl_resource(M2MBase *base)
bool success = false;
if(base) {
int8_t result = 0;
sn_nsdl_dynamic_resource_parameters_s* nsdl_resource = base->get_nsdl_resource();
tr_debug("M2MNsdlInterface::create_nsdl_resource - path (%s)", nsdl_resource->static_resource_parameters->path);
sn_nsdl_dynamic_resource_parameters_s* orig_resource = base->get_nsdl_resource();
tr_debug("M2MNsdlInterface::create_nsdl_resource - path (%.*s)", orig_resource->static_resource_parameters->pathlen,
orig_resource->static_resource_parameters->path);

// needed on deletion
if (base->observation_handler() == NULL) {
base->set_observation_handler(this);
}

result = sn_nsdl_put_resource(_nsdl_handle, nsdl_resource);
result = sn_nsdl_put_resource(_nsdl_handle, orig_resource);
tr_debug("M2MNsdlInterface::create_nsdl_resource - Creating in NSDL-C result %d", result);

// Either the resource is created or it already
Expand Down

0 comments on commit 5567aff

Please sign in to comment.