GT TURBO is an iOS application designed for Near-Infrared (NIR) Spectrography measurements using Bluetooth Low Energy (BLE) communication. The app interfaces with a custom GT TURBO device that contains an AS7265X spectral sensor, enabling real-time NIR measurements and data collection.
- Automatic BLE device discovery and connection
- Real-time battery level monitoring
- Independent start/stop measurement controls
- Automatic data collection and storage
- Debug console for monitoring device communication
- Automatic file upload to server after measurement
- Background BLE operation support
- Modern SwiftUI interface with intuitive controls
-
iOS Application:
- SwiftUI + Combine
- SwiftData
- CoreBluetooth
- URLSession
- iOS 14.0+
-
Server Infrastructure:
- Python FastAPI backend
- Raw file storage system
- Nginx reverse proxy
- ngrok for secure tunneling
┌─────────────────┐ BLE ┌──────────────┐
│ GT TURBO │◄──────────► │ iOS App │
│ (AS7265X) │ Protocol │ (Swift/UIKit)│
└─────────────────┘ └──────┬───────┘
│
│ HTTPS
▼
┌────────────────┐
│ ngrok Tunnel │
└────────┬───────┘
│
▼
┌───────────────────────────────────────────────────┐
│ Server Stack │
│ ┌─────────────┐ ┌─────────────┐ │
│ │ Nginx │ ► │ FastAPI │ │
│ │(Reverse Proxy) │ Backend │ │
│ └─────────────┘ └──────┬──────┘ │
│ │ │
│ ┌────────────┴──────────┐ │
│ │ Raw File Storage │ │
│ │ │ │
│ └─────────────────────┘ │
└───────────────────────────────────────────────────┘
The server is built using FastAPI, a modern Python web framework, with a single endpoint:
@app.post("/upload-file/")
async def upload_file(file: UploadFile):
# Store raw measurement file
return {"status": "success"}
- Direct file system storage for measurement data
- Organized directory structure by date and device ID
- Raw data preservation for maximum flexibility
- Simple file naming convention for easy retrieval
- iOS app collects NIR data
- After 45-second delay, initiates file upload
- File transmitted via HTTPS through ngrok tunnel
- Nginx routes request to FastAPI backend
- FastAPI stores raw measurement file
- Response sent back to iOS app
- HTTPS encryption for all communications
- ngrok secure tunneling
- Request validation and sanitization
- File type verification
- Size limits on uploads
- Rate limiting
- Python 3.9+
- ngrok account
- Domain name (optional)
- Clone server repository
- Configure environment variables:
cp .env.example .env # Edit .env with your settings
- Install dependencies:
pip install -r requirements.txt
- Start FastAPI server:
uvicorn main:app --host 0.0.0.0 --port 8000
- Start ngrok tunnel:
ngrok http 8000
- Update iOS app with new server URL
- Server health checks
- Request logging
- Error tracking
- Storage space monitoring
- File integrity verification
The application follows a clean architecture pattern with clear separation of concerns:
- Implements CoreBluetooth protocols for device communication
- Handles device discovery, connection, and data transfer
- Manages BLE services and characteristics
- Based on Apple's CoreBluetooth framework and inspired by iOS-nRF-Toolbox
- Manages measurement data persistence
- Handles file creation and management
- Implements server upload functionality
- Uses SwiftData for local storage
- Modern SwiftUI implementation
- Reactive updates using Combine
- Clean and intuitive user interface
- Real-time status updates
- Services:
- Battery Service (0x180F)
- Write Service (0x1818)
- Read Service (0x1819)
- Characteristics:
- Battery Level (0x2A19)
- Write Characteristic (0x2A3D)
- Notify Characteristic (0x2A3E)
-
Start Command:
- Sends current timestamp to device
- Creates new measurement file
- Begins data collection
-
Data Processing:
- Receives NIR spectral data
- Stores raw data in measurement file
- Updates UI with collection status
-
Stop Command:
- Sends stop signal to device
- Finalizes measurement file
- Initiates upload timer
- Creates unique files for each measurement session
- Implements 45-second delay before upload
- Automatic server upload with retry mechanism
- Local storage backup
- Xcode 15.0+
- iOS 14.0+
- GT TURBO device
- Active internet connection for file upload
- Clone the repository
- Open
gtturbo.xcodeproj
in Xcode - Configure signing certificate
- Build and run on target device
- Enable Bluetooth on iOS device
- Power on GT TURBO device
- App will automatically discover and connect
- Verify connection status in app
- Connect to GT TURBO device
- Wait for stable connection
- Press "Start Measurement"
- Monitor data collection in debug console
- Press "Stop Measurement"
- Wait for data processing
- File will automatically upload after 45 seconds
- Check upload status in recent measurements
- Apple CoreBluetooth Documentation
- iOS-nRF-Toolbox
- Apple SwiftUI Documentation
- Apple Human Interface Guidelines
Contributions are welcome! Please read our contributing guidelines and submit pull requests for any enhancements.
This project is proprietary and confidential. All rights reserved.
For support and questions, please contact the development team.