@@ -37,14 +37,17 @@ static M2MResource* m2m_put_res;
3737static M2MResource* m2m_post_res;
3838static M2MResource* m2m_deregister_res;
3939
40+ EventQueue queue (32 * EVENTS_EVENT_SIZE);
41+ Thread t;
42+
4043void print_client_ids (void )
4144{
4245 printf (" Account ID: %s\n " , cloud_client->endpoint_info ()->account_id .c_str ());
4346 printf (" Endpoint name: %s\n " , cloud_client->endpoint_info ()->internal_endpoint_name .c_str ());
4447 printf (" Device ID: %s\n\n " , cloud_client->endpoint_info ()->endpoint_name .c_str ());
4548}
4649
47- void button_press (void )
50+ void value_increment (void )
4851{
4952 m2m_get_res->set_value (m2m_get_res->get_value_int () + 1 );
5053 printf (" Counter %" PRIu64 " \n " , m2m_get_res->get_value_int ());
@@ -191,6 +194,9 @@ int main(void)
191194 cloud_client->add_objects (m2m_obj_list);
192195 cloud_client->setup (network); // cloud_client->setup(NULL); -- https://jira.arm.com/browse/IOTCLT-3114
193196
197+ t.start (callback (&queue, &EventQueue::dispatch_forever));
198+ queue.call_every (10000 , value_increment);
199+
194200 while (cloud_client_running) {
195201 int in_char = getchar ();
196202 if (in_char == ' i' ) {
@@ -201,9 +207,6 @@ int main(void)
201207 printf (" Storage erased, rebooting the device.\n\n " );
202208 wait (1 );
203209 NVIC_SystemReset ();
204- } else if (in_char > 0 && in_char != 0x03 ) { // Ctrl+C is 0x03 in Mbed OS and Linux returns negative number
205- button_press (); // Simulate button press
206- continue ;
207210 }
208211 deregister_client ();
209212 break ;
0 commit comments