# Parent App Setup Guide

## Overview
The Parent App allows parents to track their child's school bus in real-time using their phone number.

## Features
- **Phone-based Login**: Parents login using the phone number registered in the system
- **Student Selection**: If a parent has multiple children, they can select which one to track
- **Live Bus Tracking**: Real-time bus location updates every 5 seconds
- **Bus Information**: View bus number, driver info, battery level, and last update time

## Setup Instructions

### 1. Backend API (Already Created)
The following API endpoints are available:
- `api/parent_login.php` - Parent authentication
- `api/get_bus_location.php` - Get live bus location

### 2. B4A Project Setup
1. Open B4A IDE
2. Create a new project called "BusTrack Parent"
3. Add the following files from `bustrack/parent_app/`:
   - `Main.bas` (Login and Student Selection)
   - `MapActivity.bas` (Live Tracking Map)
   - `APIModule.bas` (Networking)
   - `Starter.bas` (Service)

4. Required Libraries:
   - `HTTPUtils2` (OkHttpUtils2)
   - `JSON`
   - `Phone`

5. Update `APIModule.bas`:
   - Change `ServerURL` to your server IP (e.g., `http://192.168.1.5/bustrack/api`)

### 3. Testing the App
1. **Add a Student** in the Admin Panel with a parent phone number
2. **Assign a Bus** to that student
3. **Start the Driver App** to send GPS data
4. **Open Parent App** and login with the parent phone number
5. **Select the student** and view live bus location

## App Flow
```
Login (Phone) → Student Selection → Live Map View
```

## Notes
- The map view currently shows coordinates as text. For production, integrate Google Maps or OSMDroid library.
- Push notifications can be added using Firebase Cloud Messaging (FCM).
- ETA calculation can be implemented using Google Distance Matrix API.
