void* wait_for_bootstrap(void* arg) { MbedClient *client; client = (MbedClient*) arg; if(client->bootstrap_successful()) { printf("\n============== After Bootstrapping ==============\n"); display_mallinfo(); printf("Registering endpoint\n"); client->test_register(); } return NULL; }
void app_start(int /*argc*/, char* /*argv*/[]) { trace_init(); //Sets the console baud-rate output.baud(115200); // This sets up the network interface configuration which will be used // by LWM2M Client API to communicate with mbed Device server. if (esp8266::init(D1, D0) != 0) { output.printf("Error on esp8266::init!\r\n"); } if (esp8266::connect("Wifi", "Password")) { output.printf("Error on esp8266::connect\r\n"); } output.printf("MAC address is %s\r\n", esp8266::getMACAddress()); output.printf("IP address is %s\r\n", esp8266::getIPAddress()); output.printf("Device name %s\r\n", MBED_ENDPOINT_NAME); // On press of SW3 button on K64F board, example application // will call unregister API towards mbed Device Server unreg_button.fall(&mbed_client, &MbedClient::test_unregister); // On press of SW2 button on K64F board, example application // will send observation towards mbed Device Server obs_button.fall(&mbed_client, &MbedClient::update_resource); // Create LWM2M Client API interface to manage register and unregister mbed_client.create_interface(); // Create LWM2M server object specifying mbed device server // information. M2MSecurity* register_object = mbed_client.create_register_object(); // Create LWM2M device object specifying device resources // as per OMA LWM2M specification. M2MDevice* device_object = mbed_client.create_device_object(); // Create Generic object specifying custom resources M2MObject* generic_object = mbed_client.create_generic_object(); // Add all the objects that you would like to register // into the list and pass the list for register API. M2MObjectList object_list; object_list.push_back(device_object); object_list.push_back(generic_object); mbed_client.set_register_object(register_object); // Issue register command. mbed_client.test_register(register_object, object_list); update_ticker.attach(&mbed_client, &MbedClient::test_update_register, 25); }
void* wait_for_bootstrap(void* arg) { MbedClient *client; client = (MbedClient*) arg; if(client->bootstrap_successful()) { printf("Registering endpoint\n"); // Create LWM2M device object specifying device resources // as per OMA LWM2M specification. M2MDevice* device_object = client->create_device_object(); M2MObject* object = client->create_generic_object(); // Add all the objects that you would like to register // into the list and pass the list for register API. M2MObjectList object_list; object_list.push_back(device_object); object_list.push_back(object); // Issue register command. client->test_register(object_list); } return NULL; }