1

我正在研究 Pebble 表盘,但遇到了问题,函数 app_message_outbox_send 似乎抛出了一个错误(然后我的应用程序崩溃了)。错误是“[INFO] E call_internal.c:36 系统调用失败!0..0x8 不在应用程序空间中。”

相关代码:

static void askPhoneForCharge(){
    if(bluetooth_connection_service_peek()){
        DictionaryIterator *iter;
        app_message_outbox_begin(&iter);
        dict_write_uint8(iter, KEY_PHONE_ASK, 0);
        app_message_outbox_send();
    }else{
        phoneCharging = 0;
        phoneCharge = 0;
        updatePhoneBattery();
    }
}

以下是我如何设置处理程序并打开通道:

app_message_register_inbox_received(inboxReceivedCallback);
app_message_register_inbox_dropped(inboxDroppedCallback);
app_message_register_outbox_failed(outboxFailedCallback);
app_message_register_outbox_sent(outboxSentCallback);
app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());
4

2 回答 2

2

事实证明,在初始化阶段你不能使用消息函数,所以我启动了一个只执行一次的计时器来处理初始消息传递。

于 2015-01-05T15:29:37.357 回答
0

我在发送被 Up_button_click 处理程序调用的 app_message_outbox_send() 命令时遇到了同样的问题。Init() 方法中的以下初始化代码为我修复了它。查看“注册消息处理程序”和“初始化缓冲区”

void out_sent_handler(DictionaryIterator *sent, void *context){}
static void out_fail_handler(DictionaryIterator *failed, AppMessageResult reason, void* context){}

static void in_received_handler(DictionaryIterator *iter, void* context){}

void in_drop_handler(AppMessageResult reason, void *context){}

static void init() {
// Register message handlers
  app_message_register_outbox_sent(out_sent_handler);
  app_message_register_inbox_received(in_received_handler);
  app_message_register_inbox_dropped(in_drop_handler);
  app_message_register_outbox_failed(out_fail_handler);

  // Init buffers
  app_message_open(64, 64);
  // Create main Window element and assign to pointer
  s_main_window = window_create();



  // Set handlers to manage the elements inside the Window
  window_set_window_handlers(s_main_window, (WindowHandlers) {
    .load = main_window_load,
    .unload = main_window_unload
  });
  // Show the Window on the watch, with animated=true
  window_stack_push(s_main_window, true);
}
于 2015-06-06T17:49:17.987 回答