0% found this document useful (0 votes)
13 views3 pages

Firmware Engineer - Assignment - Enlog

Uploaded by

Abhiram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Firmware Engineer - Assignment - Enlog

Uploaded by

Abhiram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ENLOG – Firmware Engineer Test Assignment

IMPORTANT INSTRUCTIONS:

1. Submission Format:
You must submit this assignment in a ZIP file containing all your relevant source
code and documents.

2. AI Tool Usage Prohibited:


The use of any AI tools (such as ChatGPT, GitHub Copilot, Google Gemini, etc.) for
this assignment is STRICTLY PROHIBITED.

Please note: AI-generated answers are easily trackable these days and will be
flagged. Ensure that all work is your own.

3. Deadline Compliance:
Assignments must be submitted on or before the given deadline. Late submissions
may not be accepted.

OBJECTIVE:

Problem 1. -

Consider a Scenario -
Your ESP32 publishes simulated temperature values (rand() % 100) to

device/9600/telemetry

Every 2 seconds but sometimes the MQTT broker is stopped/restarted.

Write a code to that also handles the following conditions -

• If the broker is unavailable, buffer outgoing messages in RAM (max 20).

• On reconnection, publish buffered messages in the correct order.

• If the buffer overflows, discard the oldest message and log it.
Problem 2 -

Consider a Scenario -
Your device has a local JSON file (stored in SPIFFS or embedded as a string for test)
containing register details for a peripheral device. Example:

{ "device": "PH1",

"registers": [

{ "addr": "0x00", "name": "VOLTAGE", "desc": "Line Voltage", "unit": "V" },

{ "addr": "0x01", "name": "CURRENT", "desc": "Line Current", "unit": "A" },

{ "addr": "0x02", "name": "POWER", "desc": "Active Power", "unit": "W" }

Write a code a that also handles the following –

• Load this JSON file at startup (either from SPIFFS/NVS, or just use a const string
for test).

• Parse the JSON.

• For each register, print the following line to the log:

[REG] Addr=0x00 Name=VOLTAGE Desc="Line Voltage" Unit=V

• If a required key (like "name") is missing, log a warning instead of crashing.

Problem 3 -

Consider a Scenario:
Your device must maintain a TCP socket connection to a server at 192.168.1.100:5000
(choose any free server as per convenience) .

Write a code that -

• At startup, connect to the server via TCP socket.

• Send a heartbeat message "PING" every 10 seconds.

• If the server responds "PONG", log "Server Alive".

• If no response is received within 5 seconds, consider the connection lost:

o Close the socket


o Reconnect automatically

o Resume heartbeat.

• Log all events (connected, disconnected, message sent/received).

Problem 4 –

Consider a Scenario:
You are asked to design a calendar event manager for an embedded device (like a smart IoT
scheduler).

This should fulfill following Requirements:

• Define a data type (struct, union, enum etc.) with at least three event types:

o MEETING

o REMINDER

o BIRTHDAY

• Define a data type CalendarEvent with:

o int day, month, year – date fields

o char title[32] – short event title

o enum EventType type – type of event

o A datatype to store type-specific details:

▪ For MEETING: store char location[32]

▪ For REMINDER: store int minutes_before

▪ For BIRTHDAY: store char person_name[32]

• Write a function void print_event(CalendarEvent *e) that prints event details like:

[BIRTHDAY] 15/08/2025 "Dad's Birthday" Person: Dad

[MEETING] 16/08/2025 "Team Sync" Location: Conference Room

[REMINDER] 17/08/2025 "Pay Bills" Reminder: 30 min before

You might also like