Troubleshooting

As the last topic for the thing program, let us review how to troubleshoot when you encounter problems.

The Thing-IF SDK allows you to log internal information generated when each function is executed. You can select from various output destinations other than the console because you can choose any logging functions to implement in the user program. The reference implementation for Linux uses vfprintf() so that the log is output to the console.

Adjust the logger_cb_impl function if you want to change the log destination of the reference implementation.

By default, logging is disabled. To enable logging, run make with the DEBUG symbol when you build the Thing-IF SDK.

$ make DEBUG=1

By incorporating the built libkiithingifsdk.so to Hello Thing-IF, you can get internal information as below.

file:kii/kii-core/kii_core.c, line:466 request: POST https://api-jp.kii.com/thing-if/apps/11111111/onboardings HTTP/1.1
host:api-jp.kii.com
x-kii-appid:11111111
x-kii-appkey:22222222222222222222222222222222
x-kii-sdk:sn=tic;sv=0.9.1
content-type:application/vnd.kii.OnboardingWithVendorThingIDByThing+json
authorization:bearer TL7PVlCO8ny_U2kEEq2j1Wk7wOCjvu3VTlAC4lsWqg
content-length:106

{"vendorThingID":"1111","thingPassword":"DEF456","thingType":"HelloThingIF-SmartLED","thingProperties":{}}
file:kii/kii-core/kii_core.c, line:147 socket state: 0
file:kii/kii-core/kii_core.c, line:147 socket state: 1
file:kii/kii-core/kii_core.c, line:147 socket state: 2
file:kii/kii-core/kii_core.c, line:147 socket state: 2
file:kii/kii-core/kii_core.c, line:147 socket state: 3
file:kii/kii-core/kii_core.c, line:147 socket state: 3
file:kii/kii-core/kii_core.c, line:147 socket state: 3
file:kii/kii-core/kii_core.c, line:147 socket state: 3
file:kii/kii-core/kii_core.c, line:147 socket state: 4
file:kii/kii-core/kii_core.c, line:474 response core: 200, response body: {
  "accessToken" : "eeHHSmFfZ_reK0gY2E6b87maVph_YRaTyws5pENTQG0",
  "thingID" : "th.727f20a0a022-ee1a-61b1-1f82-0a8c8aeb",
  "mqttEndpoint" : {
    "installationID" : "apm83n9esjgab9tpx95wvwtxb",
    "username" : "11111111-NA6uA7OiaOtEC0Jr52xIl4a",
    "password" : "HjCanzgoIIJuazawzTWlkVOzdkNSBcOtnFBLFyMopjzIkuHvSmhOvLJiRmdHJqub",
    "mqttTopic" : "piGkFeBEjaxNBZOocPMzNL3",
    "host" : "jp-mqtt-13915c439c5e.kii.com",
    "portTCP" : 1883,
    "portSSL" : 8883,
    "portWS" : 12470,
    "portWSS" : 12473,
    "ttl" : 2147483647
  }
}

The logged information includes the execution position with the source file name, line number, and detailed information.

See the source directory used to build the Thing-IF SDK for the source file. You can directly check what is executed in the SDK because the Thing-IF SDK is open source.

The debug information includes requests and responses for network access. Such requests and responses are based on the REST API specification of the Thing-IF SDK. For example, the logged information above follows the REST API specification of onboarding.

If you get any unknown error from the thing program, debug it by checking the detail with this logging feature.


What's Next?

To wrap up the tutorial, let us review some hints for the next step.

Go to Hints for the Next Step.