Пример #1
0
void* wait_for_unregister(void* arg) {
    MbedClient *client;
    client = (MbedClient*) arg;
    if(client->unregister_successful()) {
        printf("Unregistered done --> exiting\n");
        close_function();
    }
    return NULL;
}
Пример #2
0
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;
}
Пример #3
0
void app_start(int /*argc*/, char* /*argv*/[]) {

    //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.
    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();

    // 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.
    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));
}
Пример #4
0
void* send_observation(void* arg) {
    MbedClient *client;
    client = (MbedClient*) arg;
    static uint8_t counter = 0;
    while(1) {
        sleep(1);
        if(counter >= 10 &&
           client->register_successful()) {
            printf("Sending observation\n");
            client->update_resource();
            counter = 0;
        }
        else
            counter++;
    }
    return NULL;
}
Пример #5
0
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;
}
Пример #6
0
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);
}
Пример #7
0
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));
}