0

我有以下代码,我从手机中的 js 向我的 pebble watchapp 发送消息。这是与sdk2。

Pebble.sendAppMessage({note_id:json[count].note_id,
title:json[count].title,
text:json[count].text,
total_count: count
});

当我运行应用程序时,我可以 console.log() JS 中的 total_count 属性,它正确地得到了 count ,比如 2。

然而,在我的 pebble 应用程序中,当我尝试在in_received_handler函数中提取它时,下面代码中的 APP LOG 会打印出 536999434。

Tuple *total_count_tuple = dict_find(iter, TOTAL_COUNT_KEY);

if (total_count_tuple) {
    current_count = (int)total_count_tuple->value->cstring;
    APP_LOG(APP_LOG_LEVEL_DEBUG, "In in_received_handler, total count     %u",current_count);

}

它正在计数,所以我知道字典正在填写并发送到手表,但我不知道如何让我存储在 js 中的值在卵石端相同。

有经验的卵石程序员有什么想法吗?

4

1 回答 1

1

您正在发送一个整数,因此要读取它,您需要使用:

current_count = total_count_tuple->value->int32;

代替:

current_count = (int)total_count_tuple->value->cstring;
于 2014-02-27T01:54:55.380 回答