Hello.
We provide support for Our devices and software that is developed by Us. And as far as this question goes It sounds You should look for recommendations on how to program it on forums that have active programmers that can share their tips.
But the logic that should be used in solving the issue is that there are 2 devices with IMEIs and You simply need to associate them with 1 object. TSM232 should not go as a completely separate object in Your server. Because all the data received was still gathered by FMx640 and it just was forwarded by TSM232 as FMx640 had no means of sending it to the server.
So I hope it helps and best of luck to You in Your developments.
Regards.