tgiot-device-simulator


Nametgiot-device-simulator JSON
Version 1.0.0.5 PyPI version JSON
download
home_pageNone
SummaryA comprehensive IoT device simulator for Azure IoT Hub and IoT Platform servers
upload_time2025-11-04 12:44:40
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords iot azure simulator device telemetry
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Device Simulator

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.

## Features

### 🔧 Device Configuration

- **Local Configuration**: Load device configuration from local files if already configured
- **Interactive CLI Setup**: Command-line interface for device configuration and management
- **OAuth2 Authentication**: Secure authentication with IoT Platform server
- **Device Provisioning**: Automatic device creation in IoT Hub
- **Configuration Management**: Get and set device configurations through IoT Hub
- **Schema Management**: Download and cache device type schemas locally

### 🔌 Connectivity

- **Azure IoT Hub Integration**: Connect to IoT Hub using device connection strings
- **Gateway Support**: Connect through configured gateways
- **SAS Token Authentication**: Secure device authentication

### 📊 Device Twin Monitoring

- **Desired Properties**: Listen for twin configuration changes from IoT Hub
- **Reported Properties**: Update device status and configurations to IoT Hub only if reported section of the device is empty
- **Default Configurations**: Apply schema-based default values and sync with IoT Hub

### 📡 Telemetry (D2C Messages)

- **Message Types**:
  - 🚨 **Events**: Critical notifications and warnings
  - 📈 **Measurements**: Sensor readings and metrics
  - ⚡ **Status**: Device health and operational status
  - 🔧 **FW Debug**: Firmware debugging and diagnostic information
- **Scheduled Transmission**: Configurable intervals for each message type, on each trigger all the messages of this type will be sent (all events/meausrement/etc)
- **Schema Compliance**: Values generated according to device type schema
- **Data Continuity**: Coordinated values based on previous messages

### 🎯 Command Handling (C2D)

- **Command Reception**: Process commands from IoT Platform
- **Schema Validation**: Verify commands against device type schema
- **Response Generation**: Automatic success responses when required

## Prerequisites

- Python 3.9 or higher (supports Python 3.9-3.13)
- pip package manager
- Virtual environment
- Azure IoT Hub instance
- IoT Platform server with OAuth2 support
- Device type schemas in IoT Platform server

## Installation

### Quick Setup (Recommended)

```bash
# Clone the repository
git clone <repository-url>
cd tandem-platform-simulator

# Run setup script
# Windows:
setup.bat
# Linux/macOS:
bash setup.sh
```

The setup script will:

1. Create a virtual environment
2. Install the package in development mode with all dependencies
3. Copy configuration template
4. Set up logging directory

### Manual Installation

```bash
# Create virtual environment
python -m venv venv

# Activate virtual environment
# Windows:
venv\Scripts\activate
# Linux/macOS:
source venv/bin/activate

# Install package in development mode with all dependencies
pip install -e ".[dev]"

# Copy configuration template
copy simulator\config\templates\config.template.json config\config.json  # Windows
# cp simulator/config/templates/config.template.json config/config.json  # Linux/macOS
```

## Configuration

### Local Device Configuration

If you have existing device configuration, create these files:

**`config/device-config.json`**

```json
{
  "deviceId": "your-device-id",
  "gatewayId": "your-gateway-id",
  "deviceType": "your-device-type",
  "lastUpdated": "2025-08-24T10:30:00Z"
}
```

**`schemas/device-type-schema.json`**

### Application Configuration

**`config/config.json`**

```json
{
  "iotPlatform": {
    "baseUrl": "https://your-iot-platform.com/api",
    "oauth2": {
      "clientId": "your-client-id",
      "authorization_endpoint": "https://your-authority.your-region.cloudapp.azure.com/application/o/authorize/",
      "token_endpoint": "https://your-authority.your-region.cloudapp.azure.com/application/o/token/"
    }
  },
  "provisioner": {
    "baseUrl": "https://your-provisioner-app.azurewebsites.net"
  },
  "iotHub": {
    "hostName": "your-iot-hub-name.azure-devices.net"
  },
  "messaging": {
    "intervals": {
      "measurement": 60,
      "sw_logs": 180,
      "state": 120,
      "events": 300
    },
    "enabled": {
      "measurement": true,
      "sw_logs": false,
      "state": true,
      "events": true
    }
  },
  "logging": {
    "level": "INFO",
    "file": "logs/simulator.log"
  }
}
```

### Message Type Configuration

The `messaging` configuration has two sections:

- **`intervals`**: How often each message type is sent (in seconds)
- **`enabled`**: Whether each message type should be sent at all

**Message Types:**

- **measurement**: Sensor readings and metrics
- 🔧 **sw_logs**: Software logs and debugging information
- 🔄 **state**: Device state and operational status
- ⚠️ **events**: Event notifications and alerts

**Default Settings:**

- All message types are **enabled** by default except `sw_logs` (disabled)
- You can disable any message type by setting its `enabled` value to `false`
- Disabled message types will not generate telemetry tasks, saving resources

## Usage

### 1. Start the Simulator

```bash
# Activate virtual environment first (if not already active)
# Windows:
venv\Scripts\activate
# Linux/macOS:
source venv/bin/activate

# Start the simulator (recommended way)
iot-simulator

# Initialize configuration if needed
iot-simulator --init

# Alternative way (direct module execution)
python -m simulator.main
```

### 2. Device Configuration Flow

#### Option A: Pre-configured Device

If `config/device-config.json` and corresponding schema exist:

- ✅ Device automatically starts tracking
- 🔗 Connects to IoT Hub using stored connection string
- 📊 Begins twin monitoring and telemetry transmission

#### Option B: New Device Setup

If no local configuration exists:

1. **🌐 CLI-based Authorization**

   - Follow OAuth2 login prompts in terminal
   - Authenticate with IoT Platform credentials via browser
   - Grant device management permissions

2. **⚙️ Device Configuration via CLI**

   - **New Device Creation**:

     - Enter Device ID through command prompts
     - Select from available Managed Groups (displayed in terminal)
     - Choose Device Type from server list (interactive menu)
     - Provision new device in IoT Hub
     - Set initial configurations in IoT Hub device twin

   - **OR Choose Existing Device**:
     - Select from available devices list displayed in terminal
     - Get device configurations from IoT Hub device twin
     - Get selected device data from server: id, gateway id, managed-group, type.

3. **💾 Schema Download**
   - Device type schema downloaded from IoT Platform
   - Configuration saved locally for future use

### 3. Runtime Operations

#### Twin Configuration Monitoring

```
[TWIN] Listening for desired property changes from IoT Hub...
[TWIN] Generated default configs from schema
[TWIN] Desired property updated from IoT Hub: {'telemetryInterval': 45}
[TWIN] Patched reported property: {'telemetryInterval': 45}
```

#### Telemetry Transmission

```
[D2C] Sending measurement: {"temperature": 23.5, "humidity": 65.2}
[D2C] Sending state: {"batteryLevel": 85, "signalStrength": -67}
[D2C] Sending events: {"type": "highTemperature", "value": 78.2}
[D2C] Sending sw_logs: {"firmware_version": "1.2.3", "memory_usage": 65, "cpu_temp": 42}
```

#### Command Handling

```
[C2D] Received command: reboot
[C2D] Command validated against schema
[C2D] Sending response: {"status": "success", "timestamp": "2025-10-26T10:30:00Z"}
```

## Project Structure

```
tandem-platform-simulator/
├── pyproject.toml            # Modern Python packaging configuration
├── setup.bat/setup.sh        # Setup scripts for development environment
├── simulator/               # Main package
│   ├── main.py             # Primary application entry point
│   ├── api/                # Platform API clients
│   │   ├── device_creation_metadata_api.py
│   │   └── firmware_version_api.py
│   ├── auth/               # OAuth2 authentication
│   │   ├── oauth_flow.py
│   │   └── oauth2_client.py
│   ├── config/             # Configuration management
│   │   ├── config_manager.py
│   │   ├── schemas.py
│   │   └── templates/
│   │       └── config.template.json
│   ├── connectivity/       # IoT Hub client
│   │   └── iot_hub_client.py
│   ├── device_setup/       # CLI-based device configuration
│   │   ├── setup_coordinator.py
│   │   ├── configuration_ui.py
│   │   └── device_selector.py
│   ├── provisioning/       # Device provisioning
│   │   └── device_provisioner.py
│   ├── telemetry/          # D2C message generation
│   │   ├── sender.py
│   │   ├── telemetry_generator.py
│   │   └── message_generators/
│   │       ├── measurement_generator.py
│   │       ├── state_generator.py
│   │       ├── alerts_generator.py
│   │       └── fw_debug_generator.py
│   ├── twin/               # Device twin manager
│   │   ├── twin_manager.py
│   │   ├── default_config_applier.py
│   │   ├── firmware_reporter.py
│   │   └── reported_store.py
│   ├── commands/           # C2D command processing
│   │   └── command_handler.py
│   └── utils/              # Utilities and logging
│       ├── logger.py
│       ├── version_parser.py
│       └── schema/
│           ├── schema_generator.py
│           ├── schema_reference_resolver.py
│           └── schema_value_generator.py
├── config/                 # Configuration files
│   ├── config.json         # Application configuration (created from template)
│   ├── device-config.json  # Device-specific config (auto-generated)
│   └── auth-tokens.json    # OAuth tokens (auto-generated)
├── schemas/                # Device type schemas (downloaded)
├── certificates/           # Device certificates (if using)
├── twin_schemas/          # Twin schemas
├── tests/                  # Test suite
│   └── commands/
├── logs/                   # Application logs
└── README.md
```

## Logging

The simulator provides detailed logging for all operations:

- **🔐 Authentication**: OAuth2 flow, token management
- **⚙️ Configuration**: Device setup, schema downloads
- **🔗 Connectivity**: IoT Hub connections, reconnection attempts
- **👥 Twin Operations**: Desired/reported property changes
- **📡 Telemetry**: Message generation and transmission
- **🎯 Commands**: Command reception and response generation

Logs are written to both console and `logs/simulator.log` file.

## Error Handling

### Common Issues

**Configuration Missing**

```bash
# Initialize configuration if not exists
iot-simulator --init
# Edit the generated config/config.json with your settings
```

**Authentication Failures**

```bash
# Clear stored tokens and re-authenticate
del config\auth-tokens.json  # Windows
# rm config/auth-tokens.json  # Linux/macOS
iot-simulator
```

**Connection Issues**

```bash
# Check IoT Hub connectivity and device configuration
# Verify config/config.json settings
# Check config/device-config.json exists and is valid
```

**Schema Validation Errors**

```bash
# Re-run setup to download fresh schema
# Delete old schema files and device config
del schemas\*-schema.json config\device-config.json  # Windows
# rm schemas/*-schema.json config/device-config.json  # Linux/macOS
iot-simulator
```

## Development

### Development Setup

The project uses modern Python packaging with `pyproject.toml`. Development dependencies are automatically installed with the `[dev]` extra.

**Package name:** `tgiot-device-simulator`

```bash
# Install in development mode with all tools
pip install -e ".[dev]"
```

### Available Development Commands

```bash
# Code formatting
black .                    # Format all Python files
isort .                   # Sort imports

# Linting
ruff check .              # Fast Python linter
mypy .                    # Type checking

# Testing
pytest                    # Run all tests
pytest tests/ -v          # Verbose test output
pytest --cov=simulator    # Run tests with coverage

# Build and install
pip install -e .          # Install package locally
pip install -e ".[dev]"   # Install with dev dependencies

# Package build (for distribution)
python -m build           # Build wheel and source distribution
```

### Project Structure

```
├── pyproject.toml        # Modern Python packaging configuration
├── simulator/           # Main package
│   ├── main.py         # Primary application entry point
│   ├── api/            # Platform API clients
│   ├── auth/           # OAuth2 authentication
│   ├── config/         # Configuration management
│   ├── connectivity/   # IoT Hub client
│   ├── device_setup/   # CLI-based device configuration
│   ├── provisioning/   # Device provisioning logic
│   ├── telemetry/      # Telemetry sender
│   │   └── message_generators/  # Message type generators
│   ├── twin/           # Device twin manager
│   ├── commands/       # C2D command processing
│   └── utils/          # Utilities and logging
│       └── schema/     # Schema utilities
├── config/             # Configuration files
├── tests/              # Test suite
├── schemas/            # Device type schemas
├── certificates/       # Device certificates
├── twin_schemas/       # Twin schemas
└── logs/               # Application logs
```

**Entry Points:**

- `iot-simulator` - Console command (recommended)
- `iot-simulator --init` - Initialize configuration
- `python -m simulator.main` - Direct module execution

---

**Tandem Platform Device Simulator** - Bridging the gap between IoT devices and cloud platforms with intelligent simulation and monitoring capabilities.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tgiot-device-simulator",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "iot, azure, simulator, device, telemetry",
    "author": null,
    "author_email": "IoT Platform Team <iot-platform@example.com>",
    "download_url": "https://files.pythonhosted.org/packages/df/8d/cad1ebd213de5f5614c311083d65b3b179f95f33a09fedb4b588127e6bb1/tgiot_device_simulator-1.0.0.5.tar.gz",
    "platform": null,
    "description": "# Device Simulator\n\nA 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.\n\n## Features\n\n### \ud83d\udd27 Device Configuration\n\n- **Local Configuration**: Load device configuration from local files if already configured\n- **Interactive CLI Setup**: Command-line interface for device configuration and management\n- **OAuth2 Authentication**: Secure authentication with IoT Platform server\n- **Device Provisioning**: Automatic device creation in IoT Hub\n- **Configuration Management**: Get and set device configurations through IoT Hub\n- **Schema Management**: Download and cache device type schemas locally\n\n### \ud83d\udd0c Connectivity\n\n- **Azure IoT Hub Integration**: Connect to IoT Hub using device connection strings\n- **Gateway Support**: Connect through configured gateways\n- **SAS Token Authentication**: Secure device authentication\n\n### \ud83d\udcca Device Twin Monitoring\n\n- **Desired Properties**: Listen for twin configuration changes from IoT Hub\n- **Reported Properties**: Update device status and configurations to IoT Hub only if reported section of the device is empty\n- **Default Configurations**: Apply schema-based default values and sync with IoT Hub\n\n### \ud83d\udce1 Telemetry (D2C Messages)\n\n- **Message Types**:\n  - \ud83d\udea8 **Events**: Critical notifications and warnings\n  - \ud83d\udcc8 **Measurements**: Sensor readings and metrics\n  - \u26a1 **Status**: Device health and operational status\n  - \ud83d\udd27 **FW Debug**: Firmware debugging and diagnostic information\n- **Scheduled Transmission**: Configurable intervals for each message type, on each trigger all the messages of this type will be sent (all events/meausrement/etc)\n- **Schema Compliance**: Values generated according to device type schema\n- **Data Continuity**: Coordinated values based on previous messages\n\n### \ud83c\udfaf Command Handling (C2D)\n\n- **Command Reception**: Process commands from IoT Platform\n- **Schema Validation**: Verify commands against device type schema\n- **Response Generation**: Automatic success responses when required\n\n## Prerequisites\n\n- Python 3.9 or higher (supports Python 3.9-3.13)\n- pip package manager\n- Virtual environment\n- Azure IoT Hub instance\n- IoT Platform server with OAuth2 support\n- Device type schemas in IoT Platform server\n\n## Installation\n\n### Quick Setup (Recommended)\n\n```bash\n# Clone the repository\ngit clone <repository-url>\ncd tandem-platform-simulator\n\n# Run setup script\n# Windows:\nsetup.bat\n# Linux/macOS:\nbash setup.sh\n```\n\nThe setup script will:\n\n1. Create a virtual environment\n2. Install the package in development mode with all dependencies\n3. Copy configuration template\n4. Set up logging directory\n\n### Manual Installation\n\n```bash\n# Create virtual environment\npython -m venv venv\n\n# Activate virtual environment\n# Windows:\nvenv\\Scripts\\activate\n# Linux/macOS:\nsource venv/bin/activate\n\n# Install package in development mode with all dependencies\npip install -e \".[dev]\"\n\n# Copy configuration template\ncopy simulator\\config\\templates\\config.template.json config\\config.json  # Windows\n# cp simulator/config/templates/config.template.json config/config.json  # Linux/macOS\n```\n\n## Configuration\n\n### Local Device Configuration\n\nIf you have existing device configuration, create these files:\n\n**`config/device-config.json`**\n\n```json\n{\n  \"deviceId\": \"your-device-id\",\n  \"gatewayId\": \"your-gateway-id\",\n  \"deviceType\": \"your-device-type\",\n  \"lastUpdated\": \"2025-08-24T10:30:00Z\"\n}\n```\n\n**`schemas/device-type-schema.json`**\n\n### Application Configuration\n\n**`config/config.json`**\n\n```json\n{\n  \"iotPlatform\": {\n    \"baseUrl\": \"https://your-iot-platform.com/api\",\n    \"oauth2\": {\n      \"clientId\": \"your-client-id\",\n      \"authorization_endpoint\": \"https://your-authority.your-region.cloudapp.azure.com/application/o/authorize/\",\n      \"token_endpoint\": \"https://your-authority.your-region.cloudapp.azure.com/application/o/token/\"\n    }\n  },\n  \"provisioner\": {\n    \"baseUrl\": \"https://your-provisioner-app.azurewebsites.net\"\n  },\n  \"iotHub\": {\n    \"hostName\": \"your-iot-hub-name.azure-devices.net\"\n  },\n  \"messaging\": {\n    \"intervals\": {\n      \"measurement\": 60,\n      \"sw_logs\": 180,\n      \"state\": 120,\n      \"events\": 300\n    },\n    \"enabled\": {\n      \"measurement\": true,\n      \"sw_logs\": false,\n      \"state\": true,\n      \"events\": true\n    }\n  },\n  \"logging\": {\n    \"level\": \"INFO\",\n    \"file\": \"logs/simulator.log\"\n  }\n}\n```\n\n### Message Type Configuration\n\nThe `messaging` configuration has two sections:\n\n- **`intervals`**: How often each message type is sent (in seconds)\n- **`enabled`**: Whether each message type should be sent at all\n\n**Message Types:**\n\n- **measurement**: Sensor readings and metrics\n- \ud83d\udd27 **sw_logs**: Software logs and debugging information\n- \ud83d\udd04 **state**: Device state and operational status\n- \u26a0\ufe0f **events**: Event notifications and alerts\n\n**Default Settings:**\n\n- All message types are **enabled** by default except `sw_logs` (disabled)\n- You can disable any message type by setting its `enabled` value to `false`\n- Disabled message types will not generate telemetry tasks, saving resources\n\n## Usage\n\n### 1. Start the Simulator\n\n```bash\n# Activate virtual environment first (if not already active)\n# Windows:\nvenv\\Scripts\\activate\n# Linux/macOS:\nsource venv/bin/activate\n\n# Start the simulator (recommended way)\niot-simulator\n\n# Initialize configuration if needed\niot-simulator --init\n\n# Alternative way (direct module execution)\npython -m simulator.main\n```\n\n### 2. Device Configuration Flow\n\n#### Option A: Pre-configured Device\n\nIf `config/device-config.json` and corresponding schema exist:\n\n- \u2705 Device automatically starts tracking\n- \ud83d\udd17 Connects to IoT Hub using stored connection string\n- \ud83d\udcca Begins twin monitoring and telemetry transmission\n\n#### Option B: New Device Setup\n\nIf no local configuration exists:\n\n1. **\ud83c\udf10 CLI-based Authorization**\n\n   - Follow OAuth2 login prompts in terminal\n   - Authenticate with IoT Platform credentials via browser\n   - Grant device management permissions\n\n2. **\u2699\ufe0f Device Configuration via CLI**\n\n   - **New Device Creation**:\n\n     - Enter Device ID through command prompts\n     - Select from available Managed Groups (displayed in terminal)\n     - Choose Device Type from server list (interactive menu)\n     - Provision new device in IoT Hub\n     - Set initial configurations in IoT Hub device twin\n\n   - **OR Choose Existing Device**:\n     - Select from available devices list displayed in terminal\n     - Get device configurations from IoT Hub device twin\n     - Get selected device data from server: id, gateway id, managed-group, type.\n\n3. **\ud83d\udcbe Schema Download**\n   - Device type schema downloaded from IoT Platform\n   - Configuration saved locally for future use\n\n### 3. Runtime Operations\n\n#### Twin Configuration Monitoring\n\n```\n[TWIN] Listening for desired property changes from IoT Hub...\n[TWIN] Generated default configs from schema\n[TWIN] Desired property updated from IoT Hub: {'telemetryInterval': 45}\n[TWIN] Patched reported property: {'telemetryInterval': 45}\n```\n\n#### Telemetry Transmission\n\n```\n[D2C] Sending measurement: {\"temperature\": 23.5, \"humidity\": 65.2}\n[D2C] Sending state: {\"batteryLevel\": 85, \"signalStrength\": -67}\n[D2C] Sending events: {\"type\": \"highTemperature\", \"value\": 78.2}\n[D2C] Sending sw_logs: {\"firmware_version\": \"1.2.3\", \"memory_usage\": 65, \"cpu_temp\": 42}\n```\n\n#### Command Handling\n\n```\n[C2D] Received command: reboot\n[C2D] Command validated against schema\n[C2D] Sending response: {\"status\": \"success\", \"timestamp\": \"2025-10-26T10:30:00Z\"}\n```\n\n## Project Structure\n\n```\ntandem-platform-simulator/\n\u251c\u2500\u2500 pyproject.toml            # Modern Python packaging configuration\n\u251c\u2500\u2500 setup.bat/setup.sh        # Setup scripts for development environment\n\u251c\u2500\u2500 simulator/               # Main package\n\u2502   \u251c\u2500\u2500 main.py             # Primary application entry point\n\u2502   \u251c\u2500\u2500 api/                # Platform API clients\n\u2502   \u2502   \u251c\u2500\u2500 device_creation_metadata_api.py\n\u2502   \u2502   \u2514\u2500\u2500 firmware_version_api.py\n\u2502   \u251c\u2500\u2500 auth/               # OAuth2 authentication\n\u2502   \u2502   \u251c\u2500\u2500 oauth_flow.py\n\u2502   \u2502   \u2514\u2500\u2500 oauth2_client.py\n\u2502   \u251c\u2500\u2500 config/             # Configuration management\n\u2502   \u2502   \u251c\u2500\u2500 config_manager.py\n\u2502   \u2502   \u251c\u2500\u2500 schemas.py\n\u2502   \u2502   \u2514\u2500\u2500 templates/\n\u2502   \u2502       \u2514\u2500\u2500 config.template.json\n\u2502   \u251c\u2500\u2500 connectivity/       # IoT Hub client\n\u2502   \u2502   \u2514\u2500\u2500 iot_hub_client.py\n\u2502   \u251c\u2500\u2500 device_setup/       # CLI-based device configuration\n\u2502   \u2502   \u251c\u2500\u2500 setup_coordinator.py\n\u2502   \u2502   \u251c\u2500\u2500 configuration_ui.py\n\u2502   \u2502   \u2514\u2500\u2500 device_selector.py\n\u2502   \u251c\u2500\u2500 provisioning/       # Device provisioning\n\u2502   \u2502   \u2514\u2500\u2500 device_provisioner.py\n\u2502   \u251c\u2500\u2500 telemetry/          # D2C message generation\n\u2502   \u2502   \u251c\u2500\u2500 sender.py\n\u2502   \u2502   \u251c\u2500\u2500 telemetry_generator.py\n\u2502   \u2502   \u2514\u2500\u2500 message_generators/\n\u2502   \u2502       \u251c\u2500\u2500 measurement_generator.py\n\u2502   \u2502       \u251c\u2500\u2500 state_generator.py\n\u2502   \u2502       \u251c\u2500\u2500 alerts_generator.py\n\u2502   \u2502       \u2514\u2500\u2500 fw_debug_generator.py\n\u2502   \u251c\u2500\u2500 twin/               # Device twin manager\n\u2502   \u2502   \u251c\u2500\u2500 twin_manager.py\n\u2502   \u2502   \u251c\u2500\u2500 default_config_applier.py\n\u2502   \u2502   \u251c\u2500\u2500 firmware_reporter.py\n\u2502   \u2502   \u2514\u2500\u2500 reported_store.py\n\u2502   \u251c\u2500\u2500 commands/           # C2D command processing\n\u2502   \u2502   \u2514\u2500\u2500 command_handler.py\n\u2502   \u2514\u2500\u2500 utils/              # Utilities and logging\n\u2502       \u251c\u2500\u2500 logger.py\n\u2502       \u251c\u2500\u2500 version_parser.py\n\u2502       \u2514\u2500\u2500 schema/\n\u2502           \u251c\u2500\u2500 schema_generator.py\n\u2502           \u251c\u2500\u2500 schema_reference_resolver.py\n\u2502           \u2514\u2500\u2500 schema_value_generator.py\n\u251c\u2500\u2500 config/                 # Configuration files\n\u2502   \u251c\u2500\u2500 config.json         # Application configuration (created from template)\n\u2502   \u251c\u2500\u2500 device-config.json  # Device-specific config (auto-generated)\n\u2502   \u2514\u2500\u2500 auth-tokens.json    # OAuth tokens (auto-generated)\n\u251c\u2500\u2500 schemas/                # Device type schemas (downloaded)\n\u251c\u2500\u2500 certificates/           # Device certificates (if using)\n\u251c\u2500\u2500 twin_schemas/          # Twin schemas\n\u251c\u2500\u2500 tests/                  # Test suite\n\u2502   \u2514\u2500\u2500 commands/\n\u251c\u2500\u2500 logs/                   # Application logs\n\u2514\u2500\u2500 README.md\n```\n\n## Logging\n\nThe simulator provides detailed logging for all operations:\n\n- **\ud83d\udd10 Authentication**: OAuth2 flow, token management\n- **\u2699\ufe0f Configuration**: Device setup, schema downloads\n- **\ud83d\udd17 Connectivity**: IoT Hub connections, reconnection attempts\n- **\ud83d\udc65 Twin Operations**: Desired/reported property changes\n- **\ud83d\udce1 Telemetry**: Message generation and transmission\n- **\ud83c\udfaf Commands**: Command reception and response generation\n\nLogs are written to both console and `logs/simulator.log` file.\n\n## Error Handling\n\n### Common Issues\n\n**Configuration Missing**\n\n```bash\n# Initialize configuration if not exists\niot-simulator --init\n# Edit the generated config/config.json with your settings\n```\n\n**Authentication Failures**\n\n```bash\n# Clear stored tokens and re-authenticate\ndel config\\auth-tokens.json  # Windows\n# rm config/auth-tokens.json  # Linux/macOS\niot-simulator\n```\n\n**Connection Issues**\n\n```bash\n# Check IoT Hub connectivity and device configuration\n# Verify config/config.json settings\n# Check config/device-config.json exists and is valid\n```\n\n**Schema Validation Errors**\n\n```bash\n# Re-run setup to download fresh schema\n# Delete old schema files and device config\ndel schemas\\*-schema.json config\\device-config.json  # Windows\n# rm schemas/*-schema.json config/device-config.json  # Linux/macOS\niot-simulator\n```\n\n## Development\n\n### Development Setup\n\nThe project uses modern Python packaging with `pyproject.toml`. Development dependencies are automatically installed with the `[dev]` extra.\n\n**Package name:** `tgiot-device-simulator`\n\n```bash\n# Install in development mode with all tools\npip install -e \".[dev]\"\n```\n\n### Available Development Commands\n\n```bash\n# Code formatting\nblack .                    # Format all Python files\nisort .                   # Sort imports\n\n# Linting\nruff check .              # Fast Python linter\nmypy .                    # Type checking\n\n# Testing\npytest                    # Run all tests\npytest tests/ -v          # Verbose test output\npytest --cov=simulator    # Run tests with coverage\n\n# Build and install\npip install -e .          # Install package locally\npip install -e \".[dev]\"   # Install with dev dependencies\n\n# Package build (for distribution)\npython -m build           # Build wheel and source distribution\n```\n\n### Project Structure\n\n```\n\u251c\u2500\u2500 pyproject.toml        # Modern Python packaging configuration\n\u251c\u2500\u2500 simulator/           # Main package\n\u2502   \u251c\u2500\u2500 main.py         # Primary application entry point\n\u2502   \u251c\u2500\u2500 api/            # Platform API clients\n\u2502   \u251c\u2500\u2500 auth/           # OAuth2 authentication\n\u2502   \u251c\u2500\u2500 config/         # Configuration management\n\u2502   \u251c\u2500\u2500 connectivity/   # IoT Hub client\n\u2502   \u251c\u2500\u2500 device_setup/   # CLI-based device configuration\n\u2502   \u251c\u2500\u2500 provisioning/   # Device provisioning logic\n\u2502   \u251c\u2500\u2500 telemetry/      # Telemetry sender\n\u2502   \u2502   \u2514\u2500\u2500 message_generators/  # Message type generators\n\u2502   \u251c\u2500\u2500 twin/           # Device twin manager\n\u2502   \u251c\u2500\u2500 commands/       # C2D command processing\n\u2502   \u2514\u2500\u2500 utils/          # Utilities and logging\n\u2502       \u2514\u2500\u2500 schema/     # Schema utilities\n\u251c\u2500\u2500 config/             # Configuration files\n\u251c\u2500\u2500 tests/              # Test suite\n\u251c\u2500\u2500 schemas/            # Device type schemas\n\u251c\u2500\u2500 certificates/       # Device certificates\n\u251c\u2500\u2500 twin_schemas/       # Twin schemas\n\u2514\u2500\u2500 logs/               # Application logs\n```\n\n**Entry Points:**\n\n- `iot-simulator` - Console command (recommended)\n- `iot-simulator --init` - Initialize configuration\n- `python -m simulator.main` - Direct module execution\n\n---\n\n**Tandem Platform Device Simulator** - Bridging the gap between IoT devices and cloud platforms with intelligent simulation and monitoring capabilities.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A comprehensive IoT device simulator for Azure IoT Hub and IoT Platform servers",
    "version": "1.0.0.5",
    "project_urls": {
        "Homepage": "https://tandemg.com"
    },
    "split_keywords": [
        "iot",
        " azure",
        " simulator",
        " device",
        " telemetry"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b7f21c27fc1559d60a1256bdac37aabac192400124df13f4d9f1d585f3c2c6d6",
                "md5": "c954cb9990e23807282449702ae6f2a6",
                "sha256": "2d9c90bd731264b3b81edb84035f776f7049cff466a717901c6514f51f5f52e5"
            },
            "downloads": -1,
            "filename": "tgiot_device_simulator-1.0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c954cb9990e23807282449702ae6f2a6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 47869,
            "upload_time": "2025-11-04T12:44:38",
            "upload_time_iso_8601": "2025-11-04T12:44:38.334222Z",
            "url": "https://files.pythonhosted.org/packages/b7/f2/1c27fc1559d60a1256bdac37aabac192400124df13f4d9f1d585f3c2c6d6/tgiot_device_simulator-1.0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "df8dcad1ebd213de5f5614c311083d65b3b179f95f33a09fedb4b588127e6bb1",
                "md5": "7d1f63dffc87de386959dcaf255591bd",
                "sha256": "7651f91668aad4281b71edc8c31ae47749077cb6352eae58fe8f87919ea46672"
            },
            "downloads": -1,
            "filename": "tgiot_device_simulator-1.0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "7d1f63dffc87de386959dcaf255591bd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 39386,
            "upload_time": "2025-11-04T12:44:40",
            "upload_time_iso_8601": "2025-11-04T12:44:40.065053Z",
            "url": "https://files.pythonhosted.org/packages/df/8d/cad1ebd213de5f5614c311083d65b3b179f95f33a09fedb4b588127e6bb1/tgiot_device_simulator-1.0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-11-04 12:44:40",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "tgiot-device-simulator"
}
        
Elapsed time: 2.06347s