Why does a websocket in PebbleKit JS cause iOS app to crash? - pebble-watch

I am attempting to log Pebble accelerometer data to my computer. I was hoping to use PebbleKit JS to communicate with the watch itself, and then use websockets to send that data to my computer, but currently the websocket only sends one message and then the iOS app crashes.
Here is the content of pebble-js-app.js:
var ws = new WebSocket('ws://192.168.1.134:8888');
// Called when JS is ready
Pebble.addEventListener("ready",
function(e) {
console.log("js initialized");
}
);
// Called when incoming message from the Pebble is received
Pebble.addEventListener("appmessage",
function(e) {
console.log(ws.readyState);
if (ws.readyState === 1) {
ws.send('this gets sent');
ws.send(e.payload.message);
}
console.log("acc data: " + e.payload.message);
}
);
And here is the log that I get when I run the app:
[INFO ] Enabling application logging...
[INFO ] Displaying logs ... Ctrl-C to interrupt.
[INFO ] JS: starting app: 4C74DC80-A54E-4D0B-9BAB-FD355D364334 accelero
[INFO ] app is ready: 1
[INFO ] JS: accelerometer: js initialized
[INFO ] JS: accelerometer: 0
[INFO ] JS: accelerometer: acc data: 3131
[INFO ] JS: accelerometer: 1
[ERROR ] Lost connection to Pebble
The websocket server running on my computer logs the first message sent from the javascript. Only one message is sent, even when the order is changed (e.g. it prints either this gets sent or a single actual reading from the accelerometer). Curiously, the built-in logging (console.log) from javascript started only printing 3131 for the received data, even when the websocket sends some valid data. Can you see any errors in the code or do you have any other suggestions?

Related

HarmonyOS wearable vibrator not activating

I'm creating a HarmonyOS Wearable app using the JS Framework and I want to use the vibrator. The watch definitely has a vibrator because I can feel it when I use the scroll weel in the settings app.
So I requested the system_grant ohos.permission.VIBRATE permission in the config.json file as described here
"module": {
...
"reqPermissions": [
{
"name": "ohos.permission.VIBRATE",
"reason": "Make vibrates"
}
]
...
}
Then it should be simple to use the imported vibrator like this
import vibrator from '#system.vibrator';
export default {
// ...
onShow() {
console.log("VIBRATOR");
vibrator.vibrate({
mode : "long",
success: () => console.debug("Vibrator Success"),
fail : (data, code) => console.log("Vibrator handle fail, data = ${data}, code = ${code}"),
complete : () => console.debug("Vibrator Complete")
});
}
// ...
}
I do get the VIBRATOR log in HiLog but non of the other logs in the vibrator callbacks nor does the device vibrate.
Does anyone know what I'm doing wrong?
EDIT:
I noticed a bunch of error logs after the VIBRATOR log. I cant figure out what they mean so I'm posting them here.
D 03B00/JSApp: app Log: VIBRATOR
E 03900/Ace: [<private> (<private>)] ace Log: [JS Framework] Failed to invoke the event handler of "viewappear" on div (_root):
E 03900/Ace: TypeError: value has no property
E 03900/Ace: [<private> (<private>)] Qjs FireAsyncEvent FAILED !! jsCall: <private>
E 03900/Ace: [<private> (<private>)] [DUMP] <private>
E 03900/Ace: [<private> (<private>)] <private>
The JS API document is written based on the wearables. The standard usage of smart devices is as follows:
vibrator.vibrate({
mode: "short"
});
or
vibrator.vibrate();

aws-amplify subscription to appsync stops after 2 mins

When subscribing to appsync using amplify using API.graphql(graphqlOperation(subscription)); the subscription works for a while, but the I get socket closed error.
CONSOLE LOG [native code]: {
"[INFO] 24:12.893 MqttOverWSProvider": {
"errorCode": 8,
"errorMessage": "AMQJS0008I Socket closed.",
"uri": "wss://<uri>
The same subscription works in the appsync console without any issue and I get events as long as the subscription is running, but stops after around 2 mins on device.
code involved
let cs = await this.subscriptionService.appSubscriptions();
this.sbscriptions = this.cs.subscribe({
next: data => {
console.dir(data);
},
error: error => console.dir(JSON.stringify(error)),
close: () => console.log("closed")
});
This part of code throws no error, and the error shown above is only visible when setting LOG_LEVEL = DEBUG
NOTE : The subscription does work for a while before this error shows up, and in that time I can see all the events that I trigger from console.

Cannot received events in hyperledger composer 0.19.3 client

I am using hyperledger composer 0.19.3 with hyperledger fabric 1.1. I have a composer client app and I am trying to listen for events from a transaction that emitted the event. I can see the event in the historian within the composer rest server. However the debug trace log shows the following over and over again "could not find any connected event hubs out of 1 defined hubs to listen on for chaincode events...". The code is as follows:
This client app is modeled off the sample digitalProperty land title example.
listen() {
LOG.info('Awaiting events');
this.bizNetworkConnection.on('event', (event) => {
// event: { "$class": "org.namespace.BasicEvent", "eventId": "0000-0000-0000-000000#0" }
console.log(event);
});
}

iOS push notifications not showing up through Parse local server

I'm doing whatever i can to send ios push notifications to a react-native app and for that app to display notifications.
I've been trying to figure this out for months.
I have a local Parse server running with the following config:
{
"appId": "org.reactjs.native.example.ReactZeroNotifications",
"masterKey": "masterkey",
"databaseURI": "mongodb://localhost/test",
"push": {
"ios": [
{
"pfx": "reactnotification-dev.p12",
"bundleId": "org.reactjs.native.example.ReactZeroNotifications",
"passphrase": "*",
"production": false
},
{
"pfx": "reactnotification-prod.p12",
"bundleId": "org.reactjs.native.example.ReactZeroNotifications",
"passphrase": "*",
"production": true
}
]
}
}
I then send a post request to http://localhost:1337/parse/push with the following headers:
X-Parse-Application-Id: org.reactjs.native.example.ReactZeroNotifications
X-Parse-Master-Key: masterkey
and the following raw JSON data:
{"where": {"deviceType": "ios"},"data":{"alert": "hello NOTIFICATIONS!!"}}
Meanwhile I have a react-native app running with pushnotification linked as a library and I receive the register event with a token.
However, my notification event never goes off and I never see a notification at the top of my iPhone as I'm trying to accomplish.
(Note: I just want to see a notification on a react-native app... no matter how this is accomplished, I feel as if I could figure out the rest if I can just get it to work once)
As per recommendation i turned on verbose on the parse server and received the following after posting:
verbose: sending push to 0 installations
verbose: sent push!
0 success, 0 failures

Changing the "Upload failed" Message

I would like to change the "Upload failed" message to one returned from my server-side processing.
I can see the message I want in the onError callback but I'm not sure how to used that instead of the default message.
Thoughts, examples or further reading advice welcome (new here).
The implementation of what you're trying to do depends on whether you are using Fine Uploader Basic/Core or Regular/UI. This is because UI mode offers some extra goodies for displaying error messages and such.
A few properties/options that may benefit you:
Fine Uploader Basic/Core mode
text.defaultResponseError
Message sent to the onError callback if no specific information about the error can be determined. This is used if the server indicates failure in the response but does not include an “error” property in the response and the error code is 200 (XHR only)
var uploader = new qq.FineUploaderBasic({
/* ... */
text: {
defaultResponseError: "Oh noes! Upload fail."
}
});
The documentation on 'text'
Fine Uploader Regular/UI mode
failedUploadTextDisplay.mode option
Valid values are “default” (display the text defined in failUploadText next to each failed file), “none” (don’t display any text next to a failed file), and “custom” (display error response text from the server next to the failed file or Blob).
failedUploadTextDisplay.responseProperty option
The property from the server response containing the error text to display next to the failed file or Blob. This is ignored unless mode is “custom”.
var uploader = new qq.FineUploader({
/* ... */
text: {
defaultResponseError: "Oh noes! Upload fail."
},
failedUploadTextDisplay: {
mode: 'custom', // Display error responses from the server.
responseProperty: 'errorMsg' // Default is 'error', change this to match the
// property that contains the error message from
// your server
}
});
The documentation on failedUploadTextDisplay
For people who still use FineUploaded and above does not work, that is because the key is not changed to failUpload.
Usage for a custom message on UI end would be
text: {
failUpload: 'Your upload faile message goes here
},
More details can be found here - https://docs.fineuploader.com/branch/master/upgrading-to-4.html
If you want to display the server-side message, you can do it the below way:
failedUploadTextDisplay {
mode: 'custom',
responseProperty: 'server side error key goes here'
}
If you wish to completely remove it, i.e, not show the message below file if file upload has failed, use below
failedUploadTextDisplay {
mode: 'none'
}

Resources