A Node.js server for managing remote BLE device connections with admin control capabilities.
- Multiple Connection Types: TCP and TLS support for both remote control and admin connections
- Device Management: Connect, monitor, and manage BLE devices
- Admin Commands: Interactive CLI to send commands to devices, list sessions, and manage connections
- Session Tracking: Track connected devices with uptime, firmware versions, and MAC addresses
- Node.js (v14+)
- OpenSSL (for certificate generation)
- Generate TLS certificates (required for TLS ports):
./generate-certs.shThis creates:
./tls/server.key- Private key./tls/server.crt- Self-signed certificate (valid 365 days)
- Start the server:
node remote-admin.js| Variable | Description | Default |
|---|---|---|
TLS_KEY_PATH |
Path to TLS private key | ./tls/server.key |
TLS_CERT_PATH |
Path to TLS certificate | ./tls/server.crt |
Example with custom paths:
TLS_KEY_PATH=/etc/ssl/private/server.key TLS_CERT_PATH=/etc/ssl/certs/server.crt node remote-admin.js| Port | Protocol | Purpose |
|---|---|---|
| 5000 | TCP | Remote control |
| 5001 | TCP | Admin interface |
| 5040 | TLS | Remote control (secure) |
| 5041 | TLS | Admin interface (secure) |
Connect to port 5001 (or 5041 for TLS) to access the admin interface.
| Command | Description |
|---|---|
ls [filter] |
List all connected devices (optional filter) |
cmd <id|mac> <command> |
Send command to device by ID or MAC |
cmdall <command> |
Send command to all connected devices |
drop <id> |
Drop connection by device ID |
# List all sessions
ls
# Filter sessions containing 'trace'
ls trace
# Send command to device with ID 0x3E8
cmd 3E8 SYS DUMP
# Send command by MAC address
cmd AA:BB:CC:DD:EE:FF SYS
# Send command to multiple devices
cmd 1001,1002,1003 SYS
# Broadcast command to all devices
cmdall sys debug
# Drop device with ID 1001
drop 1001- Decimal:
1001,2048 - Hexadecimal:
3E8,0x3E8(case-insensitive, A-F supported)
- With colons:
AA:BB:CC:DD:EE:FF - Without colons:
AABBCCDDEEFF - Comma-separated for multiple targets:
AA:BB:CC:DD:EE:FF,11:22:33:44:55:66
.
├── remote-admin.js # Main server script
├── remote-admin.test.js # Unit tests
├── remote-admin.spec.js # Integration tests
├── generate-certs.sh # Certificate generation script
├── tls/
│ ├── server.key # TLS private key (generated)
│ └── server.crt # TLS certificate (generated)
└── README.md # This file
Devices identify themselves by sending their MAC address. Upon connection:
- Server waits for device MAC address (5-second timeout)
- Valid device receives
SYSandSYS DBGcommands - Session is tracked with device info (firmware version, trace, etc.)
To modify configuration, edit the CONFIG object in remote-admin.js:
const CONFIG = {
PORTS: {
RC: 5000,
ADMIN: 5001,
RC_TLS: 5040,
ADMIN_TLS: 5041,
},
TIMEOUTS: {
LOGIN_VALIDATION: 5000, // ms
KEEP_ALIVE: 120 * 1000, // ms
},
// ...
};MIT