XBee network: how to add a new XBee Router/End Device in an existing network

Hi everybody,

This is my context:

  • 1 XBee coordinator in the apartment #1 with PAN ID=1234
  • 1 XBee coordinator in another apartment #2 with PAN ID = 5678
  • ...

I want to add my XBee router in apartment #1. There is no initial configuration on XBee about PAN ID (= default value, for example "1").

So, how can be sure that my XBee router will connect to my XBee coordinator in the same apartment and not in another one ? What is the mechanism (sequence) to develop in my router to configure automatically the correct PAN ID according the PAN ID of the correct coordinator ?

Thank you for your help !

Anthony