I'm trying to send a message from an Android companion app to a Pebble watchface app, but this fails with an APP_MSG_BUSY error. Reading the logs, I can reconstruct the following sequence of events, which is happening repeatedly:
- Pebble app calls
app_message_outbox_send. - Android companion app receives
PebbleDataReceiver.receiveDatacall. - Android companion app calls
PebbleDataReceiver.sendAckToPebble(context, id). - Pebble app receives
outbox_sentcall. - Android companion app does some work which takes less about 70ms.
- Android companion app calls
PebbleKit.sendDataToPebble. - Pebble app receives
inbox_droppedcall withAPP_MSG_BUSY. adb logcatshows the following warnings:
Pbl : [AppMessage] there is not UUID for transactionId : -1
Pbl : [JsInAppMessageHandler] sendAckNackToJs: run: can not send ack message to javascript code because uuid is null
APP_MSG_BUSY suggests there is an incoming or outgoing message in progress. However, you can see from the events above that there is no outgoing message. Also, this is happening for every incoming message, even the first that the Pebble app receives after restarting.
Can anyone offer some insight into what's going on here?
I found my mistake: when I called
app_message_open, I passed a value forsize_inboundthat was too small to receive any of the messages that were being sent. Unfortunately, theAppMessageResultgiven to my inbox_dropped function wasn'tAPP_MSG_BUFFER_OVERFLOWas one might expect, butAPP_MSG_BUSY.Now for sheer speculation: what might have exacerbated this was that
size_outboundwas large enough. In fact, my mistake was swapping thesize_inboundandsize_outboundarguments. Maybe, by some logic, it didn't make sense to sendAPP_MSG_BUFFER_OVERFLOWbecause at least one of the buffers was large enough?