Project for CS/ECE4501 - WiOT Final Project
RentScan is a wireless rental management system that uses NFC technology to track items and manage rentals. The system consists of two main components: a main device (NFC reader with BLE peripheral) and a gateway device (BLE central) that processes rental information.
Users scan an NFC tag attached to an item using the nRF52840DK's NFC reader to initiate or manage a rental. The system uses Bluetooth Low Energy (BLE) to communicate rental status updates wirelessly to the gateway device, which maintains a rental database and simulates backend connectivity.
The RentScan system enables a simple, contactless rental process:
- The main device reads NFC tags attached to rental items
- The gateway device manages the rental database and communicates with a backend
- When a tag is scanned, the rental status is toggled (available → rented, or rented → returned)
-
Main Device: nRF52840 with NFC reading capabilities
- Reads NTAG216 NFC tags
- Processes tag data
- Communicates with gateway via BLE
-
Gateway Device: nRF52840 with BLE central capabilities
- Maintains rental database
- Processes tag data from main device
- Simulates backend connectivity
- Provides command-line interface for management
- NFC Tag Interaction: Utilizes the nRF52840DK's built-in NFC capabilities to read item information from tags.
- BLE Communication: Sends rental status updates (e.g., Tag ID scanned, start/end time, user info) wirelessly via BLE GATT connection to a gateway.
- Gateway Service: Manages rental database with start/end functionality and status tracking.
- Backend Simulation: Simulates connecting to a backend service with connection state changes and message queuing.
- Rental Expiration: Logic to determine when a rental expires based on timestamps, with automatic expiration handling.
The system currently provides the following functionality:
- NFC tag reading from the main device (NTAG216 tags)
- BLE connectivity between devices
- Rental management (start/end rentals, check rental status)
- Simulated backend connection with offline queuing
- Command-line interface for manual control
- 2 x nRF52840DK boards: One acting as the main NFC reader/BLE peripheral, the other acting as the BLE central/gateway.
- NFC Antenna: Attached to the primary nRF52840DK board.
- NFC Tags: NTAG216 tags (even read-only tags work with the system).
- USB Cables: For programming, power, and connecting devices to PC.
- IDE: Visual Studio Code with nRF Connect Extension.
- SDK: nRF Connect SDK v2.5.1
- OS: Zephyr RTOS.
-
BLE GATT Subscription: The gateway device sometimes fails to properly subscribe to BLE notifications from the main device. This causes a "Device is not subscribed to characteristic" error when trying to send tag data.
-
BLE Connection Stability: Occasionally, the system encounters "Found valid connection in disconnected state" errors that require device reset.
-
Manual Command Issue: Some shell commands like
manual_sub
andshow_handles
are not recognized properly due to build configuration issues.
For demonstration purposes, the system can be operated with this workflow:
- The main device successfully reads NFC tags and displays the tag ID
- The gateway device can manually start/end rentals using the CLI:
rentscan rental start <tag_id> <user_id> <duration> rentscan rental end <tag_id>
See DEMO_GUIDE.md for detailed demonstration instructions.
NFC-Rental-System/
├── RentScan/
│ ├── common/ # Common code shared between devices
│ │ └── include/ # Common header files
│ │ └── rentscan_protocol.h # Communication protocol definition
│ │
│ ├── main_device/ # Main device (NFC reader + BLE peripheral)
│ │ ├── include/ # Header files for main device
│ │ │ └── main_device_config.h # Configuration parameters
│ │ └── src/ # Source files for main device
│ │ ├── main.c # Main application
│ │ ├── nfc_handler.h/c # NFC handling functionality
│ │ ├── ble_service.h/c # BLE peripheral service
│ │ └── rental_manager.h/c # Rental state management
│ │
│ └── gateway_device/ # Gateway device (BLE central + backend connector)
│ ├── include/ # Header files for gateway device
│ │ └── gateway_config.h # Configuration parameters
│ └── src/ # Source files for gateway device
│ ├── main.c # Main application
│ ├── ble_central.h/c # BLE central functionality
│ └── gateway_service.h/c # Backend communication service
│
├── samples_reference/ # Keep original samples for reference
│ ├── tag_reader/
│ ├── peripheral_uart/
│ └── central_uart/
├── docs/
├── .gitignore
└── README.md
cd RentScan
west build -p -b nrf52840dk_nrf52840 main_device
west flash
cd RentScan
west build -p -b nrf52840dk_nrf52840 gateway_device
west flash
rentscan status # Show current status
rentscan scan start # Start scanning for devices
rentscan scan stop # Stop scanning
rentscan reset # Reset the BLE stack
rentscan rental start <id> <user> <duration> # Start a rental
rentscan rental end <id> # End a rental
rentscan rental list # List active rentals
-
Robust BLE Implementation: Implement proper retry mechanisms for GATT discovery and handle connection edge cases more gracefully.
-
Enhanced Security: Add encryption for NFC and BLE communication to protect rental data.
-
User Authentication: Implement user identification through separate NFC cards or mobile app integration.
-
Actual Backend Integration: Replace the simulated backend with a real cloud database service.
-
Battery Optimization: Implement power management features to extend battery life for portable deployment.
-
Mobile Application: Develop a companion mobile app to manage rentals and view rental history.
In a full implementation, the RentScan system would work as follows:
When a customer wants to rent an item:
- They bring the item to a rental station
- The item's NFC tag is scanned by the main device
- The main device reads the unique tag ID and sends it to the gateway
- The gateway checks if the item is available and starts a rental
- A receipt could be printed or sent electronically
- The item status is updated in the backend database
When the item is returned:
- The item's tag is scanned again
- The main device reads the tag ID and sends it to the gateway
- The gateway recognizes the item is already rented and ends the rental
- Rental duration and any fees are calculated
- The item becomes available for the next customer
The system could be expanded to multiple stations, all connected to a central backend, enabling items to be rented from one location and returned to another.
- Marvin Rivera | ariveram128
- Raul Cancho | RaulCancho
- Salina Tran | dinosaur-sal
- Sami Kang | skang0812