Skip to content

feat/modernize-self-service-deploy#2

Open
mateuscardosodeveloper wants to merge 5 commits into
masterfrom
feat/modernize-self-service-deploy
Open

feat/modernize-self-service-deploy#2
mateuscardosodeveloper wants to merge 5 commits into
masterfrom
feat/modernize-self-service-deploy

Conversation

@mateuscardosodeveloper

@mateuscardosodeveloper mateuscardosodeveloper commented Jun 9, 2026

Copy link
Copy Markdown

What does PR do?

Modernizes the TagoIO TCP middleware example so users can clone, configure, and deploy their own connector middleware without fighting an outdated codebase. Closes the self-service refactor requested in the issue and adds SDK-based uplink plus Class A downlink as a realistic reference.

📦 Dependencies & runtime

  • Adopts pnpm with a committed lockfile and workspace build approval
  • Adds the current @tago-io/sdk (^12.2.2); targets Node.js 24

📡 SDK-based uplink

  • Resolves each serial to a device token (Network.resolveToken) and forwards the hex payload via Device.sendData

📥 Class A downlink over TCP

  • After every uplink, reads a pending downlink Configuration Parameter (sent !== true)
  • Writes the raw bytes back on the same TCP socket and marks the parameter as read

🧩 Connector example

  • Adds examples/payload-parser.js decoding temperature and humidity, with two matching test frames documented end to end

🛠️ Process management & containerization

  • pm2 ecosystem config with restart-on-crash and log handling
  • Multi-stage Dockerfile (small final image, non-root), docker-compose, and a GitHub Actions test workflow

📚 Documentation

  • README rewritten for the self-service path: what it does, token/env configuration, running with pm2 or Docker, and verifying data reaches TagoIO
  • Troubleshooting for port mapping, missing delimiters, and netcat availability

✅ Acceptance criteria (issue)

  • All dependencies on current versions, no deprecated-package warnings
  • Middleware runs under pm2 with a committed config file
  • docker build / docker run bring it up with env-based configuration
  • README walks a user from clone to a running middleware connected to TagoIO
  • Example payload flow verified end to end after the refactor

Type of alteration

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Switch package management to pnpm with a committed lockfile and workspace
build approval, add multi-stage Docker, compose, pm2, and a GitHub Actions
test workflow. Point all scripts and entrypoints at dist/main.js and add the
SDK dependency.
Replace the raw HTTP fetch with @tago-io/sdk, resolving each serial to a
device token and forwarding the hex payload with Device.sendData. After every
uplink, read a pending "downlink" configuration parameter and write its bytes
back on the same socket for Class A devices. Refactor the frame splitter to a
functional factory and warn when a connection closes on an unterminated frame.
Rewrite the README around the SDK uplink, the Class A downlink, and pnpm
commands, with troubleshooting for port mapping, missing delimiters, and
netcat availability. Add examples/payload-parser.js decoding temperature and
humidity for the Connector.
Comment thread src/uplink/uplink.ts Fixed
Comment thread src/uplink/uplink.ts Fixed
Comment thread src/uplink/uplink.ts Fixed
Device-provided values (serial, frame) were interpolated into the console
format string, which CodeQL flagged as a format-string injection. Pass them as
%s/%d arguments instead so format specifiers in device data are not evaluated.
Drop the connection when a frame exceeds MAX_FRAME_LENGTH so a peer that
never sends the delimiter can no longer grow the buffer until the process
runs out of memory. Decode the delimiter to a string and split on it
directly, removing the redundant Buffer round-trip in the splitter.
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.

2 participants