void app_start(int /*argc*/, char* /*argv*/[]) { //Sets the console baud-rate output.baud(115200); // MAC address handling mbed_mac_address(mmac); // This sets up the network interface configuration which will be used // by LWM2M Client API to communicate with mbed Device server. //eth.init("192.168.1.248","255.255.255.0","192.168.1.1"); eth.init(); //Use DHCP eth.connect(); lwipv4_socket_init(); output.printf("IP address %s\r\n", eth.getIPAddress()); // 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(); // Create LED Object M2MObject* led_object = mbed_client.create_led_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); object_list.push_back(led_object); mbed_client.set_register_object(register_object); // Issue register command. FunctionPointer2<void, M2MSecurity*, M2MObjectList> fp(&mbed_client, &MbedClient::test_register); minar::Scheduler::postCallback(fp.bind(register_object,object_list)); minar::Scheduler::postCallback(&mbed_client,&MbedClient::test_update_register).period(minar::milliseconds(25000)); }
void app_start(int /*argc*/, char* /*argv*/[]) { //Sets the console baud-rate output.baud(115200); // start the accelerometer acc.enable(); // print device name for easy reference output.printf("Device Name is '%s'\r\n\r\n",MBED_ENDPOINT_NAME); // This sets up the network interface configuration which will be used // by LWM2M Client API to communicate with mbed Device server. eth.init(); //Use DHCP eth.connect(); output.printf("%s\n", eth.getMACAddress()); char *ip = eth.getIPAddress(); if (ip) { output.printf("IP Address is: %s\n", ip); } else { error("Failed to aquire IP address\n"); } lwipv4_socket_init(); // 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); // 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* sdw_object = mbed_client.create_sdw_object(); // Create Generic object specifying custom resources M2MObject* led_object = mbed_client.create_led_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(sdw_object); object_list.push_back(led_object); mbed_client.set_register_object(register_object); // Issue register command. FunctionPointer2<void, M2MSecurity*, M2MObjectList> fp(&mbed_client, &MbedClient::test_register); minar::Scheduler::postCallback(fp.bind(register_object, object_list)); minar::Scheduler::postCallback(&mbed_client, &MbedClient::update_sdw_resource).period(minar::milliseconds(1000)); minar::Scheduler::postCallback(&mbed_client, &MbedClient::test_update_register).period(minar::milliseconds(25000)); }