- IoT Overview
- 1. Getting Started
- 2. Creating an IoT Solution
- 2.1. Model the Device
- 2.2. Create an Instance of the Device from Template
- 2.3. Create Event Source and Threshold Policy for the Device
- 2.4. Create Event Stream for Device
- 2.5. Create Application
- 2.6. Create Event Stream for Application
- 2.7. Subscribe to Events
- 2.8. Configure the Device
- 2.9. Configure the Application
- 2.10. Send Event from Device
- 3. API Documentation
- Back to Learning Center
Send Event from Device
To send an event from the car, the gateway on the car must perform the following steps:
- Read engine fault code: The gateway will read the engine fault code every minute.
- Construct message: The gateway will construct JSON string for the event. - For example:
{ “engine_fault_code”: 10200 }
- Encrypt message: The JSON event string must be encrypted using the producerPublicKey and the message must be encoded in Base64 format.
For example:”ew0KInRlbXAiOiAyNS4zLA0KImh1bWlkaXR5Iiw1NC44DQp9”
- Generate a messageID: A unique messageID is generated to identify the message.
For Example:“65eb9268-b0d1-4f75-a855-71eac716a351”
- Construct event message: Construct a JSON message including messageID, deviceID, eventTemplateID and the encoded message.
For Example:{ “messageID”: “65eb9268-b0d1-4f75-a855-71eac716a351”, “deviceID”: “7d7289e5-a45b-42a1-a762-1a662756e715”, “eventTemplateID”: “48c713f8-5b69-49f0-afb1-e5618ac9bae9”, “message”: “ew0KInRlbXAiOiAyNS4zLA0KImh1bWlkaXR5Iiw1NC44DQp9” }
- Send event: Send the event to IoT platform.