io-manager-device-net
v0.0.125
Published
Network communication module for WBM IO Manager devices running on Raspberry Pi. Handles device discovery, real-time I/O control, and firmware management over TCP/UDP protocols.
Maintainers
Readme
WBM IO Manager Device Network
Network communication module for managing WBM IO devices on Raspberry Pi systems. Handles device discovery, real-time I/O control, and firmware management over TCP/UDP protocols.
Overview
This module provides a complete solution for managing custom PCB hardware devices over Ethernet networks. It's designed to run on Raspberry Pi systems and communicates with WBM devices using proprietary protocols.
Key Features
- Device Discovery: Automatic detection of devices on the network
- Real-time I/O: Control outputs and receive input events instantly
- Firmware Management: Upload and manage device firmware
- Health Monitoring: Continuous device status tracking
- Multi-device Support: Manage multiple devices simultaneously
- Ownership Management: Prevent conflicts between multiple IO Manager instances
Architecture
┌─────────────────┐ UDP Broadcast ┌─────────────────┐
│ Raspberry Pi │ ──────────────────► │ WBM Devices │
│ IO Manager │ │ (PCB Hardware) │
│ │ ◄────────────────── │ │
└─────────────────┘ TCP Commands └─────────────────┘Network Protocols
- UDP Port 41234: Device discovery broadcasts
- TCP Port 11420: Device command interface
- TCP Port 11421: Device event reporting
Supported Device Types
- Alarm Panels
- I/O Boards
- MIDI Controllers
- Custom PCB devices with WBM firmware
Installation
npm install io-manager-device-netSystem Requirements
- OS: Linux (Raspberry Pi OS recommended)
- Node.js: >= 18.0.0
- Network: Ethernet interface (eth0)
- Hardware: Raspberry Pi with Ethernet connectivity
Quick Start
import ioManager, {
getAvailableDevices,
takeOwnership,
addSystemDevice
} from 'io-manager-device-net';
// Listen for input events from devices
ioManager.on('inputEvent', (event) => {
console.log('Input received:', event);
});
// Discover available devices
getAvailableDevices();
// Listen for discovered devices
ioManager.on('availableDevices', async (devices) => {
for (const device of devices) {
// Take ownership and add to system
await takeOwnership(device.address);
// Add device configuration...
}
});Device Discovery
The system uses UDP broadcasts to discover devices:
import { getAvailableDevices, getIOManagerDevices } from 'io-manager-device-net';
// Find unclaimed devices
getAvailableDevices();
// Find devices already managed by other IO Manager instances
getIOManagerDevices();Device Management
Adding Devices
import { addSystemDevice, getAllInfo } from 'io-manager-device-net';
// Get complete device information
const deviceInfo = await getAllInfo('192.168.1.100');
// Add device to system management
addSystemDevice(
deviceConfig,
updateCallback,
currentFirmware,
sendOutputsCallback
);Device Status Monitoring
// Monitor device status changes
ioManager.on('deviceStatusChange', ({ deviceId, status }) => {
console.log(`Device ${deviceId} is now ${status}`);
});
// Get system-wide device status
ioManager.on('systemDeviceStatus', (devices) => {
devices.forEach(dev => {
console.log(`${dev.serialNumber}: ${dev.status}`);
});
});I/O Operations
Controlling Outputs
import { sendOutputEvent, sendMidiOutputEvent, setLeds } from 'io-manager-device-net';
// Control digital/analog outputs
await sendOutputEvent('192.168.1.100', 5, 255);
// Send MIDI data
await sendMidiOutputEvent('192.168.1.100', 'midiOut1', [0x90, 0x40, 0x7F]);
// Control LED brightness
await setLeds('192.168.1.100', [
{ led: 0, brightness: 128 },
{ led: 1, brightness: 255 }
]);Receiving Input Events
// Handle all input types
ioManager.on('inputEvent', (event) => {
switch (event.devInputType) {
case 'buttons':
console.log(`Button ${event.inputName}: ${event.value}`);
break;
case 'midiIns':
console.log(`MIDI: ${event.midiMessage}`);
break;
case 'variableInputs':
console.log(`Sensor ${event.inputName}: ${event.value}`);
break;
}
});Firmware Management
import { Device } from 'io-manager-device-net';
// Upload firmware to device
const device = new Device(config);
await device.updateFirmware('/path/to/firmware.bin');
// Monitor upload progress
ioManager.on('deviceUploadProgress', ({ deviceId, state, progress }) => {
console.log(`${deviceId}: ${state} ${progress}%`);
});Configuration
Network Setup
The module automatically detects network configuration from the Raspberry Pi's eth0 interface:
import { updateLocalNetInfo, broadcastSting } from 'io-manager-device-net';
// Refresh network information
updateLocalNetInfo();
// Get current broadcast address
const broadcast = broadcastSting();Device Configuration
Devices support various I/O types defined in their hardware definitions:
interface DeviceDefs {
buttons?: DeviceChannel[]; // Digital inputs
variableInputs?: DeviceChannel[]; // Analog inputs
gpos?: DeviceChannel[]; // Digital outputs
variableOutputs?: DeviceChannel[]; // Analog outputs
leds?: LedDef[]; // LED outputs
midiIns?: { n: string }[]; // MIDI inputs
midiOuts?: { n: string }[]; // MIDI outputs
rs232ios?: { n: string }[]; // Serial ports
}Error Handling
The module provides comprehensive error handling:
try {
await sendOutputEvent('192.168.1.100', 1, 255);
} catch (error) {
console.error('Output command failed:', error.message);
}
// Network errors are logged but don't crash the system
ioManager.on('notify', ({ type, dev }) => {
if (type === 'MISSING') {
console.log(`Device ${dev.name} went offline`);
}
});Development
Building
npm run buildDevelopment Mode
npm run devProject Structure
src/
├── index.ts # Main module and device management
├── tcp.ts # TCP communication and protocols
├── udp.ts # UDP device discovery
├── device.ts # Device class and lifecycle management
└── types/ # TypeScript type definitionsProtocol Reference
WBM Commands
| Command | Purpose | Response |
|---------|---------|----------|
| WBM:AREYOUAVAILABLE | Device discovery | IAMAVAILABLE |
| WBM:YOUARENOWMINE | Take ownership | IAMYOURS |
| WBM:OUTPUTEVENT | Control outputs | GOTIT |
| WBM:MIDIOUTPUTEVENT | Send MIDI | GOTIT |
| WBM:getInfo | Get device info | Device details |
| WBM:getDefs | Get capabilities | I/O definitions |
Event Types
inputEvent: Real-time input data from devicesavailableDevices: List of discoverable devicesdeviceStatusChange: Individual device status updatessystemDeviceStatus: System-wide device healthdeviceUploadProgress: Firmware upload progress
Troubleshooting
Common Issues
Device not discovered
- Check network connectivity
- Verify device is powered and on same subnet
- Ensure device firmware supports WBM protocol
Connection timeouts
- Check firewall settings on Raspberry Pi
- Verify TCP ports 11420/11421 are accessible
- Check device network configuration
Permission errors
- Ensure Node.js has network permissions
- Run with appropriate user privileges on Raspberry Pi
Debug Logging
Enable verbose logging to troubleshoot issues:
// All network communication is logged to console
// Check console output for protocol detailsLicense
MIT
Support
This module is designed for WBM hardware systems. For hardware-specific support, consult your WBM device documentation.
