Buildfire: Vibrate issue - buildfire

buildfire.notifications.vibrate({
milliseconds: 500
}, function (err, data) {
console.log(data);
});
buildfire.notifications.beep({
times: 1
}, function (err, data) {
console.log(data);
});
I am having an issue with the vibrate not working. The beep is beeping 3 times, and no vibrate on iphone in (silent mode - off) and nothing in silent mode.

If you make it 1000 milliseconds in vibrate it should work fine. iOS currently does not allow changing the duration for it.
Regarding the three beeps, that is how iOS beeps; 1 beep sounds like 3. if you make it 2 it will sound like 6.

Related

A script that runs every second in a chrome extension with manifest v3

This is my first chrome extension using manifest v3, and I want to make a timer in it.
This is supposed to update every second, and not run on any specific tab nor the popup window.
I tried to do this in my service worker:
let counter = 0
setInterval(() => {
counter++
}, 1000)
But that didn't work well, because after around half a minute, the service worker would go "inactive", and thus stop this loop.
So I am just looking for a way to make a loop that executes some code every 1 second. This loop always has to be running. And I do not really have a way to "launch" say a function every second from another page. I can start it once, but because of the service worker that goes inactive after a while, then this script has to either just never die or relaunch itself every second.
Is this even possible?
Google recommends using their "Alarm API" instead of timers to schedule running code: https://developer.chrome.com/docs/extensions/mv3/migrating_to_service_workers/#alarms
So instead of running a "setTimeout" or "setInterval" in your background worker like this:
const TIMEOUT = 3 * 60 * 1000; // 3 minutes in milliseconds
setTimeout(() => {
chrome.action.setIcon({
path: getRandomIconPath(),
});
}, TIMEOUT);
You should instruct Chrome on when to run it instead:
chrome.alarms.create({ delayInMinutes: 3 });
chrome.alarms.onAlarm.addListener(() => {
chrome.action.setIcon({
path: getRandomIconPath(),
});
});

receive 10 continue press key together in ari-client ChannelDtmfReceived

how to receive 10 digit number those press by user in phone. i am using "ari-client" Modula of nodejs
client.on( 'StasisStart', function (event, channel) {
channel.answer(
function (err) {
if (err) {
logger.error(err);
}
channel.play({media: 'sound:priv-callee-options'}, playback, function (err, playback) {
if(err){
return logger.error(err);
}
});
channel.on('ChannelDtmfReceived', function (event, channel) {
var digitPressed = event.digit;
if(digitPressed==1234567890){
client.channels.hold(
{channelId: channel.id},
function (err) {
console.log("Phone On Hold..");
}
);
}
});
});
});
Use application Read
pro-sip*CLI> core show application Read
-= Info about application 'Read' =-
[Synopsis]
Read a variable.
[Description]
Reads a #-terminated string of digits a certain number of times from the user
in to the given <variable>.
This application sets the following channel variable upon completion:
${READSTATUS}: This is the status of the read operation.
OK
ERROR
HANGUP
INTERRUPTED
SKIPPED
TIMEOUT
[Syntax]
Read(variable[,filename[&filename2[&...]][,maxdigits[,options[,attempts[,timeout]]]]])
[Arguments]
variable
The input digits will be stored in the given <variable> name.
filename
file(s) to play before reading digits or tone with option i
maxdigits
Maximum acceptable number of digits. Stops reading after <maxdigits>
have been entered (without requiring the user to press the '#' key).
Defaults to '0' - no limit - wait for the user press the '#' key.
Any value below '0' means the same. Max accepted value is '255'.
options
s: to return immediately if the line is not up.
i: to play filename as an indication tone from your "indication
s.conf".
n: to read digits even if the line is not up.
attempts
If greater than '1', that many <attempts> will be made in the event
no data is entered.
timeout
The number of seconds to wait for a digit response. If greater than
'0', that value will override the default timeout. Can be floating
point.
[See Also]
SendDTMF()
pro-sip*CLI>

How to prevent repeated responses from Node.js server

We're running into a problem where we're getting multiple responses sent from our Node server to a web client which are connected by a socket server (socket.io). By listening with Docklight, I can see that we're really only getting a single response from the serial device, but for some reason the Node server is sending multiples, and they accumulate, so the first time you send a serial command (and it doesn't matter what commands) might only get a couple, next time a couple more, next time a couple more and so on. So if you run several serial commands, you'll get back lots of multiple responses.
Our environment is Windows 7 64 bit, Node V 4.5.0, serialport V 4.0.1. However, this needs to run on Windows, Mac & Linux when we're done. The dev team (me & one other guy) are both fairly new to Node, but otherwise capable developers.
I think what's happening is I'm not using the .flush() & .drain() functions properly and the serialport buffer still contains serial data. Our proprietary devices return either S>, or <Executed/> prompts when a command has completed, so I store the serial response in a buffer until I see one or the other, then process the data (in this example just providing a boolean response whether the device is responding with one or the other or not). For example, if I send a <CR><LF> to one of our devices, it should respond with S> (or <Executed/> depending).
The client calls into the server with this:
socket.on('getDeviceConnected', readDeviceResponse);
function readDeviceResponse(isDeviceResponding) {
console.log('getDeviceConnected');
console.log(isDeviceResponding);
}
function getDeviceConnected() {
console.log("Sending carriage return / line feed.");
socket.emit('getDeviceConnected', '\r\n');
}
And on the server, here's what I'm trying:
socket.on('getDeviceConnected', function (connectionData) {
//write over serial buffer before the write occurs to prevent command accumulation in the buffer.
serialBuffer = '';
sbeSerialPort.write(connectionData, function (err, results) {
//since there's no way to tell if the serial device hasn't responded, set a time out to return a false after allowing one second to elapse
setTimeout(function () {
console.log('Inside getDeviceConnected setTimeout');
console.log('Is serial device responding:', isSerialDeviceResponding);
if (!isSerialDeviceResponding) {
console.log('Serial device timed out.');
socket.emit('getDeviceConnected', false);
}
}, 1000);
if (err) {
console.log('Serial port error level:', err);
}
if (results) {
if (results === 2) {
console.log('Serial port is responding');
}
}
});
sbeSerialPort.on('data', function (serialData) {
isSerialDeviceResponding = true;
console.log('Does S> prompt exist?', serialData.lastIndexOf('S>'));
while(!serialData.lastIndexOf('S>') > -1 || !serialData.lastIndexOf('<Executed/>') > -1){
serialBuffer += serialData;
break;
}
if (isSerialDeviceResponding) {
socket.emit('getDeviceConnected', true);
isSerialDeviceResponding = true;
}
sbeSerialPort.flush(function (err, results) {
if (err) {
console.log(err);
return;
}
if(results){
console.log('Serial port flush return code:', results);
}
});
});
I'm not very sure about the .flush() implementation here, and I've omitted the .drain() part because neither of them seems to do much of anything (assuming they were correctly implemented).
How do I insure that there is no data left in the serialport buffer when the .write() command is complete? Or do you see other problems with how I'm handling the serial data?
Edit, Source code up on pastebin.com:
Server.js
Client.js
HTML

NodeJS asynchronous/non-blocking io basic

Trying to get my head around a simple nodejs asynchronous way of handling i/o and a below simple snippet as an example leaves me in question marks.
// Just to simulate an io (webservice call).
var performRiskCheckViaWebservice = function(personPassportNumber, callback) {
console.log("Risk check called for personPassportNumber: "+personPassportNumber);
setTimeout(callback(personPassportNumber, "OK"), 5000);
}
function assessRisk(passportNumber) {
performRiskCheckViaWebservice(passportNumber, function(passportNumber, status){
console.log("Risk status of "+passportNumber+" is: "+status);
})
}
assessRisk("1");
assessRisk("2");
assessRisk("3");
In the above simple code snippet, my expectation is to see:
Risk check called for personPassportNumber: 1
Risk check called for personPassportNumber: 2
Risk check called for personPassportNumber: 3
And 5 seconds later:
Risk status of 1 is: OK
Risk status of 2 is: OK
Risk status of 3 is: OK
But the actual output is:
Risk check called for personPassportNumber: 1
Risk status of 1 is: OK
Risk check called for personPassportNumber: 2
Risk status of 2 is: OK
Risk check called for personPassportNumber: 3
Risk status of 3 is: OK
5 seconds later, the program halts.
What's wrong in my understanding?
As it turns out, I have to wrap the callback with an anonymous function inside the setTimeout(...). Here is the working version:
// Just to simulate an io (webservice call).
var performRiskCheckViaWebservice = function(personPassportNumber, callback) {
console.log("Risk check called for personPassportNumber: "+personPassportNumber);
setTimeout(function() {
callback(personPassportNumber, "OK")
}, 5000);
}
function assessRisk(passportNumber) {
performRiskCheckViaWebservice(passportNumber, function(personPassportNumber, status){
console.log("Risk status of "+personPassportNumber+" is: "+status);
})
}
assessRisk("1");
assessRisk("2");
assessRisk("3");
Here is a sync waterfall of your code :
sync assessRisk
sync performRiskCheckViaWebservice
sync console.log Risk.check
sync callback <== problem here
sync console.log Risk status
sync setTimeout 5000
so what you observe is normal.
you can replace
setTimeout(callback(personPassportNumber, "OK"), 5000);
by
setTimeout(callback.bind(null, personPassportNumber, "OK"), 5000);

Memory Leak Meteor.http

I'm getting a memory leak from Meteor.http.get when I try to make 5 parallel http requests / second: gist
match_ids.forEach(function(match_id){
var url = self.generateUrl(match_id);
Meteor.http.get(url, function(err, response){
if(!err && !response.data.result.error){
callback(null, response.data.result);
}else{
callback(err || response.data.result.error, match_id);
}
})
});
It seems to behave the same even if I reduce the rate down to 1 request / second.
Meteor.setInterval(function(){
module.feeder.getMatchesForCarry();
}, 2000);
Meteor.setInterval(function(){
Meteor.call("TEMP_d2_match_analyzerInsertSampleData", 9, function(err,response){});
}, 10000);
Is the source of this problem Node or Meteor?
If i perform 5 requests/sec , in about 5 minutes of running i get 80-100 mega filled
There is no issue with the code that you shared. Your memory leak, if that's indeed what you're observing, is in other places.

Resources