Skip to content

Feature hotspot creation#15

Open
diyaseb285 wants to merge 20 commits intodevfrom
featureHotspotCreation
Open

Feature hotspot creation#15
diyaseb285 wants to merge 20 commits intodevfrom
featureHotspotCreation

Conversation

@diyaseb285
Copy link
Copy Markdown
Collaborator

Summary

Provide a short, clear description of what this PR does and why.
Created a new MySQL table for hotspots, where one hotspot can be linked to many different temperatures. Added an insertHotspotData() function that will take data from the position table and take the latest position for the bot of focus, storing that one position value in the hotspot table. Combined the latest GPS coordinates with 10 temperature values, and sent the hotspot data back to the server file.


Related Task

Closes Create and store hotspots in db based off of incoming data from radio


Type of Change

Select all that apply:

  • [✓ ] 🆕 Feature
  • 🐞 Bug Fix
  • 🧹 Refactor
  • 🧾 Documentation Update
  • 🧰 Maintenance / Tooling
  • Other (specify below)

📄 Documentation

  • All of the following applicable documentation changes were added
    • How to connect the new device and wiring
    • Links to external documentation on the device
    • Any other setup or important information
  • No documentation changes required

🧪 Testing

Describe how this change was tested.
Include commands or steps used, and confirm successful results.
In init.sql, after I created the hotspot table, which has a one-to-many relationship with the botID. I tested the code, but the hotspot table would not show up, so I added: FOREIGN KEY (hotspotID) REFERENCES hotspot(hotspotID) ON DELETE CASCADE under the temperature table so that it accounted for the fact that one hotspot could have many temperature values. I also altered the storeMavlinkData(data) function in server.mjs so that the data type 'hotspot_data' was accounted for.


Image of GUI change (if applicable)

Paste an image of the GUI change.


✅ Pre-Merge Checklist

  • PR started as a Draft
  • Linked to correct Notion Task
  • Branch includes updated documentation
  • Code reviewed by peer
  • Ready for final review by Software Lead
  • All tests and builds pass
  • Notion task updated to Ready for Review

🧾 Notes (Optional)

Add any context, screenshots, or known issues reviewers should know about.

…cords. Created new hotspot table that has one-to-many relationship with temperature values. Many temp values link to one hotspot
…ion table and take the latest position for the bot of focus, storing that one position value into the hotspot table.
… table since it should be linked to bot and hotspot in order for hotspot table to show up as a MySQL table
@diyaseb285 diyaseb285 marked this pull request as draft January 17, 2026 01:27
@diyaseb285 diyaseb285 marked this pull request as ready for review February 14, 2026 05:20
Copy link
Copy Markdown
Collaborator

@mrichards03 mrichards03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work!

Comment on lines +94 to +97
//infer missionID from the bot if it is missing
if(data.missionID ==null){
const missionID =await getActiveMissionIdForBot(conn, data.botID);
data.missionID =missionID ??null; // if no active mission, set to null and let it be handled by the database constraints (if necessary) or just have battery data without a mission association
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for mission data for battery data or position data. Can be removed from insert method and remove missionid from init.sql for battery table and position table.

Comment thread server/src/services/database.service.mjs Outdated
conn = await pool.getConnection();

// If missionID not provided, try to find an active mission for this bot
let missionID = data.missionID ?? null;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data will never contain mission id, right? the robot won't be sending mission id in the temperature message so you need to query it from the db. No point looking for data.missionId if it's never populated

Comment on lines +525 to +534
const [missionRows] = await conn.execute(
`SELECT DISTINCT m.missionID AS missionID
FROM mission m
JOIN bot_mission_assignment bma ON m.missionID = bma.missionID
WHERE bma.botID = ? AND m.timeStart IS NOT NULL AND m.timeEnd IS NULL
LIMIT 1`,
[data.botID]
);
missionID = missionRows[0] ? missionRows[0].missionID : null;
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you have this but also a method (getActiveMissionIdForBot) that does the same thing? You should use the method here

data.latitude,
data.longitude,
data.altitude ?? null,
data.notes ?? null,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, there's not going to be notes in the temperature message so just insert null otherwise the code is misleading

Comment thread server/src/services/mavlink.service.mjs Outdated
ardupilotmega,
} = mavlink;
const latestGPS = {};
const tempVals = {};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't used

Comment thread server/src/services/mavlink.service.mjs Outdated
NOTE: data format for simulated battery data is arbitrary; i.e. the keys do not correspond to actual incoming data, because battery percentage is new and I do not yet know the format in which battery % will be sent by the bot. Once format is finalized, function processBatteryMessage() as well as the 'battery' table in DB must both be changed, and the battery simulation part of the function will break unless also changed accordingly.
*/

let simStarted = false;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this added? SimulateMavlinkData() is only called once on the index page so I don't see how it would ever be called again after simulation is already started? Did you encounter that as a problem?

Comment thread server/src/services/mavlink.service.mjs Outdated
let botTempData = [];

for (let i = 0; i < NUM_SIMULATED_BOTS; i++) {
let temperatureTick = false; //start with GPS so latestGPS is populated before temp data
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used

const allBatteryData = await getAllBatteryData();
io.emit('battery:update', allBatteryData);
}
//TODO: insert hotspot data, don't worry about io.emit for now
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this comment

Comment thread server/src/services/mavlinkStorage.service.mjs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants