-
-
-
I've been doing some experiments with MQTT but I'm having an issue receiving messages with a longer payload, ideally 320bytes of binary or 468bytes base64 encoded.
I wrote a tests and it seems like the mqtt client does unpredictable things over ~100 chars in the payload.This is the test client on a pixl running 2v13, with an ESP8266 connected for WiFi
var server = "192.168.1.10";
var mqtt = require("tinyMQTT").create(server);
mqtt.on('connected', function() {
console.log("MQTT Connected\n");
mqtt.subscribe("/test");
});
mqtt.on('message', function (msg) {
console.log(JSON.stringify(msg));
});
digitalWrite(D11,1); // enable ESP8266
Serial1.setup(115200, { rx: D12, tx : D10 });
var wifi = require("ESP8266WiFi_0v25").connect(Serial1, function(err) {
if (err) throw err;
console.log("Connecting to WiFi");
wifi.connect(SSID, PASSWORD, function(err) {
if (err) throw err;
console.log("WiFi Connected");
mqtt.connect();
});
});
My test source publishing a message once a second where the first characters are a number then its padded with that number of dots eg
5....
Result is in the attached file, as you can see it starts to loose parts of the payload around 100chars and at 120chars the topic becomes corrupted.
These points seemed to vary a little with different runs, and the length of the topic so I suspect its something in the overall size of the message thats the limiting factor.According to the MQTT spec it should support messages up to 256mb! while I realise thats totally crazy for Espruino it would be nice if it was able to handle a biut more. even 1kb would be enough for my needs
-
-
I've got some ESP-01's here that I'd like to put esprunio on they're a 1MB board according to esptool:
esptool.py v3.3-dev
Serial port /dev/tty.usbserial-220
Connecting....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting...
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: a4:cf:12:c9:1f:ab
Uploading stub...
Running stub...
Stub running...
Manufacturer: 5e
Device: 4014
Detected flash size: 1MB
Hard resetting via RTS pin...
Can someone advise on the command I'd need to flash them with and if I can use files from the published builds, (I don't really want to get into setting up a build environment for these) Can I use (some of ) the files in https://www.espruino.com/binaries/espruino_2v11_esp8266_4mb/ with a different map?
-
-
Been doing some experiments with a DS18B20 sensor on an Espruino WiFi, I've had a couple of successful reads but mostly I'm getting this error:
(Sorry for the screenshot I can't figure out how to copy/paste from the console!
My code is just this for now:
var ow = new OneWire(A0);
var sensor = require("DS18B20").connect(ow);
function read(){
sensor.getTemp(function (temp) {
console.log("Temp is "+temp+"°C");
});
}
-
-
SUCCESS!
After a bit more experimenting (aka brute forcing) I managed to figure out how to call the 2nd report. This code will add the ability to toggle the on screen keyboard in iOS devices when connected to a BLE keyboard from espruino.
We extend the built in keyboards report with the additional codes and then set that wiht servies so you can still use all the existing features of ble_hid_keyboard likekb.tap(kb.KEY.A, 0);
I've tested this on a pixl.js running 2.09 against an iPhone running iOs 14.6 so it works until Apple decide to change something!
var kb = require("ble_hid_keyboard");
togleReport = new Uint8Array([
// 2nd Report for iOS Toggle Keyboard
0x05, 0x0C, // Usage Page (Consumer)
0x09, 0x01, // Usage (Consumer Control)
0xA1, 0x01, // Collection (Application)
0x85, 0x02, // Report Id (2)
0x15, 0x00, // Logical minimum (0)
0x25, 0x01, // Logical maximum (1)
0x75, 0x01, // Report Size (1)
0x95, 0x01, // Report Count (1)
0x0A, 0xAE, 0x01, // Usage (AL Keyboard Layout)
0x81, 0x06, // Input (Data,Value,Relative,Bit Field)
0xC0 // End Collection
]);
//Append the new report to the built in kb report
var report = new Uint8Array(kb.report.length + togleReport.length);
report.set(kb.report);
report.set(togleReport, kb.report.length);
//Set services with new combined report
NRF.setServices(undefined, { hid : report });
//Call this function to toggle the on screen keyboard
function toggleKB(){
NRF.sendHIDReport([2,1], function() {
NRF.sendHIDReport([2,0], function() {});
});
}
-
no joy with sending it as a keycode or a modifier, built a little app that just steped through each code to see what would happen!
With a little more digging it seems like the way to toggle it is to send
AL Keybard Layout
as one of the Application Launch Buttons on the USB HID spec, (section 15)I found this SO post https://stackoverflow.com/questions/22181883/bluetooth-le-hid-eject-key-code which looks like they're creating a second report object with the Application Launch buttons and then sending that for the toggle, but I couldn't figure out how to translate that into espruino to send the alternate report in NRF.sendHIDReport, is there a way to select the report ID?
-
Hi Gordon,
Sorry yes should have said I was doing the key up event as well just posted the keycode bit for clarity
Thats a good point about the maxium I'll try that, do I need to raise both Logical Maxiumum and Usage Maximum ?
Also I was confused about the vaule of the Keycodes are they Hex or Dec? the library seems to have hex for the modifiers and dec for the keycodes? are they just interchangable
-
I'm setting up a Puck to work with my iPhone as a BLE keyboard, all good so far but iOS has an annoying habit that it disables the on screen keyboard if there's a hardware one connected.
You can toggle the on-screen keyboard using the eject key on Apple Keyboards, which I belive is keycode 0x92.I'd like to be able to send this from my puck so I don't have to keep disconnecting the keyboard in bluetooth each time.
Any ideas how to do this? I've tried
NRF.sendHIDReport([0,0,146,0,0,0,0,0]
and
NRF.sendHIDReport([0,0,0x92,0,0,0,0,0]
without any luck
-
Did a bit more digging on this and some testing with my espriunio WiFi.
The 0x7780 error seems to relate to a problem with the certificate chain, likely due to the server using a self signed cert. I get this error thrown with the EsprinoWiFi as well as the Pixl.
I'm a bit out of my depth but supposedly if you call mbedtls withMBEDTLS_SSL_VERIFY_NONE
set then it will ignore the cert chain, I think this line says that should be set in esprunio though? https://github.com/espruino/Espruino/blob/master/libs/network/network.c#L599Yes I was uploading to flash already, seems like this might be just too much for the nRF52 to deal with on its own, I think I need to look at offloading the SSL to something else like an ESP-32 instead of the ESP-8266 that I'm using anyway
Its rather annoying that Tesla are forcing the powerwall to use SSL with a self signed cert, the whole project works really nicely if I could just overcome that issue. -
I did some more testing last night;
Firstly trying to fetch the pur3 page with the pixl returns an out of memory error
TLS check
http
TLS yes?
=undefined
Uncaught InternalError: Failed! mbedtls_ssl_handshake returned Not enough memory
Then I tried with my EspruinoWiFi, fetches the pur3 page fine but on the internal IP I get the same 0x7780 error, with a bit of googling this error seems to be related to the certificate chain, as my device uses a self signed cert this makes sense.
So there are now 2 problems:
The pixl still can't make an HTTPS request even to a 'good' host
Espruino doesn't like self signed certs.
Is there any way to set a flag to ignore the certificate validation and just accept the cert, like the -k option in curl? -
-
Tried with that build on the pixl and just updating the url to https but it still seems to be making the request over http, this is my code, do I need to do something else?
digitalWrite(D12,1); // enable ESP8266
Serial1.setup(115200, { rx: D2, tx : D3 });
var wifi = require("ESP8266WiFi_0v25").connect(Serial1, function(err) {
if (err) throw err;
console.log("Connecting to WiFi");
wifi.connect(SSID, PASSWORD, function(err) {
if (err) throw err;
console.log("WiFi Connected");
getCharge();
});
});
function getCharge(){
var http = require("http");
http.get("https://192.168.1.127/api/system_status/soe", function(res) {
var contents = "";
res.on('data', function(data) { contents += data; });
res.on('close', function() {
var d = JSON.parse(contents);
var charge = Math.round(d.percentage);
g.clear();
// Use the small font for a title
g.setFontBitmap();
g.drawString("Charge:");
// Use a large font for the value itself
g.setFontVector(40);
g.drawString(`${charge}%`, (g.getWidth()-g.stringWidth(`${charge}%`))/2,10);
// Update the screen
g.flip();
});
});
}
-
So I know its not currently possible but I'm wondering what options I have for this.
Currently I've got a board with a few neopixels and an ESP8266 on it that plugs onto a pixl, that then makes requests to an API to get some data which is displayed on the pixl and LEDs.The server I'm connecting to only offers HTTPS using a self signed cert and its on an internal network,there are only 2 endpoints I need to get JSON from.
Currently I'm using a very simple NodeRED flow to act as a reverse proxy and take in a plain HTTP request from the pixl then forward on over HTTPS, but this isn't ideal long term, I'd like to have everyting self contained on the device.I don't really want to swap the Pixl for an Espruino WiFi, the screen buttons and BLE are all useful parts of the design.
Could I replace the ESP8266 with an ESP32 but use this to make the HTTPS requests using its own internal client, I guess I'd need some custom code to talk serial to the E32 and then have it make the requests? Anyone done that? I guess running a second copy of espruino on the ESP-32 would be one way to go
Whats the fundimental blocker with getting HTTPS from teh nRF52 is it just not capable? Is it a question of time/money?
Any other ideas? -
-
Got my Thingy:52 in the mail this morning, and trying to put esprunio on it,
I couldn't see a softdevice file in /binaries for 2.04 so i used the 1.99 one and then put the espruino_1v99_thingy52_app.zip build onto it which worked fine, however I'd now like to update it to 2.04, but using the espruino_2v04_thingy52.zip file I get an Error 'Invalid Object' with DFU from nrfConnect on iOS.
-
I want to be able to share a URL to people to update their pixl with my latest build via the web app, I found the
?codeurl=
param which is great for getting the code into their IDE but I also need to set a couple of options, namleyDirect to Flash
andModules uploaded as functions
is it possible to set these from url params as well? that way I can give someone a URL to open where they just click connect then send to esprunio? -
-
thanks @Robin thats what I was looking for!
-
I've done a dumb thing and realised that the only working copy of some code I have is runnng on a puck, somehow I forgot to save the backup.
Is there any way to get the REPL to print out the current code thats on the device, I tried pocking at the Storage functions but I get an error
"Storage" is not defined
-
I have a pixl that currently advertises a custom service and characteristic which a puck can then discover connect to and write to.
I would like to replicate this with webbluetooth so that the puck can control a browser app instead of the pixl, is that possible? obviously doing something on the page instead of turning on the LED
Below is the code on my pixl.NRF.setServices({
"60970001-dddd-49b8-acea-2b7f5d2660dd": {
"60970002-dddd-49b8-acea-2b7f5d2660dd": {
value : [0],
maxLen : 1,
writable : true,
onWrite : function(evt) {
digitalWrite(LED, evt.data[0]);
digitalWrite(D13, evt.data[0]);
}
}
}
}, { uart : true });
// On disconnect
NRF.on('disconnect', function() {
digitalWrite(LED,0);
digitalWrite(D13,0)
});
// Change name
NRF.setAdvertising({}, {name:"BLEPTT"});6
@MaBe I've just tested with the sample output code on https://www.espruino.com/Waveform and that plays back fine on an ESP32 so looks like thats ok its just my encoding that I need to look at
@Gordon is there any more detail on the audio encoding for waveform, at the moment I have PCM frames with 16bit 8KHz samples, little endian
But trying to play these back with waveform produces noise