- // Initialize Wifi service
- wifi_error_e ret = wifi_initialize();
- if (WIFI_ERROR_NONE != ret)
- {
- OIC_LOG(ERROR, TAG, "wifi_initialize failed");
- return CA_STATUS_FAILED;
- }
-
- // Set callback for receiving state changes
- ret = wifi_set_device_state_changed_cb(CAWIFIDeviceStateChangedCb, NULL);
- if (WIFI_ERROR_NONE != ret)
- {
- OIC_LOG(ERROR, TAG, "wifi_set_device_state_changed_cb failed");
- return CA_STATUS_FAILED;
- }
-
- // Set callback for receiving connection state changes
- ret = wifi_set_connection_state_changed_cb(CAWIFIConnectionStateChangedCb, NULL);
- if (WIFI_ERROR_NONE != ret)
- {
- OIC_LOG(ERROR, TAG, "wifi_set_connection_state_changed_cb failed");
- return CA_STATUS_FAILED;
- }
+ // Initialize Wifi service.
+ if (WIFI_ERROR_NONE != wifi_initialize())
+ {
+ OIC_LOG(ERROR, TAG, "wifi_initialize failed");
+ }
+
+ // Initialize Connections.
+ connection_error_e ret = connection_create(&connection);
+ if (CONNECTION_ERROR_NONE != ret)
+ {
+ OIC_LOG(ERROR, TAG, "connection_create failed");
+ return CA_STATUS_FAILED;
+ }
+
+ // Set callback for receiving state changes.
+ ret = connection_set_type_changed_cb(connection, CAIPConnectionStateChangedCb, NULL);
+ if (CONNECTION_ERROR_NONE != ret)
+ {
+ OIC_LOG(ERROR, TAG, "connection_set_type_changed_cb failed");
+ return CA_STATUS_FAILED;
+ }