Skip to content

An Android smartwatch application to read and send sensor data to the server.

License

Notifications You must be signed in to change notification settings

TOM-Platform/TOM-Client-WearOS

Repository files navigation

TOM-Client-WearOS

An Android smartwatch application to read and send sensor data to the server.

  • This application is based on Google’s ExerciseSampleCompose using ExerciseClient API.
  • A Room database has been added to save exercise metrics such as heart rate, calories, speed, etc., in the local database on the watch.
  • It also uses Ktor OkHttp to send exercise data to the server using web sockets.
  • See overview here

Requirements

  • AndroidStudio

Installation

Search Location

Choosing which API to use

  • In app/src/main/java/com/hci/tom/android/presentation/ExerciseViewModel.kt, you can modify the options to choose which API you would like to use for search locations.
companion object {
    // 0 for OpenStreetMap, 1 for Google Maps
    private const val PLACES_OPTION = 0
}

Setting up config files

  • Create an object class named ApiKeys.kt in app/src/main/java/com/hci/tom/android/network directory and add the following code:
package com.hci.tom.android.network

object ApiKeys {
    const val GOOGLE_MAP_API_KEY = "{YOUR_GOOGLE_MAPS_API_KEY}"
}
  • In app/src/main/java/com/hci/tom/android/network/Credentials.kt, modify the code accordingly:
package com.hci.tom.android.network

object Credentials {
    const val SERVER_URL = "ws://{IP_ADDRESS}:{SERVER_PORT}"
}

You can set the IP address to 10.0.2.2 if you are using the emulator. This is because the emulator runs behind a virtual router isolated from your computer network interfaces, 10.0.2.2 is an alias to your host loopback interface. (127.0.0.1 on development machine) You can refer to https://developer.android.com/studio/run/emulator-networking for more info.

ADB debug from computer

  • Debugging
  • Go to platform-tools cd <USER_FOLDER>\Android\Sdk\platform-tools (<USER_FOLDER> is the folder where Android SDK is installed, e.e., C:\Users\<NAME>\AppData\Local\)
  • Connect adb, adb connect <WATCH_IP>
  • To disconnect, adb disconnect

Application Execution

Emulator

Simulating an exercise session

  • To simulate an exercise session on an emulator, you can use the following command in the terminal:
adb shell am broadcast -a "whs.synthetic.user.START_EXERCISE"--ei exercise_options_heart_rate 90 --ef exercise_options_average_speed 2.5 --ez exercise_options_use_location true com.google.android.wearable.healthservices
  • You can visit this link if you would like to modify the simulated run stats. Ensure that developer options is enabled on the emulator as well.

Simulating voice input

  • To enable microphone input on an emulator, you can use the following command in the terminal:
adb emu avd hostmicon

Make sure to enable this option in extended controls as well, you have to enable it everytime you restart the emulator: image

Protobuf

  • Change to Project View at the top left of Android Studio.

image

  • Create your proto file in app/src/main/proto, create a new proto directory if necessary. Please refer here for more info on how to structure your proto file.

image

  • You can set the package directory using option java_package = "{dir_path}" and the generated class name using option java_outer_classname = "{class_name}" before the message and after the syntax.
  • Build the project and the generated class should be in app/build/generated/source/proto/debug/java/{dir_path} and you can import the class from there to use the class builder functions.

image

Development

Guides

Linting

Intellij IDEA

  1. Install the ktlint plugin in the Marketplace here

Command-Line

  1. Install ktlint Guide
  2. Run ktlint --editorconfig=.editorconfig

References

About

An Android smartwatch application to read and send sensor data to the server.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages