#define TAG "ENROLLEE_SAMPLE"
void *listeningFunc(void *);
+pthread_t thread_handle = NULL;
/**
* Secure Virtual Resource database for Iotivity Server
* It contains Server's Identity and the PSK credentials
* of other devices which the server trusts
*/
+#ifdef MULTIPLE_OWNER
+static char CRED_FILE[] = "oic_svr_db_server_MOT.dat";
+#else
static char CRED_FILE[] = "oic_svr_db_server.dat";
+#endif
OCPersistentStorage ps;
printf("============\n");
}
-void WiFiProvCbInApp(ESWiFiProvData *eventData)
+void ConnectRequestCbInApp(ESConnectRequest *connectRequest)
{
- printf("WiFiProvCbInApp IN\n");
+ printf("ConnectRequestCbInApp IN\n");
- if(eventData->ssid != NULL)
+ if(connectRequest == NULL)
{
- printf("SSID : %s\n", eventData->ssid);
- }
- else
- {
- printf("ERROR! SSID IS NULL\n");
- return;
+ printf("connectRequest is NULL\n");
+ return ;
}
- if(eventData->pwd != NULL)
+ for(int i = 0 ; i < connectRequest->numRequest ; ++i)
{
- printf("Password : %s\n", eventData->pwd);
- }
- else
- {
- printf("ERROR! Password IS NULL\n");
- return;
+ printf("connect : %d\n", connectRequest->connect[i]);
}
- if(eventData->authtype == NONE_AUTH || eventData->authtype == WEP || \
- eventData->authtype == WPA_PSK || eventData->authtype == WPA2_PSK)
- {
- printf("AuthType : %d\n", eventData->authtype);
- }
- else
- {
- printf("ERROR! AuthType IS NULL\n");
- return;
- }
+ printf("ConnectRequestCbInApp OUT\n");
+}
- if(eventData->enctype == NONE_ENC || eventData->enctype == WEP_64 || \
- eventData->enctype == WEP_128 || eventData->enctype == TKIP || \
- eventData->enctype == AES || eventData->enctype == TKIP_AES)
- {
- printf("EncType : %d\n", eventData->enctype);
- }
- else
+void WiFiConfProvCbInApp(ESWiFiConfData *eventData)
+{
+ printf("WiFiConfProvCbInApp IN\n");
+
+ if(eventData == NULL)
{
- printf("ERROR! EncType IS NULL\n");
- return;
+ printf("ESWiFiConfData is NULL\n");
+ return ;
}
+ printf("SSID : %s\n", eventData->ssid);
+ printf("Password : %s\n", eventData->pwd);
+ printf("AuthType : %d\n", eventData->authtype);
+ printf("EncType : %d\n", eventData->enctype);
+
if(eventData->userdata != NULL)
{
printf("userValue : %d\n", ((UserProperties *)(eventData->userdata))->userValue_int);
}
- printf("WiFiProvCbInApp OUT\n");
+ printf("WiFiConfProvCbInApp OUT\n");
}
-void DevConfProvCbInApp(ESDevConfProvData *eventData)
+void DevConfProvCbInApp(ESDevConfData *eventData)
{
printf("DevConfProvCbInApp IN\n");
- if(eventData->language != NULL)
- {
- printf("Language : %s\n", eventData->language);
- }
- else
- {
- printf("ERROR! Language IS NULL\n");
- return;
- }
-
- if(eventData->country != NULL)
- {
- printf("Country : %s\n", eventData->country);
- }
- else
+ if(eventData == NULL)
{
- printf("ERROR! Country IS NULL\n");
- return;
+ printf("ESDevConfData is NULL\n");
+ return ;
}
printf("DevConfProvCbInApp OUT\n");
}
-void CloudDataProvCbInApp(ESCloudProvData *eventData)
+void CoapCloudConfProvCbInApp(ESCoapCloudConfData *eventData)
{
- printf("CloudDataProvCbInApp IN\n");
+ printf("CoapCloudConfProvCbInApp IN\n");
- if(eventData->authCode != NULL)
+ if(eventData == NULL)
{
- printf("AuthCode : %s\n", eventData->authCode);
- }
- else
- {
- printf("ERROR! AuthCode IS NULL\n");
- return;
+ printf("ESCoapCloudConfData is NULL\n");
+ return ;
}
- if(eventData->authProvider != NULL)
- {
- printf("AuthProvider : %s\n", eventData->authProvider);
- }
- else
- {
- printf("ERROR! AuthProvider IS NULL\n");
- return;
- }
+ printf("AuthCode : %s\n", eventData->authCode);
+ printf("AcessToken : %s\n", eventData->accessToken);
+ printf("AcessTokenType : %d\n", eventData->accessTokenType);
+ printf("AuthProvider : %s\n", eventData->authProvider);
+ printf("CI Server : %s\n", eventData->ciServer);
- if(eventData->ciServer != NULL)
- {
- printf("CI Server : %s\n", eventData->ciServer);
- }
- else
- {
- printf("ERROR! CI Server IS NULL\n");
- return;
- }
-
- printf("CloudDataProvCbInApp OUT\n");
+ printf("CoapCloudConfProvCbInApp OUT\n");
}
ESProvisioningCallbacks gCallbacks = {
- .WiFiProvCb = &WiFiProvCbInApp,
+ .ConnectRequestCb = &ConnectRequestCbInApp,
+ .WiFiConfProvCb = &WiFiConfProvCbInApp,
.DevConfProvCb = &DevConfProvCbInApp,
- .CloudDataProvCb = &CloudDataProvCbInApp
+ .CoapCloudConfProvCb = &CoapCloudConfProvCbInApp
};
FILE* server_fopen(const char *path, const char *mode)
return;
}
- ESResourceMask resourcemMask = ES_WIFI_RESOURCE | ES_CLOUD_RESOURCE | ES_DEVCONF_RESOURCE;
+ ESResourceMask resourcemMask = ES_WIFICONF_RESOURCE | ES_COAPCLOUDCONF_RESOURCE | ES_DEVCONF_RESOURCE;
if(ESInitEnrollee(gIsSecured, resourcemMask, gCallbacks) != ES_OK)
{
printf("OCStack init error!!\n");
}
printf("ESInitEnrollee Success\n");
- pthread_t thread_handle;
if (pthread_create(&thread_handle, NULL, listeningFunc, NULL))
{
printf("Thread creation failed\n");
printf("SetDeviceInfo IN\n");
ESDeviceProperty deviceProperty = {
- {{WiFi_11G, WiFi_11N, WiFi_11AC, WiFi_EOF}, WiFi_5G}, {"Test Device"}
+ {{WIFI_11G, WIFI_11N, WIFI_11AC, WiFi_EOF}, WIFI_5G}, {"Test Device"}
};
// Set user properties if needed
char userValue_str[] = "user_str";
g_userProperties.userValue_int = 0;
- strcpy(g_userProperties.userValue_str, userValue_str);
+
+ strncpy(g_userProperties.userValue_str, userValue_str, strlen(userValue_str) + 1);
SetUserProperties(&g_userProperties);
if(ESSetDeviceProperty(&deviceProperty) == ES_ERROR)
+ {
printf("ESSetDeviceProperty Error\n");
+ }
printf("SetDeviceInfo OUT\n");
}
return;
}
+ if (0 != pthread_cancel(thread_handle))
+ {
+ printf("Thread cancellation failed\n");
+ return;
+ }
+
//stop OC Stack
if (OCStop() != OC_STACK_OK)
{
printf("EasySetup Enrollee SAMPLE\n");
printf("#########################\n");
PrintMenu();
- char option;
+ char option = '\0';
while(true)
{
PrintMenu();
break;
}
- if (option == 'Q' || option == 'q') break;
+ if (option == 'Q' || option == 'q')
+ {
+ break;
+ }
}
}
return 0;
void *listeningFunc(void * data)
{
(void)data;
- OCStackResult result;
+ OCStackResult result = OC_STACK_ERROR;
while (true)
{