A Java-based web servlet that serves as a bridge between the mobile controller and the ESP32 hardware. This component ensures that commands are correctly routed and provides a central point for managing the robot car's network configuration.
- Language: Java 8+
- Framework: Java EE Servlet API
- JSON Handler: GSON (Google)
- Deployment: Apache Tomcat / NetBeans
- Network Abstracton: Allows the mobile app to communicate with a fixed server URL (or ngrok) without worrying about the ESP32's local IP changes.
- Security: Adds a layer of control between the external internet and your local IoT hardware.
- Scalability: Easily add logging, authentication, or multi-car support in the future.
- Java JDK 8 or higher
- Apache Tomcat (or any Servlet container)
- NetBeans IDE (Recommended for easy deployment)
- GSON Library (Included in
lib/)
- Open the project in NetBeans.
- Locate
src/java/controller/RobotCar.java. - Update the
ESP32_URLconstant with your ESP32's actual IP address:private static final String ESP32_URL = "http://192.168.x.x/control";
- Right-click the project in NetBeans and select Clean and Build.
- Select Run. This will typically deploy the project to your local Tomcat server.
- The servlet will be available at:
http://localhost:8080/RobotCarControllerBackend/control
Used by the mobile app to send commands.
- Parameters:
cmd(String) - e.g.,F,B,L,R,S. - Response: JSON object indicating success or failure.
{ "status": "success" }
Used to verify that the servlet is running.
- Response: Plain text status message.
- GSON: Used for JSON response generation.
- Java Servlet API: Core web functionality.