SIP-based lamp
Overview
I have designed and built a SIP device that lights a lamp when called by phone.
This device was specifically created for a local hardware store. Because they offer timber cutting services, employees are operating a vertical panel saw - which is very loud and calls on their portable phone go overheard.
This led to missed calls and I have been asked to find a solution - with a budget of CHF 100. The project aimed at providing a (dust-proof) visual indicator whenever the portable phone rings, so the operator could hear it even in noisy areas.
The device was built using a Raspberry Pi 1 and a relay shield. Coding of a custom-made SIP-stack and the service was done in Go.
Details
The company I worked for operated a Cisco based telephony system. The only SIP-based devices were just too expensive.
Technically, an analog device could have been purchased and combined with an ATA device. They’re designed to attach legacy, analog devices (e.g. phones, fax) to a SIP-based PBX like Cisco Unified Communications Manager .
But creating a new service based on an out-of-date technology was not an option. Hence, I decided to design it myself.
Technical stuff
Hardware
The hardware had to be cheap, but dust-proof and comply with electrical regulations.
I ended up placing a Raspberry Pi 1 single board computer in an electrical box and attaching a Relay shield (4 channels to potentially allow future expansion) to it using the provided GPIO pins.
As the light indicator was based on a 230V powered garden light, a high-voltage connection was needed in the box anyway. Therefore, it could be used to power the board as well using an USB power cable.
Software
Some software was needed to use the relay shield whenever a call comes in. Besides Linux as an operating system, some more components were required. I always wanted to play around with Google’s fairly new Go programming language. The device was built and tested for Cisco CallManager 8.6.2 but could be connected to any SIP-based PBX.
SIP Stack
At the time, no proper SIP stack existed for Go, I had to build the necessary parts on my own. The resulting library is far away from complete, but handles call setup and call teardown very reliably. Usage is fairly simple:
// Register:
s = sip.CreateClient()
s.SetDefaultTransport(appconfig.Transport)
r := sip.RegisterInfo{
sip.Connectinfo{
appconfig.Transport,
appconfig.ProxyIP,
appconfig.ProxyPort,
},
sip.Connectinfo{
appconfig.Transport,
GetOutboundIP(proxyIP),
appconfig.LocalPort,
},
appconfig.Phonenumber,
sip.DigestUserInfo(
appconfig.Username,
appconfig.Password
),
0,
}
// Accept calls:
s.OnIncomingCall(func(call *sip.Call) {
log.Println("Incoming Call")
})
s.OnCancel(func(call *sip.Call) {
log.Println("Cancel existing call")
})
The library is open-source (free for everyone to use) and can be found on a Github repository. Also, the application code is on another one found here.
Configuration
The configuration is done using a JSON file, an example can be found in the repository.
In Cisco Unified Communications Manager, the device is configured as Third-Party SIP Device (Basic), attached to the actual portable phone using a Shared Line. Also, a Digest User needs to be created and added to the device.
OpenSSH server was enabled in order to be able to remotely configure / update the device. In theory, a web UI could be added to facilitate mass-rollout.