3About the presenter (Leonardo) Software Development Manager at V2COM, leading the development of both embedded software for edge/field devices and server-side software that receives field data and enables fast communication with remote devices.Eight years of development and architectural experience on mobile, embedded and server platforms to enable management and operation of highly scalable and fast telemetry and network control systems.
4About the presenter (Tiago) Lead Software Developer for Embedded at V2COM, leading the development of embedded software for edge/field devices.Six years of development and architectural experience on embedded Java platforms, building reliable communication devices that stays on the field for years.
5About the presentation Explore how to build reliable remote communication devices that must stay online, connected, and transmitting field data without interruptions. Using Java ME, a solid foundation was built that can be used to deploy many kinds of applications in the field, with fast, reliable development. In this session, see what the difficulties, ideas, and insights were that led to this foundation, which is currently in use in more than 50,000 devices in Brazil and Latin America to connect more than 800,000 field devices.
6V2COM is a leading Latin American provider of Smart Grid technologies and Advanced Metering Infrastructure (AMI). Our offer includes hardware, software and services that can reduce losses and increase water and energy efficiency, currently connecting more than devices.Besides the economic gains for our customers, we develop technologies with significant impact on the environment (avoiding losses of important natural resources) and with social responsibility (our Smart Grid systems can be used to offer free internet access in challenging areas)
7Awarded 2013 Java Business Innovation Award JCP member, nominated for EC electionMore interaction with community to foster Java ME development in this age of IoT!
10Intelligenceware Suite Legacy SystemsIntelligenceware SuiteWANTerminalLANDevicesIP NetworkWireless NetworkLocal Network
11Use cases Automated Meter Reading (AMR) Network control Read “dumb meters” and send data over to UtilityBoth energy and water metersCan be any meter, really!Like our Zigbier refrigerator’s temperature sensor, with alarms for too cold or hot!Network controlRemotely connect SCADA systems to field devices like reclosures“transparent pipe” between SCADA and DeviceDNP3/IEC104 protocols and proprietary as well
13The techonology used Gateway: Oracle Java Micro Edition 1 (Java profile IMP-NG version 2 & CLDC 1.1 Hl), embedded in a Gemalto TC65i module.Started with Siemens TC45, 6 years ago!Intelligenceware Suite:Oracle Java Enterprise Edition 5Oracle Java Standard Edition 6Oracle Utilities Meter Data Management 2.0
15The 3 commandments“If the device has a power from source, it must be on”Our first commandment is to keep the device always on.If it can be on, it must be on, no matter what.“The firmware must be remotely upgradable”One of few certainties in software developments is that bugs always happen!So, we must be able to OTAP (over-the-air provision) the device“If it’s on, it must be online and connected (or trying to be...)”It doesn’t suffice to be on. It must be also be avaiable so that communication can happen
16Hardware choices WatchDog Dual Sim Card Dual Serial Java ME One of the few always-must-have circuit for any device is a watchdog to turn it on in case it turns off or there’s a lock-upDual Sim CardGPRS infrastructure is not very reliable, so it should be able to have option in case of carrier failureDual SerialMany field devices have two serial ports, so being able to connect to both at the same time is very importantJava MEBeing able to run Java ME allows many advantages over C
17Software choices - Separation of concerns “Hardcore”Abstracts board specifics details (like GPIO)“Zion”Handles common infrastructure (backend connection, message queues, locks and so on)Abstracts Modem commands, so there’s one for each avaiable module (Cinterion/Gemalto; Motorola; Telit)“App”Holds application logic - As tailored as clients need it to beRanges from a simple Transparent (TN) to Automated Meter Reading (AMR)
23How to keep the device on? Problem:Module can throw Exceptions (EXIT CODEs) that shuts down the applicationSolution:Hardware Watchdog!Dedicated QG8 to handle only this (power on/off)10 minutes timeout: either the firmware “swings” the GPIO, or it gets powered off then onMany other software watchdogs...Many other conditions can mean a “lock up”
24How to keep the device online? Problem:GPRS connections can be unstable, specially when needed most: thunderstorms and harsh weather conditionSolution:Dual-SIM cards, so if a network fails, there can be anotherMany soft watchdogs to retry attachmentsTurn on/off modem, like our phonesAttach/Deattach
25How to get behind public APN firewall? Problem:Can’t use a server socket while communicating on public networks!Solutions:Device polls server, asking for new commandsThis doesn’t work for always-on connection needsExpensive on resourcesSoftware Switch (server side)!Meet-in-the-middle approach
26How to keep the TCP connection up? Problem:You don’t know the connection is broken until you have a blocking read() or write()TCP keep-alive is not enoughNo module support for this...Solution:Keep-Alive packetsApplication-level bytes sent to make sure connection is not off
27How to keep the firmware updated? Problem:There are MANY devices deployed, each with a software versionNo one wants to mass-deploy...Not all updates are required for all devicesSolution:Axon has control of each versionUpdates are dispatched as needed and/or cleared by client
28How to debug in-device? Problem: Solution: No simple logging framework to write log toLog redirection works for serial port only, not remote connectionsSolution:Built a simple logging framework that handles debug level, message, threads
29How to debug off-device? Problem:How can we run/test outside the framework?Many classes you depend on are hardware specific (Files, Connections)Solution:Built a simple “java abstraction layer” that implements javax.microedition classes (and proprietary ones too) that runs on Java SE on the desktop.
30How to keep historical, debugging info? Problem:No long-term storage on devices to keep logsFlash memory can hold at most 30 minutes of logsThe logs you need are the ones when device is unreachable, but alas, you can’t download it.Solution:Have a “black box” flight recorderSmall, coded files that can hold critical information for weeks
31How to synchronize access to resources? Problem:Access to system resources must be synchronizedSerial device, system filessynchronized can lead to unknown lock upsSome race conditions hard to track ando also some bugs...Solution:Custom implementation of Java SE’s LockReentrantLock inspiredAdded few methods for conveniencetryLock, so that you lock if you can, but don’t fail if you can’tfastLock, for locks that should last than 2 secods
32How to default parameters? Problem:Same firmware for different clients with different needs, lots of parametersParameters for APN, Serial, Timings and suchFlash memory can get corrupt and you lose your parameter files!Solution:Use JAD parametersJAD can be custom tailored to each clientCan provide good defaults
33Pending challenges...... because you can’t win them all...
34Many pain points are still there Make smaller binary fragments?And small updates over the air.Run multiple applications at the same time?More “permanent” and/or remote loggingSecurity issuesBetter management of keysAnti-tampering measures
36Java ME 8 has much new features! Java ME 8 seems to have addressed some, if not most, this problems and abstractionsDevice I/OAccess PointNIO... And many others!Some still need worksNo concurrency support might mean no locks...We’ll work with JSRs to try and address the rest of themV2COM is joining the JCP EC to help foster Java ME evolution