I’ve been doing Xbees for a couple of years now and have had more than a few communications with Digi’s engineers.
API mode with escapes is HIGHLY recommended for anything beyond just setting things up once by hand and then using it as a wireless serial port in transparent mode.
If you are sending data and AT commands at run time, you definitely need API mode.
And yes, use API mode 2! Escapes will save your butt ( ask me how I know )
I just looked at the XBee code online and it looks pretty good at first glance. At least it uses API mode.
There are somethings I didn’t see that I do, disabling sending data until AP returns associated, reseting the Xbee when it stops responding and depending on the XBee, switching from transparent mode to API mode.
But that could be considered Application specific