Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Unable To Auto Identify Port For Connecting To The Meter.

Unable to auto identify port for connecting to the meter.

By saraf_kshitiz , 20 December, 2024
Forums
Gurux DLMS for Android

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

Profile picture for user Kurumi

Kurumi

1 year 5 months ago

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

saraf_kshitiz

1 year 5 months ago

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

Profile picture for user Kurumi

Kurumi

1 year 5 months ago

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

saraf_kshitiz

1 year 5 months ago

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

Profile picture for user Kurumi

Kurumi

1 year 5 months ago

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

saraf_kshitiz

1 year 5 months ago

Ok sir, thanks.

Ok sir, thanks.

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin