-
Hmm, your screenshot shows some strange words (danish ?)
Did you download binary from Espruino Server, or compile by yourself ?
Just downloaded from http://www.espruino.com/binaries/travis/master/espruino_1v99.175_esp32.tgz
and get what I expected (1v99.175) -
The only way to get temperature on ESP32 is a sensless function.
Your finger is much more helpful to get temperatur os the chip
temprature_sens_read() and no, its not a typo ;-)
Description from Espressif guys is
temprature_sens_read (sic.) returns ADC counts. To convert these into degrees C you would need to perform some kind of calibration by measuring the temperature with an external tool. -
@wilberforce, lets go to github for next changes, thats ok for me.
You mentioned somewhere about hot chip with BLE supported firmware.
Is this still the case if you disable BLE ?Short and quick answer here.
- message will go away with changes for UART.
- NRF object and Bluetooth object are still available. Still searching for a nice idea, .... As Gordon mentioned, there would be a backdoor to access them even they are set to nothing. And adding an "IfBLEenabled()" to all functions looks like an oversized solution to me.
- message will go away with changes for UART.
-
-
Bluetooth on ESP32 eats a lot of memory. Only 2500 JsVars are available with Bluetooth and Wifi.
Just pushed a version to branch ESP-v3.0 with new commands to bypass this problem for those that need more memory instead of BLE or Wifi :- ESP32.enableBLE(false/true) , adds about 1900 additional JsVars
- ESP32.enableWifi/false/true) , adds about 3800 additional JsVars
- ESP32.getState() , flags are added for BLE/Wifi status
Default is BLE and Wifi are enbaled.
If you don't need one of them in your application:- type command to disable (argument = false)
- this status is saved in NVS (special storage area of ESP32)
- any saved source is deleted. This needs to be done to avoid overflow in JsVars
- ESP32 board performs a restart
- during restart status in NVS is checked, and based on that available RAM for JsVars is calculated
From now on, the board starts according to enabled/disabled protocols.
To go back to original, you can flash all memory, or use the ESP32.enable-functions with true.
To get this function running, a new mode for allocationg memory for JsVars is added. Please see ESP32.py in boards directory.
@Gordon, could you please take a closer look to changes in jsvar.h and jsvar.c
@wilberforce, I've never had the problem with hot chips, could you please check with your boards - ESP32.enableBLE(false/true) , adds about 1900 additional JsVars
-
@wilberforce, I've UART running with my Android phone.
@Gordon, testing the same with Windows is a desaster.
There is nothing I can replicate. Problems occur following a kind of randomizing.
Problems like:- BLE scanner shows all boards, but admin page shows only a few of them.
- sometimes ESP32 is not recognized, sometimes puck.js is not recognized
- testing with Chrome browser tells "Bluetooth Adapter not available", from time to time
- sometimes WebIDE recognizes boards (even Puck.js), but does not connect
- and some others where I don't even know how to describe
My priority right now is to add enable/disable for Bluetooth which saves about 2000 jsVars.
Once this is done, next step will be to add UART, at least for Android clients
Last not least, Windows will get a new try. BTW, feedback from ESP32Forum to Windows was poor, and misleading. Nothing from an Espruino guy. - BLE scanner shows all boards, but admin page shows only a few of them.
-
-
Worked a bit on a switch for BLE.
To be prepared for surprises, the idea is to calculate available jsVars.
Assumptions are:- heap of 50000 bytes is sufficient
- use steps of 100
maximum no. of JsVars is 20000
Do you guys agree ?int heapVars; heapVars = (esp_get_free_heap_size() - 50000) / 16; heapVars = heapVars - heapVars % 100; if(heapVars > 20000) heapVars = 20000; jsVarsSize = heapVars; jsvInit();
One more question could we do something like
Bluetooth = nothing;
NRF = nothing;or with a new (empty) object called isDisabled
Bluetooth = new(isDisabled());
NRF = new(isDisabled()); - heap of 50000 bytes is sufficient
-
In a very early state I found a way to switch BLE on or off under testing.
Workflow right now is like this- added an ESP32 specific command (ESP32enableBLE(mode);)
- this functions stores a flag in Flash (in the moment partition free)
- HWreset the board
- during startup, read the flag from Flash, and according to that init BLE, or not
Results in my test environment is heap of 103388 to 74252.
This would be around 2000 additional jsVars, if BLE is not used
Before making this nicer, better tested etc, I've some questions
- Should we use partition free, or is there a better place ?
- Do we need a message during startup, that BLE is disabled ?
- Is there a way to make NRF, Bluetooth and others inactive, so they cannot be called by accident ?
- Is there an option to use of HWReset ?
- some other questions, not comin to my mind right now ;-)
- what should be default setting, with or without BLE ?
- added an ESP32 specific command (ESP32enableBLE(mode);)
-
@Wilberforce, thats correct, first of all I've to pair in Admin screen. Same as with Puck.
With actual version this step works fine, I see connected.
If devicename is like PUCK* or Espruino now, the board is shown in Select list of WebIDE
After click on connect, connection starts. on ESP32 I see the connected event
Next, after a second or two, an MTU event appears which gives size of MTU (AFAIK) only
And then, 3 more seconds later we get a disconnect event.Does windows expect something, that ESP32 does not deliver or ????
-
Problem was missing SetDeviceInitialised for Serial1.
Now LoopbackA.setConsole() and Serial1.setConsole() works fine.BTW, looks to me, like LOOPbackA and LoopbackB are not initialised, at least flag is not set.
One more success, Bluetooth.setConsole works fine, and next Serial1.setConsole from my Android with nRf UART V2.0 returns control to webIDE.
Life can be so beautiful.Now I've to figure out, why Windows10 does not like my ESP32, .......
-
Oh, LoopbackA.setConsole(), and I get an illegal instruction panic
If I call Serial1.setConsole() without LoobackA.setConsole before, everything looks fine.
Now have to do some work to check stack and see how panic happens.Problem starts in jshUSARTSetup, have to dig deeper.
Oh, this problem is fixed, default in switch for serial ports was wrong.
But now the problem is the same as before with Bluetooth.
Console does not come back.One more chance for me to dig deeper, .....
-
Now that Bluetooth.print works fine, next step is to test Bluetooth as console.
First step is to write a simple function, which- set a timeout
- in this, timeout set bluetooth to console
2.1. set one more timeout - in this timeout set Console back to Serial1
Some prints are added to each step.
Expectation for this function is,
- after 1 sec console is switched to Bluetooth, which happens
- 5secs later console is switched back to Serial1, which never happens
Hopefully the following description is not too confusing
function testConsole(){ setTimeout(function(){ Bluetooth.setConsole(true); setTimeout(function() { //Bluetooth.print("BT \n"); Serial1.print("Ser BT \n"); Serial1.setConsole(true); //Bluetooth.print("SER set\n"); Serial1.print("Ser SER set\n"); },5000); //Bluetooth.print("BT set\n"); Serial1.print("Ser BT set\n"); },1000); }
Testing itself is
- upload the function
- start uart service in WebIDE
- connect from my android to uart service with nRF UART v2.0
- call the function TestConsole in WebIDE
On WebIDE I see
testConsole() // start of function(see function above)**
=undefined
-> Bluetooth // Message from firmware
Ser BT set // Bluetooth is set to console
Ser BT // before setting Serial to be console// message missing from firmware, that Serial1 is switched back from BT // message missing from 2nd setTimeout, that serial is set to console
In nRF Uart everything looks like expected
RX: <- Serial1 //message from firmware, console switched from Serial1 to BT
BT set // Bluetooth is set to Console
BT // before switching back to Serial[J->Serial1 // message from firmware, console switched to Serial
RX: Ser set // message from 2nd setTimeout, console is switched back to Serial1 - set a timeout
-
-
Hmm, tried to use timer. Something may be wrong in my understanding of jstExecuteFn
Or, another option, I'm on the wrong train ?
Short hint, addCharToNotif is called from jshUSARTKick[#define](https://forum.espruino.com/search/?q=%23define) notifBufferSize 10 uint8_t notifBuffer[notifBufferSize]; uint8_t notifBufferPnt = 0; bool inNotif = false; void sendNotifBuffer(){ if(uart_gatts_if != ESP_GATT_IF_NONE){ esp_ble_gatts_send_indicate(uart_gatts_if,0,uart_tx_handle,notifBufferPnt,notifBuffer,false); } notifBufferPnt = 0; } void notifTimerCB(){ if(notifBufferPnt > 0) sendNotifBuffer(); jstStopExecuteFn(notifTimerCB,NULL); inNotif = false; } void startNotifTimer(){ JsSysTime time = jshGetSystemTime(); inNotif = true; jstExecuteFn(notifTimerCB, NULL, time , 10);//assumed that CB is called after 10 ms ?? } void addCharToNotif(int c){ notifBuffer[notifBufferPnt] = (uint8_t)c; notifBufferPnt++; if(notifBufferPnt >= notifBufferSize) sendNotifBuffer(); if(!inNotif) startNotifTimer(); }
-
On my best understanding there is one major location to call USARTKick, which is jshTransmit
jshTransmit is called with one char in jsdevices.c and in jswrap_serial.c
In jsdevices its called from jshTransmitPrintfCallback which loops through a string
In jswrap_serial its called from _jswrap_serial_print_cb which iterates through an arg (jsVar)
Both cases a string is send with lot of calls to USARTKick. For Bluetooth it would be a better idea, to send strings, to avoid overhead.If I would now replace many calls to USARTKick by a function that sends a string, what would be the best way ?
Adding an #ifdef USE_BLUEOOTH in jsdevices and jswrap_serial is doable, but would be ugly.
We could add a call in bluetooth.h for strings
Or add a call to jshardware.h like USART_SendStringThere are pros and cons for all solutions. Looks to me, like we have to change core sources in each case.
What would be best, or is there another way to solve the problem. -
@Wilberforce, thanks for your feedback
- So we have agreement for removing OTA, great.
- I've seen, you already created an espv3 branch. Would it be correct, to change line 3 to v3 and line 4 to esp32 branch in build-idf.sh ? I will do my best to bring up a version. Pretty sure, I've to contact you to get a better understanding of BuildTool. For example, right now, I've no idea how to test my changes.
- For compiling we will need a new compiler version. How/where would we tell which compiler to use ?
- with/without BLE is a problem. Creating 2 firmware binaries would mean 2 different precompiled templates, more maintenance, etc. etc. An option to switch BLE on/off during runtime would not help, since we would need a kind of jsVar-renumber to increase or decrease number of jsVars.
- and, number of jsVars, hmm, using V3 already eats a lot of RAM, much more than V2.1. My assumption is, maximum will be somewhere between 3500 and 4000 jsVars. If there is anybody interested in that and having the time to check this seriously, please go ahead and give us some feedback.
- BTW, do you have experience with Gordons point to upload code directly to flash ?
- I had a big discussion with Gordon in Nürnberg. He has a great idea, how to reduce RAM usage for jsVars and store them in Flash. This is future talk, but will be a big step.
- So we have agreement for removing OTA, great.
-
For a day or so, V3.0 is released.
We've been waiting long time for this step.
My plan now is, to get Espruino running with actual sources, which are- Espruino itself
- ESP-IDF V3.0
- Bluetooth support for ESP32
- support PSRAM in WROVER boards giving us 20000 jsVars (or more ?)
- support of BLE serial (NRF UART) is under development. Windows 10 Is not really helpful for that. This will take some time.
-last not least documents
Everything will be done first in ESP32 branch.
There are some restrictions like
- reduce jsvars to 2500, I'm just testing with 3000 and got no problems(yet). If you need more, WROVER boards are available. Last not least, there is somebody in the ESP32 forum adding a 8MB PSRAM, priced less than 1$
- Bluetooth eats memory like crazy. Size of binary, including BLE Uart and bonding is 1280KB. There is a build option to build Espruino without Bluetooth, but even that is really big
- do we need OTA for ESP32 ? Flashing more than 1MB over the air, is this really helpful ? It reduces available Flash a lot.
Once this upgrade to V3.0 is done and works fine, next steps are
- merge ESP32 branch into master. For this step @Gordon is the man
- upgrade EspruinoBuildTools to V3.0. This is a tool from @Wilberforce, so he has the knowhow
Please take my plan as starting point only.
Any comments, especially from guys (hopefully) involved, are welcome. - Espruino itself
-
I get Puck.js connected without problems.
Sometimes I've to drop and reconnect, but it works fine.Please see here http://www.jumware.com/JUMSpruino/problems/Bluetooth_ESP32.html
for some screenshots and a videonRF connect gives same raw data for advertising as Puck.js does, except the name ;-)
nRF UART v2.0 connects, sends data and receives data.Under windows (changing the name to Espruino doesn't change anything)
- admin page for adding bluetooth devices finds the ESP32 device
- - after click on device "establish connection" is shown (my translation)
- - some seconde later "try again" is shown
With Puck.js I've to do the same and it connects. And next Puck.js is available for IDE
- admin page for adding bluetooth devices finds the ESP32 device
-
I've a first test running for ESP32 having NUS (Nordic uart service) .
It is recognized on my Android. There are some problems, anyway it's fine for first step.On Windows10 same device is scanned/found, but it does not connect.
Somewhere I found a hint of missing HID.
I've seen http://www.espruino.com/modules/ble_hid_keyboard.js and followed the link http://www.usb.org/developers/hidpage/Hut1_12v2.pdfMy knowldege around HID is (very) close to zero.
Is there any idea, how HID needs to be configured for NUS ?
Or, may be, I'm on the wrong train ? -
-
Hmmm,
so I've to catch device EV_BLUETOOTH in jshUSARTSetup.
Anyway, if EV_BLUETOOTH is already initialised this should be skipped.
I see -> Bluetooth on console, up to that point everything is fine.
If next step (set Console Device) is done, app runs into IRQ timeout.I cannot find the step, where something like Bluetooth.write is called. There should be a, let me say connection/function, to write data to ESP32 bluetooth device from Serial object.
Walking through jswrap_serial and jsdevices, at the end, it should go to jshUSARTKick with device = EV_BLUETOOTH, is that correct ?
-
-
For information only, there is an overlapping of GPIO16/17 on some boards
For WROVER boards, those with additional 4MB PSRAM, 16/17 are used for the PSRAM.
For WROOM boards like yours it should'nt be a problem.