error: 'ping' was not declared in this scope

t would be nice to be able to step through the code

You've got debug prints; what do they tell you?