Fixes C Examples & Add Timeout Support

I was using this on my device a few days ago and I ended up tidying up a few things on my local copy.
This resolves some issues with device timeouts and much better (IMHO) errors are printed out when something stupid is done at connection time. The issue with multiple valid device ids is not fixed here, though it looks like that was solved some time ago in the python version.

Thanks for the effort put into getting this driver working in the first place.
Why the indentation changes here? In particular, why align a declaration with the start of a code block? Not sure if the changes were deliberate or not, but please keep style in line with the rest of the codebase.