Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-cloud-example-lpc546xx by
Code_Additions.txt
- Committer:
- clarkjarvis
- Date:
- 2018-10-11
- Revision:
- 5:e521ea1f4c22
- Child:
- 6:19cb3d7341c6
File content as of revision 5:e521ea1f4c22:
static MbedCloudClientResource* rate_ptr;
// Mbed Cloud Client resource setup
MbedCloudClientResource *button = mbedClient.create_resource("3200/0/5501", "button_resource");
button->set_value("0");
button->methods(M2MMethod::GET);
button->observable(true);
button->attach_notification_callback(button_callback);
MbedCloudClientResource *rate = mbedClient.create_resource("3201/0/5853", "blink_rate_resource");
rate->set_value("500");
rate->methods(M2MMethod::GET | M2MMethod::PUT);
rate->observable(false);
rate->attach_put_callback(blink_rate_updated);
rate_ptr = rate;
MbedCloudClientResource *blink = mbedClient.create_resource("3201/0/5850", "blink_enable_resource");
blink->methods(M2MMethod::POST);
blink->attach_post_callback(blink_enable_callback);
void blink_rate_updated(const char *) {
printf("PUT received, Storing LED Blink Rate: %s (ms)\r\n", rate_ptr->get_value().c_str());
}
void blink_enable_callback(void *) {
String pattern_str = rate_ptr->get_value();
const char *rate = pattern_str.c_str();
printf("POST received. Enabling LED Blink Rate = %s (ms)\n", rate);
float value = atoi(rate_ptr->get_value().c_str())/1000.0;
timer.detach();
timer.attach(&led_toggle,value);
}
void button_callback(const M2MBase& object, const NoticationDeliveryStatus status)
{
printf("Button notification. Callback: (%s)\n", object.uri_path());
}
button->set_value(button_count);
