FRDM K64F Metronome

Committer:
ram54288
Date:
Sun May 14 18:35:07 2017 +0000
Revision:
0:a2cb7295a1f7
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ram54288 0:a2cb7295a1f7 1 /*
ram54288 0:a2cb7295a1f7 2 * Copyright (c) 2015 ARM Limited. All rights reserved.
ram54288 0:a2cb7295a1f7 3 * SPDX-License-Identifier: Apache-2.0
ram54288 0:a2cb7295a1f7 4 * Licensed under the Apache License, Version 2.0 (the License); you may
ram54288 0:a2cb7295a1f7 5 * not use this file except in compliance with the License.
ram54288 0:a2cb7295a1f7 6 * You may obtain a copy of the License at
ram54288 0:a2cb7295a1f7 7 *
ram54288 0:a2cb7295a1f7 8 * http://www.apache.org/licenses/LICENSE-2.0
ram54288 0:a2cb7295a1f7 9 *
ram54288 0:a2cb7295a1f7 10 * Unless required by applicable law or agreed to in writing, software
ram54288 0:a2cb7295a1f7 11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
ram54288 0:a2cb7295a1f7 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ram54288 0:a2cb7295a1f7 13 * See the License for the specific language governing permissions and
ram54288 0:a2cb7295a1f7 14 * limitations under the License.
ram54288 0:a2cb7295a1f7 15 */
ram54288 0:a2cb7295a1f7 16 #include <string.h>
ram54288 0:a2cb7295a1f7 17 #include <stdlib.h>
ram54288 0:a2cb7295a1f7 18 #include <stdarg.h>
ram54288 0:a2cb7295a1f7 19
ram54288 0:a2cb7295a1f7 20 //libServices
ram54288 0:a2cb7295a1f7 21 #include "ns_types.h"
ram54288 0:a2cb7295a1f7 22 #include "ns_cmdline.h"
ram54288 0:a2cb7295a1f7 23 #include "cmd_lwm2m.h"
ram54288 0:a2cb7295a1f7 24 #include "lwm2mtest.h"
ram54288 0:a2cb7295a1f7 25
ram54288 0:a2cb7295a1f7 26 #define CMD_MAN_LWM2M_CLIENT "lwm2m-client <cmd> [options] LWM2M mbed Client API\n"\
ram54288 0:a2cb7295a1f7 27 "setup <p> [options] Set up the LWM2M Interface\n"\
ram54288 0:a2cb7295a1f7 28 "<p>:\n"\
ram54288 0:a2cb7295a1f7 29 " Options for setup command\n"\
ram54288 0:a2cb7295a1f7 30 " --endpoint <name> Endpoint Name (mandatory)\n"\
ram54288 0:a2cb7295a1f7 31 " --type <name> Resource Type\n"\
ram54288 0:a2cb7295a1f7 32 " --lifetime <n> Lifetime in seconds, default is -1 means not included\n"\
ram54288 0:a2cb7295a1f7 33 " --port <n> Listen port, default is 5683\n"\
ram54288 0:a2cb7295a1f7 34 " --domain <name> Domain for mbed Device Server, default is empty\n"\
ram54288 0:a2cb7295a1f7 35 " --binding_mode <n> Binding Mode, NOT_SET = 0|UDP = 1(default)|QUEUE = 2|SMS = 4\n"\
ram54288 0:a2cb7295a1f7 36 " --network_interface <n> Network Interface, Uninitialized = 0 ,LwIP_IPv4 = 1(default), LwIP_IPv6 = 2, Nanostack_IPv6 = 4\n"\
ram54288 0:a2cb7295a1f7 37 "bootstrap_object <p> [options]\n"\
ram54288 0:a2cb7295a1f7 38 "<p>:\n"\
ram54288 0:a2cb7295a1f7 39 " Options for bootstrap object command\n"\
ram54288 0:a2cb7295a1f7 40 " --address <name> Bootstrap server address, format is coap://192.168.0.1:5683\n"\
ram54288 0:a2cb7295a1f7 41 "bootstrap Issues Bootstrap command\n"\
ram54288 0:a2cb7295a1f7 42 "object <p> [options]\n"\
ram54288 0:a2cb7295a1f7 43 "<p>:\n"\
ram54288 0:a2cb7295a1f7 44 " Options for custom object\n"\
ram54288 0:a2cb7295a1f7 45 " --name <name> Object name\n"\
ram54288 0:a2cb7295a1f7 46 " --new_instance <n> If you need new instance 0=false(default), 1=true\n"\
ram54288 0:a2cb7295a1f7 47 " --object_observable <n> Object is observable false=0(default), true=1\n"\
ram54288 0:a2cb7295a1f7 48 " --object_instance_observable <n> Object Instance is observable false=0(default), true=1\n"\
ram54288 0:a2cb7295a1f7 49 " --object_instance_id <n> Instance id of object instance 0=(default)\n"\
ram54288 0:a2cb7295a1f7 50 " --object_operation <n> Operation Mode, Default is 0, NOT_ALLOWED = 0, GET_ALLOWED = 1,\n"\
ram54288 0:a2cb7295a1f7 51 "PUT_ALLOWED = 2, GET_PUT_ALLOWED = 3, POST_ALLOWED = 4,GET_POST_ALLOWED = 5,\n"\
ram54288 0:a2cb7295a1f7 52 "PUT_POST_ALLOWED = 6, GET_PUT_POST_ALLOWED = 7, DELETE_ALLOWED = 8\n"\
ram54288 0:a2cb7295a1f7 53 " --object_instance_operation <n> Operation Mode, Default is 0, NOT_ALLOWED = 0, GET_ALLOWED = 1,\n"\
ram54288 0:a2cb7295a1f7 54 "PUT_ALLOWED = 2, GET_PUT_ALLOWED = 3, POST_ALLOWED = 4,GET_POST_ALLOWED = 5,\n"\
ram54288 0:a2cb7295a1f7 55 "PUT_POST_ALLOWED = 6, GET_PUT_POST_ALLOWED = 7, DELETE_ALLOWED = 8\n"\
ram54288 0:a2cb7295a1f7 56 "static_resource <p> [options]\n"\
ram54288 0:a2cb7295a1f7 57 "<p>:\n"\
ram54288 0:a2cb7295a1f7 58 " Options for static resource\n"\
ram54288 0:a2cb7295a1f7 59 " --object_instance <n> Instance Id of the object this resource is associated with, default is 0\n"\
ram54288 0:a2cb7295a1f7 60 " --name <name> Resource name\n"\
ram54288 0:a2cb7295a1f7 61 " --value <name> Resource value\n"\
ram54288 0:a2cb7295a1f7 62 " --value_type <n> Value Type String=0, Integer=1\n"\
ram54288 0:a2cb7295a1f7 63 " --multiple_instance <n> Supports multiple instances, false=0(default), true=1\n"\
ram54288 0:a2cb7295a1f7 64 "dynamic_resource <p> [options]\n"\
ram54288 0:a2cb7295a1f7 65 "<p>:\n"\
ram54288 0:a2cb7295a1f7 66 " Options for dynamic resource\n"\
ram54288 0:a2cb7295a1f7 67 " --object_instance <n> Instance Id of the object this resource is associated with, default is 0\n"\
ram54288 0:a2cb7295a1f7 68 " --name <name> Resource name\n"\
ram54288 0:a2cb7295a1f7 69 " --observable <n> Resource is observable false=0(default), true=1\n"\
ram54288 0:a2cb7295a1f7 70 " --multiple_instance <n> Supports multiple instances, false=0(default), true=1\n"\
ram54288 0:a2cb7295a1f7 71 " --resource_operation <n> Operation Mode, Default is 1, NOT_ALLOWED = 0, GET_ALLOWED = 1,\n"\
ram54288 0:a2cb7295a1f7 72 "PUT_ALLOWED = 2, GET_PUT_ALLOWED = 3, POST_ALLOWED = 4,GET_POST_ALLOWED = 5,\n"\
ram54288 0:a2cb7295a1f7 73 "PUT_POST_ALLOWED = 6, GET_PUT_POST_ALLOWED = 7, DELETE_ALLOWED = 8\n"\
ram54288 0:a2cb7295a1f7 74 "dynamic_resource <p> [options]\n"\
ram54288 0:a2cb7295a1f7 75 "static_resource_instance <p> [options]\n"\
ram54288 0:a2cb7295a1f7 76 "<p>:\n"\
ram54288 0:a2cb7295a1f7 77 " Options for static resource instance\n"\
ram54288 0:a2cb7295a1f7 78 " --object_instance <n> Instance Id of the object this resource is associated with, default is 0\n"\
ram54288 0:a2cb7295a1f7 79 " --resource_instance <n> Instance Id of the resource associated with, default is 0\n"\
ram54288 0:a2cb7295a1f7 80 " --name <name> Resource name\n"\
ram54288 0:a2cb7295a1f7 81 " --value <name> Resource value\n"\
ram54288 0:a2cb7295a1f7 82 " --value_type <n> Value Type String=0, Integer=1\n"\
ram54288 0:a2cb7295a1f7 83 " --multiple_instance <n> Supports multiple instances, false=0(default), true=1\n"\
ram54288 0:a2cb7295a1f7 84 "dynamic_resource <p> [options]\n"\
ram54288 0:a2cb7295a1f7 85 "dynamic_resource_instance <p> [options]\n"\
ram54288 0:a2cb7295a1f7 86 "<p>:\n"\
ram54288 0:a2cb7295a1f7 87 " Options for dynamic resource instance\n"\
ram54288 0:a2cb7295a1f7 88 " --object_instance <n> Instance Id of the object this resource is associated with, default is 0\n"\
ram54288 0:a2cb7295a1f7 89 " --resource_instance <n> Instance Id of the resource associated with, default is 0\n"\
ram54288 0:a2cb7295a1f7 90 " --name <name> Resource name\n"\
ram54288 0:a2cb7295a1f7 91 " --value_type <n> Value Type String=0, Integer=1(default)\n"\
ram54288 0:a2cb7295a1f7 92 " --observable <n> Resource is observable false=0(default), true=1\n"\
ram54288 0:a2cb7295a1f7 93 " --multiple_instance <n> Supports multiple instances, false=0(default), true=1\n"\
ram54288 0:a2cb7295a1f7 94 " --resource_instance_operation <n> Operation Mode, Default is 1, NOT_ALLOWED = 0, GET_ALLOWED = 1,\n"\
ram54288 0:a2cb7295a1f7 95 "PUT_ALLOWED = 2, GET_PUT_ALLOWED = 3, POST_ALLOWED = 4,GET_POST_ALLOWED = 5,\n"\
ram54288 0:a2cb7295a1f7 96 "PUT_POST_ALLOWED = 6, GET_PUT_POST_ALLOWED = 7, DELETE_ALLOWED = 8\n"\
ram54288 0:a2cb7295a1f7 97 "dynamic_resource <p> [options]\n"\
ram54288 0:a2cb7295a1f7 98 "device <p> [options]\n"\
ram54288 0:a2cb7295a1f7 99 "<p>:\n"\
ram54288 0:a2cb7295a1f7 100 " Options for device object \n"\
ram54288 0:a2cb7295a1f7 101 " --manufacturer <name> Manufacturer name\n"\
ram54288 0:a2cb7295a1f7 102 " --model_number <name> Model number\n"\
ram54288 0:a2cb7295a1f7 103 " --serial_number <name> Serial number\n"\
ram54288 0:a2cb7295a1f7 104 " --device_type <name> Device Type\n"\
ram54288 0:a2cb7295a1f7 105 " --hardware_version <name> Hardware version\n"\
ram54288 0:a2cb7295a1f7 106 " --software_version <name> Software version\n"\
ram54288 0:a2cb7295a1f7 107 " --firmware_version <name> Firmware version\n"\
ram54288 0:a2cb7295a1f7 108 " --available_power_sources <n> Number of available power sources, Must have Instance ID\n"\
ram54288 0:a2cb7295a1f7 109 " --power_source_voltage <n> Power source voltage, Must have Instance ID\n"\
ram54288 0:a2cb7295a1f7 110 " --power_source_current <n> Power source current, Must have Instance ID\n"\
ram54288 0:a2cb7295a1f7 111 " --battery_level <n> Battery level\n"\
ram54288 0:a2cb7295a1f7 112 " --battery_status <n> Battery status\n"\
ram54288 0:a2cb7295a1f7 113 " --memory_free <n> Free memory, in bytes\n"\
ram54288 0:a2cb7295a1f7 114 " --memory_total <n> Free memory in bytes\n"\
ram54288 0:a2cb7295a1f7 115 " --error_code <n> Error Code, Must have Instance ID\n"\
ram54288 0:a2cb7295a1f7 116 " --current_time <n> Current Time, EPOCH format\n"\
ram54288 0:a2cb7295a1f7 117 " --utc_offset <name> UTC Format\n"\
ram54288 0:a2cb7295a1f7 118 " --timezone <name> Time zone \n"\
ram54288 0:a2cb7295a1f7 119 " --instance_id <n> Instance ID for multiple resources \n"\
ram54288 0:a2cb7295a1f7 120 "firmware <p> [options]\n"\
ram54288 0:a2cb7295a1f7 121 "<p>:\n"\
ram54288 0:a2cb7295a1f7 122 " Options for firmware object \n"\
ram54288 0:a2cb7295a1f7 123 " --package <name> Firmware package\n"\
ram54288 0:a2cb7295a1f7 124 " --package_uri <name> URI from where the device can download package\n"\
ram54288 0:a2cb7295a1f7 125 " --state <n> State of firmware update\n"\
ram54288 0:a2cb7295a1f7 126 " --update_supported_objects <bool> Send update registration message after fw update\n"\
ram54288 0:a2cb7295a1f7 127 " --update_results <n> Result of downloading or updating firmware\n"\
ram54288 0:a2cb7295a1f7 128 " --package_name <name> Package name\n"\
ram54288 0:a2cb7295a1f7 129 " --package_version <name> Package version\n"\
ram54288 0:a2cb7295a1f7 130 "register_object <p> [options]\n"\
ram54288 0:a2cb7295a1f7 131 "<p>:\n"\
ram54288 0:a2cb7295a1f7 132 " Options for register command\n"\
ram54288 0:a2cb7295a1f7 133 " --address <name> mbed Device Server address, format is coap://192.168.0.1:5683\n"\
ram54288 0:a2cb7295a1f7 134 " --secure <number> 1 == secure mode, non-secure otherwise (remember: secure port is 5684)\n"\
ram54288 0:a2cb7295a1f7 135 "register Issues Register command\n"\
ram54288 0:a2cb7295a1f7 136 "update-register <p> [options] Issues Update registration command\n"\
ram54288 0:a2cb7295a1f7 137 "<p>:\n"\
ram54288 0:a2cb7295a1f7 138 " Options for update-register command\n"\
ram54288 0:a2cb7295a1f7 139 " --lifetime <n> Lifetime value in seconds\n"\
ram54288 0:a2cb7295a1f7 140 "unregister Issues Un-register command\n"\
ram54288 0:a2cb7295a1f7 141 "set_value <p> [options]\n"\
ram54288 0:a2cb7295a1f7 142 "<p>:\n"\
ram54288 0:a2cb7295a1f7 143 " Options for set_value command \n"\
ram54288 0:a2cb7295a1f7 144 " --name <name> Resource name (Mandatory)\n"\
ram54288 0:a2cb7295a1f7 145 " --value <value> Resource value (Mandatory)\n"\
ram54288 0:a2cb7295a1f7 146 " --object_instance <n> Instance ID of object this resource is associated with, default is 0\n"\
ram54288 0:a2cb7295a1f7 147 "set_value_instance <p> [options]\n"\
ram54288 0:a2cb7295a1f7 148 "<p>:\n"\
ram54288 0:a2cb7295a1f7 149 " Options for set_value_instance command for Resource Instances\n"\
ram54288 0:a2cb7295a1f7 150 " --name <name> Resource name (Mandatory)\n"\
ram54288 0:a2cb7295a1f7 151 " --value <value> Resource value (Mandatory)\n"\
ram54288 0:a2cb7295a1f7 152 " --object_instance <n> Instance ID of object this resource is associated with, default is 0\n"\
ram54288 0:a2cb7295a1f7 153 " --resource_instance <n> Instance ID of object of the resource, default is 0\n"\
ram54288 0:a2cb7295a1f7 154 "resource_value <p> [options]\n"\
ram54288 0:a2cb7295a1f7 155 "<p>:\n"\
ram54288 0:a2cb7295a1f7 156 " Options for resource_value command\n"\
ram54288 0:a2cb7295a1f7 157 " --firmware <n> Resource instance id in Firmware object\n"\
ram54288 0:a2cb7295a1f7 158
ram54288 0:a2cb7295a1f7 159 #define EXIT_MANUAL "exit :closes the application\n"
ram54288 0:a2cb7295a1f7 160
ram54288 0:a2cb7295a1f7 161
ram54288 0:a2cb7295a1f7 162 int lwm2m_client_command(int argc, char *argv[]);
ram54288 0:a2cb7295a1f7 163 int lwm2m_client_setup_command(int argc, char *argv[]);
ram54288 0:a2cb7295a1f7 164 int lwm2m_client_device_command(int argc, char *argv[]);
ram54288 0:a2cb7295a1f7 165 int lwm2m_client_object_command(int argc, char *argv[]);
ram54288 0:a2cb7295a1f7 166 int lwm2m_client_static_resource_command(int argc, char *argv[]);
ram54288 0:a2cb7295a1f7 167 int lwm2m_client_dynamic_resource_command(int argc, char *argv[]);
ram54288 0:a2cb7295a1f7 168 int lwm2m_client_static_resource_instance_command(int argc, char *argv[]);
ram54288 0:a2cb7295a1f7 169 int lwm2m_client_dynamic_resource_instance_command(int argc, char *argv[]);
ram54288 0:a2cb7295a1f7 170 int lwm2m_client_bootstrap_object_command(int argc, char *argv[]);
ram54288 0:a2cb7295a1f7 171 int lwm2m_client_bootstrap_command();
ram54288 0:a2cb7295a1f7 172 int lwm2m_client_register_object_command(int argc, char *argv[]);
ram54288 0:a2cb7295a1f7 173 int lwm2m_client_register_command();
ram54288 0:a2cb7295a1f7 174 int lwm2m_client_update_register_command(int argc, char *argv[]);
ram54288 0:a2cb7295a1f7 175 int lwm2m_client_unregister_command();
ram54288 0:a2cb7295a1f7 176 int lwm2m_client_set_value_command(int argc, char *argv[]);
ram54288 0:a2cb7295a1f7 177 int lwm2m_client_set_value_instance_command(int argc, char *argv[]);
ram54288 0:a2cb7295a1f7 178 int lwm2m_client_firmware_command(int argc, char *argv[]);
ram54288 0:a2cb7295a1f7 179 int lwm2m_client_resource_value(int argc, char *argv[]);
ram54288 0:a2cb7295a1f7 180 int exit_command(int argc, char *argv[]);
ram54288 0:a2cb7295a1f7 181
ram54288 0:a2cb7295a1f7 182 void lwm2m_command_init(void)
ram54288 0:a2cb7295a1f7 183 {
ram54288 0:a2cb7295a1f7 184 cmd_add("lwm2m-client", lwm2m_client_command, "LWM2M Client specific command", CMD_MAN_LWM2M_CLIENT);
ram54288 0:a2cb7295a1f7 185 cmd_alias_add("lwm2m-client-test-setup", "lwm2m-client setup --endpoint lwm2m-endpoint --type test --lifetime 3600");
ram54288 0:a2cb7295a1f7 186 cmd_alias_add("lwm2m-client-test-device", "lwm2m-client device --manufacturer ARM --model_number 2015 --serial_number 12345");
ram54288 0:a2cb7295a1f7 187 cmd_alias_add("lwm2m-client-test-bootstrap-object", "lwm2m-client bootstrap_object --address coap://10.45.3.10:5693");
ram54288 0:a2cb7295a1f7 188 cmd_alias_add("lwm2m-client-test-register-object", "lwm2m-client register_object --address coap://10.45.3.10:5683");
ram54288 0:a2cb7295a1f7 189 cmd_alias_add("lwm2m-client-test-object", "lwm2m-client object --name 10 --object_observable 1 --object_instance_observable 1 --object_operation 3 --object_instance_operation 3");
ram54288 0:a2cb7295a1f7 190 cmd_alias_add("lwm2m-client-test-dynamic_resource", "lwm2m-client dynamic_resource --name 1 --resource_operation 3 --observable 0");
ram54288 0:a2cb7295a1f7 191 cmd_alias_add("lwm2m-client-test-secure-register-object", "lwm2m-client register_object --address coap://10.45.3.10:5684 --secure 1");
ram54288 0:a2cb7295a1f7 192 cmd_add("exit", exit_command, "exit command", EXIT_MANUAL);
ram54288 0:a2cb7295a1f7 193 }
ram54288 0:a2cb7295a1f7 194 char *test_mem_block = 0;
ram54288 0:a2cb7295a1f7 195 int test_timer;
ram54288 0:a2cb7295a1f7 196 M2MLWClient lwm2m_client;
ram54288 0:a2cb7295a1f7 197
ram54288 0:a2cb7295a1f7 198 int lwm2m_client_command(int argc, char *argv[])
ram54288 0:a2cb7295a1f7 199 {
ram54288 0:a2cb7295a1f7 200 if( strcmp(argv[1], "setup") == 0 )
ram54288 0:a2cb7295a1f7 201 {
ram54288 0:a2cb7295a1f7 202 return lwm2m_client_setup_command(argc, argv);
ram54288 0:a2cb7295a1f7 203 }
ram54288 0:a2cb7295a1f7 204 else if( strcmp(argv[1], "bootstrap_object") == 0 )
ram54288 0:a2cb7295a1f7 205 {
ram54288 0:a2cb7295a1f7 206 return lwm2m_client_bootstrap_object_command(argc, argv);
ram54288 0:a2cb7295a1f7 207 }
ram54288 0:a2cb7295a1f7 208 else if( strcmp(argv[1], "bootstrap") == 0 )
ram54288 0:a2cb7295a1f7 209 {
ram54288 0:a2cb7295a1f7 210 return lwm2m_client_bootstrap_command();
ram54288 0:a2cb7295a1f7 211 }
ram54288 0:a2cb7295a1f7 212 else if( strcmp(argv[1], "device") == 0 )
ram54288 0:a2cb7295a1f7 213 {
ram54288 0:a2cb7295a1f7 214 return lwm2m_client_device_command(argc, argv);
ram54288 0:a2cb7295a1f7 215 }
ram54288 0:a2cb7295a1f7 216 else if( strcmp(argv[1], "firmware") == 0 )
ram54288 0:a2cb7295a1f7 217 {
ram54288 0:a2cb7295a1f7 218 return lwm2m_client_firmware_command(argc, argv);
ram54288 0:a2cb7295a1f7 219 }
ram54288 0:a2cb7295a1f7 220 else if( strcmp(argv[1], "resource_value") == 0 )
ram54288 0:a2cb7295a1f7 221 {
ram54288 0:a2cb7295a1f7 222 return lwm2m_client_resource_value(argc, argv);
ram54288 0:a2cb7295a1f7 223 }
ram54288 0:a2cb7295a1f7 224 else if( strcmp(argv[1], "object") == 0 )
ram54288 0:a2cb7295a1f7 225 {
ram54288 0:a2cb7295a1f7 226 return lwm2m_client_object_command(argc, argv);
ram54288 0:a2cb7295a1f7 227 }
ram54288 0:a2cb7295a1f7 228 else if( strcmp(argv[1], "static_resource") == 0 )
ram54288 0:a2cb7295a1f7 229 {
ram54288 0:a2cb7295a1f7 230 return lwm2m_client_static_resource_command(argc, argv);
ram54288 0:a2cb7295a1f7 231 }
ram54288 0:a2cb7295a1f7 232 else if( strcmp(argv[1], "dynamic_resource") == 0 )
ram54288 0:a2cb7295a1f7 233 {
ram54288 0:a2cb7295a1f7 234 return lwm2m_client_dynamic_resource_command(argc, argv);
ram54288 0:a2cb7295a1f7 235 }
ram54288 0:a2cb7295a1f7 236 else if( strcmp(argv[1], "static_resource_instance") == 0 )
ram54288 0:a2cb7295a1f7 237 {
ram54288 0:a2cb7295a1f7 238 return lwm2m_client_static_resource_instance_command(argc, argv);
ram54288 0:a2cb7295a1f7 239 }
ram54288 0:a2cb7295a1f7 240 else if( strcmp(argv[1], "dynamic_resource_instance") == 0 )
ram54288 0:a2cb7295a1f7 241 {
ram54288 0:a2cb7295a1f7 242 return lwm2m_client_dynamic_resource_instance_command(argc, argv);
ram54288 0:a2cb7295a1f7 243 }
ram54288 0:a2cb7295a1f7 244 else if( strcmp(argv[1], "register_object") == 0 )
ram54288 0:a2cb7295a1f7 245 {
ram54288 0:a2cb7295a1f7 246 return lwm2m_client_register_object_command(argc, argv);
ram54288 0:a2cb7295a1f7 247 }
ram54288 0:a2cb7295a1f7 248 else if( strcmp(argv[1], "register") == 0 )
ram54288 0:a2cb7295a1f7 249 {
ram54288 0:a2cb7295a1f7 250 return lwm2m_client_register_command();
ram54288 0:a2cb7295a1f7 251 }
ram54288 0:a2cb7295a1f7 252 else if( strcmp(argv[1], "update-register") == 0 )
ram54288 0:a2cb7295a1f7 253 {
ram54288 0:a2cb7295a1f7 254 return lwm2m_client_update_register_command(argc, argv);
ram54288 0:a2cb7295a1f7 255 }
ram54288 0:a2cb7295a1f7 256 else if( strcmp(argv[1], "unregister") == 0 )
ram54288 0:a2cb7295a1f7 257 {
ram54288 0:a2cb7295a1f7 258 return lwm2m_client_unregister_command();
ram54288 0:a2cb7295a1f7 259 }
ram54288 0:a2cb7295a1f7 260 else if ( strcmp(argv[1], "set_value") == 0)
ram54288 0:a2cb7295a1f7 261 {
ram54288 0:a2cb7295a1f7 262 return lwm2m_client_set_value_command(argc, argv);
ram54288 0:a2cb7295a1f7 263 }
ram54288 0:a2cb7295a1f7 264 else if ( strcmp(argv[1], "set_value_instance") == 0)
ram54288 0:a2cb7295a1f7 265 {
ram54288 0:a2cb7295a1f7 266 return lwm2m_client_set_value_instance_command(argc, argv);
ram54288 0:a2cb7295a1f7 267 }
ram54288 0:a2cb7295a1f7 268 //:TODO what another commands should be there ?
ram54288 0:a2cb7295a1f7 269 return CMDLINE_RETCODE_COMMAND_NOT_IMPLEMENTED;
ram54288 0:a2cb7295a1f7 270 }
ram54288 0:a2cb7295a1f7 271
ram54288 0:a2cb7295a1f7 272 int lwm2m_client_setup_command(int argc, char *argv[])
ram54288 0:a2cb7295a1f7 273 {
ram54288 0:a2cb7295a1f7 274 char *endpoint = 0;
ram54288 0:a2cb7295a1f7 275 char *type = 0;
ram54288 0:a2cb7295a1f7 276 int lifetime = -1;
ram54288 0:a2cb7295a1f7 277 int32_t port = 5683;
ram54288 0:a2cb7295a1f7 278 char *domain = 0;
ram54288 0:a2cb7295a1f7 279 int32_t binding_mode = 1;
ram54288 0:a2cb7295a1f7 280 int32_t network_interface = 1;
ram54288 0:a2cb7295a1f7 281
ram54288 0:a2cb7295a1f7 282 if (!cmd_parameter_val(argc, argv, "--endpoint", &endpoint)) {
ram54288 0:a2cb7295a1f7 283 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 284 }
ram54288 0:a2cb7295a1f7 285 int opt_params = 0;
ram54288 0:a2cb7295a1f7 286 cmd_parameter_val(argc, argv, "--type", &type);
ram54288 0:a2cb7295a1f7 287 if (cmd_parameter_int(argc, argv, "--lifetime", &lifetime)) {
ram54288 0:a2cb7295a1f7 288 if (opt_params != 0) {
ram54288 0:a2cb7295a1f7 289 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 290 }
ram54288 0:a2cb7295a1f7 291 else {
ram54288 0:a2cb7295a1f7 292 opt_params += 1;
ram54288 0:a2cb7295a1f7 293 }
ram54288 0:a2cb7295a1f7 294 }
ram54288 0:a2cb7295a1f7 295 if (cmd_parameter_int(argc, argv, "--port", &port)) {
ram54288 0:a2cb7295a1f7 296 if (port > UINT16_MAX || opt_params != 1) {
ram54288 0:a2cb7295a1f7 297 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 298 }
ram54288 0:a2cb7295a1f7 299 else {
ram54288 0:a2cb7295a1f7 300 opt_params += 1;
ram54288 0:a2cb7295a1f7 301 }
ram54288 0:a2cb7295a1f7 302 }
ram54288 0:a2cb7295a1f7 303 if (cmd_parameter_val(argc, argv, "--domain", &domain)) {
ram54288 0:a2cb7295a1f7 304 if (opt_params != 2) {
ram54288 0:a2cb7295a1f7 305 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 306 }
ram54288 0:a2cb7295a1f7 307 else {
ram54288 0:a2cb7295a1f7 308 opt_params += 1;
ram54288 0:a2cb7295a1f7 309 }
ram54288 0:a2cb7295a1f7 310 }
ram54288 0:a2cb7295a1f7 311 if (cmd_parameter_int(argc, argv, "--binding_mode", &binding_mode)) {
ram54288 0:a2cb7295a1f7 312 if (opt_params != 3) {
ram54288 0:a2cb7295a1f7 313 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 314 }
ram54288 0:a2cb7295a1f7 315 else {
ram54288 0:a2cb7295a1f7 316 opt_params += 1;
ram54288 0:a2cb7295a1f7 317 }
ram54288 0:a2cb7295a1f7 318 }
ram54288 0:a2cb7295a1f7 319 if (cmd_parameter_int(argc, argv, "--network_interface", &network_interface)) {
ram54288 0:a2cb7295a1f7 320 if (opt_params != 4) {
ram54288 0:a2cb7295a1f7 321 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 322 }
ram54288 0:a2cb7295a1f7 323 else {
ram54288 0:a2cb7295a1f7 324 opt_params += 1;
ram54288 0:a2cb7295a1f7 325 }
ram54288 0:a2cb7295a1f7 326 }
ram54288 0:a2cb7295a1f7 327
ram54288 0:a2cb7295a1f7 328 bool success = false;
ram54288 0:a2cb7295a1f7 329 if (lwm2m_client.create_interface(opt_params,
ram54288 0:a2cb7295a1f7 330 endpoint,
ram54288 0:a2cb7295a1f7 331 type,
ram54288 0:a2cb7295a1f7 332 lifetime,
ram54288 0:a2cb7295a1f7 333 port,
ram54288 0:a2cb7295a1f7 334 domain,
ram54288 0:a2cb7295a1f7 335 binding_mode,
ram54288 0:a2cb7295a1f7 336 network_interface)) {
ram54288 0:a2cb7295a1f7 337 return CMDLINE_RETCODE_SUCCESS;
ram54288 0:a2cb7295a1f7 338 }
ram54288 0:a2cb7295a1f7 339
ram54288 0:a2cb7295a1f7 340 return CMDLINE_RETCODE_FAIL;
ram54288 0:a2cb7295a1f7 341 }
ram54288 0:a2cb7295a1f7 342
ram54288 0:a2cb7295a1f7 343 int lwm2m_client_device_command(int argc, char *argv[])
ram54288 0:a2cb7295a1f7 344 {
ram54288 0:a2cb7295a1f7 345 int return_code = CMDLINE_RETCODE_SUCCESS;// CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 346 char *manufacturer = 0;
ram54288 0:a2cb7295a1f7 347 char *model_number = 0;
ram54288 0:a2cb7295a1f7 348 char *serial_number = 0;
ram54288 0:a2cb7295a1f7 349 char *device_type = 0;
ram54288 0:a2cb7295a1f7 350 char *hardware_version = 0;
ram54288 0:a2cb7295a1f7 351 char *software_version = 0;
ram54288 0:a2cb7295a1f7 352 char *firmware_version = 0;
ram54288 0:a2cb7295a1f7 353 char *utc_offset = 0;
ram54288 0:a2cb7295a1f7 354 char *timezone = 0;
ram54288 0:a2cb7295a1f7 355 int32_t current_time = 0;
ram54288 0:a2cb7295a1f7 356 int32_t available_power_sources = 0;
ram54288 0:a2cb7295a1f7 357 int32_t power_source_voltage = 0;
ram54288 0:a2cb7295a1f7 358 int32_t power_source_current = 0;
ram54288 0:a2cb7295a1f7 359 int32_t battery_status = 0;
ram54288 0:a2cb7295a1f7 360 int32_t battery_level = 0;
ram54288 0:a2cb7295a1f7 361 int32_t memory_free = 0;
ram54288 0:a2cb7295a1f7 362 int32_t memory_total = 0;
ram54288 0:a2cb7295a1f7 363 int32_t error_code = 0;
ram54288 0:a2cb7295a1f7 364 int32_t instance_id = 0;
ram54288 0:a2cb7295a1f7 365
ram54288 0:a2cb7295a1f7 366 lwm2m_client.create_device_object();
ram54288 0:a2cb7295a1f7 367
ram54288 0:a2cb7295a1f7 368 if(cmd_parameter_val(argc, argv, "--manufacturer", &manufacturer)) {
ram54288 0:a2cb7295a1f7 369 if(!lwm2m_client.create_device_object(M2MDevice::Manufacturer,
ram54288 0:a2cb7295a1f7 370 manufacturer)) {
ram54288 0:a2cb7295a1f7 371 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 372 }
ram54288 0:a2cb7295a1f7 373 }
ram54288 0:a2cb7295a1f7 374 if(cmd_parameter_val(argc, argv, "--model_number", &model_number)) {
ram54288 0:a2cb7295a1f7 375 if(!lwm2m_client.create_device_object(M2MDevice::ModelNumber,
ram54288 0:a2cb7295a1f7 376 model_number)) {
ram54288 0:a2cb7295a1f7 377 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 378 }
ram54288 0:a2cb7295a1f7 379 }
ram54288 0:a2cb7295a1f7 380 if(cmd_parameter_val(argc, argv, "--serial_number", &serial_number)){
ram54288 0:a2cb7295a1f7 381 if(!lwm2m_client.create_device_object(M2MDevice::SerialNumber,
ram54288 0:a2cb7295a1f7 382 serial_number)) {
ram54288 0:a2cb7295a1f7 383 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 384 }
ram54288 0:a2cb7295a1f7 385 }
ram54288 0:a2cb7295a1f7 386 if(cmd_parameter_val(argc, argv, "--device_type", &device_type)){
ram54288 0:a2cb7295a1f7 387 if(!lwm2m_client.create_device_object(M2MDevice::DeviceType,
ram54288 0:a2cb7295a1f7 388 device_type)) {
ram54288 0:a2cb7295a1f7 389 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 390 }
ram54288 0:a2cb7295a1f7 391 }
ram54288 0:a2cb7295a1f7 392 if(cmd_parameter_val(argc, argv, "--hardware_version", &hardware_version)){
ram54288 0:a2cb7295a1f7 393 if(!lwm2m_client.create_device_object(M2MDevice::HardwareVersion,
ram54288 0:a2cb7295a1f7 394 hardware_version)) {
ram54288 0:a2cb7295a1f7 395 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 396 }
ram54288 0:a2cb7295a1f7 397 }
ram54288 0:a2cb7295a1f7 398 if(cmd_parameter_val(argc, argv, "--software_version", &software_version)){
ram54288 0:a2cb7295a1f7 399 if(!lwm2m_client.create_device_object(M2MDevice::SoftwareVersion,
ram54288 0:a2cb7295a1f7 400 software_version)) {
ram54288 0:a2cb7295a1f7 401 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 402 }
ram54288 0:a2cb7295a1f7 403 }
ram54288 0:a2cb7295a1f7 404 if(cmd_parameter_val(argc, argv, "--firmware_version", &firmware_version)){
ram54288 0:a2cb7295a1f7 405 if(!lwm2m_client.create_device_object(M2MDevice::FirmwareVersion,
ram54288 0:a2cb7295a1f7 406 firmware_version)) {
ram54288 0:a2cb7295a1f7 407 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 408 }
ram54288 0:a2cb7295a1f7 409 }
ram54288 0:a2cb7295a1f7 410 if(cmd_parameter_int(argc, argv, "--available_power_sources", &available_power_sources)){
ram54288 0:a2cb7295a1f7 411 if(cmd_parameter_int(argc, argv, "--instance_id", &instance_id)) {
ram54288 0:a2cb7295a1f7 412 if(!lwm2m_client.create_device_object(M2MDevice::AvailablePowerSources,
ram54288 0:a2cb7295a1f7 413 available_power_sources,instance_id)) {
ram54288 0:a2cb7295a1f7 414 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 415 }
ram54288 0:a2cb7295a1f7 416 }
ram54288 0:a2cb7295a1f7 417 }
ram54288 0:a2cb7295a1f7 418 if(cmd_parameter_int(argc, argv, "--power_source_voltage", &power_source_voltage)){
ram54288 0:a2cb7295a1f7 419 if(cmd_parameter_int(argc, argv, "--instance_id", &instance_id)) {
ram54288 0:a2cb7295a1f7 420 if(!lwm2m_client.create_device_object(M2MDevice::PowerSourceVoltage,
ram54288 0:a2cb7295a1f7 421 power_source_voltage,instance_id)) {
ram54288 0:a2cb7295a1f7 422 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 423 }
ram54288 0:a2cb7295a1f7 424 }
ram54288 0:a2cb7295a1f7 425 }
ram54288 0:a2cb7295a1f7 426 if(cmd_parameter_int(argc, argv, "--power_source_current", &power_source_current)){
ram54288 0:a2cb7295a1f7 427 if(cmd_parameter_int(argc, argv, "--instance_id", &instance_id)) {
ram54288 0:a2cb7295a1f7 428 if(!lwm2m_client.create_device_object(M2MDevice::PowerSourceCurrent,
ram54288 0:a2cb7295a1f7 429 power_source_current,instance_id)) {
ram54288 0:a2cb7295a1f7 430 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 431 }
ram54288 0:a2cb7295a1f7 432 }
ram54288 0:a2cb7295a1f7 433 }
ram54288 0:a2cb7295a1f7 434 if(cmd_parameter_int(argc, argv, "--battery_level", &battery_level)){
ram54288 0:a2cb7295a1f7 435 if(!lwm2m_client.create_device_object(M2MDevice::BatteryLevel,
ram54288 0:a2cb7295a1f7 436 battery_level)) {
ram54288 0:a2cb7295a1f7 437 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 438 }
ram54288 0:a2cb7295a1f7 439 }
ram54288 0:a2cb7295a1f7 440 if(cmd_parameter_int(argc, argv, "--battery_status", &battery_status)){
ram54288 0:a2cb7295a1f7 441 if(!lwm2m_client.create_device_object(M2MDevice::BatteryStatus,
ram54288 0:a2cb7295a1f7 442 battery_status)) {
ram54288 0:a2cb7295a1f7 443 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 444 }
ram54288 0:a2cb7295a1f7 445 }
ram54288 0:a2cb7295a1f7 446 if(cmd_parameter_int(argc, argv, "--memory_free", &memory_free)){
ram54288 0:a2cb7295a1f7 447 if(!lwm2m_client.create_device_object(M2MDevice::MemoryFree,
ram54288 0:a2cb7295a1f7 448 memory_free)) {
ram54288 0:a2cb7295a1f7 449 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 450 }
ram54288 0:a2cb7295a1f7 451 }
ram54288 0:a2cb7295a1f7 452 if(cmd_parameter_int(argc, argv, "--memory_total", &memory_total)){
ram54288 0:a2cb7295a1f7 453 if(!lwm2m_client.create_device_object(M2MDevice::MemoryTotal,
ram54288 0:a2cb7295a1f7 454 memory_total)) {
ram54288 0:a2cb7295a1f7 455 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 456 }
ram54288 0:a2cb7295a1f7 457 }
ram54288 0:a2cb7295a1f7 458 if(cmd_parameter_int(argc, argv, "--error_code", &error_code)){
ram54288 0:a2cb7295a1f7 459 if(cmd_parameter_int(argc, argv, "--instance_id", &instance_id)) {
ram54288 0:a2cb7295a1f7 460 if(!lwm2m_client.create_device_object(M2MDevice::ErrorCode,
ram54288 0:a2cb7295a1f7 461 error_code,instance_id)) {
ram54288 0:a2cb7295a1f7 462 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 463 }
ram54288 0:a2cb7295a1f7 464 }
ram54288 0:a2cb7295a1f7 465 }
ram54288 0:a2cb7295a1f7 466 if(cmd_parameter_int(argc, argv, "--current_time", &current_time)){
ram54288 0:a2cb7295a1f7 467 if(!lwm2m_client.create_device_object(M2MDevice::CurrentTime,
ram54288 0:a2cb7295a1f7 468 current_time)) {
ram54288 0:a2cb7295a1f7 469 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 470 }
ram54288 0:a2cb7295a1f7 471 }
ram54288 0:a2cb7295a1f7 472 if(cmd_parameter_val(argc, argv, "--utc_offset", &utc_offset)){
ram54288 0:a2cb7295a1f7 473 if(!lwm2m_client.create_device_object(M2MDevice::UTCOffset,
ram54288 0:a2cb7295a1f7 474 utc_offset)) {
ram54288 0:a2cb7295a1f7 475 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 476 }
ram54288 0:a2cb7295a1f7 477 }
ram54288 0:a2cb7295a1f7 478 if(cmd_parameter_val(argc, argv, "--timezone", &timezone)){
ram54288 0:a2cb7295a1f7 479 if(!lwm2m_client.create_device_object(M2MDevice::Timezone,
ram54288 0:a2cb7295a1f7 480 timezone)) {
ram54288 0:a2cb7295a1f7 481 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 482 }
ram54288 0:a2cb7295a1f7 483 }
ram54288 0:a2cb7295a1f7 484
ram54288 0:a2cb7295a1f7 485 return return_code;
ram54288 0:a2cb7295a1f7 486 }
ram54288 0:a2cb7295a1f7 487
ram54288 0:a2cb7295a1f7 488 int lwm2m_client_firmware_command(int argc, char *argv[])
ram54288 0:a2cb7295a1f7 489 {
ram54288 0:a2cb7295a1f7 490 int return_code = CMDLINE_RETCODE_SUCCESS;// CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 491 char *package = 0;
ram54288 0:a2cb7295a1f7 492 char *package_uri = 0;
ram54288 0:a2cb7295a1f7 493 char *package_name = 0;
ram54288 0:a2cb7295a1f7 494 char *package_version = 0;
ram54288 0:a2cb7295a1f7 495 int32_t state = 1;
ram54288 0:a2cb7295a1f7 496 int32_t update_result = 0;
ram54288 0:a2cb7295a1f7 497 int32_t update_supported_objects = 0;
ram54288 0:a2cb7295a1f7 498
ram54288 0:a2cb7295a1f7 499 lwm2m_client.create_firmware_object();
ram54288 0:a2cb7295a1f7 500
ram54288 0:a2cb7295a1f7 501 if(cmd_parameter_val(argc, argv, "--package", &package)) {
ram54288 0:a2cb7295a1f7 502 uint16_t length = (uint16_t)sizeof(package);
ram54288 0:a2cb7295a1f7 503 if(!lwm2m_client.create_firmware_object(M2MFirmware::Package,
ram54288 0:a2cb7295a1f7 504 (const uint8_t*)package, length)) {
ram54288 0:a2cb7295a1f7 505 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 506 }
ram54288 0:a2cb7295a1f7 507 }
ram54288 0:a2cb7295a1f7 508
ram54288 0:a2cb7295a1f7 509 if(cmd_parameter_val(argc, argv, "--package_uri", &package_uri)) {
ram54288 0:a2cb7295a1f7 510 if(!lwm2m_client.create_firmware_object(M2MFirmware::PackageUri,
ram54288 0:a2cb7295a1f7 511 package_uri)) {
ram54288 0:a2cb7295a1f7 512 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 513 }
ram54288 0:a2cb7295a1f7 514 }
ram54288 0:a2cb7295a1f7 515 if(cmd_parameter_int(argc, argv, "--state", &state)) {
ram54288 0:a2cb7295a1f7 516 if(!lwm2m_client.create_firmware_object(M2MFirmware::State,
ram54288 0:a2cb7295a1f7 517 state)) {
ram54288 0:a2cb7295a1f7 518 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 519 }
ram54288 0:a2cb7295a1f7 520 }
ram54288 0:a2cb7295a1f7 521 if(cmd_parameter_int(argc, argv, "--update_supported_objects", &update_supported_objects)) {
ram54288 0:a2cb7295a1f7 522 if(!lwm2m_client.create_firmware_object(M2MFirmware::UpdateSupportedObjects,
ram54288 0:a2cb7295a1f7 523 update_supported_objects)) {
ram54288 0:a2cb7295a1f7 524 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 525 }
ram54288 0:a2cb7295a1f7 526 }
ram54288 0:a2cb7295a1f7 527 if(cmd_parameter_int(argc, argv, "--update_results", &update_result)) {
ram54288 0:a2cb7295a1f7 528 if(!lwm2m_client.create_firmware_object(M2MFirmware::UpdateResult,
ram54288 0:a2cb7295a1f7 529 update_result)) {
ram54288 0:a2cb7295a1f7 530 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 531 }
ram54288 0:a2cb7295a1f7 532 }
ram54288 0:a2cb7295a1f7 533 if(cmd_parameter_val(argc, argv, "--package_name", &package_name)) {
ram54288 0:a2cb7295a1f7 534 if(!lwm2m_client.create_firmware_object(M2MFirmware::PackageName,
ram54288 0:a2cb7295a1f7 535 package_name)) {
ram54288 0:a2cb7295a1f7 536 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 537 }
ram54288 0:a2cb7295a1f7 538 }
ram54288 0:a2cb7295a1f7 539 if(cmd_parameter_val(argc, argv, "--package_version", &package_version)) {
ram54288 0:a2cb7295a1f7 540 if(!lwm2m_client.create_firmware_object(M2MFirmware::PackageVersion,
ram54288 0:a2cb7295a1f7 541 package_version)) {
ram54288 0:a2cb7295a1f7 542 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 543 }
ram54288 0:a2cb7295a1f7 544 }
ram54288 0:a2cb7295a1f7 545 lwm2m_client.set_fw_execute_function();
ram54288 0:a2cb7295a1f7 546 return return_code;
ram54288 0:a2cb7295a1f7 547 }
ram54288 0:a2cb7295a1f7 548
ram54288 0:a2cb7295a1f7 549 int lwm2m_client_resource_value(int argc, char *argv[])
ram54288 0:a2cb7295a1f7 550 {
ram54288 0:a2cb7295a1f7 551 int resource = 0;
ram54288 0:a2cb7295a1f7 552 if(cmd_parameter_int(argc, argv, "--firmware", &resource)) {
ram54288 0:a2cb7295a1f7 553 if (resource == 3 || resource == 4 || resource == 5) {
ram54288 0:a2cb7295a1f7 554 lwm2m_client.firmware_resource_int(resource);
ram54288 0:a2cb7295a1f7 555 }
ram54288 0:a2cb7295a1f7 556 else if (resource == 0) {
ram54288 0:a2cb7295a1f7 557 lwm2m_client.firmware_resource_buffer();
ram54288 0:a2cb7295a1f7 558 }
ram54288 0:a2cb7295a1f7 559 else {
ram54288 0:a2cb7295a1f7 560 lwm2m_client.firmware_resource_string(resource);
ram54288 0:a2cb7295a1f7 561 }
ram54288 0:a2cb7295a1f7 562 }
ram54288 0:a2cb7295a1f7 563 return CMDLINE_RETCODE_SUCCESS;
ram54288 0:a2cb7295a1f7 564 }
ram54288 0:a2cb7295a1f7 565
ram54288 0:a2cb7295a1f7 566 int lwm2m_client_object_command(int argc, char *argv[])
ram54288 0:a2cb7295a1f7 567 {
ram54288 0:a2cb7295a1f7 568 int return_code = CMDLINE_RETCODE_SUCCESS;// CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 569 char *object_name = 0;
ram54288 0:a2cb7295a1f7 570 int32_t new_instance = 0;
ram54288 0:a2cb7295a1f7 571 int32_t object_operation = 0;
ram54288 0:a2cb7295a1f7 572 int32_t object_instance_operation = 0;
ram54288 0:a2cb7295a1f7 573 int32_t object_instance_id = 0;
ram54288 0:a2cb7295a1f7 574 int32_t object_observable = 0;
ram54288 0:a2cb7295a1f7 575 int32_t object_instance_observable = 0;
ram54288 0:a2cb7295a1f7 576
ram54288 0:a2cb7295a1f7 577 if(cmd_parameter_val(argc, argv, "--name", &object_name)) {
ram54288 0:a2cb7295a1f7 578 cmd_parameter_int(argc, argv, "--new_instance", &new_instance);
ram54288 0:a2cb7295a1f7 579 cmd_parameter_int(argc, argv, "--object_operation", &object_operation);
ram54288 0:a2cb7295a1f7 580 cmd_parameter_int(argc, argv, "--object_instance_operation", &object_instance_operation);
ram54288 0:a2cb7295a1f7 581 cmd_parameter_int(argc, argv, "--object_instance_id", &object_instance_id);
ram54288 0:a2cb7295a1f7 582 cmd_parameter_int(argc, argv, "--object_observable", &object_observable);
ram54288 0:a2cb7295a1f7 583 cmd_parameter_int(argc, argv, "--object_instance_observable", &object_instance_observable);
ram54288 0:a2cb7295a1f7 584
ram54288 0:a2cb7295a1f7 585 if(!lwm2m_client.create_object(object_name,
ram54288 0:a2cb7295a1f7 586 new_instance,
ram54288 0:a2cb7295a1f7 587 object_operation,
ram54288 0:a2cb7295a1f7 588 object_instance_operation,
ram54288 0:a2cb7295a1f7 589 object_instance_id,
ram54288 0:a2cb7295a1f7 590 object_observable,
ram54288 0:a2cb7295a1f7 591 object_instance_observable)) {
ram54288 0:a2cb7295a1f7 592 return_code = CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 593 }
ram54288 0:a2cb7295a1f7 594 }
ram54288 0:a2cb7295a1f7 595 return return_code;
ram54288 0:a2cb7295a1f7 596 }
ram54288 0:a2cb7295a1f7 597
ram54288 0:a2cb7295a1f7 598 int lwm2m_client_static_resource_command(int argc, char *argv[])
ram54288 0:a2cb7295a1f7 599 {
ram54288 0:a2cb7295a1f7 600 int return_code = CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 601 char *name = 0;
ram54288 0:a2cb7295a1f7 602 char *value_string = 0;
ram54288 0:a2cb7295a1f7 603 int32_t value_int = 0;
ram54288 0:a2cb7295a1f7 604 int32_t value_type = -1;
ram54288 0:a2cb7295a1f7 605 int32_t multiple_instance = 0;
ram54288 0:a2cb7295a1f7 606 int32_t object_instance = 0;
ram54288 0:a2cb7295a1f7 607
ram54288 0:a2cb7295a1f7 608 cmd_parameter_int(argc, argv, "--multiple_instance", &multiple_instance);
ram54288 0:a2cb7295a1f7 609 cmd_parameter_int(argc, argv, "--object_instance", &object_instance);
ram54288 0:a2cb7295a1f7 610
ram54288 0:a2cb7295a1f7 611
ram54288 0:a2cb7295a1f7 612 if(cmd_parameter_int(argc, argv, "--value_type", &value_type)) {
ram54288 0:a2cb7295a1f7 613 if(0 == value_type){
ram54288 0:a2cb7295a1f7 614 if(cmd_parameter_val(argc, argv, "--name", &name) &&
ram54288 0:a2cb7295a1f7 615 cmd_parameter_val(argc, argv, "--value", &value_string)) {
ram54288 0:a2cb7295a1f7 616 if(lwm2m_client.create_static_resource_string(name,value_string,
ram54288 0:a2cb7295a1f7 617 multiple_instance,object_instance)) {
ram54288 0:a2cb7295a1f7 618 return_code = CMDLINE_RETCODE_SUCCESS;
ram54288 0:a2cb7295a1f7 619 }
ram54288 0:a2cb7295a1f7 620 }
ram54288 0:a2cb7295a1f7 621 } else if(1 == value_type){
ram54288 0:a2cb7295a1f7 622 if(cmd_parameter_val(argc, argv, "--name", &name) &&
ram54288 0:a2cb7295a1f7 623 cmd_parameter_int(argc, argv, "--value", &value_int)) {
ram54288 0:a2cb7295a1f7 624 if(lwm2m_client.create_static_resource_int(name,value_int,
ram54288 0:a2cb7295a1f7 625 multiple_instance,object_instance)) {
ram54288 0:a2cb7295a1f7 626 return_code = CMDLINE_RETCODE_SUCCESS;
ram54288 0:a2cb7295a1f7 627 }
ram54288 0:a2cb7295a1f7 628 }
ram54288 0:a2cb7295a1f7 629 }
ram54288 0:a2cb7295a1f7 630 }
ram54288 0:a2cb7295a1f7 631 return return_code;
ram54288 0:a2cb7295a1f7 632 }
ram54288 0:a2cb7295a1f7 633
ram54288 0:a2cb7295a1f7 634 int lwm2m_client_dynamic_resource_command(int argc, char *argv[])
ram54288 0:a2cb7295a1f7 635 {
ram54288 0:a2cb7295a1f7 636 int return_code = CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 637 char *name = 0;
ram54288 0:a2cb7295a1f7 638 int32_t multiple_instance = 0;
ram54288 0:a2cb7295a1f7 639 int32_t object_instance = 0;
ram54288 0:a2cb7295a1f7 640 int32_t observable = 0;
ram54288 0:a2cb7295a1f7 641 int32_t resource_operation = 1;
ram54288 0:a2cb7295a1f7 642 int32_t value_type = -1;
ram54288 0:a2cb7295a1f7 643
ram54288 0:a2cb7295a1f7 644 cmd_parameter_int(argc, argv, "--value_type", &value_type);
ram54288 0:a2cb7295a1f7 645 cmd_parameter_int(argc, argv, "--multiple_instance", &multiple_instance);
ram54288 0:a2cb7295a1f7 646 cmd_parameter_int(argc, argv, "--object_instance", &object_instance);
ram54288 0:a2cb7295a1f7 647 cmd_parameter_int(argc, argv, "--observable", &observable);
ram54288 0:a2cb7295a1f7 648 cmd_parameter_int(argc, argv, "--resource_operation", &resource_operation);
ram54288 0:a2cb7295a1f7 649 if(-1 == value_type){
ram54288 0:a2cb7295a1f7 650 value_type = 1;
ram54288 0:a2cb7295a1f7 651 }
ram54288 0:a2cb7295a1f7 652
ram54288 0:a2cb7295a1f7 653 if(cmd_parameter_val(argc, argv, "--name", &name)) {
ram54288 0:a2cb7295a1f7 654 if(0 == value_type) {
ram54288 0:a2cb7295a1f7 655 if(lwm2m_client.create_dynamic_resource_string(name,observable,
ram54288 0:a2cb7295a1f7 656 multiple_instance,
ram54288 0:a2cb7295a1f7 657 object_instance,
ram54288 0:a2cb7295a1f7 658 resource_operation)) {
ram54288 0:a2cb7295a1f7 659 return_code = CMDLINE_RETCODE_SUCCESS;
ram54288 0:a2cb7295a1f7 660 }
ram54288 0:a2cb7295a1f7 661 }
ram54288 0:a2cb7295a1f7 662 else if(1 == value_type){
ram54288 0:a2cb7295a1f7 663 if(lwm2m_client.create_dynamic_resource_int(name,observable,
ram54288 0:a2cb7295a1f7 664 multiple_instance,
ram54288 0:a2cb7295a1f7 665 object_instance,
ram54288 0:a2cb7295a1f7 666 resource_operation)) {
ram54288 0:a2cb7295a1f7 667 return_code = CMDLINE_RETCODE_SUCCESS;
ram54288 0:a2cb7295a1f7 668 }
ram54288 0:a2cb7295a1f7 669 }
ram54288 0:a2cb7295a1f7 670
ram54288 0:a2cb7295a1f7 671 }
ram54288 0:a2cb7295a1f7 672 return return_code;
ram54288 0:a2cb7295a1f7 673 }
ram54288 0:a2cb7295a1f7 674
ram54288 0:a2cb7295a1f7 675 int lwm2m_client_static_resource_instance_command(int argc, char *argv[])
ram54288 0:a2cb7295a1f7 676 {
ram54288 0:a2cb7295a1f7 677 int return_code = CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 678 char *name = 0;
ram54288 0:a2cb7295a1f7 679 char *value_string = 0;
ram54288 0:a2cb7295a1f7 680 int32_t value_int = 0;
ram54288 0:a2cb7295a1f7 681 int32_t value_type = -1;
ram54288 0:a2cb7295a1f7 682 int32_t multiple_instance = 0;
ram54288 0:a2cb7295a1f7 683 int32_t object_instance = 0;
ram54288 0:a2cb7295a1f7 684 int32_t resource_instance = 0;
ram54288 0:a2cb7295a1f7 685
ram54288 0:a2cb7295a1f7 686 cmd_parameter_int(argc, argv, "--multiple_instance", &multiple_instance);
ram54288 0:a2cb7295a1f7 687 cmd_parameter_int(argc, argv, "--object_instance", &object_instance);
ram54288 0:a2cb7295a1f7 688 cmd_parameter_int(argc, argv, "--resource_instance", &resource_instance);
ram54288 0:a2cb7295a1f7 689
ram54288 0:a2cb7295a1f7 690 if(cmd_parameter_int(argc, argv, "--value_type", &value_type)) {
ram54288 0:a2cb7295a1f7 691 if(0 == value_type){
ram54288 0:a2cb7295a1f7 692 if(cmd_parameter_val(argc, argv, "--name", &name) &&
ram54288 0:a2cb7295a1f7 693 cmd_parameter_val(argc, argv, "--value", &value_string)) {
ram54288 0:a2cb7295a1f7 694 if(lwm2m_client.create_static_resource_instance_string(name,value_string,
ram54288 0:a2cb7295a1f7 695 multiple_instance,
ram54288 0:a2cb7295a1f7 696 object_instance,
ram54288 0:a2cb7295a1f7 697 resource_instance)) {
ram54288 0:a2cb7295a1f7 698 return_code = CMDLINE_RETCODE_SUCCESS;
ram54288 0:a2cb7295a1f7 699 }
ram54288 0:a2cb7295a1f7 700 }
ram54288 0:a2cb7295a1f7 701 } else if(1 == value_type){
ram54288 0:a2cb7295a1f7 702 if(cmd_parameter_val(argc, argv, "--name", &name) &&
ram54288 0:a2cb7295a1f7 703 cmd_parameter_int(argc, argv, "--value", &value_int)) {
ram54288 0:a2cb7295a1f7 704 if(lwm2m_client.create_static_resource_instance_int(name,value_int,
ram54288 0:a2cb7295a1f7 705 multiple_instance,
ram54288 0:a2cb7295a1f7 706 object_instance,
ram54288 0:a2cb7295a1f7 707 resource_instance)) {
ram54288 0:a2cb7295a1f7 708 return_code = CMDLINE_RETCODE_SUCCESS;
ram54288 0:a2cb7295a1f7 709 }
ram54288 0:a2cb7295a1f7 710 }
ram54288 0:a2cb7295a1f7 711 }
ram54288 0:a2cb7295a1f7 712 }
ram54288 0:a2cb7295a1f7 713 return return_code;
ram54288 0:a2cb7295a1f7 714 }
ram54288 0:a2cb7295a1f7 715
ram54288 0:a2cb7295a1f7 716 int lwm2m_client_dynamic_resource_instance_command(int argc, char *argv[])
ram54288 0:a2cb7295a1f7 717 {
ram54288 0:a2cb7295a1f7 718 int return_code = CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 719 char *name = 0;
ram54288 0:a2cb7295a1f7 720 int32_t multiple_instance = 0;
ram54288 0:a2cb7295a1f7 721 int32_t object_instance = 0;
ram54288 0:a2cb7295a1f7 722 int32_t resource_instance = 0;
ram54288 0:a2cb7295a1f7 723 int32_t observable = 0;
ram54288 0:a2cb7295a1f7 724 int32_t resource_instance_operation = 1;
ram54288 0:a2cb7295a1f7 725 int32_t value_type = -1;
ram54288 0:a2cb7295a1f7 726
ram54288 0:a2cb7295a1f7 727 cmd_parameter_int(argc, argv, "--value_type", &value_type);
ram54288 0:a2cb7295a1f7 728 cmd_parameter_int(argc, argv, "--multiple_instance", &multiple_instance);
ram54288 0:a2cb7295a1f7 729 cmd_parameter_int(argc, argv, "--object_instance", &object_instance);
ram54288 0:a2cb7295a1f7 730 cmd_parameter_int(argc, argv, "--resource_instance", &resource_instance);
ram54288 0:a2cb7295a1f7 731 cmd_parameter_int(argc, argv, "--observable", &observable);
ram54288 0:a2cb7295a1f7 732 cmd_parameter_int(argc, argv, "--resource_instance_operation", &resource_instance_operation);
ram54288 0:a2cb7295a1f7 733 if(-1 == value_type){
ram54288 0:a2cb7295a1f7 734 value_type = 1;
ram54288 0:a2cb7295a1f7 735 }
ram54288 0:a2cb7295a1f7 736
ram54288 0:a2cb7295a1f7 737 if(cmd_parameter_val(argc, argv, "--name", &name)) {
ram54288 0:a2cb7295a1f7 738 if(0 == value_type){
ram54288 0:a2cb7295a1f7 739 if(lwm2m_client.create_dynamic_resource_instance_string(name,observable,
ram54288 0:a2cb7295a1f7 740 multiple_instance,
ram54288 0:a2cb7295a1f7 741 object_instance,
ram54288 0:a2cb7295a1f7 742 resource_instance,
ram54288 0:a2cb7295a1f7 743 resource_instance_operation)) {
ram54288 0:a2cb7295a1f7 744 return_code = CMDLINE_RETCODE_SUCCESS;
ram54288 0:a2cb7295a1f7 745 }
ram54288 0:a2cb7295a1f7 746 }
ram54288 0:a2cb7295a1f7 747 else if(1 == value_type){
ram54288 0:a2cb7295a1f7 748 if(lwm2m_client.create_dynamic_resource_instance_int(name,observable,
ram54288 0:a2cb7295a1f7 749 multiple_instance,
ram54288 0:a2cb7295a1f7 750 object_instance,
ram54288 0:a2cb7295a1f7 751 resource_instance,
ram54288 0:a2cb7295a1f7 752 resource_instance_operation)) {
ram54288 0:a2cb7295a1f7 753 return_code = CMDLINE_RETCODE_SUCCESS;
ram54288 0:a2cb7295a1f7 754 }
ram54288 0:a2cb7295a1f7 755 }
ram54288 0:a2cb7295a1f7 756 }
ram54288 0:a2cb7295a1f7 757 return return_code;
ram54288 0:a2cb7295a1f7 758 }
ram54288 0:a2cb7295a1f7 759
ram54288 0:a2cb7295a1f7 760 int lwm2m_client_bootstrap_object_command(int argc, char *argv[])
ram54288 0:a2cb7295a1f7 761 {
ram54288 0:a2cb7295a1f7 762 int return_code = CMDLINE_RETCODE_FAIL;
ram54288 0:a2cb7295a1f7 763 char *address = 0;
ram54288 0:a2cb7295a1f7 764
ram54288 0:a2cb7295a1f7 765 if( cmd_parameter_val(argc, argv, "--address", &address) ){
ram54288 0:a2cb7295a1f7 766 if(lwm2m_client.create_bootstrap_object(address)){
ram54288 0:a2cb7295a1f7 767 return_code = CMDLINE_RETCODE_SUCCESS;
ram54288 0:a2cb7295a1f7 768 }
ram54288 0:a2cb7295a1f7 769 } else {
ram54288 0:a2cb7295a1f7 770 return_code = CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 771 }
ram54288 0:a2cb7295a1f7 772 return return_code;
ram54288 0:a2cb7295a1f7 773 }
ram54288 0:a2cb7295a1f7 774
ram54288 0:a2cb7295a1f7 775 int lwm2m_client_bootstrap_command()
ram54288 0:a2cb7295a1f7 776 {
ram54288 0:a2cb7295a1f7 777 int return_code = CMDLINE_RETCODE_FAIL;
ram54288 0:a2cb7295a1f7 778
ram54288 0:a2cb7295a1f7 779 if(lwm2m_client.test_bootstrap()){
ram54288 0:a2cb7295a1f7 780 return_code = CMDLINE_RETCODE_EXCUTING_CONTINUE;
ram54288 0:a2cb7295a1f7 781 }
ram54288 0:a2cb7295a1f7 782 return return_code;
ram54288 0:a2cb7295a1f7 783 }
ram54288 0:a2cb7295a1f7 784
ram54288 0:a2cb7295a1f7 785 int lwm2m_client_register_object_command(int argc, char *argv[])
ram54288 0:a2cb7295a1f7 786 {
ram54288 0:a2cb7295a1f7 787 char *address = 0;
ram54288 0:a2cb7295a1f7 788 cmd_parameter_val(argc, argv, "--address", &address);
ram54288 0:a2cb7295a1f7 789
ram54288 0:a2cb7295a1f7 790 int useSecureConn = 0;
ram54288 0:a2cb7295a1f7 791 if( !cmd_parameter_int(argc, argv, "--secure", &useSecureConn) ){
ram54288 0:a2cb7295a1f7 792 useSecureConn = 0;
ram54288 0:a2cb7295a1f7 793 }
ram54288 0:a2cb7295a1f7 794
ram54288 0:a2cb7295a1f7 795 if(lwm2m_client.create_register_object(address, useSecureConn == 1)) {
ram54288 0:a2cb7295a1f7 796 return CMDLINE_RETCODE_SUCCESS;
ram54288 0:a2cb7295a1f7 797 }
ram54288 0:a2cb7295a1f7 798 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 799 }
ram54288 0:a2cb7295a1f7 800
ram54288 0:a2cb7295a1f7 801 int lwm2m_client_register_command()
ram54288 0:a2cb7295a1f7 802 {
ram54288 0:a2cb7295a1f7 803 if(lwm2m_client.test_register()) {
ram54288 0:a2cb7295a1f7 804 return CMDLINE_RETCODE_EXCUTING_CONTINUE;
ram54288 0:a2cb7295a1f7 805 }
ram54288 0:a2cb7295a1f7 806 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 807 }
ram54288 0:a2cb7295a1f7 808
ram54288 0:a2cb7295a1f7 809 int lwm2m_client_update_register_command(int argc, char *argv[])
ram54288 0:a2cb7295a1f7 810 {
ram54288 0:a2cb7295a1f7 811 int ret_code = CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 812 int32_t lifetime = 0;
ram54288 0:a2cb7295a1f7 813
ram54288 0:a2cb7295a1f7 814 cmd_parameter_int(argc, argv, "--lifetime", &lifetime);
ram54288 0:a2cb7295a1f7 815
ram54288 0:a2cb7295a1f7 816 if(lifetime >= 0) {
ram54288 0:a2cb7295a1f7 817 if(lwm2m_client.test_update_register(lifetime)) {
ram54288 0:a2cb7295a1f7 818 ret_code = CMDLINE_RETCODE_EXCUTING_CONTINUE;
ram54288 0:a2cb7295a1f7 819 }
ram54288 0:a2cb7295a1f7 820 }
ram54288 0:a2cb7295a1f7 821 return ret_code;
ram54288 0:a2cb7295a1f7 822 }
ram54288 0:a2cb7295a1f7 823
ram54288 0:a2cb7295a1f7 824 int lwm2m_client_unregister_command()
ram54288 0:a2cb7295a1f7 825 {
ram54288 0:a2cb7295a1f7 826 if(lwm2m_client.test_unregister()) {
ram54288 0:a2cb7295a1f7 827 return CMDLINE_RETCODE_EXCUTING_CONTINUE;
ram54288 0:a2cb7295a1f7 828 }
ram54288 0:a2cb7295a1f7 829 return CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 830 }
ram54288 0:a2cb7295a1f7 831
ram54288 0:a2cb7295a1f7 832 int lwm2m_client_set_value_command(int argc, char *argv[])
ram54288 0:a2cb7295a1f7 833 {
ram54288 0:a2cb7295a1f7 834 int return_code = CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 835 char *name = 0;
ram54288 0:a2cb7295a1f7 836 int32_t value = 0;
ram54288 0:a2cb7295a1f7 837 int32_t object_instance = 0;
ram54288 0:a2cb7295a1f7 838
ram54288 0:a2cb7295a1f7 839 cmd_parameter_int(argc, argv, "--object_instance", &object_instance);
ram54288 0:a2cb7295a1f7 840
ram54288 0:a2cb7295a1f7 841 if(cmd_parameter_val(argc, argv, "--name", &name) &&
ram54288 0:a2cb7295a1f7 842 cmd_parameter_int(argc, argv, "--value", &value)) {
ram54288 0:a2cb7295a1f7 843 if(lwm2m_client.set_resource_value(name,value,object_instance)) {
ram54288 0:a2cb7295a1f7 844 return_code = CMDLINE_RETCODE_SUCCESS;
ram54288 0:a2cb7295a1f7 845 }
ram54288 0:a2cb7295a1f7 846 }
ram54288 0:a2cb7295a1f7 847 return return_code;
ram54288 0:a2cb7295a1f7 848 }
ram54288 0:a2cb7295a1f7 849
ram54288 0:a2cb7295a1f7 850 int lwm2m_client_set_value_instance_command(int argc, char *argv[])
ram54288 0:a2cb7295a1f7 851 {
ram54288 0:a2cb7295a1f7 852 int return_code = CMDLINE_RETCODE_INVALID_PARAMETERS;
ram54288 0:a2cb7295a1f7 853 char *name = 0;
ram54288 0:a2cb7295a1f7 854 int32_t value = 0;
ram54288 0:a2cb7295a1f7 855 int32_t object_instance = 0;
ram54288 0:a2cb7295a1f7 856 int32_t resource_instance = 0;
ram54288 0:a2cb7295a1f7 857
ram54288 0:a2cb7295a1f7 858 cmd_parameter_int(argc, argv, "--object_instance", &object_instance);
ram54288 0:a2cb7295a1f7 859 cmd_parameter_int(argc, argv, "--resource_instance", &resource_instance);
ram54288 0:a2cb7295a1f7 860
ram54288 0:a2cb7295a1f7 861 if(cmd_parameter_val(argc, argv, "--name", &name) &&
ram54288 0:a2cb7295a1f7 862 cmd_parameter_int(argc, argv, "--value", &value)) {
ram54288 0:a2cb7295a1f7 863 if(lwm2m_client.set_resource_instance_value(name,value,
ram54288 0:a2cb7295a1f7 864 object_instance,
ram54288 0:a2cb7295a1f7 865 resource_instance)) {
ram54288 0:a2cb7295a1f7 866 return_code = CMDLINE_RETCODE_SUCCESS;
ram54288 0:a2cb7295a1f7 867 }
ram54288 0:a2cb7295a1f7 868 }
ram54288 0:a2cb7295a1f7 869 return return_code;
ram54288 0:a2cb7295a1f7 870 }
ram54288 0:a2cb7295a1f7 871
ram54288 0:a2cb7295a1f7 872 int exit_command(int argc, char *argv[])
ram54288 0:a2cb7295a1f7 873 {
ram54288 0:a2cb7295a1f7 874 exit(1);
ram54288 0:a2cb7295a1f7 875 }