Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Firmware Internals

Code Structure

hx711

This module implements load cell support. It is an async version of the loadcell crate with project-specific changes.

ble

This module implements the Bluetooth Low Energy (BLE) functionality:

  • Defines the GATT server and services
  • Handles advertising and connections
  • Defines the Progressor service with data point and control point characteristics

progressor

The progressor module implements the Tindeq API used for BLE communication between the ESP32-C3 and a smartphone.

Main Tasks

The main.rs file defines several asynchronous tasks that run concurrently:

  • measurement_task:
    • Initializes the load cell.
    • Handles taring and reads measurements from the sensor.
  • ble_task:
    • Long-running background task required alongside other BLE tasks.
  • gatt_events_task:
    • Processes GATT events such as control-point writes.
  • data_processing_task:
    • Handles sending notifications with data points.
  • battery_voltage_task:
    • Periodically reads the battery voltage.
  • deep_sleep_task:
    • Monitors inactivity; after a timeout, the device enters deep sleep.

Communication between tasks occurs via a Channel.