X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=plugins%2Fsamples%2Flinux%2FIotivityandZigbeeServer.c;h=b9780742a6189ecd787a046dfeb39ae227cf1f8b;hb=efddb8ca5f3bc77cfba770a96900cb43fe661ee0;hp=5f05eadbb81d62655d07908309c5715d82ea054b;hpb=78d5cb6296c178dea7e6e9c10abf3ccd72002c1d;p=platform%2Fupstream%2Fiotivity.git diff --git a/plugins/samples/linux/IotivityandZigbeeServer.c b/plugins/samples/linux/IotivityandZigbeeServer.c index 5f05ead..b978074 100644 --- a/plugins/samples/linux/IotivityandZigbeeServer.c +++ b/plugins/samples/linux/IotivityandZigbeeServer.c @@ -22,95 +22,95 @@ #include #include #include +#include "oic_string.h" +#include "oic_malloc.h" #define TAG "IoTivityZigbeeServer" #define defaultComPort "/dev/ttyUSB0" int main() { - OC_LOG(INFO, TAG, "Initializing IoTivity..."); + OIC_LOG(INFO, TAG, "Initializing IoTivity..."); OCStackResult result = OCInit(NULL, 0, OC_SERVER); if (result != OC_STACK_OK) { - OC_LOG_V(ERROR, TAG, "OCInit Failed %d", result); + OIC_LOG_V(ERROR, TAG, "OCInit Failed %d", result); return -1; } result = SetPlatformInfo(); if (result != OC_STACK_OK) { - OC_LOG_V(ERROR, TAG, "SetPlatformInfo Failed %d", result); + OIC_LOG_V(ERROR, TAG, "SetPlatformInfo Failed %d", result); goto IotivityStop; } result = SetDeviceInfo(); if (result != OC_STACK_OK) { - OC_LOG_V(ERROR, TAG, "SetPlatformInfo Failed: %d", result); + OIC_LOG_V(ERROR, TAG, "SetPlatformInfo Failed: %d", result); goto IotivityStop; } result = OCStartPresence(0); if (result != OC_STACK_OK) { - OC_LOG_V(ERROR, TAG, "OCStartPresence Failed: %d", result); + OIC_LOG_V(ERROR, TAG, "OCStartPresence Failed: %d", result); goto IotivityStop; } // PIStartPlugin PIPlugin* plugin = NULL; - OC_LOG(INFO, TAG, "IoTivity Initialized properly, Starting Zigbee Plugin..."); + OIC_LOG(INFO, TAG, "IoTivity Initialized properly, Starting Zigbee Plugin..."); result = PIStartPlugin(defaultComPort, PLUGIN_ZIGBEE, &plugin); if (result != OC_STACK_OK) { - OC_LOG_V(ERROR, TAG, "Zigbee Plugin Start Failed: %d", result); + OIC_LOG_V(ERROR, TAG, "Zigbee Plugin Start Failed: %d", result); goto IotivityStop; } if (signal(SIGINT, processCancel) == SIG_ERR) { - OC_LOG(ERROR, TAG, "Unable to catch SIGINT, terminating..."); + OIC_LOG(ERROR, TAG, "Unable to catch SIGINT, terminating..."); } else { - OC_LOG(INFO, TAG, "Zigbee Plugin started correctly, press Ctrl-C to terminate application"); + OIC_LOG(INFO, TAG, "Zigbee Plugin started correctly, press Ctrl-C to terminate application"); // Loop until sigint while (!processSignal(false) && result == OC_STACK_OK) { result = OCProcess(); if (result != OC_STACK_OK) { - OC_LOG_V(ERROR, TAG, "OCProcess Failed: %d", result); + OIC_LOG_V(ERROR, TAG, "OCProcess Failed: %d", result); break; } result = PIProcess(plugin); if (result != OC_STACK_OK) { - OC_LOG_V(ERROR, TAG, "PIProcess Failed: %d", result); + OIC_LOG_V(ERROR, TAG, "PIProcess Failed: %d", result); } } } - OC_LOG(INFO, TAG, "Stopping Zigbee Plugin..."); - // PIStopPlugin - OC_LOG(INFO, TAG, "Zigbee Plugin Stopped"); + OIC_LOG(INFO, TAG, "Stopping Zigbee Plugin..."); result = PIStopPlugin(plugin); if (result != OC_STACK_OK) { - OC_LOG_V(ERROR, TAG, "Zigbee Plugin Stop Failed: %d", result); + OIC_LOG_V(ERROR, TAG, "Zigbee Plugin Stop Failed: %d", result); } - + OIC_LOG(INFO, TAG, "Zigbee Plugin Stopped"); // OCStop IotivityStop: - OC_LOG(INFO, TAG, "Stopping IoTivity..."); + OIC_LOG(INFO, TAG, "Stopping IoTivity..."); result = OCStop(); if (result != OC_STACK_OK) { - OC_LOG_V(ERROR, TAG, "OCStop Failed: %d", result); + OIC_LOG_V(ERROR, TAG, "OCStop Failed: %d", result); return 0; } - OC_LOG(INFO, TAG, "Application Completed Successfully"); + OIC_LOG(INFO, TAG, "Application Completed Successfully"); return 0; } @@ -136,11 +136,15 @@ OCStackResult SetPlatformInfo() OCStackResult SetDeviceInfo() { - static const OCDeviceInfo deviceInfo = + static OCDeviceInfo deviceInfo = { - .deviceName = "IoTivity/Zigbee Server Sample" + .deviceName = "IoTivity/Zigbee Server Sample", + .specVersion = "IoTivity/Zigbee Device Spec Version", + .dataModleVersion = "IoTivity/Zigbee Data Model Version", }; - + char *dup = OICStrdup("oic.wk.d"); + deviceInfo.types = (OCStringLL *)OICCalloc(1, sizeof(OCStringLL)); + deviceInfo.types->value = dup; return OCSetDeviceInfo(deviceInfo); } @@ -162,4 +166,3 @@ void processCancel(int signal) processSignal(true); } } -