Goal: To display a live visualization of the power used (in kW) by the electric drivetrain of the car.
Secondary goals: Add more features and data visualization
Implemented using Re-frame on ClojureScript on Expo on React Native.
Fully functional REPL to a running program on a real device.
All changes immediately visible on the device without recompiling or restarting.
Install Expo XDE and mobile client
If you don’t want to use XDE (not IDE, it stands for Expo Development Tools), you can use exp CLI.
yarn install
- edit node_modules/react-native-obd2/android/src/main/java/com/jetbridge/reactobd2/ReactNativeOBD2Package.java
- delete method createJSModules()
brew tap homebrew/cask
brew cask install android-ndk
brew cask install android-platform-tools
brew cask install android-sdk
Add env vars to .bashrc / .zshrc:
export ANDROID_SDK_ROOT="/usr/local/share/android-sdk"
export ANDROID_HOME=$ANDROID_SDK_ROOT
export ANDROID_NDK_HOME="/usr/local/share/android-ndk"'
Accept licenses:
sdkmanager --licenses
npm install -g react-native-cli
react-native link
- Plug in phone with a USB cable, development powers need to be unlocked.
- Open XDE and click “Open existing project…”
- Open ‘high-voltage’ project directory
- Start the project
cd android
./gradlew installDevMinSdkDevKernelDebug
adb reverse tcp:3449 tcp:3449
lein with-profile dev repl
(start-figwheel)
On your phone, open Expo. High-voltage should appear on the list. Tap on it.
From this moment on you only need to save your files in $EDITOR and figwheel will immediately evaluate changes in the running program.
You will also have a fully functional REPL to your program running on your phone. The holy grail of programming.
Libraries requiring linking use ExpoKit
Install ExpoKit:
exp detach
Install and link:
npm install -g react-native-cli
react-native link
Start and run Android project (first run will download the internet):
cd android
./gradlew installDevMinSdkDevKernelDebug