Recommended Code For Factory Operations
Factory firmware is an essential part of the Electric Imp Connected Factory Process. It drives all of your devices in the factory: Devices Under Test (DUTs) on the assembly line and the imp-based BlinkUp™ fixtures that you use to prepare these DUTs for Electric Imp impCloud™ access.
Each of these types of device run their own, device-specific factory firmware: one for fixtures, another for DUTs. You develop factory firmware within impCentral™’s Test Zone in the code editor of a Test DUT Device Group (DUT firmware) and a Test Fixture Device Group (fixture firmware).
Note To minimize factory escapes — working and saleable production devices that are outside of your supply chain — it’s very important to ensure that your DUT firmware is not a version of your application firmware. A DUT that is removed from the factory should not be able to operate as a production device.
The listings that follows provide a complete suite of fixture firmware and DUT firmware that can be used as the basis for your own factory firmware. The code was written to run on the impFactory™ appliance, but can be readily adapted to your own BlinkUp fixture hardware, which should have a button that can be used by the operator to trigger BlinkUp when the fixture’s LED and a DUT are physically aligned, LED to photo-sensor, and ready for factory BlinkUp.
When the impFactory’s green button is pressed, BlinkUp will begin. The amber LED on the front of the impCentral will flash in time with the BlinkUp signal, which is delivered via the 3.5mm jack on the back of the impFactory, marked LED. This jack is intended to be used with an external LED.
The DUT firmware comprises device code and includes a placeholder (myTestFunction()) for your own test code. It also includes blessing code (see blessDeviceUnderTest()), which also performs some typical product set-up operations. The agent code receives messages from the device as the testing and blessing processes proceed, and relays the data they contain to a logging server and to the fixture.
The fixture firmware comprises device code which configures the impFactory for operation on the assembly line (see configureFactoryFixture()). This ensure that when the unit’s green button is pressed, the function blinkupTriggered() is called: this in turn calls the imp API method server.factoryblinkup() to perform factory BlinkUp on a fresh DUT.
The agent code not only relays operational data from the fixture to a logging server (you will need to enter a suitable URL and endpoint) but also establishes an API through which DUT agents report blessing information.