tgiot-device-simulator 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tgiot_device_simulator-1.0.0/PKG-INFO +424 -0
- tgiot_device_simulator-1.0.0/README.md +374 -0
- tgiot_device_simulator-1.0.0/pyproject.toml +196 -0
- tgiot_device_simulator-1.0.0/setup.cfg +4 -0
- tgiot_device_simulator-1.0.0/simulator/__init__.py +5 -0
- tgiot_device_simulator-1.0.0/simulator/api/__init__.py +6 -0
- tgiot_device_simulator-1.0.0/simulator/api/device_creation_metadata_api.py +120 -0
- tgiot_device_simulator-1.0.0/simulator/api/firmware_version_api.py +59 -0
- tgiot_device_simulator-1.0.0/simulator/auth/__init__.py +6 -0
- tgiot_device_simulator-1.0.0/simulator/auth/oauth2_client.py +79 -0
- tgiot_device_simulator-1.0.0/simulator/auth/oauth_flow.py +91 -0
- tgiot_device_simulator-1.0.0/simulator/commands/__init__.py +5 -0
- tgiot_device_simulator-1.0.0/simulator/commands/command_handler.py +95 -0
- tgiot_device_simulator-1.0.0/simulator/config/__init__.py +5 -0
- tgiot_device_simulator-1.0.0/simulator/config/config_manager.py +251 -0
- tgiot_device_simulator-1.0.0/simulator/config/schemas.py +100 -0
- tgiot_device_simulator-1.0.0/simulator/config/templates/config.template.json +34 -0
- tgiot_device_simulator-1.0.0/simulator/connectivity/__init__.py +5 -0
- tgiot_device_simulator-1.0.0/simulator/connectivity/iot_hub_client.py +201 -0
- tgiot_device_simulator-1.0.0/simulator/device_setup/__init__.py +7 -0
- tgiot_device_simulator-1.0.0/simulator/device_setup/configuration_ui.py +136 -0
- tgiot_device_simulator-1.0.0/simulator/device_setup/device_selector.py +78 -0
- tgiot_device_simulator-1.0.0/simulator/device_setup/setup_coordinator.py +99 -0
- tgiot_device_simulator-1.0.0/simulator/main.py +309 -0
- tgiot_device_simulator-1.0.0/simulator/provisioning/__init__.py +5 -0
- tgiot_device_simulator-1.0.0/simulator/provisioning/device_provisioner.py +210 -0
- tgiot_device_simulator-1.0.0/simulator/telemetry/__init__.py +19 -0
- tgiot_device_simulator-1.0.0/simulator/telemetry/message_generators/__init__.py +13 -0
- tgiot_device_simulator-1.0.0/simulator/telemetry/message_generators/alerts_generator.py +68 -0
- tgiot_device_simulator-1.0.0/simulator/telemetry/message_generators/base_message_generator.py +17 -0
- tgiot_device_simulator-1.0.0/simulator/telemetry/message_generators/fw_debug_generator.py +81 -0
- tgiot_device_simulator-1.0.0/simulator/telemetry/message_generators/measurement_generator.py +64 -0
- tgiot_device_simulator-1.0.0/simulator/telemetry/message_generators/state_generator.py +84 -0
- tgiot_device_simulator-1.0.0/simulator/telemetry/sender.py +118 -0
- tgiot_device_simulator-1.0.0/simulator/telemetry/telemetry_generator.py +58 -0
- tgiot_device_simulator-1.0.0/simulator/twin/__init__.py +5 -0
- tgiot_device_simulator-1.0.0/simulator/twin/default_config_applier.py +78 -0
- tgiot_device_simulator-1.0.0/simulator/twin/firmware_reporter.py +54 -0
- tgiot_device_simulator-1.0.0/simulator/twin/reported_store.py +24 -0
- tgiot_device_simulator-1.0.0/simulator/twin/twin_manager.py +100 -0
- tgiot_device_simulator-1.0.0/simulator/utils/__init__.py +5 -0
- tgiot_device_simulator-1.0.0/simulator/utils/logger.py +27 -0
- tgiot_device_simulator-1.0.0/simulator/utils/schema/__init__.py +11 -0
- tgiot_device_simulator-1.0.0/simulator/utils/schema/schema_generator.py +111 -0
- tgiot_device_simulator-1.0.0/simulator/utils/schema/schema_reference_resolver.py +54 -0
- tgiot_device_simulator-1.0.0/simulator/utils/schema/type_mapper.py +129 -0
- tgiot_device_simulator-1.0.0/simulator/utils/version_parser.py +31 -0
- tgiot_device_simulator-1.0.0/tgiot_device_simulator.egg-info/PKG-INFO +424 -0
- tgiot_device_simulator-1.0.0/tgiot_device_simulator.egg-info/SOURCES.txt +51 -0
- tgiot_device_simulator-1.0.0/tgiot_device_simulator.egg-info/dependency_links.txt +1 -0
- tgiot_device_simulator-1.0.0/tgiot_device_simulator.egg-info/entry_points.txt +2 -0
- tgiot_device_simulator-1.0.0/tgiot_device_simulator.egg-info/requires.txt +28 -0
- tgiot_device_simulator-1.0.0/tgiot_device_simulator.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tgiot-device-simulator
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A comprehensive IoT device simulator for Azure IoT Hub and IoT Platform servers
|
|
5
|
+
Author-email: IoT Platform Team <iot-platform@example.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/your-org/iot-device-simulator
|
|
8
|
+
Project-URL: Documentation, https://iot-device-simulator.readthedocs.io
|
|
9
|
+
Project-URL: Repository, https://github.com/your-org/iot-device-simulator.git
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/your-org/iot-device-simulator/issues
|
|
11
|
+
Keywords: iot,azure,simulator,device,telemetry
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
Requires-Dist: azure-iot-device>=2.12.0
|
|
26
|
+
Requires-Dist: aiohttp>=3.10.0
|
|
27
|
+
Requires-Dist: rich>=13.6.0
|
|
28
|
+
Requires-Dist: pydantic>=2.12.0
|
|
29
|
+
Requires-Dist: authlib>=1.2.0
|
|
30
|
+
Requires-Dist: faker>=26.0.0
|
|
31
|
+
Requires-Dist: PyJWT>=2.8.0
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
36
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
37
|
+
Requires-Dist: mypy>=1.6.0; extra == "dev"
|
|
38
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
39
|
+
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
40
|
+
Requires-Dist: pre-commit>=3.0.0; extra == "dev"
|
|
41
|
+
Provides-Extra: test
|
|
42
|
+
Requires-Dist: pytest>=7.4.0; extra == "test"
|
|
43
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "test"
|
|
44
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "test"
|
|
45
|
+
Provides-Extra: lint
|
|
46
|
+
Requires-Dist: ruff>=0.1.0; extra == "lint"
|
|
47
|
+
Requires-Dist: mypy>=1.6.0; extra == "lint"
|
|
48
|
+
Requires-Dist: black>=23.0.0; extra == "lint"
|
|
49
|
+
Requires-Dist: isort>=5.12.0; extra == "lint"
|
|
50
|
+
|
|
51
|
+
# Device Simulator
|
|
52
|
+
|
|
53
|
+
A comprehensive IoT device simulator that connects to Azure IoT Hub and IoT Platform servers. This simulator can provision devices, monitor device twins, send telemetry data, and handle commands according to device type schemas.
|
|
54
|
+
|
|
55
|
+
## Features
|
|
56
|
+
|
|
57
|
+
### 🔧 Device Configuration
|
|
58
|
+
|
|
59
|
+
- **Local Configuration**: Load device configuration from local files if already configured
|
|
60
|
+
- **Interactive CLI Setup**: Command-line interface for device configuration and management
|
|
61
|
+
- **OAuth2 Authentication**: Secure authentication with IoT Platform server
|
|
62
|
+
- **Device Provisioning**: Automatic device creation in IoT Hub
|
|
63
|
+
- **Configuration Management**: Get and set device configurations through IoT Hub
|
|
64
|
+
- **Schema Management**: Download and cache device type schemas locally
|
|
65
|
+
|
|
66
|
+
### 🔌 Connectivity
|
|
67
|
+
|
|
68
|
+
- **Azure IoT Hub Integration**: Connect to IoT Hub using device connection strings
|
|
69
|
+
- **Gateway Support**: Connect through configured gateways
|
|
70
|
+
- **SAS Token Authentication**: Secure device authentication
|
|
71
|
+
|
|
72
|
+
### 📊 Device Twin Monitoring
|
|
73
|
+
|
|
74
|
+
- **Desired Properties**: Listen for twin configuration changes from IoT Hub
|
|
75
|
+
- **Reported Properties**: Update device status and configurations to IoT Hub only if reported section of the device is empty
|
|
76
|
+
- **Default Configurations**: Apply schema-based default values and sync with IoT Hub
|
|
77
|
+
|
|
78
|
+
### 📡 Telemetry (D2C Messages)
|
|
79
|
+
|
|
80
|
+
- **Message Types**:
|
|
81
|
+
- 🚨 **Events**: Critical notifications and warnings
|
|
82
|
+
- 📈 **Measurements**: Sensor readings and metrics
|
|
83
|
+
- ⚡ **Status**: Device health and operational status
|
|
84
|
+
- 🔧 **FW Debug**: Firmware debugging and diagnostic information
|
|
85
|
+
- **Scheduled Transmission**: Configurable intervals for each message type, on each trigger all the messages of this type will be sent (all events/meausrement/etc)
|
|
86
|
+
- **Schema Compliance**: Values generated according to device type schema
|
|
87
|
+
- **Data Continuity**: Coordinated values based on previous messages
|
|
88
|
+
|
|
89
|
+
### 🎯 Command Handling (C2D)
|
|
90
|
+
|
|
91
|
+
- **Command Reception**: Process commands from IoT Platform
|
|
92
|
+
- **Schema Validation**: Verify commands against device type schema
|
|
93
|
+
- **Response Generation**: Automatic success responses when required
|
|
94
|
+
|
|
95
|
+
## Prerequisites
|
|
96
|
+
|
|
97
|
+
- Python 3.8 or higher
|
|
98
|
+
- pip package manager
|
|
99
|
+
- Virtual environment
|
|
100
|
+
- Azure IoT Hub instance
|
|
101
|
+
- IoT Platform server with OAuth2 support
|
|
102
|
+
- Device type schemas in IoT Platform server
|
|
103
|
+
|
|
104
|
+
## Installation
|
|
105
|
+
|
|
106
|
+
### Quick Setup (Recommended)
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# Clone the repository
|
|
110
|
+
git clone <repository-url>
|
|
111
|
+
cd iot-device-simulator
|
|
112
|
+
|
|
113
|
+
# Run setup script
|
|
114
|
+
# Windows:
|
|
115
|
+
setup.bat
|
|
116
|
+
# Linux/macOS:
|
|
117
|
+
bash setup.sh
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The setup script will:
|
|
121
|
+
1. Create a virtual environment
|
|
122
|
+
2. Install the package in development mode with all dependencies
|
|
123
|
+
3. Copy configuration template
|
|
124
|
+
4. Set up logging directory
|
|
125
|
+
|
|
126
|
+
### Manual Installation
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Create virtual environment
|
|
130
|
+
python -m venv venv
|
|
131
|
+
|
|
132
|
+
# Activate virtual environment
|
|
133
|
+
# Windows:
|
|
134
|
+
venv\Scripts\activate
|
|
135
|
+
# Linux/macOS:
|
|
136
|
+
source venv/bin/activate
|
|
137
|
+
|
|
138
|
+
# Install package in development mode with all dependencies
|
|
139
|
+
pip install -e ".[dev]"
|
|
140
|
+
|
|
141
|
+
# Copy configuration template
|
|
142
|
+
copy config\config.template.json config\config.json # Windows
|
|
143
|
+
# cp config/config.template.json config/config.json # Linux/macOS
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Configuration
|
|
147
|
+
|
|
148
|
+
### Local Device Configuration
|
|
149
|
+
|
|
150
|
+
If you have existing device configuration, create these files:
|
|
151
|
+
|
|
152
|
+
**`config/device-config.json`**
|
|
153
|
+
|
|
154
|
+
```json
|
|
155
|
+
{
|
|
156
|
+
"deviceId": "your-device-id",
|
|
157
|
+
"gatewayId": "your-gateway-id",
|
|
158
|
+
"deviceType": "your-device-type",
|
|
159
|
+
"lastUpdated": "2025-08-24T10:30:00Z"
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**`schemas/device-type-schema.json`**
|
|
164
|
+
|
|
165
|
+
### Application Configuration
|
|
166
|
+
|
|
167
|
+
**`config/config.json`**
|
|
168
|
+
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"iotPlatform": {
|
|
172
|
+
"baseUrl": "https://your-iot-platform.com",
|
|
173
|
+
"oauth2": {
|
|
174
|
+
"clientId": "your-client-id",
|
|
175
|
+
"authorization_endpoint": "https://your-authority.your-region.cloudapp.azure.com/application/o/authorize/",
|
|
176
|
+
"token_endpoint": "https://your-authority.your-region.cloudapp.azure.com/application/o/token/"
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
"messaging": {
|
|
180
|
+
"intervals": {
|
|
181
|
+
"measurement": 60,
|
|
182
|
+
"sw_logs": 180,
|
|
183
|
+
"state": 120,
|
|
184
|
+
"events": 300
|
|
185
|
+
},
|
|
186
|
+
"enabled": {
|
|
187
|
+
"measurement": true,
|
|
188
|
+
"sw_logs": false,
|
|
189
|
+
"state": true,
|
|
190
|
+
"events": true
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Message Type Configuration
|
|
197
|
+
|
|
198
|
+
The `messaging` configuration has two sections:
|
|
199
|
+
|
|
200
|
+
- **`intervals`**: How often each message type is sent (in seconds)
|
|
201
|
+
- **`enabled`**: Whether each message type should be sent at all
|
|
202
|
+
|
|
203
|
+
**Message Types:**
|
|
204
|
+
|
|
205
|
+
- **measurement**: Sensor readings and metrics
|
|
206
|
+
- 🔧 **sw_logs**: Software logs and debugging information
|
|
207
|
+
- 🔄 **state**: Device state and operational status
|
|
208
|
+
- ⚠️ **events**: Event notifications and alerts
|
|
209
|
+
|
|
210
|
+
**Default Settings:**
|
|
211
|
+
|
|
212
|
+
- All message types are **enabled** by default except `sw_logs` (disabled)
|
|
213
|
+
- You can disable any message type by setting its `enabled` value to `false`
|
|
214
|
+
- Disabled message types will not generate telemetry tasks, saving resources
|
|
215
|
+
|
|
216
|
+
## Usage
|
|
217
|
+
|
|
218
|
+
### 1. Start the Simulator
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
# Activate virtual environment first (if not already active)
|
|
222
|
+
# Windows:
|
|
223
|
+
venv\Scripts\activate
|
|
224
|
+
# Linux/macOS:
|
|
225
|
+
source venv/bin/activate
|
|
226
|
+
|
|
227
|
+
# Start the simulator (modern way)
|
|
228
|
+
iot-simulator
|
|
229
|
+
|
|
230
|
+
# Alternative way
|
|
231
|
+
python main.py
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### 2. Device Configuration Flow
|
|
235
|
+
|
|
236
|
+
#### Option A: Pre-configured Device
|
|
237
|
+
|
|
238
|
+
If `config/device-config.json` and corresponding schema exist:
|
|
239
|
+
|
|
240
|
+
- ✅ Device automatically starts tracking
|
|
241
|
+
- 🔗 Connects to IoT Hub using stored connection string
|
|
242
|
+
- 📊 Begins twin monitoring and telemetry transmission
|
|
243
|
+
|
|
244
|
+
#### Option B: New Device Setup
|
|
245
|
+
|
|
246
|
+
If no local configuration exists:
|
|
247
|
+
|
|
248
|
+
1. **🌐 CLI-based Authorization**
|
|
249
|
+
|
|
250
|
+
- Follow OAuth2 login prompts in terminal
|
|
251
|
+
- Authenticate with IoT Platform credentials via browser
|
|
252
|
+
- Grant device management permissions
|
|
253
|
+
|
|
254
|
+
2. **⚙️ Device Configuration via CLI**
|
|
255
|
+
|
|
256
|
+
- **Fill Device Details**:
|
|
257
|
+
|
|
258
|
+
- Enter Device ID through command prompts
|
|
259
|
+
- Select from available Managed Groups (displayed in terminal)
|
|
260
|
+
- Choose Device Type from server list (interactive menu)
|
|
261
|
+
- Provision new device in IoT Hub
|
|
262
|
+
- Set initial configurations in IoT Hub device twin
|
|
263
|
+
|
|
264
|
+
- **OR Choose Existing Device**:
|
|
265
|
+
- Select from available devices list displayed in terminal
|
|
266
|
+
- Get device configurations from IoT Hub device twin
|
|
267
|
+
- Get selected device data from server: id, gateway id, managed-group, type.
|
|
268
|
+
|
|
269
|
+
3. **💾 Schema Download**
|
|
270
|
+
- Device type schema downloaded from IoT Platform
|
|
271
|
+
- Configuration saved locally for future use
|
|
272
|
+
|
|
273
|
+
### 3. Runtime Operations
|
|
274
|
+
|
|
275
|
+
#### Twin Configuration Monitoring
|
|
276
|
+
|
|
277
|
+
```
|
|
278
|
+
[TWIN] Listening for desired property changes from IoT Hub...
|
|
279
|
+
[TWIN] Applied default configurations from schema to IoT Hub
|
|
280
|
+
[TWIN] Desired property updated from IoT Hub: telemetryInterval = 45
|
|
281
|
+
[TWIN] Reported property set to IoT Hub: telemetryInterval = 45
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
#### Telemetry Transmission
|
|
285
|
+
|
|
286
|
+
```
|
|
287
|
+
[D2C] Sending measurement: {"temperature": 23.5, "humidity": 65.2}
|
|
288
|
+
[D2C] Sending status: {"batteryLevel": 85, "signalStrength": -67}
|
|
289
|
+
[D2C] Sending alert: {"type": "highTemperature", "value": 78.2}
|
|
290
|
+
[D2C] Sending sw_logs: {"firmware_version": "1.2.3", "memory_usage": 65, "cpu_temp": 42}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
#### Command Handling
|
|
294
|
+
|
|
295
|
+
```
|
|
296
|
+
[C2D] Received command: reboot
|
|
297
|
+
[C2D] Command validated against schema
|
|
298
|
+
[C2D] Sending response: {"status": "success", "timestamp": "2025-08-24T10:30:00Z"}
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
## Project Structure
|
|
302
|
+
|
|
303
|
+
```
|
|
304
|
+
device-simulator/
|
|
305
|
+
├── src/
|
|
306
|
+
│ ├── auth/ # OAuth2 authentication
|
|
307
|
+
│ ├── config/ # Configuration management
|
|
308
|
+
│ ├── connectivity/ # IoT Hub connection
|
|
309
|
+
│ ├── twin/ # Device Twin handling
|
|
310
|
+
│ ├── telemetry/ # D2C message generation
|
|
311
|
+
│ ├── commands/ # C2D command processing
|
|
312
|
+
│ ├── cli/ # Command-line interface for setup
|
|
313
|
+
│ └── utils/ # Shared utilities
|
|
314
|
+
├── config/
|
|
315
|
+
│ ├── config.json # Application configuration
|
|
316
|
+
│ ├── device-config.json # Device-specific config
|
|
317
|
+
│ └── config.template.json # Configuration template
|
|
318
|
+
├── schemas/ # Device type schemas
|
|
319
|
+
├── logs/ # Application logs
|
|
320
|
+
├── requirements.txt # Python dependencies
|
|
321
|
+
├── main.py # Application entry point
|
|
322
|
+
└── README.md
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
## Logging
|
|
326
|
+
|
|
327
|
+
The simulator provides detailed logging for all operations:
|
|
328
|
+
|
|
329
|
+
- **🔐 Authentication**: OAuth2 flow, token management
|
|
330
|
+
- **⚙️ Configuration**: Device setup, schema downloads
|
|
331
|
+
- **🔗 Connectivity**: IoT Hub connections, reconnection attempts
|
|
332
|
+
- **👥 Twin Operations**: Desired/reported property changes
|
|
333
|
+
- **📡 Telemetry**: Message generation and transmission
|
|
334
|
+
- **🎯 Commands**: Command reception and response generation
|
|
335
|
+
|
|
336
|
+
Logs are written to both console and `logs/simulator.log` file.
|
|
337
|
+
|
|
338
|
+
## Error Handling
|
|
339
|
+
|
|
340
|
+
### Common Issues
|
|
341
|
+
|
|
342
|
+
**Authentication Failures**
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
# Clear stored tokens
|
|
346
|
+
del config\auth-tokens.json # Windows
|
|
347
|
+
# rm config/auth-tokens.json # Linux/macOS
|
|
348
|
+
python main.py
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
**Connection Issues**
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
# Verify connection string
|
|
355
|
+
python -m src.utils.verify_connection
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
**Schema Validation Errors**
|
|
359
|
+
|
|
360
|
+
```bash
|
|
361
|
+
# Re-download schema
|
|
362
|
+
python -m src.config.refresh_schema
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
## Development
|
|
366
|
+
|
|
367
|
+
### Development Setup
|
|
368
|
+
|
|
369
|
+
The project uses modern Python packaging with `pyproject.toml`. Development dependencies are automatically installed with the `[dev]` extra.
|
|
370
|
+
|
|
371
|
+
```bash
|
|
372
|
+
# Install in development mode with all tools
|
|
373
|
+
pip install -e ".[dev]"
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### Available Development Commands
|
|
377
|
+
|
|
378
|
+
```bash
|
|
379
|
+
# Code formatting
|
|
380
|
+
black . # Format all Python files
|
|
381
|
+
isort . # Sort imports
|
|
382
|
+
|
|
383
|
+
# Linting
|
|
384
|
+
ruff check . # Fast Python linter
|
|
385
|
+
mypy . # Type checking
|
|
386
|
+
|
|
387
|
+
# Testing
|
|
388
|
+
pytest # Run all tests
|
|
389
|
+
pytest tests/ -v # Verbose test output
|
|
390
|
+
pytest --cov=simulator # Run tests with coverage
|
|
391
|
+
|
|
392
|
+
# Build and install
|
|
393
|
+
pip install -e . # Install package locally
|
|
394
|
+
pip install -e ".[dev]" # Install with dev dependencies
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### Project Structure
|
|
398
|
+
|
|
399
|
+
```
|
|
400
|
+
├── pyproject.toml # Modern Python packaging configuration
|
|
401
|
+
├── main.py # Legacy entry point (wrapper)
|
|
402
|
+
├── simulator/ # Main package
|
|
403
|
+
│ ├── main.py # Primary application entry point
|
|
404
|
+
│ ├── auth/ # OAuth2 authentication
|
|
405
|
+
│ ├── config/ # Configuration management
|
|
406
|
+
│ ├── connectivity/ # IoT Hub client
|
|
407
|
+
│ ├── device_setup/ # Device configuration
|
|
408
|
+
│ ├── provisioning/ # API-based provisioning
|
|
409
|
+
│ ├── telemetry/ # Telemetry sender
|
|
410
|
+
│ ├── twin/ # Device twin manager
|
|
411
|
+
│ └── utils/ # Utilities and logging
|
|
412
|
+
├── config/ # Configuration files
|
|
413
|
+
├── tests/ # Test suite
|
|
414
|
+
└── logs/ # Application logs
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
**Entry Points:**
|
|
418
|
+
- `iot-simulator` - Modern console command (recommended)
|
|
419
|
+
- `python main.py` - Legacy compatibility wrapper
|
|
420
|
+
- `python -m simulator.main` - Direct module execution
|
|
421
|
+
|
|
422
|
+
---
|
|
423
|
+
|
|
424
|
+
**Device Simulator** - Bridging the gap between IoT devices and cloud platforms with intelligent simulation and monitoring capabilities.
|