typedef enum
{
+
ES_ERROR = -1,
ES_OK = 0,
ES_NETWORKFOUND = 1,
ES_RECVTRIGGEROFPROVRES,
} ESResult;
+typedef enum
+{
+ /**
+ * Default state of the device
+ */
+ ES_INIT_STATE,
+
+ /**
+ * Device will move to this state once the on boarding begins
+ */
+ ES_ON_BOARDING_STATE,
+
+ /**
+ * Device will move to this state after successful on-boarding of the device
+ */
+ ES_ON_BOARDED_STATE,
+
+ /**
+ * Device will move to this state once the on boarding is done
+ */
+ ES_PROVISIONING_STATE,
+
+ /**
+ * Easy setup process is successful.
+ */
+ ES_PROVISIONED_STATE,
+
+ /**
+ * This state is arbitrary one, any time device can come into this state
+ * Device will move to this state if the ownership transfer initiated by the Application
+ */
+ ES_OWNERSHIP_TRANSFERRING_STATE,
+
+ /**
+ * This state is arbitrary one, any time device can come into this state
+ * Device will move to this state if the ownership transfer is completed
+ */
+ ES_OWNERSHIP_TRANSFERRED_STATE,
+
+ /**
+ * This state is arbitrary one, any time device can come into this state
+ * Device will move to this state once the Application factory reset the device
+ */
+ ES_FACTORY_RESET_STATE,
+}EnrolleeState;
+
+
/**
* Provisioning Device Status
// Private internal function prototypes
//-----------------------------------------------------------------------------
-void EventCallbackInOnboarding(ESResult event);
-void EventCallbackInProvisioning(ESResult event);
-void EventCallbackAfterProvisioning(ESResult event);
+void EventCallbackInOnboarding(ESResult esResult);
+void EventCallbackInProvisioning(ESResult esResult);
+void EventCallbackAfterProvisioning(ESResult esResult);
-void EventCallbackInOnboarding(ESResult event)
+void EventCallbackInOnboarding(ESResult esResult)
{
- if (event == ES_NETWORKFOUND || event == ES_NETWORKCONNECTED)
- {
- if (g_cbForEnrolleeStatus != NULL)
- {
- g_cbForEnrolleeStatus(event);
+ if (g_cbForEnrolleeStatus != NULL){
+ OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with esResult = %d", esResult);
+ if(esResult == ES_OK){
+ OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
+ ES_ON_BOARDED_STATE);
+ g_cbForEnrolleeStatus(esResult, ES_ON_BOARDED_STATE);
}
+ else{
+ OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
+ ES_INIT_STATE);
+ g_cbForEnrolleeStatus(esResult, ES_INIT_STATE);
+ }
+ }
+ else{
+ OC_LOG(ERROR, ES_ENROLLEE_TAG, "g_cbForEnrolleeStatus is NULL");
}
}
-void EventCallbackInProvisioning(ESResult event)
+void EventCallbackInProvisioning(ESResult esResult)
{
ESResult res = ES_OK;
- if (event == ES_RECVTRIGGEROFPROVRES)
+ if (esResult == ES_RECVTRIGGEROFPROVRES)
{
targetSsid = (char *) malloc(MAXSSIDLEN);
targetPass = (char *) malloc(MAXNETCREDLEN);
if (g_cbForEnrolleeStatus != NULL)
{
- g_cbForEnrolleeStatus(res);
+ if(res == ES_NETWORKCONNECTED){
+ OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
+ ES_PROVISIONED_STATE);
+ g_cbForEnrolleeStatus(ES_OK, ES_PROVISIONED_STATE);
+ }
+ else{
+ OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
+ ES_PROVISIONING_STATE);
+ g_cbForEnrolleeStatus(ES_OK, ES_PROVISIONING_STATE);
+ }
+
}
}
}
-void EventCallbackAfterProvisioning(ESResult event)
+void EventCallbackAfterProvisioning(ESResult esResult)
{
- if (event == ES_NETWORKFOUND || event == ES_NETWORKCONNECTED)
- {
- if (g_cbForEnrolleeStatus != NULL)
- {
- g_cbForEnrolleeStatus(event);
+ if (g_cbForEnrolleeStatus != NULL){
+ if(esResult == ES_OK){
+ OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
+ ES_PROVISIONED_STATE);
+ g_cbForEnrolleeStatus(esResult, ES_PROVISIONED_STATE);
}
+ else{
+ OC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Calling the application with enrolleestate = %d",
+ ES_PROVISIONING_STATE);
+ g_cbForEnrolleeStatus(esResult, ES_PROVISIONING_STATE);
+ }
+ }
+ else{
+ OC_LOG(ERROR, ES_ENROLLEE_TAG, "g_cbForEnrolleeStatus is NULL");
}
}
if(ConnectToWiFiNetwork(ssid, passwd, EventCallbackInOnboarding) != ES_NETWORKCONNECTED)
{
OC_LOG(ERROR, ES_ENROLLEE_TAG, "ConnectToWiFiNetwork Failed");
- cb(ES_NETWORKNOTCONNECTED);
+ cb(ES_ERROR, ES_ON_BOARDING_STATE);
return ES_ERROR;
}
else{
OC_LOG(INFO, ES_ENROLLEE_TAG, "ConnectToWiFiNetwork Success");
- cb(ES_NETWORKCONNECTED);
+ cb(ES_OK, ES_ON_BOARDED_STATE);
return ES_OK;
}
}