libgnokii example: gnobatmon - read battery level
This is the second version of small program which continuously reads battery level from the phone and executes a script when it changes.
I first wrote this program to draw a graph of battery discharge over time, but since the FBUS protocol has only 5 levels (0, 1, 2 ,3 and 4 which this program converts to 0, 25, 50, 75 and 100) it turned out pretty dull; the AT driver supports 101 levels (0 to 100) so it could produce a more interesting graph, if phone firmware supports more than 5 levels, that is. This program outputs
-1 when battery level can't be read.