Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int tries;
- void updateText(char * message)
- {
- text_layer_set_text(&text, message);
- }
- void sendPacket()
- {
- DictionaryIterator *iterator;
- AppMessageResult result = app_message_out_get(&iterator);
- app_message_out_send();
- app_message_out_release();
- }
- void received_data(DictionaryIterator *received, void *context) {
- tries++;
- updateText(itoa(tries));
- sendPacket();
- }
- void handle_init(AppContextRef ctx) {
- (void)ctx;
- window_init(&window, "Report window");
- window_stack_push(&window, true /* Animated */);
- Layer* topLayer = window_get_root_layer(&window);
- text_layer_init(&text, GRect(2,0,142,30));
- text_layer_set_font(&text, fonts_get_system_font(FONT_KEY_GOTHIC_24));
- layer_add_child(topLayer, (Layer *)&text);
- sendPacket();
- }
- void pbl_main(void *params) {
- tries = 1;
- PebbleAppHandlers handlers = {
- .init_handler = &handle_init,
- .messaging_info =
- {
- .buffer_sizes =
- {
- .inbound = 9,
- .outbound = 1
- },
- .default_callbacks.callbacks = {
- .in_received = received_data,
- }
- }
- };
- app_event_loop(params, &handlers);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement