Hardcoding a fixed XBee PAN ID
From Digi Developer
Many customers wish to preload an XBee PAN ID to simplify installations where there may be multiple XBee networks in view. While XCTU can manually set a fixed PAN ID into an XBee, this value is lost if the XBee adapter is reset to 'factory', is reflashed to a new firmware, or the commissioning button is pressed four times. Once lost, the XBee may associate to the wrong gateway without manual intervention.
There is a simple way to force in a persistent PAN ID - this is especially useful for the XBee AIO and DIO adapters since XCTU cannot talk serially to them.
Save a profile for an "AT Router" firmware with your desired PAN ID added. The result is a text file - here is an example which sets the PAN Id to 9999
XB24-ZB_2270.mxi 80 0 251 2270 0 [A]ID=9999
The trick is to edit the file, changing the [A] to [D], so the .PRO file becomes:
XB24-ZB_2270.mxi 80 0 251 2270 0 [D]ID=9999
Once you load this profile and reprogram the XBee to AT Router firmware, then the PAN ID will always be 9999 (or as you specified). This survives a reflash to other firmwares such as the XBee AIO firmware.