Hi Mikko Kurumi Sir,
A big thanks for your continued support, with your help, we are able to develop a DLMS mobile app.
I was trying to automate the process of connecting to the meter, and here I got stuck from the past few days.
For making an association, I am setting the following keys, some in MainActivity.java and some in MainFragment.java :-
// In MainActivity.java
mDevice.setManufacturer(intent.getString("manufacturer"));
GXAuthentication gxAuthentication = new GXAuthentication();
gxAuthentication.setType(Authentication.HIGH);
mDevice.setAuthentication(gxAuthentication);
mDevice.setClientAddress(48);
mDevice.setPassword(intent.getString("passwordHLS"));
mDevice.setSecurity(getSecurity(intent));
mDevice.setSystemTitle(intent.getString("systemTitle"));
mDevice.setAuthenticationKey(intent.getString("authKey"));
mDevice.setBlockCipherKey(intent.getString("encryptKey"));
mDevice.setInvocationCounter("0.0.43.1.3.255");
// In MainFragment.java
mClient.setAuthentication(mDevice.getAuthentication().getType());
mClient.setPassword(mDevice.getPassword().getBytes(getString(R.string.ascii)));
mClient.getCiphering().setSecurity(mDevice.getSecurity());
mClient.getCiphering().setSystemTitle(mDevice.getSystemTitle().getBytes(getString(R.string.ascii)));
mClient.getCiphering().setAuthenticationKey(mDevice.getAuthenticationKey().getBytes(getString(R.string.ascii)));
mClient.getCiphering().setBlockCipherKey(mDevice.getBlockCipherKey().getBytes(getString(R.string.ascii)));
if (prefs.getLong("invocationCounter", Integer.MIN_VALUE) > 0)
mClient.getCiphering().setInvocationCounter(prefs.getLong("invocationCounter", 0) + 100);
saveSettings();
But, I'm not able to set the port inside the code, for this, I have to manually open the "Media Settings" inside the app.
Is there any way to automate this, set the media port inside the code only, so that user does not have to navigate to the MediaFragment?
Will be waiting for a response.
Thanks,
Kshitiz Saraf
Hi, You can select the…
Hi,
You can select the default port like this:
GXSerial serial = (GXSerial)mDevice.getMedia();
if (serial.getPorts().length != 0){
serial.setPort(serial.getPorts()[0]);
}
BR,
Mikko
Hi Mikko Kurumi Sir, Thanks…
Hi Mikko Kurumi Sir,
Thanks for the code, it is working fine.
One more thing, there is a popup inside the app for allowing the UART cable. User have to click on OK on that dialog.
Is there something we can do to automate that too?
Thanks,
Kshitiz
Hi Kshitiz, Android asks the…
Hi Kshitiz,
Android asks the access rights once and if you accept them they are not asked after that. If your application asks them every time I believe you are using an unknown serial port manufacturer. What Vendor ID and Product ID your serial port is using? You can see them if you press the Info button.
BR,
Mikko
Hello Mikko Kurumi Sir, The…
Hello Mikko Kurumi Sir,
The app asks for the permission to use UART cable everytime the cable is reconnected to the device.
The details you asked for are as follows :-
Manufacturer info: FTDI: FT230X Basic UART
Vendor: Future Technology Devices International, Ltd ID: 403
Product: Bridge(I2C/SPI/UART/FIFO) ID: 6015
Thanks,
Kshitiz
Hello Mr. Kshitiz Saraf, Get…
Hello Mr. Kshitiz Saraf,
Get the latest version from Github or use version 2.0.9. Support for new USB to serial port converters is added and Future Technology Devices International, Ltd is part of them. The access rights are asked only once.
BR,
Mikko
Ok sir, thanks.
Ok sir, thanks.