http://mbed.org/users/eencae/code/N5110/#1af393359298