I have a Timer Swing of 15 seconds, which sends packets through my Coordinator API (XBee S2) to up to 20 Routers AT. And I am receiving all my packets through a SerialPortEvent (I'm using RXTXcomm.jar library), every packet I received I store in a Buffer ArrayList. Are they two different threads? I still have the main GUI going on.
So, my question is: what the best way to send and receive packet to/from multiple XBee modules? I think about two alternatives, make a for-loop to send unicast packet to every module (up to 20), after that, verifying my buffer receptor if I get any response. I currently using this approach, but sometimes I lose packets, maybe because XBee is halfduplex and I am receiving at same time of sending?
The another alternative is send a unicast packet and wait a response for each one. In that case, what would be the timeout response I should wait in order to not delay my timer swing (15 seconds). Should I increase this 15 seconds?
EDIT:
My current timeout is 300 ms for the ACK and 450 ms for the response