Phidget Network Server
General Overview
The Phidget WebService is a background process that broadcasts all events and data from a USB Phidget over the network:
It uses link local addressing which allows you to use simple server names in your code. The link local addressing is provided by the programs Bonjour, avahi, or mDNSResponder, depending on your system, and the correct program is either installed already or with the Phidget libraries.
You can listen to the Phidget data and control the Phidgets over the network using one or more computers. You can still use the Phidget on the computer it is directly connected to, just by using a remote version of the open()
call in your local code:
File:Webservice general pctopc.png
Since Phidgets supports many operating systems, the listening and controlling computer doesn't have to be a computer.... it could be an Android phone or an iOS iPhone/iPad:
File:Webservice general pctoandroid.png
The WebService runs on a local network. It is relatively durable because it uses link local addressing, which - depending on your operating system and router settings - will often work in the absence of DHCP. Link local addressing will often persist even when access to the global Internet fails or is not available.
WebService on the Phidget Single Board Computer
The Phidget Single Board Computer (SBC) can provide a compact, inexpensive way to easily run the WebService. It runs the WebService in the background automatically from the moment you turn it on, and allows you to read from and control all Phidgets attached to it:
This can allow for a compact, mobile-based system like this:
File:Webservice general sbctoandroid.png
The SBC runs Linux, which provides a full operating system on which to develop code, serve web pages, and control Phidgets.
Using The Network Service
Each Operating System page has a section on how to use the Network Service on that operating system:
The operating systems pages have complete examples on how to set up a network service process and using it to remotely control or gather data from Phidgets. The pages also tell you how to start and stop the Network Service on your computer, and how to run it with or without mDNS (Bonjour, avahi, etc).
Examples
Below are some quick examples showing how simple it is to open a Phidget remotely over the Network Service:
C/C++
Phidget_setDeviceSerialNumber((PhidgetHandle) device, 37299);
Phidget_setIsRemote((PhidgetHandle) device, 1);
Phidget_open((PhidgetHandle) device);
CPhidget_openRemoteIP ((CPhidgetHandle) device, serial_number, "127.0.0.1", 5001, NULL);
C#
Java
Python
Troubleshooting
When using the Network Service, both the client and server should have the same version of the Network Service installed. The easiest way to ensure this is to update your libraries on both ends.
For other troubleshooting tips, try our General Troubleshooting page, in its Network Service section.