Best practice to generate unique systemPort value for parallel test execution

Hello @SankalpSharmaSDET, @Zeuge

Were you able to achieve the execution as expected ?
Currently I am trying the same but I am not able to use system port cap as it should.

Could you please help me it ?
Here is what I have tried and my functions and code that I am using.

For now , I am able to initiate app on both the device but the test case execution starts on only one and then ends giving Session ID null error.

Details for what I have tried

Thanking you in advance.