AssetTracker for Photon

I am glad you found a solution !! - the above is very true of not only photon but probably "all things". What many don't know is that there are other things that happen outside of the loop to keep things working - Loop is really where you should call lots of things from and try and make sure none of them block for significant periods while "waiting for stuff" - as you so rightly say, a state machine is a great way to do this - or even a few timers that call functions periodically and then return!