A gRPC-based IoT device simulator that demonstrates various patterns of device communication and management.
- Register new devices with unique IDs
- Device type and metadata management
- Status tracking (ONLINE, OFFLINE, MAINTENANCE, ERROR)
- Client-side streaming of sensor data
- Support for different sensor types
- Timestamp and metadata included with readings
- Configurable streaming frequency
- Server-side streaming of device status
- Real-time status updates
- Error and maintenance state notifications
- Health monitoring
- Bidirectional streaming for device control
- Real-time command execution
- Command acknowledgement and response
- Parameter-based command configuration
- Java 17
- gRPC
- Protocol Buffers
- Maven
- Logback for logging
- JUnit for testing
iot-simulator/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/iot/simulator/
│ │ │ ├── server/ # gRPC server implementation
│ │ │ ├── client/ # Simulator client implementation
│ │ │ ├── device/ # Device simulation logic
│ │ │ └── util/ # Utility classes
│ │ └── proto/
│ │ └── iot_service.proto # Service definitions
│ └── test/ # Test cases
└── pom.xml
- Java 17 or later
- Maven 3.6 or later
mvn clean install
mvn exec:java -Dexec.mainClass="com.iot.simulator.server.IoTServer"
mvn exec:java -Dexec.mainClass="com.iot.simulator.client.IoTClient"
RegistrationRequest request = RegistrationRequest.newBuilder()
.setName("Temperature Sensor 1")
.setType("TEMPERATURE")
.build();
RegistrationResponse response = stub.registerDevice(request);
StreamObserver<SensorData> requestObserver = stub.streamSensorData(responseObserver);
requestObserver.onNext(SensorData.newBuilder()
.setDeviceId("device-1")
.setSensorType("TEMPERATURE")
.setValue(22.5)
.setTimestamp(System.currentTimeMillis())
.build());
This project is licensed under the MIT License - see the LICENSE file for details.