Handling real-time data is easy when you have 5G. But what happens when a natural disaster hits and cellular networks go dark?
During a recent hackathon, my team and I built NalamMesh, a Digital Public Infrastructure (DPI) aimed at hospital readiness. When asked how our system would survive a total internet blackout, we had to rethink our architecture.
Here is how we implemented a 2G SMS fallback system using Node.js to keep critical patient vitals transmitting even when the internet is dead.
1. The Problem: When the Internet Fails
In cities like Chennai, we are no strangers to severe monsoons and floods. During these critical times, the first thing to collapse is the 4G/5G data infrastructure. Imagine an ambulance carrying a critical patient navigating through waterlogged streets. The hospital needs to prepare the ICU triage with the patient's vitals (Heart Rate, SpO2, BP) before they arrive. But with zero internet connectivity, modern React or Flutter dashboards become completely useless. We needed a solution that works when the internet dies.
2. Why 2G SMS is the Ultimate Fallback
While data networks require high-bandwidth infrastructure, SMS operates differently. It uses the cellular network's control channels (the signaling path used by towers to track your phone). Even if the internet cables are cut, as long as there is a faint 2G cellular signal to make a voice call, a 160-character text message can go through. By compressing a patient's vitals into a tiny string payload, we realized we could bypass the need for an internet connection entirely.
3. The Architecture of NalamMesh
Our goal with NalamMesh was to build a resilient Digital Public Infrastructure (DPI). The architecture is incredibly lightweight:
- The Client (Ambulance/CHW): A simple mobile-responsive UI where paramedics input vitals.
- The Offline Trigger: If the app detects navigator.onLine is false, it intercepts the API call and triggers the phone's native SMS intent.
- The Gateway: The SMS is sent to a central Twilio/Vonage virtual number.
- The Backend (Node.js): A webhook receives the SMS, parses the compressed string (e.g., ID:123|HR:95|O2:92), and updates our MongoDB database, instantly reflecting on the hospital's React dashboard.
4. The Code: Sending Vitals Offline
Instead of sending heavy JSON objects, we format the data into a strict string structure. Here is a simplified version of our Node.js webhook controller that handles the incoming SMS data:
// Express route handling incoming SMS from the cellular gateway
app.post('/api/sms-webhook', async (req, res) => {
try {
const incomingText = req.body.Body; // Example: "ID:101|HR:110|BP:120/80|O2:94"
const senderPhone = req.body.From;
// Parse the compressed SMS string
const vitalsData = incomingText.split('|');
const patientData = {
patientId: vitalsData[0].split(':')[1],
heartRate: vitalsData[1].split(':')[1],
bloodPressure: vitalsData[2].split(':')[1],
spO2: vitalsData[3].split(':')[1],
timestamp: new Date()
};
// Save to MongoDB
await PatientVitals.create(patientData);
// Alert the React Dashboard via WebSockets
io.emit('emergency_vital_update', patientData);
res.status(200).send('<Response></Response>'); // Acknowledge receipt
} catch (error) {
console.error("Failed to parse fallback SMS", error);
res.status(500).send("Error");
}
});
5. Future Scope: Hardware Mesh Networks
While the 2G SMS fallback is a solid software approach, what happens if the cellular towers completely fall? During our hackathon presentation, the judges asked us this exact question. Our next evolution for NalamMesh is integrating LoRa (Long Range) modules (like the ESP32 LoRa). This will allow ambulances to transmit vitals using pure radio frequencies to a localized hospital receiver, creating a true, 100% zero-connectivity hardware mesh network.
Conclusion
Building tech for disaster management forces you to unlearn modern conveniences. It teaches you that sometimes, a 30-year-old technology like SMS is more reliable than a cutting-edge 5G WebRTC stream. As developers, we need to build for the worst-case scenario, because in healthcare, a loading spinner can cost lives.
Top comments (0)