phatpaul / ble-ftp-cordova-example

Example Android/iOS Cordova App to demo the BLE-FTP service
Apache License 2.0
5 stars 0 forks source link

ble-ftp-cordova-example

Example Android/iOS Cordova App to demo the BLE-FTP service

I wrote this BLE-FTP service to transfer configuration files back-and-forth from my ESP32 to a Android/iOS App (Cordova). It can transfer large files, but the rate is pretty slow, limited by the BLE bandwidth. It works with MTU sizes from 20~512B (but performance is much better at higher MTU).

This example is to be used with https://github.com/eagi223/esp-idf_Bluetooth_Multi-Service on ESP32

Prereqs (Common for all OS and targets)

  1. Ensure you pull the most recent master branch & update the submodules ( git submodule update --recursive --init)

  2. Install node.js (once)

    • On Windows, download and install exe from website.
    • On Ubuntu 20:
      curl -sL https://deb.nodesource.com/setup_16.x -o nodesource_setup.sh
      sudo bash nodesource_setup.sh
      sudo apt install nodejs npm

      In Windows: If you want to get rid of the requirement to type npx before node commands, add this to your PATH (in User variables): %USERPROFILE%\AppData\Roaming\npm

  3. CD to this repo root directory. (same dir as package.json)

  4. Install build prerequisites (once)

    npm install

Updating npm packages

# check global packages like npm (you may have to prefix 'sudo' on linux or macOS)
(sudo) npm install -g npm@latest
(sudo) npm upgrade -g
(sudo) npm outdated -g
# check and upgrade local packages
npm upgrade
npm audit fix
npm outdated
# (optional and risky) if you want to upgrade an outdated package x beyond "wanted":
npm install x@latest
# (that will also update the version specified in package.json)

Prereqs for Android

Note: this was tested using Cordova-Android version 11. Android SDK 32.

Windows:

Linux:

sudo apt install openjdk-11-jdk
sudo apt install gradle # doesn't matter that it's an old version in the ubuntu repo, it will be upgraded as needed by gradle-wrapper
sudo add-apt-repository ppa:maarten-fonville/android-studio
sudo apt install android-studio

Launch Android Studio to install the SDK (using SDK 32 with cordova-android@11 )

nano ~/.bashrc
# add to the end of the file:
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export PATH=${JAVA_HOME}/bin:${PATH}
export ANDROID_SDK_ROOT=${HOME}/Android/Sdk
export PATH=${ANDROID_SDK_ROOT}/tools:${PATH}
export PATH=${ANDROID_SDK_ROOT}/platform-tools:${PATH}
export PATH=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/:${PATH}
export PATH=${ANDROID_SDK_ROOT}/emulator/:${PATH}
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

source ~/.bashrc

Build for Android

Android Debug build

Note: debug build won't run on older Android devices which don't support ES6 modules

Debug run on android (i.e. replace device for emulator)

Android debugging

adb using USB cable

adb using TCP/IP (WiFi)

Webview debugging with Chromium

Build for iOS

Prereqs for iOS Build

Updating npm packages

iOS Debug build

Debug run on iOS