As I am not always on-site managing our physical buttons can be challenging.
Is there a way to:
- Send a command in the IDE to rename a button?
- Poll the buttons via ssh (or otherwise) to obtain their battery power/status?
Thank you
As I am not always on-site managing our physical buttons can be challenging.
Is there a way to:
Thank you
@Emil
From the IDE module. I was able to figure it out by sending a request to an endpoint and catching the payload that way. Thank you!
I'm looking for a way to see the complete request payload when a button is click/doubl-clicked/hold. I need to know the request structure so I can use it in a follow-up payload HTTP response.
How do I see it apart from the string that shows up in console?
@Emil said in Which javascript version on SDK?:
old javascript version
Is it possible to have a javascript in this environment send an SMS to the smsburst API?
We have it working in other environments, but this one just doesnt seem to work.
const http = require('http');
// Basic authentication credentials
const encodedAuth = Buffer.from('abcd123:Password123!').toString('base64');
// Setting up the headers for the request
const headers = {
"Authorization": "Basic " + encodedAuth
};
// Message details
const message = encodeURIComponent("IVONNE: Testing from Flic SDK");
const to = encodeURIComponent("+16475551212");
const senderNumber = encodeURIComponent("18335551212");
const repliesToEmail = encodeURIComponent("email@example.com");
// Constructing the URL
const url = "https://api.transmitsms.com/send-sms.json?message=" + message + "&to=" + to + "&from=" + senderNumber + "&replies_to_email=" + repliesToEmail;
// Making the HTTP request
function sendSmsViaTransmitSms() {
console.log("Starting request to SMS Burst API...");
http.makeRequest({
url: url,
method: 'POST',
headers: headers
}, function(error, result) {
if (error) {
console.error("An error occurred during the HTTP request:", error);
} else {
console.log("Received response from SMS Burst API");
console.log("Response status code:", result.statusCode);
console.log("Response headers:", result.headers);
// Check if result.content exists and log it
if (typeof result.content !== 'undefined') {
console.log("Response body:", result.content);
} else {
console.log("Response body not available in this format");
}
}
});
}
// Execute the function to send the SMS
sendSmsViaTransmitSms();
Error is:
TypeError: undefined not callable (property 'from' of [object Function])
at [anon] (duk_js_call.c:2917) internal
at [anon] (root/basicBurstSMSTest/main.js:1)
at require (init.js:131)
at [anon] (init.js:139) preventsyield
at runInit () native strict preventsyield
at handlePacket (pipe_communication.js:48)
at readCallback (pipe_communication.js:93) preventsyield
I'm having some trouble building a basic script that sends sms alerts stored on the flichub.
What javascript version is used in this environment for HBACE27-27526
Firmware: 4.2.14
@Emil ```
const http = require('http');
const burstAPI_Key = 'api_key_here';
const burstAPI_Secret = 'API_secret_here;
// Function to encode credentials to Base64 for Basic Authentication
function base64Encode(str) {
return Buffer.from(str).toString('base64');
}
// Forming the Authorization header
const authHeader = 'Basic ' + base64Encode(burstAPI_Key + ':' + burstAPI_Secret);
// Making the HTTP request
function checkSmsBurstApi() {
http.makeRequest({
url: 'https://api.transmitsms.com/get-lists.json',
method: 'GET',
headers: {
"Authorization": authHeader
}
}, function(err, res) {
if (err) {
console.error("An error occurred:", err);
} else {
console.log("Response status code:", res.statusCode);
// Optionally, log the response body or headers here for more information
}
});
}
// Execute the function to check the API
checkSmsBurstApi();
The above code results in this error:
TypeError: undefined not callable (property 'from' of [object Function])
at [anon] (duk_js_call.c:2917) internal
at base64Encode (root/basicBurstSMSTest/main.js:8)
at [anon] (root/basicBurstSMSTest/main.js:12)
at require (init.js:131)
at [anon] (init.js:139) preventsyield
at runInit () native strict preventsyield
at handlePacket (pipe_communication.js:48)
at readCallback (pipe_communication.js:93) preventsyield
Thanks for the ongoing support.
Hello Community,
I'm currently working with the Flic Hub SDK and facing an issue with making authenticated HTTP requests to the SMS Burst API. Despite the script working correctly on my local Node.js environment, I consistently receive a 401 Unauthorized error when running it on the Flic Hub.
Here's a brief overview of what I'm trying to achieve and the steps I've taken so far:
Goal:
To make an authenticated GET request to the SMS Burst API from the Flic Hub SDK environment.
Approach:
I am using Basic Authentication, encoding the API key and secret in Base64 and setting it in the Authorization header.
Here's a snippet of the script I'm using which does not work:
const http = require('http');
const burstAPI_Key = 'api_key_here';
const burstAPI_Secret = 'API_secret_here!';
// Headers with API key and secret key
const headers = {
"x-api-key": burstAPI_Key,
"x-secret-key": burstAPI_Secret
};
// Making the HTTP request
function checkSmsBurstApi() {
http.makeRequest({
url: 'https://api.transmitsms.com/get-lists.json',
method: 'GET',
headers: headers
}, function(err, res) {
if (err) {
console.error("An error occurred:", err);
} else {
console.log("Response status code:", res.statusCode);
// Optionally, log the response body or headers here for more information
}
});
}
// Execute the function to check the API
checkSmsBurstApi();
Issue:
The script works fine locally on my Node.js setup, but in the Flic Hub SDK, it results in a 401 error.
I've double-checked the API credentials, and they are correct.
Questions:
Are there known issues or specific requirements for making authenticated HTTP requests in the Flic Hub SDK environment?
Does the Flic Hub SDK handle HTTP headers differently that might affect Basic Authentication?
Any suggestions or alternative methods that could help resolve this issue?
I appreciate any insights or advice you can offer. Thank you in advance for your help!