CSharpTradFriLibrary icon indicating copy to clipboard operation
CSharpTradFriLibrary copied to clipboard

[BUG] - GenerateAppSecret is not working

Open gkapellmann opened this issue 1 year ago • 1 comments

Describe the bug For some reason, when I run these three lines:

string applicationName = "UnitTestApp";
TradfriController controller = new TradfriController("HomeTradfri", "10.0.0.16");

var appSecret = await controller.GenerateAppSecret("**************", applicationName);

I get a "Object null" exception in "GenerateAppSecret", but the exception doesnt give anything else of information.

Expected behavior I would expect to get a "TradfriAuth" object as an asnwer.

Screenshots

pic

gkapellmann avatar Dec 20 '24 02:12 gkapellmann

The problem is, the _coapClient is null.

I think the Problem sits here:

Class: TradfriController Method: GenerateAppSecret

Instead of: var ep = new DTLSClientEndPoint(authKey); ep.Start();

It should be:

        var ep = new DTLSClientEndPoint(authKey);
    (Implementation as CoapImplementation)._coapClient = new CoapClient(new Uri($"coaps://{_gatewayIp}"))
        {
            EndPoint = ep
        };
        ep.Start();

The equal code runs in ConnectAppKey and in ConnectPSK

Programmierhans avatar Apr 23 '25 07:04 Programmierhans