Avatar for fanoush

fanoush

Member since Jul 2018 • Last active Apr 2024

Most recent activity

  • in General
    Avatar for fanoush

    use spiffs or any other way to load files to storage

    The Storage https://www.espruino.com/Reference#Stora­ge already has its own simplified filesystem so no spiffs is needed/possible there. The main feature of Storage is that each file takes continuous area of flash and files are directly mappable to some memory address. The disadvantage is that you cannot append to such file or overwrite existing data, you need to create it with some size and either fill it with data completely at creation time or write only to areas not written yet = bytes with all bits set (0xff = 255). So it is something between low level flash access and simplified filesystem.

    Then there is a hybrid on top of it https://www.espruino.com/Reference#Stora­geFile which can append but cannot write/contain 0xff=255 bytes.

    But while it is limited as described it can work just fine for serving text files with webserver.

  • in ESP32
    Avatar for fanoush

    I can both read and write / edit the value of certain characteristic, but could not call the onWrite() callback function

    Yes that is good, what I meant is that if you don't get the callback then you don't know what value was written so writing is not very useful.

  • in ESP32
    Avatar for fanoush

    Check issue #1777 Improve ESP32 implementation for fixed and open issues.

    Thanks. Not much BLE related there however, I see only

    • NRF.updateServices() needs fixing issue 2292
    • BLE/NRF error , check issue 2493, issue 2292
      so I guess this patch mentioned above solves/helps with #2292 which is actually quite old and known

    So it makes sense there is no info in the list about using BLE characteristics (writing callback + notifications) since nobody could try with NRF.setServices not working.

  • in ESP32
    Avatar for fanoush

    There are indeed some issues with ESP32, sad

    Yes, not a long time ago only advertising worked well on ESP32 so even this state is much better. If setting up service with characteristics did not work (at all I guess?) and is fixed only now it means nobody used it before. Does at least reading and writing values of characteristics work? As a workaround for now it may be good enough to read characteristics periodically instead of using notifications.

    Oh but you said writing does not work because the callback is not called so you don't get the new value. Oh, well.

    I don't know what project are you working on but if you just need some bidirectional communication you may use the interpreter console itself over BLE to pass the data. Sorry I don't use ESP32 with Espruino for BLE so I am not sure what already works, @MaBe does at least the Nordic UART console work over BLE on ESP32?

    Or maybe @Gordon knows what is BLE state for ESP32 and what is still missing? I've seen some significant BLE related work done for ESP32 port in recent year.

  • in ESP32
    Avatar for fanoush

    Well but does it work? I did not test it.

  • in ESP32
    Avatar for fanoush

    I'll try to build from source

    it is actually very easy, on typical linux (ubuntu, debian) or in WSL you just checkout the Espruino github repo and run provision script that will download stuff for specific BOARD and its platform. I think on Ubuntu this works just with apt-get install build-essential python-is-python3 python3-pip git curl

    ~$ git clone https://github.com/espruino/Espruino ; cd Espruino
    ~/Espruino$ . scripts/provision.sh ESP32
    Provision BOARDNAME = ESP32
    Provision FAMILY = ESP32
    ===== ESP32
    pip 20.3.4 from /usr/lib/python3/dist-packages/pip (python 3.9)
    python/pip installed
    pyserial installed
    installing app folder
    installing esp-idf folder
    installing xtensa-esp32-elf-gcc
    ESP_IDF_PATH=/home/fanoush/Espruino/esp-­idf
    ESP_APP_TEMPLATE_PATH=/home/fanoush/Espr­uino/app
    PATH=$PATH:/home/fanoush/Espruino/xtensa­-esp32-elf/bin/
    GCC is /home/fanoush/Espruino/xtensa-esp32-elf/­bin//xtensa-esp32-elf-gcc
    ~/Espruino$ make BOARD=ESP32 RELEASE=1 clean
    Cleaning targets
    ~/Espruino$ make BOARD=ESP32 RELEASE=1
    

    Also you can trick it and just use github to build it for you, ESP32 is part of build checks, so if you go to
    https://github.com/espruino/Espruino and click the green checkmark next to some recent commit you go e.g. to
    https://github.com/espruino/Espruino/act­ions/runs/8781555980/job/24093818739
    if you expand the "Upload ESP32 Artifact" step there is

    Artifact ESP32 has been successfully uploaded! Final size is 2908638 bytes. Artifact ID is 1434877087
    Artifact download URL: https://github.com/espruino/Espruino/act­ions/runs/8781555980/artifacts/143487708­7
    

    so just click that link to download zip of build results for that commit.

    So you can just fork Espruino repo, push change(s) to your forked repo and get the result zip of your custom ESP32 build.

  • in ESP32
    Avatar for fanoush

    May be there are some bugs in ESP32 code

    yes, it is not so stable, there is no official ESP32 based Espruino device so this is just community effort.
    I don't have device to test but I think this could help

    diff --git a/targets/esp32/BLE/esp32_gatts_func.c b/targets/esp32/BLE/esp32_gatts_func.c
    index 7fd09fdc2..30d7171b5 100644
    --- a/targets/esp32/BLE/esp32_gatts_func.c
    +++ b/targets/esp32/BLE/esp32_gatts_func.c
    @@ -449,10 +449,10 @@ void gatts_char_init(JsvObjectIterator *ble_char_it){
       const char *errorStr;
       ble_uuid_t ble_uuid;
       gatts_char[ble_char_pos].service_pos = ble_service_pos;
    -  if((errorStr = bleVarToUUIDAndUnLock(&ble_uuid,jsvObjec­tIteratorGetKey(&ble_char_it)))){
    +  if((errorStr = bleVarToUUIDAndUnLock(&ble_uuid,jsvObjec­tIteratorGetKey(ble_char_it)))){
         jsExceptionHere(JSET_ERROR,"invalid Char UUID:%s",errorStr);
       }
    -  JsVar *charVar = jsvObjectIteratorGetValue(&ble_char_it);­
    +  JsVar *charVar = jsvObjectIteratorGetValue(ble_char_it);
       gatts_char[ble_char_pos].char_uuid.len = ESP_UUID_LEN_16;
       gatts_char[ble_char_pos].char_uuid.uuid.­uuid16 = ble_uuid.uuid;
       gatts_char[ble_char_pos].char_perm = 0;
    

    attached is result of the build with that patch applied. maybe it helps, maybe you'll hit another bug

  • in ESP32
    Avatar for fanoush

    sorry, I don't use ESP32 very much but when looking at similar nrf52 code here
    https://github.com/espruino/Espruino/blo­b/master/targets/nrf5x/bluetooth.c#L3127­
    I think it takes &serviceit which is JsvObjectIterator serviceit;
    while I think in ESP32 code it already takes pointer to iterator https://github.com/espruino/Espruino/blo­b/master/targets/esp32/BLE/esp32_gatts_f­unc.c#L448 JsvObjectIterator *ble_char_it and it passes another reference to it
    https://github.com/espruino/Espruino/blo­b/master/targets/esp32/BLE/esp32_gatts_f­unc.c#L452 jsvObjectIteratorGetKey(&ble_char_it)

    I guess there should be ble_char_it used instead of &ble_char_it in that method (possibly in more places).

    If you can build from source maybe you can try to fix it?

  • in ESP32
    Avatar for fanoush

    Oh that is strange. The code is common for all platforms
    https://github.com/espruino/Espruino/blo­b/master/libs/bluetooth/bluetooth_utils.­c#L135
    and the error message you see in your first example is here
    https://github.com/espruino/Espruino/blo­b/master/libs/bluetooth/bluetooth_utils.­c#L167

    Are you using recent/latest version of Espruino?

    EDIT: the specific ESP32 code printing the message starting with "invalid Char UUID:" is here
    https://github.com/espruino/Espruino/blo­b/master/targets/esp32/BLE/esp32_gatts_f­unc.c#L453
    but for parsing it is calling the common bleVarToUUIDAndUnLock method

    and what is also strange is that it probably parses the service ID in same format
    on line 510, before it breaks few lines below on parsing characteristics here
    https://github.com/espruino/Espruino/blo­b/master/targets/esp32/BLE/esp32_gatts_f­unc.c#L521
    so looks like maybe it reads the string from some wrong place and gets some garbage(?)

  • in Bangle.js
    Avatar for fanoush

    Steps to reset NR52 Device

    grab software here
    The apps built in Rust so you'll need that plus Rust package manager cargo
    also need "sudo apt-get install libusb-1.0-0-dev librust-pkg-config-dev"
    Then run nrf-recover

    Well what I meant is nrf_recover command/script defined inside OpenOCD nrf52 target https://github.com/openocd-org/openocd/b­lob/master/tcl/target/nrf52.cfg#L73 which can be typed in openocd command line as instructed by that message.

    But it is great you are not satisfied with doing stuff in easy ways. The https://github.com/probe-rs/probe-rs used by that code looks like nice rust library for using those debug probes.

Actions