ATCommand class instance is not in transparent data mode | Telit Cinterion IoT Developer Community
September 14, 2016 - 10:53am, 1950 views
I long as I need to make a data call I have to open an instance of ATCommand in transparent mode.
I'm using SynchronizedAtCommand class to manage the variable but I'm still having some problems.
I know that the link between the Java code and the board persist even after the java program is terminated. That's a problem if you are in transparent mode because there won't be chanel available if any exception occurs and you try to instantiate a new one.
Is there any way to manage this?
In this case I'm forced to have an instance of ATCommand in transparent mode because it's imposible to switch modes as I tested in this code:
public void testATCommands(){ // try with "true" and "false"
ATCommand atc_instance = new ATCommand(true); System.out.println("atc_instance = "+atc_instance); if(!atc_instance.csdSupported()){ System.out.println("Not CSD supported"); try { System.out.println("atc_instance.setDTR(true)"); atc_instance.setDTR(true); } catch (IOException e) { e.printStackTrace(); } }else { System.out.println("CDS supported"); } if(!atc_instance.csdSupported()){ System.out.println("Still not supported"); } System.out.println("atc_instance.breakConnection();"); atc_instance.breakConnection(); if(!atc_instance.csdSupported()){ System.out.println("Not CDS supported"); }else { System.out.println("CDS supported"); } }
Hello,
I'm not sure if I understand your problem correctly. In the code you try to create the ATCommand instance with CSD support (true) ons without CSD support (false). To make a data call you need the instance with CSD support.
To get into the transparent data mode after establishing the connection you need to open the data streams with getDataOutputStream() and getDataInputStream(). You should ****** that the streams are closed and instance released if not needed any more or in case of exception - it should be done in the finally block. In case the MIDlet is stopped it should also release the resources as the virtual machine is still working.
There are limited number of available ATCommand class instances and as I remember there is probably only one available with CSD support.
Because of Java garbage collection mechanism the released instance may not be yet available just after it was released. Garbage collection is managed by VM and it may take some time.
Regards,
Bartłomiej