Skip to content

Commit

Permalink
[all] coaps URI bugfix; log fix to avoid Californium library logs to …
Browse files Browse the repository at this point in the history
…show up always; code formatting.
  • Loading branch information
EskoDijk committed Jun 27, 2024
1 parent 9d64169 commit c9f693f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/google/openthread/LoggerInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,7 @@ public static void Init(boolean verbose) {
break;
}
}

((Logger)LoggerFactory.getLogger(CALIFORNIUM)).setLevel(levelLibrary);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static OtRegistrarConfig DefaultPledge() {
config.domainName = null;
config.keyStoreFile = "./credentials/default_pledge.p12";
config.masaUri = null;
config.registrarUri = "localhost:5684";
config.registrarUri = "coaps://localhost:5684";
config.logVerbose = false;
return config;
}
Expand Down
23 changes: 12 additions & 11 deletions src/main/java/com/google/openthread/pledge/PledgeException.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,32 @@
public class PledgeException extends Exception {

/**
* An optional CoAP response code, from a CoAP response, that was unexpected or related to the
* exception.
* An optional CoAP response code, from a CoAP response, that was unexpected or related to the exception.
*/
public ResponseCode code = null;

/** An optional CoAP diagnostic message, from a CoAP response, to clarify what went wrong. */
/**
* An optional CoAP diagnostic message, from a CoAP response, to clarify what went wrong.
*/
public String diagMsg = null;

public PledgeException(String msg) {
this(msg, null, null);
}

public PledgeException(String msg, CoapResponse resp) {
super(
msg
+ ((resp.getCode() != null) ? (" (" + resp.getCode().toString() + ")") : "")
+ ((resp.getCode() != null && resp.getPayload() != null)
? (" - CoAP diagnostic: '" + new String(resp.getPayload()) + "'")
: ""));
super(msg + ((resp.getCode() != null) ? (" (" + resp.getCode().toString() + ")") : "")
+ ((resp.getCode() != null && resp.getPayload() != null)
? (" - CoAP diagnostic: '" + new String(resp.getPayload()) + "'") : ""));
this.code = resp.getCode();
if (!ResponseCode.isSuccess(this.code) && resp.getPayload() != null)
if (!ResponseCode.isSuccess(this.code) && resp.getPayload() != null) {
this.diagMsg = new String(resp.getPayload());
}
}

public PledgeException(String msg, ResponseCode coapCode, String coapDiagnosticMsg) {}
public PledgeException(String msg, ResponseCode coapCode, String coapDiagnosticMsg) {
// FIXME
}

private static final long serialVersionUID = -1980574489782019605L;
}
3 changes: 2 additions & 1 deletion src/main/java/com/google/openthread/pledge/PledgeMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ private static void runCli(Pledge pledge) {

System.out.println("Done");
} catch (Exception e) {
logger.error("error: {}", e.getMessage(), e);
logger.error("error: {}", e.getMessage());
logger.debug("details:", e);
}
}
}
Expand Down

0 comments on commit c9f693f

Please sign in to comment.