Pebble Communication Issues [AppSync/AppMessage] - android

I'm currently attempting to use AppSync to sync a piece of data between an android app and a pebble app. However, I seem to not be able to get the pebble to realize that any data is being transferred - that is, no logs are being produced where they should be. What is really bothering me is that this is essentially the code found in the pebble weather example. I've pasted the relevant bits of code below - could someone possibly look it over and suggest where any issues may be? I've made sure that the UUIDs in both programs (pebble app and android app) are the same, and that they are on the same network, and that the pebble is actually connected to the phone, and that the android function is actually being called and all.
Snippet of pebble app code:
static void sync_error_callback(DictionaryResult dict_error, AppMessageResult app_message_error, void *context) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "App Message Sync Error: %d", app_message_error);
}
static void sync_tuple_changed_callback(const uint32_t key, const Tuple* new_tuple, const Tuple* old_tuple, void* context) {
APP_LOG(APP_LOG_LEVEL_DEBUG, new_tuple->value->cstring);
}
void home_screen_load() {
// set up each one of the SimpleMenuItems
Tuplet initial_values[] = {
TupletCString(0x0, "Initial 1")
};
app_sync_init(&sync, sync_buffer, sizeof(sync_buffer), initial_values, ARRAY_LENGTH(initial_values), sync_tuple_changed_callback, sync_error_callback, NULL);
}
Snippet of android app:
final UUID PEBBLE_APP_UUID = UUID.fromString("10549fd4-1fe4-4d30-8a18-6f2f8149f8fd");
public void sendDataToWatch(String toSend) {
// Build up a Pebble dictionary containing the weather icon and the current temperature in degrees celsius
PebbleDictionary data = new PebbleDictionary();
data.addString(0x0, toSend);
PebbleKit.sendDataToPebble(getApplicationContext(), PEBBLE_APP_UUID, data);
}

To debug this type of problem, you should set a inbox_dropped handler and see if you get anything there.
After initializing AppMessage and AppSync, call:
app_message_register_inbox_dropped(appmsg_in_dropped);
And add this function:
static void appmsg_in_dropped(AppMessageResult reason, void *context) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "In dropped: %s", translate_error(reason));
}
Take a look at this question for the source of the translate_error function.

Related

Incomings Call with Android Sip stack in Embarcadero C++ builder

I'm trying to receive calls on my SIP application at Embarcadero with C++ builder
and I'm not able to get it. My situation is as follows:
I've made an Asterisk server, I've created several accounts to be able to do the
tests and I've downloaded the Zoiper application for both Windows and Android.
In my designed application, I'm able to make calls to those accounts registered
in Zoiper, although not through events, it seems that the listener does not
listen, and I've done it through the status changes in the call.
The Java code is like this:
SipAudioCall.Listener listener = new SipAudioCall.Listener() {
#Override
public void onCallEstablished(SipAudioCall call) {
call.startAudio();
call.setSpeakerMode(true);
call.toggleMute();
Log.d("on call established", "on call established");
}
#Override
public void onCallEnded(SipAudioCall call) {
finish();
}
};
In Embarcadero C++ builder I think it would be like this (it doesn't work)
Compiles and executes but the event never occurs:
//The Manifest counts as the necessary permissions for Android, Internet and Sip.
_di_JSipAudioCall_Listener audioCall_Listener;
_di_JSipSession_Listener sessionListener;
_di_JSipSession session;
_di_JSipManager;
_di_JSipAudioCall audioCall;
_di_JSipProfile profile;
_di_JString uri;
_di_JString uri_llamada;
void onCallEstablished2(SipAudioCall call);
//The process of profile creation and instantiation of SipManager are programmed
//and compiled and do not give any problem.
audioCall_listener = TJSipAudioCall_Listener::JavaClass->init();
audioCall_listener->onCallEstablished = onCallEstablished2;
sessionListener = TJSipSession_Listener::JavaClass->init();
session = manager->createSipSession(profile,sessionListener);
audioCall = manager->makeAudioCall(uri,uri_llamada,audioCall_listener,15);
void onCallEstablished2(SipAudioCall call)
{
audioCall->startAudio();
audioCall->setSpeakerMode(true);
}
The code made in Embarcadero C++ builder that works:
//The Manifest counts as the necessary permissions for Android, Internet and Sip.
_di_JSipAudioCall_Listener audioCall_Listener;
_di_JSipSession_Listener sessionListener;
_di_JSipSession session;
_di_JSipManager;
_di_JSipAudioCall audioCall;
_di_JSipProfile profile;
_di_JString uri;
_di_JString uri_llamada;
//The process of profile creation and instantiation of SipManager are programmed
//and compiled and do not give any problem.
audioCall_listener = TJSipAudioCall_Listener::JavaClass->init();
audioCall_listener->onCallEstablished = onCallEstablished2;
sessionListener = TJSipSession_Listener::JavaClass->init();
session = manager->createSipSession(profile,sessionListener);
audioCall = manager->makeAudioCall(uri,uri_llamada,audioCall_listener,15);
Timer1->Enabled = true;
void __fastcall TMainForm::Timer1Timer(TObject *Sender)
{
if (audioCall->getState() == 8)
{
audioCall->startAudio();
audioCall->setSpeakerMode(true);
}
if(audioCall->getState() == 0)
{
audioCall->endCall();
}
}
As for the Java code for receiving calls, I have found examples here
No ringing event on incoming calls
and here
Android Sip incoming Call using Service with Broadcast Receiver,
but they are all event based, which doesn't seem to work for me.
I have also tried to do the IncomingReceiver class, which extends from
BroadcastReceiver and at the Embarcadero gives me problems.
Class made in Embarcadero with C++ builder (not compiles):
class IncomingReceiver: public JBroadcastReceiver{
public:
__fastcall IncomingReceiver();
_di_JSipAudioCall incomingCall;
void onReceive(_di_JContext contexto, _di_JIntent intento);
void accept();
void showIncomingCallGui(_di_JIntent intento, _di_JContext contexto);
};
So, my questions are:
Why don't events work for me?
Can I receive calls without events?
If so, what would it be like without events?
What do I do if I can't get the IncomingReceiver class?
I found a page (in spanish): http://lfgonzalez.visiblogs.com/cbuilder-10-2-tokyo-jni-broadcastreceiver-android/ in which it is explained the use of BroadcastReceiver in Embarcadero C++ Builder. Maybe with this information you can get the events working in order to receive calls.

Sending data from Android to Simblee BLE not returning anything

Below is the sketch of my Simblee :
#include <SimbleeBLE.h>
void setup() {
Serial.begin(9600);
Serial.println("Waiting for connection...");
SimbleeBLE.deviceName = "Simblee";
SimbleeBLE.advertisementData = "data";
// SimbleeBLE.customUUID = "2220";
SimbleeBLE.advertisementInterval = MILLISECONDS(300);
SimbleeBLE.txPowerLevel = -20; // (-20dbM to +4 dBm)
SimbleeBLE.begin();
}
void loop() {
}
void SimbleeBLE_onConnect()
{
Serial.println("Simblee Connected");
}
void SimbleeBLE_onDisconnect()
{
Serial.println("Simblee Disconnected");
}
void SimbleeBLE_onReceive(byte *data, int len)
{
Serial.println("Data received");
SimbleeBLE.send(1);
printf("%s\n", data);
}
void serialEvent()
{
Serial.println("Serial event");
}
I can easily connect and read data from it, bit writing to it doesn't work from my app. SimbleeBLE_onReceive is never being called.
It actually never is called even when using third party BLE apps like nRF Connect and BLE Terminal.
So I'm suspecting that the issue is with my arduino Sketch and not related to the android code.
The android code is returning GATT_ERROR 133 when trying to write.
Is anything missing from this code ? Strangely I can't find any example online where we're simply sending data to Simblee (without using SimlbeeMobile)
Thanks,
Try changing your onReceive signature to:
void SimbleeBLE_onReceive(char *data, int len)

How to utilize Android Nougat's Direct Reply feature with a NotificationListener?

My app is using a NotificationListener to read out messages from various 3rd party apps, for example WhatsApp.
So far I was able to send a reply if only one chat is unread, the code is below.
However, in the case with WhatsApp, getNotification().actions returns a null object when more than two chats are unread, as the messages are bundled together. As you can see in the pictures below, if the notifications are extended there is an option to send a direct reply as well, therefore I am certain that it is possible to utilize this, also I think apps like PushBullet are using this method.
How could I access the RemoteInput of that notification?
public static ReplyIntentSender sendReply(StatusBarNotification statusBarNotification, String name) {
Notification.Action actions[] = statusBarNotification.getNotification().actions;
for (Notification.Action act : actions) {
if (act != null && act.getRemoteInputs() != null) {
if (act.title.toString().contains(name)) {
if (act.getRemoteInputs() != null)
return new ReplyIntentSender(act);
}
}
}
return null;
}
public static class ReplyIntentSender {
[...]
public final Notification.Action action;
public ReplyIntentSender(Notification.Action extractedAction) {
action = extractedAction;
[...]
}
private boolean sendNativeIntent(Context context, String message) {
for (android.app.RemoteInput rem : action.getRemoteInputs()) {
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putCharSequence(rem.getResultKey(), message);
android.app.RemoteInput.addResultsToIntent(action.getRemoteInputs(), intent, bundle);
try {
action.actionIntent.send(context, 0, intent);
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
return false;
}
}
Some explanation how the above code works: Once a notification is received the app tries to get the actions and checks if the name is in the title of a remoteInput (normally it is in the format of "Reply to $NAME"), if that is found the Action is saved into a ReplyIntentSender class, which, when triggered by sendNativeIntent, cycles through all RemoteInputs of that Action and adds the message to the intent. If more than one chat is unread, getNotification().actions returns null.
Below are two screenshots, the first one where it is working without any problems and the second one where it doesn't.
You can consider this as my suggestion. I have done bit research on this and come up with following conclusions.(Also it looks like you have done plenty of research on this so it might be possible that you aware about what I wrote below)
Numerous apps send Wear specific notifications, and many of those contain actions accessible from an Android Wear device. We can grab those Wear notifications on the device, extracting the actions, finding the reply action (if one exists), populating it with our own response and then executing the PendingIntent which sends our response back the original app for it to send on to the recipient.
To do so you can refer this link (A nice workaround by Rob J). You can also refer this link in this context (Great research work done by Michał Tajchert).(You might need to work around with NotificationCompat.isGroupSummary)
This is what I feel(Might be I am totally wrong)
.actions method returns Array of all Notification.Action
structures attached to current notification by addAction(int,
CharSequence, PendingIntent), Here addAction method is deprecated
one so it might not working as intended.
I am not able to test this at my end otherwise I will love to provide a working solution with code.
Hope this will help you. Happy Coding!!!

Particular overload of Azure Mobile Service invokeApi is not working while calling custom API

Where is the documentation/sample for all overloads of invokeApi function for Azure Mobile Service client SDK for Android?
I found this article and tried following code, which does not work. There are no compile time or run time errors, invokeApi gets called, but it does not come back to onSuccess or onFailure. If I call invokeApi without order object, everything works as expected
PizzaOrder order = new PizzaOrder();
order.Size = "Large";
order.Flavor = "Four cheeses";
order.UserPhone = "555-555-1234";
ListenableFuture<PizzaOrderResponse> testresult = mClient.invokeApi("bookservice", order, PizzaOrderResponse.class);
Futures.addCallback(testresult, new FutureCallback<PizzaOrderResponse>() {
#Override
public void onFailure(Throwable exc) {
// failure handling code here
}
#Override
public void onSuccess(PizzaOrderResponse testresult) {
// success handling code here
}
});
One of the properties in the data object being returned by the custom API had incorrect data type. I am still not sure where the good documentation is and why custom API call did not fail but at least it is working now.

How does Skiller send info in multiplayer games [Android]

I am thinking of using Skiller to manage my multiplayer game and had some questions. I was hoping to find some tutorials on how to use it, but I'll have to look through the code and the examples to figure it out. From what I understand, the data sent back and forth in a turn based game (payload) is going to be a string. This means all my information will need to be condensed into a string and then extracted out on the other end?
For example, Pikachu wants to use Thundershock on Pidgey.
Info to send: MoveName("Thundershock"), movePower("40"), specialAttack("55")
(I could put a key at the beginning to help me figure out what is being sent.)
String payload = "Move;Thundershock; 40; 55";
Then the other player's game would take that info and figure out the damage done and send that info back
payload = "Damage; Super Effective; 23"
How does this sound?
SKApplication.getInstance().getGameManager().getTurnBasedTools().makeMove(gameId, event, payload, chatline,
new SKListenerInterface<SKGameMoveResponse>(){
#Override
public void onResponse(SKGameMoveResponse response){
String gameId = response.getGameId();
eTBGameState state = response.getGameState();
String payload = response.getPayload();
String chatline = response.getChatline();
// handle opponent's move – explained in the next section
}
#Override
public void onError(SKStatusResponse response) {
// failed to send the move
}
});
Here is the documentation site

Categories

Resources