Step 3 — New Battery Assignment¶
Purpose¶
The New step captures the details of the fresh replacement battery. The attendant scans, connects, and reads the new battery — then the app automatically calculates the energy difference and determines the swap cost.
Workflow¶
- Scan the QR code on the fresh (charged) battery.
- Connect to the battery via Bluetooth Low Energy (BLE).
-
Read the battery's data from its BLE services:
BLE Service Data Read Description ATT (Attribute) Battery ID Unique identifier of the new battery DTA (Data) Energy level Energy stored in the new battery (kWh) -
The app records the new battery ID and energy level.
Cost Calculation¶
Once both the old and new battery readings are available, the app calculates the swap cost automatically:
energy_difference = floor(new_energy - old_energy, 2)
net_energy = energy_difference - quota_remaining
cost = net_energy × rate_per_kWh
| Variable | Source |
|---|---|
new_energy |
Read from the new battery's DTA service (this step) |
old_energy |
Read from the old battery's DTA service (Step 2) |
quota_remaining |
Retrieved from the backend (Step 1) |
rate_per_kWh |
Retrieved from the backend (Step 1) |
The energy difference is floored to 2 decimal places before any further calculation. If the customer's quota covers the entire energy difference, the cost is zero and payment will be skipped.
UI Behavior¶
- The scan area provides clear visual guidance for QR placement.
- Once connected via BLE, the new battery ID and energy reading are displayed.
- The energy difference and calculated cost are shown immediately after the reading completes.
- A summary card highlights: new energy, old energy, difference, quota applied, and amount due.
What Gets Recorded¶
| Field | Example |
|---|---|
| New battery ID | BAT-2024-00789 |
| New battery energy | 2.85 kWh |
| Energy difference | 2.47 kWh |
| Quota applied | 0.50 kWh |
| Net cost | CFA 394.40 |
Error Handling¶
- QR code unreadable — retry scan or enter battery ID manually
- BLE connection failed — ensure Bluetooth is enabled and the battery is in range; retry connection
- Energy read timeout — the app retries automatically; if it persists, the attendant can re-scan
Actions¶
- Continue proceeds to Step 4 — Review
- Back returns to Step 2 — Return Old Battery