]> granicus.if.org Git - esp-idf/commitdiff
WiFi Provisioning : Added component providing framework for configuring WiFi credenti...
authorAmey Inamdar <amey@espressif.com>
Mon, 30 Jul 2018 16:09:00 +0000 (21:39 +0530)
committerAnurag Kar <anurag.kar@espressif.com>
Tue, 2 Oct 2018 13:37:28 +0000 (19:07 +0530)
Co-Authored-By: Amey Inamdar <amey@espressif.com>
Co-Authored-By: Anurag Kar <anurag.kar@espressif.com>
13 files changed:
components/wifi_provisioning/CMakeLists.txt [new file with mode: 0644]
components/wifi_provisioning/component.mk [new file with mode: 0644]
components/wifi_provisioning/include/wifi_provisioning/wifi_config.h [new file with mode: 0644]
components/wifi_provisioning/proto-c/wifi_config.pb-c.c [new file with mode: 0644]
components/wifi_provisioning/proto-c/wifi_config.pb-c.h [new file with mode: 0644]
components/wifi_provisioning/proto-c/wifi_constants.pb-c.c [new file with mode: 0644]
components/wifi_provisioning/proto-c/wifi_constants.pb-c.h [new file with mode: 0644]
components/wifi_provisioning/proto/makefile [new file with mode: 0644]
components/wifi_provisioning/proto/wifi_config.proto [new file with mode: 0644]
components/wifi_provisioning/proto/wifi_constants.proto [new file with mode: 0644]
components/wifi_provisioning/python/wifi_config_pb2.py [new file with mode: 0644]
components/wifi_provisioning/python/wifi_constants_pb2.py [new file with mode: 0644]
components/wifi_provisioning/src/wifi_config.c [new file with mode: 0644]

diff --git a/components/wifi_provisioning/CMakeLists.txt b/components/wifi_provisioning/CMakeLists.txt
new file mode 100644 (file)
index 0000000..0147d68
--- /dev/null
@@ -0,0 +1,10 @@
+set(COMPONENT_ADD_INCLUDEDIRS include)
+set(COMPONENT_PRIV_INCLUDEDIRS proto-c ../protocomm/proto-c)
+set(COMPONENT_SRCS  "src/wifi_config.c"
+                    "proto-c/wifi_config.pb-c.c"
+                    "proto-c/wifi_constants.pb-c.c")
+
+set(COMPONENT_REQUIRES lwip)
+set(COMPONENT_PRIV_REQUIRES protobuf-c protocomm)
+
+register_component()
diff --git a/components/wifi_provisioning/component.mk b/components/wifi_provisioning/component.mk
new file mode 100644 (file)
index 0000000..efeb597
--- /dev/null
@@ -0,0 +1,3 @@
+COMPONENT_SRCDIRS := src proto-c
+COMPONENT_ADD_INCLUDEDIRS := include
+COMPONENT_PRIV_INCLUDEDIRS := proto-c ../protocomm/proto-c/
diff --git a/components/wifi_provisioning/include/wifi_provisioning/wifi_config.h b/components/wifi_provisioning/include/wifi_provisioning/wifi_config.h
new file mode 100644 (file)
index 0000000..2794ae4
--- /dev/null
@@ -0,0 +1,120 @@
+// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef _WIFI_PROV_CONFIG_H_
+#define _WIFI_PROV_CONFIG_H_
+
+#include <lwip/inet.h>
+
+/**
+ * @brief   WiFi STA status for conveying back to the provisioning master
+ */
+typedef enum {
+    WIFI_PROV_STA_CONNECTING,
+    WIFI_PROV_STA_CONNECTED,
+    WIFI_PROV_STA_DISCONNECTED
+} wifi_prov_sta_state_t;
+
+/**
+ * @brief   WiFi STA connection fail reason
+ */
+typedef enum {
+    WIFI_PROV_STA_AUTH_ERROR,
+    WIFI_PROV_STA_AP_NOT_FOUND
+} wifi_prov_sta_fail_reason_t;
+
+/**
+ * @brief   WiFi STA connected status information
+ */
+typedef struct {
+    /**
+     * IP Address received by station
+     */
+    char    ip_addr[IP4ADDR_STRLEN_MAX];
+
+    char    bssid[6];   /*!< BSSID of the AP to which connection was estalished */
+    char    ssid[33];   /*!< SSID of the to which connection was estalished */
+    uint8_t channel;    /*!< Channel of the AP */
+    uint8_t auth_mode;  /*!< Authorization mode of the AP */
+} wifi_prov_sta_conn_info_t;
+
+/**
+ * @brief   WiFi status data to be sent in response to `get_status` request from master
+ */
+typedef struct {
+    wifi_prov_sta_state_t wifi_state;    /*!< WiFi state of the station */
+    union {
+        /**
+         * Reason for disconnection (valid only when `wifi_state` is `WIFI_STATION_DISCONNECTED`)
+         */
+        wifi_prov_sta_fail_reason_t fail_reason;
+
+        /**
+         * Connection information (valid only when `wifi_state` is `WIFI_STATION_CONNECTED`)
+         */
+        wifi_prov_sta_conn_info_t   conn_info;
+    };
+} wifi_prov_config_get_data_t;
+
+/**
+ * @brief   WiFi config data received by slave during `set_config` request from master
+ */
+typedef struct {
+    char    ssid[33];       /*!< SSID of the AP to which the slave is to be connected */
+    char    password[65];   /*!< Password of the AP */
+    char    bssid[6];       /*!< BSSID of the AP */
+    uint8_t channel;        /*!< Channel of the AP */
+} wifi_prov_config_set_data_t;
+
+/**
+ * @brief   Internal handlers for receiving and responding to protocomm
+ *          requests from master
+ *
+ * This is to be passed as priv_data for protocomm request handler
+ * (refer to `wifi_prov_config_data_handler()`) when calling `protocomm_add_endpoint()`.
+ */
+typedef struct wifi_prov_config_handlers {
+    /**
+     * Handler function called when connection status
+     * of the slave (in WiFi station mode) is requested
+     */
+    esp_err_t (*get_status_handler)(wifi_prov_config_get_data_t *resp_data);
+
+    /**
+     * Handler function called when WiFi connection configuration
+     * (eg. AP SSID, password, etc.) of the slave (in WiFi station mode)
+     * is to be set to user provided values
+     */
+    esp_err_t (*set_config_handler)(const wifi_prov_config_set_data_t *req_data);
+
+    /**
+     * Handler function for applying the configuration that was set in
+     * `set_config_handler`. After applying the station may get connected to
+     * the AP or may fail to connect. The slave must be ready to convey the
+     * updated connection status information when `get_status_handler` is
+     * invoked again by the master.
+     */
+    esp_err_t (*apply_config_handler)(void);
+} wifi_prov_config_handlers_t;
+
+/**
+ * @brief   Handler for receiving and responding to requests from master
+ *
+ * This is to be registered as the `wifi_config` endpoint handler
+ * (protocomm `protocomm_req_handler_t`) using `protocomm_add_endpoint()`
+ */
+esp_err_t wifi_prov_config_data_handler(uint32_t session_id, const uint8_t *inbuf, ssize_t inlen,
+                                        uint8_t **outbuf, ssize_t *outlen, void *priv_data);
+
+#endif
diff --git a/components/wifi_provisioning/proto-c/wifi_config.pb-c.c b/components/wifi_provisioning/proto-c/wifi_config.pb-c.c
new file mode 100644 (file)
index 0000000..0be6dcd
--- /dev/null
@@ -0,0 +1,744 @@
+/* Generated by the protocol buffer compiler.  DO NOT EDIT! */
+/* Generated from: wifi_config.proto */
+
+/* Do not generate deprecated warnings for self */
+#ifndef PROTOBUF_C__NO_DEPRECATED
+#define PROTOBUF_C__NO_DEPRECATED
+#endif
+
+#include "wifi_config.pb-c.h"
+void   cmd_get_status__init
+                     (CmdGetStatus         *message)
+{
+  static const CmdGetStatus init_value = CMD_GET_STATUS__INIT;
+  *message = init_value;
+}
+size_t cmd_get_status__get_packed_size
+                     (const CmdGetStatus *message)
+{
+  assert(message->base.descriptor == &cmd_get_status__descriptor);
+  return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
+}
+size_t cmd_get_status__pack
+                     (const CmdGetStatus *message,
+                      uint8_t       *out)
+{
+  assert(message->base.descriptor == &cmd_get_status__descriptor);
+  return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
+}
+size_t cmd_get_status__pack_to_buffer
+                     (const CmdGetStatus *message,
+                      ProtobufCBuffer *buffer)
+{
+  assert(message->base.descriptor == &cmd_get_status__descriptor);
+  return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
+}
+CmdGetStatus *
+       cmd_get_status__unpack
+                     (ProtobufCAllocator  *allocator,
+                      size_t               len,
+                      const uint8_t       *data)
+{
+  return (CmdGetStatus *)
+     protobuf_c_message_unpack (&cmd_get_status__descriptor,
+                                allocator, len, data);
+}
+void   cmd_get_status__free_unpacked
+                     (CmdGetStatus *message,
+                      ProtobufCAllocator *allocator)
+{
+  if(!message)
+    return;
+  assert(message->base.descriptor == &cmd_get_status__descriptor);
+  protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
+}
+void   resp_get_status__init
+                     (RespGetStatus         *message)
+{
+  static const RespGetStatus init_value = RESP_GET_STATUS__INIT;
+  *message = init_value;
+}
+size_t resp_get_status__get_packed_size
+                     (const RespGetStatus *message)
+{
+  assert(message->base.descriptor == &resp_get_status__descriptor);
+  return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
+}
+size_t resp_get_status__pack
+                     (const RespGetStatus *message,
+                      uint8_t       *out)
+{
+  assert(message->base.descriptor == &resp_get_status__descriptor);
+  return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
+}
+size_t resp_get_status__pack_to_buffer
+                     (const RespGetStatus *message,
+                      ProtobufCBuffer *buffer)
+{
+  assert(message->base.descriptor == &resp_get_status__descriptor);
+  return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
+}
+RespGetStatus *
+       resp_get_status__unpack
+                     (ProtobufCAllocator  *allocator,
+                      size_t               len,
+                      const uint8_t       *data)
+{
+  return (RespGetStatus *)
+     protobuf_c_message_unpack (&resp_get_status__descriptor,
+                                allocator, len, data);
+}
+void   resp_get_status__free_unpacked
+                     (RespGetStatus *message,
+                      ProtobufCAllocator *allocator)
+{
+  if(!message)
+    return;
+  assert(message->base.descriptor == &resp_get_status__descriptor);
+  protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
+}
+void   cmd_set_config__init
+                     (CmdSetConfig         *message)
+{
+  static const CmdSetConfig init_value = CMD_SET_CONFIG__INIT;
+  *message = init_value;
+}
+size_t cmd_set_config__get_packed_size
+                     (const CmdSetConfig *message)
+{
+  assert(message->base.descriptor == &cmd_set_config__descriptor);
+  return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
+}
+size_t cmd_set_config__pack
+                     (const CmdSetConfig *message,
+                      uint8_t       *out)
+{
+  assert(message->base.descriptor == &cmd_set_config__descriptor);
+  return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
+}
+size_t cmd_set_config__pack_to_buffer
+                     (const CmdSetConfig *message,
+                      ProtobufCBuffer *buffer)
+{
+  assert(message->base.descriptor == &cmd_set_config__descriptor);
+  return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
+}
+CmdSetConfig *
+       cmd_set_config__unpack
+                     (ProtobufCAllocator  *allocator,
+                      size_t               len,
+                      const uint8_t       *data)
+{
+  return (CmdSetConfig *)
+     protobuf_c_message_unpack (&cmd_set_config__descriptor,
+                                allocator, len, data);
+}
+void   cmd_set_config__free_unpacked
+                     (CmdSetConfig *message,
+                      ProtobufCAllocator *allocator)
+{
+  if(!message)
+    return;
+  assert(message->base.descriptor == &cmd_set_config__descriptor);
+  protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
+}
+void   resp_set_config__init
+                     (RespSetConfig         *message)
+{
+  static const RespSetConfig init_value = RESP_SET_CONFIG__INIT;
+  *message = init_value;
+}
+size_t resp_set_config__get_packed_size
+                     (const RespSetConfig *message)
+{
+  assert(message->base.descriptor == &resp_set_config__descriptor);
+  return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
+}
+size_t resp_set_config__pack
+                     (const RespSetConfig *message,
+                      uint8_t       *out)
+{
+  assert(message->base.descriptor == &resp_set_config__descriptor);
+  return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
+}
+size_t resp_set_config__pack_to_buffer
+                     (const RespSetConfig *message,
+                      ProtobufCBuffer *buffer)
+{
+  assert(message->base.descriptor == &resp_set_config__descriptor);
+  return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
+}
+RespSetConfig *
+       resp_set_config__unpack
+                     (ProtobufCAllocator  *allocator,
+                      size_t               len,
+                      const uint8_t       *data)
+{
+  return (RespSetConfig *)
+     protobuf_c_message_unpack (&resp_set_config__descriptor,
+                                allocator, len, data);
+}
+void   resp_set_config__free_unpacked
+                     (RespSetConfig *message,
+                      ProtobufCAllocator *allocator)
+{
+  if(!message)
+    return;
+  assert(message->base.descriptor == &resp_set_config__descriptor);
+  protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
+}
+void   cmd_apply_config__init
+                     (CmdApplyConfig         *message)
+{
+  static const CmdApplyConfig init_value = CMD_APPLY_CONFIG__INIT;
+  *message = init_value;
+}
+size_t cmd_apply_config__get_packed_size
+                     (const CmdApplyConfig *message)
+{
+  assert(message->base.descriptor == &cmd_apply_config__descriptor);
+  return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
+}
+size_t cmd_apply_config__pack
+                     (const CmdApplyConfig *message,
+                      uint8_t       *out)
+{
+  assert(message->base.descriptor == &cmd_apply_config__descriptor);
+  return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
+}
+size_t cmd_apply_config__pack_to_buffer
+                     (const CmdApplyConfig *message,
+                      ProtobufCBuffer *buffer)
+{
+  assert(message->base.descriptor == &cmd_apply_config__descriptor);
+  return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
+}
+CmdApplyConfig *
+       cmd_apply_config__unpack
+                     (ProtobufCAllocator  *allocator,
+                      size_t               len,
+                      const uint8_t       *data)
+{
+  return (CmdApplyConfig *)
+     protobuf_c_message_unpack (&cmd_apply_config__descriptor,
+                                allocator, len, data);
+}
+void   cmd_apply_config__free_unpacked
+                     (CmdApplyConfig *message,
+                      ProtobufCAllocator *allocator)
+{
+  if(!message)
+    return;
+  assert(message->base.descriptor == &cmd_apply_config__descriptor);
+  protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
+}
+void   resp_apply_config__init
+                     (RespApplyConfig         *message)
+{
+  static const RespApplyConfig init_value = RESP_APPLY_CONFIG__INIT;
+  *message = init_value;
+}
+size_t resp_apply_config__get_packed_size
+                     (const RespApplyConfig *message)
+{
+  assert(message->base.descriptor == &resp_apply_config__descriptor);
+  return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
+}
+size_t resp_apply_config__pack
+                     (const RespApplyConfig *message,
+                      uint8_t       *out)
+{
+  assert(message->base.descriptor == &resp_apply_config__descriptor);
+  return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
+}
+size_t resp_apply_config__pack_to_buffer
+                     (const RespApplyConfig *message,
+                      ProtobufCBuffer *buffer)
+{
+  assert(message->base.descriptor == &resp_apply_config__descriptor);
+  return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
+}
+RespApplyConfig *
+       resp_apply_config__unpack
+                     (ProtobufCAllocator  *allocator,
+                      size_t               len,
+                      const uint8_t       *data)
+{
+  return (RespApplyConfig *)
+     protobuf_c_message_unpack (&resp_apply_config__descriptor,
+                                allocator, len, data);
+}
+void   resp_apply_config__free_unpacked
+                     (RespApplyConfig *message,
+                      ProtobufCAllocator *allocator)
+{
+  if(!message)
+    return;
+  assert(message->base.descriptor == &resp_apply_config__descriptor);
+  protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
+}
+void   wi_fi_config_payload__init
+                     (WiFiConfigPayload         *message)
+{
+  static const WiFiConfigPayload init_value = WI_FI_CONFIG_PAYLOAD__INIT;
+  *message = init_value;
+}
+size_t wi_fi_config_payload__get_packed_size
+                     (const WiFiConfigPayload *message)
+{
+  assert(message->base.descriptor == &wi_fi_config_payload__descriptor);
+  return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
+}
+size_t wi_fi_config_payload__pack
+                     (const WiFiConfigPayload *message,
+                      uint8_t       *out)
+{
+  assert(message->base.descriptor == &wi_fi_config_payload__descriptor);
+  return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
+}
+size_t wi_fi_config_payload__pack_to_buffer
+                     (const WiFiConfigPayload *message,
+                      ProtobufCBuffer *buffer)
+{
+  assert(message->base.descriptor == &wi_fi_config_payload__descriptor);
+  return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
+}
+WiFiConfigPayload *
+       wi_fi_config_payload__unpack
+                     (ProtobufCAllocator  *allocator,
+                      size_t               len,
+                      const uint8_t       *data)
+{
+  return (WiFiConfigPayload *)
+     protobuf_c_message_unpack (&wi_fi_config_payload__descriptor,
+                                allocator, len, data);
+}
+void   wi_fi_config_payload__free_unpacked
+                     (WiFiConfigPayload *message,
+                      ProtobufCAllocator *allocator)
+{
+  if(!message)
+    return;
+  assert(message->base.descriptor == &wi_fi_config_payload__descriptor);
+  protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
+}
+#define cmd_get_status__field_descriptors NULL
+#define cmd_get_status__field_indices_by_name NULL
+#define cmd_get_status__number_ranges NULL
+const ProtobufCMessageDescriptor cmd_get_status__descriptor =
+{
+  PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
+  "CmdGetStatus",
+  "CmdGetStatus",
+  "CmdGetStatus",
+  "",
+  sizeof(CmdGetStatus),
+  0,
+  cmd_get_status__field_descriptors,
+  cmd_get_status__field_indices_by_name,
+  0,  cmd_get_status__number_ranges,
+  (ProtobufCMessageInit) cmd_get_status__init,
+  NULL,NULL,NULL    /* reserved[123] */
+};
+static const ProtobufCFieldDescriptor resp_get_status__field_descriptors[4] =
+{
+  {
+    "status",
+    1,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_ENUM,
+    0,   /* quantifier_offset */
+    offsetof(RespGetStatus, status),
+    &status__descriptor,
+    NULL,
+    0,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+  {
+    "sta_state",
+    2,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_ENUM,
+    0,   /* quantifier_offset */
+    offsetof(RespGetStatus, sta_state),
+    &wifi_station_state__descriptor,
+    NULL,
+    0,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+  {
+    "fail_reason",
+    10,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_ENUM,
+    offsetof(RespGetStatus, state_case),
+    offsetof(RespGetStatus, fail_reason),
+    &wifi_connect_failed_reason__descriptor,
+    NULL,
+    0 | PROTOBUF_C_FIELD_FLAG_ONEOF,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+  {
+    "connected",
+    11,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_MESSAGE,
+    offsetof(RespGetStatus, state_case),
+    offsetof(RespGetStatus, connected),
+    &wifi_connected_state__descriptor,
+    NULL,
+    0 | PROTOBUF_C_FIELD_FLAG_ONEOF,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+};
+static const unsigned resp_get_status__field_indices_by_name[] = {
+  3,   /* field[3] = connected */
+  2,   /* field[2] = fail_reason */
+  1,   /* field[1] = sta_state */
+  0,   /* field[0] = status */
+};
+static const ProtobufCIntRange resp_get_status__number_ranges[2 + 1] =
+{
+  { 1, 0 },
+  { 10, 2 },
+  { 0, 4 }
+};
+const ProtobufCMessageDescriptor resp_get_status__descriptor =
+{
+  PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
+  "RespGetStatus",
+  "RespGetStatus",
+  "RespGetStatus",
+  "",
+  sizeof(RespGetStatus),
+  4,
+  resp_get_status__field_descriptors,
+  resp_get_status__field_indices_by_name,
+  2,  resp_get_status__number_ranges,
+  (ProtobufCMessageInit) resp_get_status__init,
+  NULL,NULL,NULL    /* reserved[123] */
+};
+static const ProtobufCFieldDescriptor cmd_set_config__field_descriptors[4] =
+{
+  {
+    "ssid",
+    1,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_BYTES,
+    0,   /* quantifier_offset */
+    offsetof(CmdSetConfig, ssid),
+    NULL,
+    NULL,
+    0,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+  {
+    "passphrase",
+    2,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_BYTES,
+    0,   /* quantifier_offset */
+    offsetof(CmdSetConfig, passphrase),
+    NULL,
+    NULL,
+    0,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+  {
+    "bssid",
+    3,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_BYTES,
+    0,   /* quantifier_offset */
+    offsetof(CmdSetConfig, bssid),
+    NULL,
+    NULL,
+    0,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+  {
+    "channel",
+    4,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_INT32,
+    0,   /* quantifier_offset */
+    offsetof(CmdSetConfig, channel),
+    NULL,
+    NULL,
+    0,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+};
+static const unsigned cmd_set_config__field_indices_by_name[] = {
+  2,   /* field[2] = bssid */
+  3,   /* field[3] = channel */
+  1,   /* field[1] = passphrase */
+  0,   /* field[0] = ssid */
+};
+static const ProtobufCIntRange cmd_set_config__number_ranges[1 + 1] =
+{
+  { 1, 0 },
+  { 0, 4 }
+};
+const ProtobufCMessageDescriptor cmd_set_config__descriptor =
+{
+  PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
+  "CmdSetConfig",
+  "CmdSetConfig",
+  "CmdSetConfig",
+  "",
+  sizeof(CmdSetConfig),
+  4,
+  cmd_set_config__field_descriptors,
+  cmd_set_config__field_indices_by_name,
+  1,  cmd_set_config__number_ranges,
+  (ProtobufCMessageInit) cmd_set_config__init,
+  NULL,NULL,NULL    /* reserved[123] */
+};
+static const ProtobufCFieldDescriptor resp_set_config__field_descriptors[1] =
+{
+  {
+    "status",
+    1,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_ENUM,
+    0,   /* quantifier_offset */
+    offsetof(RespSetConfig, status),
+    &status__descriptor,
+    NULL,
+    0,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+};
+static const unsigned resp_set_config__field_indices_by_name[] = {
+  0,   /* field[0] = status */
+};
+static const ProtobufCIntRange resp_set_config__number_ranges[1 + 1] =
+{
+  { 1, 0 },
+  { 0, 1 }
+};
+const ProtobufCMessageDescriptor resp_set_config__descriptor =
+{
+  PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
+  "RespSetConfig",
+  "RespSetConfig",
+  "RespSetConfig",
+  "",
+  sizeof(RespSetConfig),
+  1,
+  resp_set_config__field_descriptors,
+  resp_set_config__field_indices_by_name,
+  1,  resp_set_config__number_ranges,
+  (ProtobufCMessageInit) resp_set_config__init,
+  NULL,NULL,NULL    /* reserved[123] */
+};
+#define cmd_apply_config__field_descriptors NULL
+#define cmd_apply_config__field_indices_by_name NULL
+#define cmd_apply_config__number_ranges NULL
+const ProtobufCMessageDescriptor cmd_apply_config__descriptor =
+{
+  PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
+  "CmdApplyConfig",
+  "CmdApplyConfig",
+  "CmdApplyConfig",
+  "",
+  sizeof(CmdApplyConfig),
+  0,
+  cmd_apply_config__field_descriptors,
+  cmd_apply_config__field_indices_by_name,
+  0,  cmd_apply_config__number_ranges,
+  (ProtobufCMessageInit) cmd_apply_config__init,
+  NULL,NULL,NULL    /* reserved[123] */
+};
+static const ProtobufCFieldDescriptor resp_apply_config__field_descriptors[1] =
+{
+  {
+    "status",
+    1,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_ENUM,
+    0,   /* quantifier_offset */
+    offsetof(RespApplyConfig, status),
+    &status__descriptor,
+    NULL,
+    0,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+};
+static const unsigned resp_apply_config__field_indices_by_name[] = {
+  0,   /* field[0] = status */
+};
+static const ProtobufCIntRange resp_apply_config__number_ranges[1 + 1] =
+{
+  { 1, 0 },
+  { 0, 1 }
+};
+const ProtobufCMessageDescriptor resp_apply_config__descriptor =
+{
+  PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
+  "RespApplyConfig",
+  "RespApplyConfig",
+  "RespApplyConfig",
+  "",
+  sizeof(RespApplyConfig),
+  1,
+  resp_apply_config__field_descriptors,
+  resp_apply_config__field_indices_by_name,
+  1,  resp_apply_config__number_ranges,
+  (ProtobufCMessageInit) resp_apply_config__init,
+  NULL,NULL,NULL    /* reserved[123] */
+};
+static const ProtobufCFieldDescriptor wi_fi_config_payload__field_descriptors[7] =
+{
+  {
+    "msg",
+    1,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_ENUM,
+    0,   /* quantifier_offset */
+    offsetof(WiFiConfigPayload, msg),
+    &wi_fi_config_msg_type__descriptor,
+    NULL,
+    0,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+  {
+    "cmd_get_status",
+    10,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_MESSAGE,
+    offsetof(WiFiConfigPayload, payload_case),
+    offsetof(WiFiConfigPayload, cmd_get_status),
+    &cmd_get_status__descriptor,
+    NULL,
+    0 | PROTOBUF_C_FIELD_FLAG_ONEOF,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+  {
+    "resp_get_status",
+    11,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_MESSAGE,
+    offsetof(WiFiConfigPayload, payload_case),
+    offsetof(WiFiConfigPayload, resp_get_status),
+    &resp_get_status__descriptor,
+    NULL,
+    0 | PROTOBUF_C_FIELD_FLAG_ONEOF,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+  {
+    "cmd_set_config",
+    12,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_MESSAGE,
+    offsetof(WiFiConfigPayload, payload_case),
+    offsetof(WiFiConfigPayload, cmd_set_config),
+    &cmd_set_config__descriptor,
+    NULL,
+    0 | PROTOBUF_C_FIELD_FLAG_ONEOF,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+  {
+    "resp_set_config",
+    13,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_MESSAGE,
+    offsetof(WiFiConfigPayload, payload_case),
+    offsetof(WiFiConfigPayload, resp_set_config),
+    &resp_set_config__descriptor,
+    NULL,
+    0 | PROTOBUF_C_FIELD_FLAG_ONEOF,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+  {
+    "cmd_apply_config",
+    14,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_MESSAGE,
+    offsetof(WiFiConfigPayload, payload_case),
+    offsetof(WiFiConfigPayload, cmd_apply_config),
+    &cmd_apply_config__descriptor,
+    NULL,
+    0 | PROTOBUF_C_FIELD_FLAG_ONEOF,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+  {
+    "resp_apply_config",
+    15,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_MESSAGE,
+    offsetof(WiFiConfigPayload, payload_case),
+    offsetof(WiFiConfigPayload, resp_apply_config),
+    &resp_apply_config__descriptor,
+    NULL,
+    0 | PROTOBUF_C_FIELD_FLAG_ONEOF,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+};
+static const unsigned wi_fi_config_payload__field_indices_by_name[] = {
+  5,   /* field[5] = cmd_apply_config */
+  1,   /* field[1] = cmd_get_status */
+  3,   /* field[3] = cmd_set_config */
+  0,   /* field[0] = msg */
+  6,   /* field[6] = resp_apply_config */
+  2,   /* field[2] = resp_get_status */
+  4,   /* field[4] = resp_set_config */
+};
+static const ProtobufCIntRange wi_fi_config_payload__number_ranges[2 + 1] =
+{
+  { 1, 0 },
+  { 10, 1 },
+  { 0, 7 }
+};
+const ProtobufCMessageDescriptor wi_fi_config_payload__descriptor =
+{
+  PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
+  "WiFiConfigPayload",
+  "WiFiConfigPayload",
+  "WiFiConfigPayload",
+  "",
+  sizeof(WiFiConfigPayload),
+  7,
+  wi_fi_config_payload__field_descriptors,
+  wi_fi_config_payload__field_indices_by_name,
+  2,  wi_fi_config_payload__number_ranges,
+  (ProtobufCMessageInit) wi_fi_config_payload__init,
+  NULL,NULL,NULL    /* reserved[123] */
+};
+static const ProtobufCEnumValue wi_fi_config_msg_type__enum_values_by_number[6] =
+{
+  { "TypeCmdGetStatus", "WI_FI_CONFIG_MSG_TYPE__TypeCmdGetStatus", 0 },
+  { "TypeRespGetStatus", "WI_FI_CONFIG_MSG_TYPE__TypeRespGetStatus", 1 },
+  { "TypeCmdSetConfig", "WI_FI_CONFIG_MSG_TYPE__TypeCmdSetConfig", 2 },
+  { "TypeRespSetConfig", "WI_FI_CONFIG_MSG_TYPE__TypeRespSetConfig", 3 },
+  { "TypeCmdApplyConfig", "WI_FI_CONFIG_MSG_TYPE__TypeCmdApplyConfig", 4 },
+  { "TypeRespApplyConfig", "WI_FI_CONFIG_MSG_TYPE__TypeRespApplyConfig", 5 },
+};
+static const ProtobufCIntRange wi_fi_config_msg_type__value_ranges[] = {
+{0, 0},{0, 6}
+};
+static const ProtobufCEnumValueIndex wi_fi_config_msg_type__enum_values_by_name[6] =
+{
+  { "TypeCmdApplyConfig", 4 },
+  { "TypeCmdGetStatus", 0 },
+  { "TypeCmdSetConfig", 2 },
+  { "TypeRespApplyConfig", 5 },
+  { "TypeRespGetStatus", 1 },
+  { "TypeRespSetConfig", 3 },
+};
+const ProtobufCEnumDescriptor wi_fi_config_msg_type__descriptor =
+{
+  PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC,
+  "WiFiConfigMsgType",
+  "WiFiConfigMsgType",
+  "WiFiConfigMsgType",
+  "",
+  6,
+  wi_fi_config_msg_type__enum_values_by_number,
+  6,
+  wi_fi_config_msg_type__enum_values_by_name,
+  1,
+  wi_fi_config_msg_type__value_ranges,
+  NULL,NULL,NULL,NULL   /* reserved[1234] */
+};
diff --git a/components/wifi_provisioning/proto-c/wifi_config.pb-c.h b/components/wifi_provisioning/proto-c/wifi_config.pb-c.h
new file mode 100644 (file)
index 0000000..8c6107f
--- /dev/null
@@ -0,0 +1,321 @@
+/* Generated by the protocol buffer compiler.  DO NOT EDIT! */
+/* Generated from: wifi_config.proto */
+
+#ifndef PROTOBUF_C_wifi_5fconfig_2eproto__INCLUDED
+#define PROTOBUF_C_wifi_5fconfig_2eproto__INCLUDED
+
+#include <protobuf-c/protobuf-c.h>
+
+PROTOBUF_C__BEGIN_DECLS
+
+#if PROTOBUF_C_VERSION_NUMBER < 1003000
+# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers.
+#elif 1003000 < PROTOBUF_C_MIN_COMPILER_VERSION
+# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c.
+#endif
+
+#include "constants.pb-c.h"
+#include "wifi_constants.pb-c.h"
+
+typedef struct _CmdGetStatus CmdGetStatus;
+typedef struct _RespGetStatus RespGetStatus;
+typedef struct _CmdSetConfig CmdSetConfig;
+typedef struct _RespSetConfig RespSetConfig;
+typedef struct _CmdApplyConfig CmdApplyConfig;
+typedef struct _RespApplyConfig RespApplyConfig;
+typedef struct _WiFiConfigPayload WiFiConfigPayload;
+
+
+/* --- enums --- */
+
+typedef enum _WiFiConfigMsgType {
+  WI_FI_CONFIG_MSG_TYPE__TypeCmdGetStatus = 0,
+  WI_FI_CONFIG_MSG_TYPE__TypeRespGetStatus = 1,
+  WI_FI_CONFIG_MSG_TYPE__TypeCmdSetConfig = 2,
+  WI_FI_CONFIG_MSG_TYPE__TypeRespSetConfig = 3,
+  WI_FI_CONFIG_MSG_TYPE__TypeCmdApplyConfig = 4,
+  WI_FI_CONFIG_MSG_TYPE__TypeRespApplyConfig = 5
+    PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WI_FI_CONFIG_MSG_TYPE)
+} WiFiConfigMsgType;
+
+/* --- messages --- */
+
+struct  _CmdGetStatus
+{
+  ProtobufCMessage base;
+};
+#define CMD_GET_STATUS__INIT \
+ { PROTOBUF_C_MESSAGE_INIT (&cmd_get_status__descriptor) \
+     }
+
+
+typedef enum {
+  RESP_GET_STATUS__STATE__NOT_SET = 0,
+  RESP_GET_STATUS__STATE_FAIL_REASON = 10,
+  RESP_GET_STATUS__STATE_CONNECTED = 11
+    PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(RESP_GET_STATUS__STATE)
+} RespGetStatus__StateCase;
+
+struct  _RespGetStatus
+{
+  ProtobufCMessage base;
+  Status status;
+  WifiStationState sta_state;
+  RespGetStatus__StateCase state_case;
+  union {
+    WifiConnectFailedReason fail_reason;
+    WifiConnectedState *connected;
+  };
+};
+#define RESP_GET_STATUS__INIT \
+ { PROTOBUF_C_MESSAGE_INIT (&resp_get_status__descriptor) \
+    , STATUS__Success, WIFI_STATION_STATE__Connected, RESP_GET_STATUS__STATE__NOT_SET, {0} }
+
+
+struct  _CmdSetConfig
+{
+  ProtobufCMessage base;
+  ProtobufCBinaryData ssid;
+  ProtobufCBinaryData passphrase;
+  ProtobufCBinaryData bssid;
+  int32_t channel;
+};
+#define CMD_SET_CONFIG__INIT \
+ { PROTOBUF_C_MESSAGE_INIT (&cmd_set_config__descriptor) \
+    , {0,NULL}, {0,NULL}, {0,NULL}, 0 }
+
+
+struct  _RespSetConfig
+{
+  ProtobufCMessage base;
+  Status status;
+};
+#define RESP_SET_CONFIG__INIT \
+ { PROTOBUF_C_MESSAGE_INIT (&resp_set_config__descriptor) \
+    , STATUS__Success }
+
+
+struct  _CmdApplyConfig
+{
+  ProtobufCMessage base;
+};
+#define CMD_APPLY_CONFIG__INIT \
+ { PROTOBUF_C_MESSAGE_INIT (&cmd_apply_config__descriptor) \
+     }
+
+
+struct  _RespApplyConfig
+{
+  ProtobufCMessage base;
+  Status status;
+};
+#define RESP_APPLY_CONFIG__INIT \
+ { PROTOBUF_C_MESSAGE_INIT (&resp_apply_config__descriptor) \
+    , STATUS__Success }
+
+
+typedef enum {
+  WI_FI_CONFIG_PAYLOAD__PAYLOAD__NOT_SET = 0,
+  WI_FI_CONFIG_PAYLOAD__PAYLOAD_CMD_GET_STATUS = 10,
+  WI_FI_CONFIG_PAYLOAD__PAYLOAD_RESP_GET_STATUS = 11,
+  WI_FI_CONFIG_PAYLOAD__PAYLOAD_CMD_SET_CONFIG = 12,
+  WI_FI_CONFIG_PAYLOAD__PAYLOAD_RESP_SET_CONFIG = 13,
+  WI_FI_CONFIG_PAYLOAD__PAYLOAD_CMD_APPLY_CONFIG = 14,
+  WI_FI_CONFIG_PAYLOAD__PAYLOAD_RESP_APPLY_CONFIG = 15
+    PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WI_FI_CONFIG_PAYLOAD__PAYLOAD)
+} WiFiConfigPayload__PayloadCase;
+
+struct  _WiFiConfigPayload
+{
+  ProtobufCMessage base;
+  WiFiConfigMsgType msg;
+  WiFiConfigPayload__PayloadCase payload_case;
+  union {
+    CmdGetStatus *cmd_get_status;
+    RespGetStatus *resp_get_status;
+    CmdSetConfig *cmd_set_config;
+    RespSetConfig *resp_set_config;
+    CmdApplyConfig *cmd_apply_config;
+    RespApplyConfig *resp_apply_config;
+  };
+};
+#define WI_FI_CONFIG_PAYLOAD__INIT \
+ { PROTOBUF_C_MESSAGE_INIT (&wi_fi_config_payload__descriptor) \
+    , WI_FI_CONFIG_MSG_TYPE__TypeCmdGetStatus, WI_FI_CONFIG_PAYLOAD__PAYLOAD__NOT_SET, {0} }
+
+
+/* CmdGetStatus methods */
+void   cmd_get_status__init
+                     (CmdGetStatus         *message);
+size_t cmd_get_status__get_packed_size
+                     (const CmdGetStatus   *message);
+size_t cmd_get_status__pack
+                     (const CmdGetStatus   *message,
+                      uint8_t             *out);
+size_t cmd_get_status__pack_to_buffer
+                     (const CmdGetStatus   *message,
+                      ProtobufCBuffer     *buffer);
+CmdGetStatus *
+       cmd_get_status__unpack
+                     (ProtobufCAllocator  *allocator,
+                      size_t               len,
+                      const uint8_t       *data);
+void   cmd_get_status__free_unpacked
+                     (CmdGetStatus *message,
+                      ProtobufCAllocator *allocator);
+/* RespGetStatus methods */
+void   resp_get_status__init
+                     (RespGetStatus         *message);
+size_t resp_get_status__get_packed_size
+                     (const RespGetStatus   *message);
+size_t resp_get_status__pack
+                     (const RespGetStatus   *message,
+                      uint8_t             *out);
+size_t resp_get_status__pack_to_buffer
+                     (const RespGetStatus   *message,
+                      ProtobufCBuffer     *buffer);
+RespGetStatus *
+       resp_get_status__unpack
+                     (ProtobufCAllocator  *allocator,
+                      size_t               len,
+                      const uint8_t       *data);
+void   resp_get_status__free_unpacked
+                     (RespGetStatus *message,
+                      ProtobufCAllocator *allocator);
+/* CmdSetConfig methods */
+void   cmd_set_config__init
+                     (CmdSetConfig         *message);
+size_t cmd_set_config__get_packed_size
+                     (const CmdSetConfig   *message);
+size_t cmd_set_config__pack
+                     (const CmdSetConfig   *message,
+                      uint8_t             *out);
+size_t cmd_set_config__pack_to_buffer
+                     (const CmdSetConfig   *message,
+                      ProtobufCBuffer     *buffer);
+CmdSetConfig *
+       cmd_set_config__unpack
+                     (ProtobufCAllocator  *allocator,
+                      size_t               len,
+                      const uint8_t       *data);
+void   cmd_set_config__free_unpacked
+                     (CmdSetConfig *message,
+                      ProtobufCAllocator *allocator);
+/* RespSetConfig methods */
+void   resp_set_config__init
+                     (RespSetConfig         *message);
+size_t resp_set_config__get_packed_size
+                     (const RespSetConfig   *message);
+size_t resp_set_config__pack
+                     (const RespSetConfig   *message,
+                      uint8_t             *out);
+size_t resp_set_config__pack_to_buffer
+                     (const RespSetConfig   *message,
+                      ProtobufCBuffer     *buffer);
+RespSetConfig *
+       resp_set_config__unpack
+                     (ProtobufCAllocator  *allocator,
+                      size_t               len,
+                      const uint8_t       *data);
+void   resp_set_config__free_unpacked
+                     (RespSetConfig *message,
+                      ProtobufCAllocator *allocator);
+/* CmdApplyConfig methods */
+void   cmd_apply_config__init
+                     (CmdApplyConfig         *message);
+size_t cmd_apply_config__get_packed_size
+                     (const CmdApplyConfig   *message);
+size_t cmd_apply_config__pack
+                     (const CmdApplyConfig   *message,
+                      uint8_t             *out);
+size_t cmd_apply_config__pack_to_buffer
+                     (const CmdApplyConfig   *message,
+                      ProtobufCBuffer     *buffer);
+CmdApplyConfig *
+       cmd_apply_config__unpack
+                     (ProtobufCAllocator  *allocator,
+                      size_t               len,
+                      const uint8_t       *data);
+void   cmd_apply_config__free_unpacked
+                     (CmdApplyConfig *message,
+                      ProtobufCAllocator *allocator);
+/* RespApplyConfig methods */
+void   resp_apply_config__init
+                     (RespApplyConfig         *message);
+size_t resp_apply_config__get_packed_size
+                     (const RespApplyConfig   *message);
+size_t resp_apply_config__pack
+                     (const RespApplyConfig   *message,
+                      uint8_t             *out);
+size_t resp_apply_config__pack_to_buffer
+                     (const RespApplyConfig   *message,
+                      ProtobufCBuffer     *buffer);
+RespApplyConfig *
+       resp_apply_config__unpack
+                     (ProtobufCAllocator  *allocator,
+                      size_t               len,
+                      const uint8_t       *data);
+void   resp_apply_config__free_unpacked
+                     (RespApplyConfig *message,
+                      ProtobufCAllocator *allocator);
+/* WiFiConfigPayload methods */
+void   wi_fi_config_payload__init
+                     (WiFiConfigPayload         *message);
+size_t wi_fi_config_payload__get_packed_size
+                     (const WiFiConfigPayload   *message);
+size_t wi_fi_config_payload__pack
+                     (const WiFiConfigPayload   *message,
+                      uint8_t             *out);
+size_t wi_fi_config_payload__pack_to_buffer
+                     (const WiFiConfigPayload   *message,
+                      ProtobufCBuffer     *buffer);
+WiFiConfigPayload *
+       wi_fi_config_payload__unpack
+                     (ProtobufCAllocator  *allocator,
+                      size_t               len,
+                      const uint8_t       *data);
+void   wi_fi_config_payload__free_unpacked
+                     (WiFiConfigPayload *message,
+                      ProtobufCAllocator *allocator);
+/* --- per-message closures --- */
+
+typedef void (*CmdGetStatus_Closure)
+                 (const CmdGetStatus *message,
+                  void *closure_data);
+typedef void (*RespGetStatus_Closure)
+                 (const RespGetStatus *message,
+                  void *closure_data);
+typedef void (*CmdSetConfig_Closure)
+                 (const CmdSetConfig *message,
+                  void *closure_data);
+typedef void (*RespSetConfig_Closure)
+                 (const RespSetConfig *message,
+                  void *closure_data);
+typedef void (*CmdApplyConfig_Closure)
+                 (const CmdApplyConfig *message,
+                  void *closure_data);
+typedef void (*RespApplyConfig_Closure)
+                 (const RespApplyConfig *message,
+                  void *closure_data);
+typedef void (*WiFiConfigPayload_Closure)
+                 (const WiFiConfigPayload *message,
+                  void *closure_data);
+
+/* --- services --- */
+
+
+/* --- descriptors --- */
+
+extern const ProtobufCEnumDescriptor    wi_fi_config_msg_type__descriptor;
+extern const ProtobufCMessageDescriptor cmd_get_status__descriptor;
+extern const ProtobufCMessageDescriptor resp_get_status__descriptor;
+extern const ProtobufCMessageDescriptor cmd_set_config__descriptor;
+extern const ProtobufCMessageDescriptor resp_set_config__descriptor;
+extern const ProtobufCMessageDescriptor cmd_apply_config__descriptor;
+extern const ProtobufCMessageDescriptor resp_apply_config__descriptor;
+extern const ProtobufCMessageDescriptor wi_fi_config_payload__descriptor;
+
+PROTOBUF_C__END_DECLS
+
+
+#endif  /* PROTOBUF_C_wifi_5fconfig_2eproto__INCLUDED */
diff --git a/components/wifi_provisioning/proto-c/wifi_constants.pb-c.c b/components/wifi_provisioning/proto-c/wifi_constants.pb-c.c
new file mode 100644 (file)
index 0000000..1ef5f57
--- /dev/null
@@ -0,0 +1,240 @@
+/* Generated by the protocol buffer compiler.  DO NOT EDIT! */
+/* Generated from: wifi_constants.proto */
+
+/* Do not generate deprecated warnings for self */
+#ifndef PROTOBUF_C__NO_DEPRECATED
+#define PROTOBUF_C__NO_DEPRECATED
+#endif
+
+#include "wifi_constants.pb-c.h"
+void   wifi_connected_state__init
+                     (WifiConnectedState         *message)
+{
+  static const WifiConnectedState init_value = WIFI_CONNECTED_STATE__INIT;
+  *message = init_value;
+}
+size_t wifi_connected_state__get_packed_size
+                     (const WifiConnectedState *message)
+{
+  assert(message->base.descriptor == &wifi_connected_state__descriptor);
+  return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
+}
+size_t wifi_connected_state__pack
+                     (const WifiConnectedState *message,
+                      uint8_t       *out)
+{
+  assert(message->base.descriptor == &wifi_connected_state__descriptor);
+  return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
+}
+size_t wifi_connected_state__pack_to_buffer
+                     (const WifiConnectedState *message,
+                      ProtobufCBuffer *buffer)
+{
+  assert(message->base.descriptor == &wifi_connected_state__descriptor);
+  return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
+}
+WifiConnectedState *
+       wifi_connected_state__unpack
+                     (ProtobufCAllocator  *allocator,
+                      size_t               len,
+                      const uint8_t       *data)
+{
+  return (WifiConnectedState *)
+     protobuf_c_message_unpack (&wifi_connected_state__descriptor,
+                                allocator, len, data);
+}
+void   wifi_connected_state__free_unpacked
+                     (WifiConnectedState *message,
+                      ProtobufCAllocator *allocator)
+{
+  if(!message)
+    return;
+  assert(message->base.descriptor == &wifi_connected_state__descriptor);
+  protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
+}
+static const ProtobufCFieldDescriptor wifi_connected_state__field_descriptors[5] =
+{
+  {
+    "ip4_addr",
+    1,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_STRING,
+    0,   /* quantifier_offset */
+    offsetof(WifiConnectedState, ip4_addr),
+    NULL,
+    &protobuf_c_empty_string,
+    0,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+  {
+    "auth_mode",
+    2,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_ENUM,
+    0,   /* quantifier_offset */
+    offsetof(WifiConnectedState, auth_mode),
+    &wifi_auth_mode__descriptor,
+    NULL,
+    0,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+  {
+    "ssid",
+    3,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_BYTES,
+    0,   /* quantifier_offset */
+    offsetof(WifiConnectedState, ssid),
+    NULL,
+    NULL,
+    0,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+  {
+    "bssid",
+    4,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_BYTES,
+    0,   /* quantifier_offset */
+    offsetof(WifiConnectedState, bssid),
+    NULL,
+    NULL,
+    0,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+  {
+    "channel",
+    5,
+    PROTOBUF_C_LABEL_NONE,
+    PROTOBUF_C_TYPE_INT32,
+    0,   /* quantifier_offset */
+    offsetof(WifiConnectedState, channel),
+    NULL,
+    NULL,
+    0,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+};
+static const unsigned wifi_connected_state__field_indices_by_name[] = {
+  1,   /* field[1] = auth_mode */
+  3,   /* field[3] = bssid */
+  4,   /* field[4] = channel */
+  0,   /* field[0] = ip4_addr */
+  2,   /* field[2] = ssid */
+};
+static const ProtobufCIntRange wifi_connected_state__number_ranges[1 + 1] =
+{
+  { 1, 0 },
+  { 0, 5 }
+};
+const ProtobufCMessageDescriptor wifi_connected_state__descriptor =
+{
+  PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
+  "WifiConnectedState",
+  "WifiConnectedState",
+  "WifiConnectedState",
+  "",
+  sizeof(WifiConnectedState),
+  5,
+  wifi_connected_state__field_descriptors,
+  wifi_connected_state__field_indices_by_name,
+  1,  wifi_connected_state__number_ranges,
+  (ProtobufCMessageInit) wifi_connected_state__init,
+  NULL,NULL,NULL    /* reserved[123] */
+};
+static const ProtobufCEnumValue wifi_station_state__enum_values_by_number[4] =
+{
+  { "Connected", "WIFI_STATION_STATE__Connected", 0 },
+  { "Connecting", "WIFI_STATION_STATE__Connecting", 1 },
+  { "Disconnected", "WIFI_STATION_STATE__Disconnected", 2 },
+  { "ConnectionFailed", "WIFI_STATION_STATE__ConnectionFailed", 3 },
+};
+static const ProtobufCIntRange wifi_station_state__value_ranges[] = {
+{0, 0},{0, 4}
+};
+static const ProtobufCEnumValueIndex wifi_station_state__enum_values_by_name[4] =
+{
+  { "Connected", 0 },
+  { "Connecting", 1 },
+  { "ConnectionFailed", 3 },
+  { "Disconnected", 2 },
+};
+const ProtobufCEnumDescriptor wifi_station_state__descriptor =
+{
+  PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC,
+  "WifiStationState",
+  "WifiStationState",
+  "WifiStationState",
+  "",
+  4,
+  wifi_station_state__enum_values_by_number,
+  4,
+  wifi_station_state__enum_values_by_name,
+  1,
+  wifi_station_state__value_ranges,
+  NULL,NULL,NULL,NULL   /* reserved[1234] */
+};
+static const ProtobufCEnumValue wifi_connect_failed_reason__enum_values_by_number[2] =
+{
+  { "AuthError", "WIFI_CONNECT_FAILED_REASON__AuthError", 0 },
+  { "NetworkNotFound", "WIFI_CONNECT_FAILED_REASON__NetworkNotFound", 1 },
+};
+static const ProtobufCIntRange wifi_connect_failed_reason__value_ranges[] = {
+{0, 0},{0, 2}
+};
+static const ProtobufCEnumValueIndex wifi_connect_failed_reason__enum_values_by_name[2] =
+{
+  { "AuthError", 0 },
+  { "NetworkNotFound", 1 },
+};
+const ProtobufCEnumDescriptor wifi_connect_failed_reason__descriptor =
+{
+  PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC,
+  "WifiConnectFailedReason",
+  "WifiConnectFailedReason",
+  "WifiConnectFailedReason",
+  "",
+  2,
+  wifi_connect_failed_reason__enum_values_by_number,
+  2,
+  wifi_connect_failed_reason__enum_values_by_name,
+  1,
+  wifi_connect_failed_reason__value_ranges,
+  NULL,NULL,NULL,NULL   /* reserved[1234] */
+};
+static const ProtobufCEnumValue wifi_auth_mode__enum_values_by_number[6] =
+{
+  { "Open", "WIFI_AUTH_MODE__Open", 0 },
+  { "WEP", "WIFI_AUTH_MODE__WEP", 1 },
+  { "WPA_PSK", "WIFI_AUTH_MODE__WPA_PSK", 2 },
+  { "WPA2_PSK", "WIFI_AUTH_MODE__WPA2_PSK", 3 },
+  { "WPA_WPA2_PSK", "WIFI_AUTH_MODE__WPA_WPA2_PSK", 4 },
+  { "WPA2_ENTERPRISE", "WIFI_AUTH_MODE__WPA2_ENTERPRISE", 5 },
+};
+static const ProtobufCIntRange wifi_auth_mode__value_ranges[] = {
+{0, 0},{0, 6}
+};
+static const ProtobufCEnumValueIndex wifi_auth_mode__enum_values_by_name[6] =
+{
+  { "Open", 0 },
+  { "WEP", 1 },
+  { "WPA2_ENTERPRISE", 5 },
+  { "WPA2_PSK", 3 },
+  { "WPA_PSK", 2 },
+  { "WPA_WPA2_PSK", 4 },
+};
+const ProtobufCEnumDescriptor wifi_auth_mode__descriptor =
+{
+  PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC,
+  "WifiAuthMode",
+  "WifiAuthMode",
+  "WifiAuthMode",
+  "",
+  6,
+  wifi_auth_mode__enum_values_by_number,
+  6,
+  wifi_auth_mode__enum_values_by_name,
+  1,
+  wifi_auth_mode__value_ranges,
+  NULL,NULL,NULL,NULL   /* reserved[1234] */
+};
diff --git a/components/wifi_provisioning/proto-c/wifi_constants.pb-c.h b/components/wifi_provisioning/proto-c/wifi_constants.pb-c.h
new file mode 100644 (file)
index 0000000..0715505
--- /dev/null
@@ -0,0 +1,99 @@
+/* Generated by the protocol buffer compiler.  DO NOT EDIT! */
+/* Generated from: wifi_constants.proto */
+
+#ifndef PROTOBUF_C_wifi_5fconstants_2eproto__INCLUDED
+#define PROTOBUF_C_wifi_5fconstants_2eproto__INCLUDED
+
+#include <protobuf-c/protobuf-c.h>
+
+PROTOBUF_C__BEGIN_DECLS
+
+#if PROTOBUF_C_VERSION_NUMBER < 1003000
+# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers.
+#elif 1003000 < PROTOBUF_C_MIN_COMPILER_VERSION
+# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c.
+#endif
+
+
+typedef struct _WifiConnectedState WifiConnectedState;
+
+
+/* --- enums --- */
+
+typedef enum _WifiStationState {
+  WIFI_STATION_STATE__Connected = 0,
+  WIFI_STATION_STATE__Connecting = 1,
+  WIFI_STATION_STATE__Disconnected = 2,
+  WIFI_STATION_STATE__ConnectionFailed = 3
+    PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WIFI_STATION_STATE)
+} WifiStationState;
+typedef enum _WifiConnectFailedReason {
+  WIFI_CONNECT_FAILED_REASON__AuthError = 0,
+  WIFI_CONNECT_FAILED_REASON__NetworkNotFound = 1
+    PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WIFI_CONNECT_FAILED_REASON)
+} WifiConnectFailedReason;
+typedef enum _WifiAuthMode {
+  WIFI_AUTH_MODE__Open = 0,
+  WIFI_AUTH_MODE__WEP = 1,
+  WIFI_AUTH_MODE__WPA_PSK = 2,
+  WIFI_AUTH_MODE__WPA2_PSK = 3,
+  WIFI_AUTH_MODE__WPA_WPA2_PSK = 4,
+  WIFI_AUTH_MODE__WPA2_ENTERPRISE = 5
+    PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(WIFI_AUTH_MODE)
+} WifiAuthMode;
+
+/* --- messages --- */
+
+struct  _WifiConnectedState
+{
+  ProtobufCMessage base;
+  char *ip4_addr;
+  WifiAuthMode auth_mode;
+  ProtobufCBinaryData ssid;
+  ProtobufCBinaryData bssid;
+  int32_t channel;
+};
+#define WIFI_CONNECTED_STATE__INIT \
+ { PROTOBUF_C_MESSAGE_INIT (&wifi_connected_state__descriptor) \
+    , (char *)protobuf_c_empty_string, WIFI_AUTH_MODE__Open, {0,NULL}, {0,NULL}, 0 }
+
+
+/* WifiConnectedState methods */
+void   wifi_connected_state__init
+                     (WifiConnectedState         *message);
+size_t wifi_connected_state__get_packed_size
+                     (const WifiConnectedState   *message);
+size_t wifi_connected_state__pack
+                     (const WifiConnectedState   *message,
+                      uint8_t             *out);
+size_t wifi_connected_state__pack_to_buffer
+                     (const WifiConnectedState   *message,
+                      ProtobufCBuffer     *buffer);
+WifiConnectedState *
+       wifi_connected_state__unpack
+                     (ProtobufCAllocator  *allocator,
+                      size_t               len,
+                      const uint8_t       *data);
+void   wifi_connected_state__free_unpacked
+                     (WifiConnectedState *message,
+                      ProtobufCAllocator *allocator);
+/* --- per-message closures --- */
+
+typedef void (*WifiConnectedState_Closure)
+                 (const WifiConnectedState *message,
+                  void *closure_data);
+
+/* --- services --- */
+
+
+/* --- descriptors --- */
+
+extern const ProtobufCEnumDescriptor    wifi_station_state__descriptor;
+extern const ProtobufCEnumDescriptor    wifi_connect_failed_reason__descriptor;
+extern const ProtobufCEnumDescriptor    wifi_auth_mode__descriptor;
+extern const ProtobufCMessageDescriptor wifi_connected_state__descriptor;
+
+PROTOBUF_C__END_DECLS
+
+
+#endif  /* PROTOBUF_C_wifi_5fconstants_2eproto__INCLUDED */
diff --git a/components/wifi_provisioning/proto/makefile b/components/wifi_provisioning/proto/makefile
new file mode 100644 (file)
index 0000000..585e422
--- /dev/null
@@ -0,0 +1,7 @@
+all: c_proto python_proto
+
+c_proto: *.proto
+       @protoc-c --c_out=../proto-c/ -I . -I ../../protocomm/proto/ *.proto
+
+python_proto: *.proto
+       @protoc --python_out=../python/ -I . -I ../../protocomm/proto/ *.proto
diff --git a/components/wifi_provisioning/proto/wifi_config.proto b/components/wifi_provisioning/proto/wifi_config.proto
new file mode 100644 (file)
index 0000000..e273dc8
--- /dev/null
@@ -0,0 +1,57 @@
+syntax = "proto3";
+
+import "constants.proto";
+import "wifi_constants.proto";
+
+message CmdGetStatus {
+
+}
+
+message RespGetStatus {
+    Status status = 1;
+    WifiStationState sta_state = 2;
+    oneof state {
+        WifiConnectFailedReason fail_reason = 10;
+        WifiConnectedState connected = 11;
+    }
+}
+
+message CmdSetConfig {
+    bytes ssid = 1;
+    bytes passphrase = 2;
+    bytes bssid = 3;
+    int32 channel = 4;
+}
+
+message RespSetConfig {
+    Status status = 1;
+}
+
+message CmdApplyConfig {
+
+}
+
+message RespApplyConfig {
+    Status status = 1;
+}
+
+enum WiFiConfigMsgType {
+    TypeCmdGetStatus = 0;
+    TypeRespGetStatus = 1;
+    TypeCmdSetConfig = 2;
+    TypeRespSetConfig = 3;
+    TypeCmdApplyConfig = 4;
+    TypeRespApplyConfig = 5;
+}
+
+message WiFiConfigPayload {
+    WiFiConfigMsgType msg = 1;
+    oneof payload {
+        CmdGetStatus cmd_get_status = 10;
+        RespGetStatus resp_get_status = 11;
+        CmdSetConfig cmd_set_config = 12;
+        RespSetConfig resp_set_config = 13;
+        CmdApplyConfig cmd_apply_config = 14;
+        RespApplyConfig resp_apply_config = 15;
+    }
+}
diff --git a/components/wifi_provisioning/proto/wifi_constants.proto b/components/wifi_provisioning/proto/wifi_constants.proto
new file mode 100644 (file)
index 0000000..95c7612
--- /dev/null
@@ -0,0 +1,31 @@
+syntax = "proto3";
+
+enum WifiStationState {
+    Connected = 0;
+    Connecting = 1;
+    Disconnected = 2;
+    ConnectionFailed = 3;
+}
+
+enum WifiConnectFailedReason {
+    AuthError = 0;
+    NetworkNotFound = 1;
+}
+
+enum WifiAuthMode {
+    Open = 0;
+    WEP  = 1;
+    WPA_PSK = 2;
+    WPA2_PSK = 3;
+    WPA_WPA2_PSK = 4;
+    WPA2_ENTERPRISE = 5;
+}
+
+message WifiConnectedState {
+    string ip4_addr = 1;
+    WifiAuthMode auth_mode = 2;
+    bytes ssid = 3;
+    bytes bssid = 4;
+    int32 channel = 5;
+}
+
diff --git a/components/wifi_provisioning/python/wifi_config_pb2.py b/components/wifi_provisioning/python/wifi_config_pb2.py
new file mode 100644 (file)
index 0000000..0dd6d43
--- /dev/null
@@ -0,0 +1,466 @@
+# Generated by the protocol buffer compiler.  DO NOT EDIT!
+# source: wifi_config.proto
+
+import sys
+_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
+from google.protobuf.internal import enum_type_wrapper
+from google.protobuf import descriptor as _descriptor
+from google.protobuf import message as _message
+from google.protobuf import reflection as _reflection
+from google.protobuf import symbol_database as _symbol_database
+from google.protobuf import descriptor_pb2
+# @@protoc_insertion_point(imports)
+
+_sym_db = _symbol_database.Default()
+
+
+import constants_pb2 as constants__pb2
+import wifi_constants_pb2 as wifi__constants__pb2
+
+
+DESCRIPTOR = _descriptor.FileDescriptor(
+  name='wifi_config.proto',
+  package='',
+  syntax='proto3',
+  serialized_pb=_b('\n\x11wifi_config.proto\x1a\x0f\x63onstants.proto\x1a\x14wifi_constants.proto\"\x0e\n\x0c\x43mdGetStatus\"\xb2\x01\n\rRespGetStatus\x12\x17\n\x06status\x18\x01 \x01(\x0e\x32\x07.Status\x12$\n\tsta_state\x18\x02 \x01(\x0e\x32\x11.WifiStationState\x12/\n\x0b\x66\x61il_reason\x18\n \x01(\x0e\x32\x18.WifiConnectFailedReasonH\x00\x12(\n\tconnected\x18\x0b \x01(\x0b\x32\x13.WifiConnectedStateH\x00\x42\x07\n\x05state\"P\n\x0c\x43mdSetConfig\x12\x0c\n\x04ssid\x18\x01 \x01(\x0c\x12\x12\n\npassphrase\x18\x02 \x01(\x0c\x12\r\n\x05\x62ssid\x18\x03 \x01(\x0c\x12\x0f\n\x07\x63hannel\x18\x04 \x01(\x05\"(\n\rRespSetConfig\x12\x17\n\x06status\x18\x01 \x01(\x0e\x32\x07.Status\"\x10\n\x0e\x43mdApplyConfig\"*\n\x0fRespApplyConfig\x12\x17\n\x06status\x18\x01 \x01(\x0e\x32\x07.Status\"\xc3\x02\n\x11WiFiConfigPayload\x12\x1f\n\x03msg\x18\x01 \x01(\x0e\x32\x12.WiFiConfigMsgType\x12\'\n\x0e\x63md_get_status\x18\n \x01(\x0b\x32\r.CmdGetStatusH\x00\x12)\n\x0fresp_get_status\x18\x0b \x01(\x0b\x32\x0e.RespGetStatusH\x00\x12\'\n\x0e\x63md_set_config\x18\x0c \x01(\x0b\x32\r.CmdSetConfigH\x00\x12)\n\x0fresp_set_config\x18\r \x01(\x0b\x32\x0e.RespSetConfigH\x00\x12+\n\x10\x63md_apply_config\x18\x0e \x01(\x0b\x32\x0f.CmdApplyConfigH\x00\x12-\n\x11resp_apply_config\x18\x0f \x01(\x0b\x32\x10.RespApplyConfigH\x00\x42\t\n\x07payload*\x9e\x01\n\x11WiFiConfigMsgType\x12\x14\n\x10TypeCmdGetStatus\x10\x00\x12\x15\n\x11TypeRespGetStatus\x10\x01\x12\x14\n\x10TypeCmdSetConfig\x10\x02\x12\x15\n\x11TypeRespSetConfig\x10\x03\x12\x16\n\x12TypeCmdApplyConfig\x10\x04\x12\x17\n\x13TypeRespApplyConfig\x10\x05\x62\x06proto3')
+  ,
+  dependencies=[constants__pb2.DESCRIPTOR,wifi__constants__pb2.DESCRIPTOR,])
+
+_WIFICONFIGMSGTYPE = _descriptor.EnumDescriptor(
+  name='WiFiConfigMsgType',
+  full_name='WiFiConfigMsgType',
+  filename=None,
+  file=DESCRIPTOR,
+  values=[
+    _descriptor.EnumValueDescriptor(
+      name='TypeCmdGetStatus', index=0, number=0,
+      options=None,
+      type=None),
+    _descriptor.EnumValueDescriptor(
+      name='TypeRespGetStatus', index=1, number=1,
+      options=None,
+      type=None),
+    _descriptor.EnumValueDescriptor(
+      name='TypeCmdSetConfig', index=2, number=2,
+      options=None,
+      type=None),
+    _descriptor.EnumValueDescriptor(
+      name='TypeRespSetConfig', index=3, number=3,
+      options=None,
+      type=None),
+    _descriptor.EnumValueDescriptor(
+      name='TypeCmdApplyConfig', index=4, number=4,
+      options=None,
+      type=None),
+    _descriptor.EnumValueDescriptor(
+      name='TypeRespApplyConfig', index=5, number=5,
+      options=None,
+      type=None),
+  ],
+  containing_type=None,
+  options=None,
+  serialized_start=770,
+  serialized_end=928,
+)
+_sym_db.RegisterEnumDescriptor(_WIFICONFIGMSGTYPE)
+
+WiFiConfigMsgType = enum_type_wrapper.EnumTypeWrapper(_WIFICONFIGMSGTYPE)
+TypeCmdGetStatus = 0
+TypeRespGetStatus = 1
+TypeCmdSetConfig = 2
+TypeRespSetConfig = 3
+TypeCmdApplyConfig = 4
+TypeRespApplyConfig = 5
+
+
+
+_CMDGETSTATUS = _descriptor.Descriptor(
+  name='CmdGetStatus',
+  full_name='CmdGetStatus',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  fields=[
+  ],
+  extensions=[
+  ],
+  nested_types=[],
+  enum_types=[
+  ],
+  options=None,
+  is_extendable=False,
+  syntax='proto3',
+  extension_ranges=[],
+  oneofs=[
+  ],
+  serialized_start=60,
+  serialized_end=74,
+)
+
+
+_RESPGETSTATUS = _descriptor.Descriptor(
+  name='RespGetStatus',
+  full_name='RespGetStatus',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  fields=[
+    _descriptor.FieldDescriptor(
+      name='status', full_name='RespGetStatus.status', index=0,
+      number=1, type=14, cpp_type=8, label=1,
+      has_default_value=False, default_value=0,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+    _descriptor.FieldDescriptor(
+      name='sta_state', full_name='RespGetStatus.sta_state', index=1,
+      number=2, type=14, cpp_type=8, label=1,
+      has_default_value=False, default_value=0,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+    _descriptor.FieldDescriptor(
+      name='fail_reason', full_name='RespGetStatus.fail_reason', index=2,
+      number=10, type=14, cpp_type=8, label=1,
+      has_default_value=False, default_value=0,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+    _descriptor.FieldDescriptor(
+      name='connected', full_name='RespGetStatus.connected', index=3,
+      number=11, type=11, cpp_type=10, label=1,
+      has_default_value=False, default_value=None,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+  ],
+  extensions=[
+  ],
+  nested_types=[],
+  enum_types=[
+  ],
+  options=None,
+  is_extendable=False,
+  syntax='proto3',
+  extension_ranges=[],
+  oneofs=[
+    _descriptor.OneofDescriptor(
+      name='state', full_name='RespGetStatus.state',
+      index=0, containing_type=None, fields=[]),
+  ],
+  serialized_start=77,
+  serialized_end=255,
+)
+
+
+_CMDSETCONFIG = _descriptor.Descriptor(
+  name='CmdSetConfig',
+  full_name='CmdSetConfig',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  fields=[
+    _descriptor.FieldDescriptor(
+      name='ssid', full_name='CmdSetConfig.ssid', index=0,
+      number=1, type=12, cpp_type=9, label=1,
+      has_default_value=False, default_value=_b(""),
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+    _descriptor.FieldDescriptor(
+      name='passphrase', full_name='CmdSetConfig.passphrase', index=1,
+      number=2, type=12, cpp_type=9, label=1,
+      has_default_value=False, default_value=_b(""),
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+    _descriptor.FieldDescriptor(
+      name='bssid', full_name='CmdSetConfig.bssid', index=2,
+      number=3, type=12, cpp_type=9, label=1,
+      has_default_value=False, default_value=_b(""),
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+    _descriptor.FieldDescriptor(
+      name='channel', full_name='CmdSetConfig.channel', index=3,
+      number=4, type=5, cpp_type=1, label=1,
+      has_default_value=False, default_value=0,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+  ],
+  extensions=[
+  ],
+  nested_types=[],
+  enum_types=[
+  ],
+  options=None,
+  is_extendable=False,
+  syntax='proto3',
+  extension_ranges=[],
+  oneofs=[
+  ],
+  serialized_start=257,
+  serialized_end=337,
+)
+
+
+_RESPSETCONFIG = _descriptor.Descriptor(
+  name='RespSetConfig',
+  full_name='RespSetConfig',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  fields=[
+    _descriptor.FieldDescriptor(
+      name='status', full_name='RespSetConfig.status', index=0,
+      number=1, type=14, cpp_type=8, label=1,
+      has_default_value=False, default_value=0,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+  ],
+  extensions=[
+  ],
+  nested_types=[],
+  enum_types=[
+  ],
+  options=None,
+  is_extendable=False,
+  syntax='proto3',
+  extension_ranges=[],
+  oneofs=[
+  ],
+  serialized_start=339,
+  serialized_end=379,
+)
+
+
+_CMDAPPLYCONFIG = _descriptor.Descriptor(
+  name='CmdApplyConfig',
+  full_name='CmdApplyConfig',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  fields=[
+  ],
+  extensions=[
+  ],
+  nested_types=[],
+  enum_types=[
+  ],
+  options=None,
+  is_extendable=False,
+  syntax='proto3',
+  extension_ranges=[],
+  oneofs=[
+  ],
+  serialized_start=381,
+  serialized_end=397,
+)
+
+
+_RESPAPPLYCONFIG = _descriptor.Descriptor(
+  name='RespApplyConfig',
+  full_name='RespApplyConfig',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  fields=[
+    _descriptor.FieldDescriptor(
+      name='status', full_name='RespApplyConfig.status', index=0,
+      number=1, type=14, cpp_type=8, label=1,
+      has_default_value=False, default_value=0,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+  ],
+  extensions=[
+  ],
+  nested_types=[],
+  enum_types=[
+  ],
+  options=None,
+  is_extendable=False,
+  syntax='proto3',
+  extension_ranges=[],
+  oneofs=[
+  ],
+  serialized_start=399,
+  serialized_end=441,
+)
+
+
+_WIFICONFIGPAYLOAD = _descriptor.Descriptor(
+  name='WiFiConfigPayload',
+  full_name='WiFiConfigPayload',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  fields=[
+    _descriptor.FieldDescriptor(
+      name='msg', full_name='WiFiConfigPayload.msg', index=0,
+      number=1, type=14, cpp_type=8, label=1,
+      has_default_value=False, default_value=0,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+    _descriptor.FieldDescriptor(
+      name='cmd_get_status', full_name='WiFiConfigPayload.cmd_get_status', index=1,
+      number=10, type=11, cpp_type=10, label=1,
+      has_default_value=False, default_value=None,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+    _descriptor.FieldDescriptor(
+      name='resp_get_status', full_name='WiFiConfigPayload.resp_get_status', index=2,
+      number=11, type=11, cpp_type=10, label=1,
+      has_default_value=False, default_value=None,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+    _descriptor.FieldDescriptor(
+      name='cmd_set_config', full_name='WiFiConfigPayload.cmd_set_config', index=3,
+      number=12, type=11, cpp_type=10, label=1,
+      has_default_value=False, default_value=None,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+    _descriptor.FieldDescriptor(
+      name='resp_set_config', full_name='WiFiConfigPayload.resp_set_config', index=4,
+      number=13, type=11, cpp_type=10, label=1,
+      has_default_value=False, default_value=None,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+    _descriptor.FieldDescriptor(
+      name='cmd_apply_config', full_name='WiFiConfigPayload.cmd_apply_config', index=5,
+      number=14, type=11, cpp_type=10, label=1,
+      has_default_value=False, default_value=None,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+    _descriptor.FieldDescriptor(
+      name='resp_apply_config', full_name='WiFiConfigPayload.resp_apply_config', index=6,
+      number=15, type=11, cpp_type=10, label=1,
+      has_default_value=False, default_value=None,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+  ],
+  extensions=[
+  ],
+  nested_types=[],
+  enum_types=[
+  ],
+  options=None,
+  is_extendable=False,
+  syntax='proto3',
+  extension_ranges=[],
+  oneofs=[
+    _descriptor.OneofDescriptor(
+      name='payload', full_name='WiFiConfigPayload.payload',
+      index=0, containing_type=None, fields=[]),
+  ],
+  serialized_start=444,
+  serialized_end=767,
+)
+
+_RESPGETSTATUS.fields_by_name['status'].enum_type = constants__pb2._STATUS
+_RESPGETSTATUS.fields_by_name['sta_state'].enum_type = wifi__constants__pb2._WIFISTATIONSTATE
+_RESPGETSTATUS.fields_by_name['fail_reason'].enum_type = wifi__constants__pb2._WIFICONNECTFAILEDREASON
+_RESPGETSTATUS.fields_by_name['connected'].message_type = wifi__constants__pb2._WIFICONNECTEDSTATE
+_RESPGETSTATUS.oneofs_by_name['state'].fields.append(
+  _RESPGETSTATUS.fields_by_name['fail_reason'])
+_RESPGETSTATUS.fields_by_name['fail_reason'].containing_oneof = _RESPGETSTATUS.oneofs_by_name['state']
+_RESPGETSTATUS.oneofs_by_name['state'].fields.append(
+  _RESPGETSTATUS.fields_by_name['connected'])
+_RESPGETSTATUS.fields_by_name['connected'].containing_oneof = _RESPGETSTATUS.oneofs_by_name['state']
+_RESPSETCONFIG.fields_by_name['status'].enum_type = constants__pb2._STATUS
+_RESPAPPLYCONFIG.fields_by_name['status'].enum_type = constants__pb2._STATUS
+_WIFICONFIGPAYLOAD.fields_by_name['msg'].enum_type = _WIFICONFIGMSGTYPE
+_WIFICONFIGPAYLOAD.fields_by_name['cmd_get_status'].message_type = _CMDGETSTATUS
+_WIFICONFIGPAYLOAD.fields_by_name['resp_get_status'].message_type = _RESPGETSTATUS
+_WIFICONFIGPAYLOAD.fields_by_name['cmd_set_config'].message_type = _CMDSETCONFIG
+_WIFICONFIGPAYLOAD.fields_by_name['resp_set_config'].message_type = _RESPSETCONFIG
+_WIFICONFIGPAYLOAD.fields_by_name['cmd_apply_config'].message_type = _CMDAPPLYCONFIG
+_WIFICONFIGPAYLOAD.fields_by_name['resp_apply_config'].message_type = _RESPAPPLYCONFIG
+_WIFICONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+  _WIFICONFIGPAYLOAD.fields_by_name['cmd_get_status'])
+_WIFICONFIGPAYLOAD.fields_by_name['cmd_get_status'].containing_oneof = _WIFICONFIGPAYLOAD.oneofs_by_name['payload']
+_WIFICONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+  _WIFICONFIGPAYLOAD.fields_by_name['resp_get_status'])
+_WIFICONFIGPAYLOAD.fields_by_name['resp_get_status'].containing_oneof = _WIFICONFIGPAYLOAD.oneofs_by_name['payload']
+_WIFICONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+  _WIFICONFIGPAYLOAD.fields_by_name['cmd_set_config'])
+_WIFICONFIGPAYLOAD.fields_by_name['cmd_set_config'].containing_oneof = _WIFICONFIGPAYLOAD.oneofs_by_name['payload']
+_WIFICONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+  _WIFICONFIGPAYLOAD.fields_by_name['resp_set_config'])
+_WIFICONFIGPAYLOAD.fields_by_name['resp_set_config'].containing_oneof = _WIFICONFIGPAYLOAD.oneofs_by_name['payload']
+_WIFICONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+  _WIFICONFIGPAYLOAD.fields_by_name['cmd_apply_config'])
+_WIFICONFIGPAYLOAD.fields_by_name['cmd_apply_config'].containing_oneof = _WIFICONFIGPAYLOAD.oneofs_by_name['payload']
+_WIFICONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+  _WIFICONFIGPAYLOAD.fields_by_name['resp_apply_config'])
+_WIFICONFIGPAYLOAD.fields_by_name['resp_apply_config'].containing_oneof = _WIFICONFIGPAYLOAD.oneofs_by_name['payload']
+DESCRIPTOR.message_types_by_name['CmdGetStatus'] = _CMDGETSTATUS
+DESCRIPTOR.message_types_by_name['RespGetStatus'] = _RESPGETSTATUS
+DESCRIPTOR.message_types_by_name['CmdSetConfig'] = _CMDSETCONFIG
+DESCRIPTOR.message_types_by_name['RespSetConfig'] = _RESPSETCONFIG
+DESCRIPTOR.message_types_by_name['CmdApplyConfig'] = _CMDAPPLYCONFIG
+DESCRIPTOR.message_types_by_name['RespApplyConfig'] = _RESPAPPLYCONFIG
+DESCRIPTOR.message_types_by_name['WiFiConfigPayload'] = _WIFICONFIGPAYLOAD
+DESCRIPTOR.enum_types_by_name['WiFiConfigMsgType'] = _WIFICONFIGMSGTYPE
+_sym_db.RegisterFileDescriptor(DESCRIPTOR)
+
+CmdGetStatus = _reflection.GeneratedProtocolMessageType('CmdGetStatus', (_message.Message,), dict(
+  DESCRIPTOR = _CMDGETSTATUS,
+  __module__ = 'wifi_config_pb2'
+  # @@protoc_insertion_point(class_scope:CmdGetStatus)
+  ))
+_sym_db.RegisterMessage(CmdGetStatus)
+
+RespGetStatus = _reflection.GeneratedProtocolMessageType('RespGetStatus', (_message.Message,), dict(
+  DESCRIPTOR = _RESPGETSTATUS,
+  __module__ = 'wifi_config_pb2'
+  # @@protoc_insertion_point(class_scope:RespGetStatus)
+  ))
+_sym_db.RegisterMessage(RespGetStatus)
+
+CmdSetConfig = _reflection.GeneratedProtocolMessageType('CmdSetConfig', (_message.Message,), dict(
+  DESCRIPTOR = _CMDSETCONFIG,
+  __module__ = 'wifi_config_pb2'
+  # @@protoc_insertion_point(class_scope:CmdSetConfig)
+  ))
+_sym_db.RegisterMessage(CmdSetConfig)
+
+RespSetConfig = _reflection.GeneratedProtocolMessageType('RespSetConfig', (_message.Message,), dict(
+  DESCRIPTOR = _RESPSETCONFIG,
+  __module__ = 'wifi_config_pb2'
+  # @@protoc_insertion_point(class_scope:RespSetConfig)
+  ))
+_sym_db.RegisterMessage(RespSetConfig)
+
+CmdApplyConfig = _reflection.GeneratedProtocolMessageType('CmdApplyConfig', (_message.Message,), dict(
+  DESCRIPTOR = _CMDAPPLYCONFIG,
+  __module__ = 'wifi_config_pb2'
+  # @@protoc_insertion_point(class_scope:CmdApplyConfig)
+  ))
+_sym_db.RegisterMessage(CmdApplyConfig)
+
+RespApplyConfig = _reflection.GeneratedProtocolMessageType('RespApplyConfig', (_message.Message,), dict(
+  DESCRIPTOR = _RESPAPPLYCONFIG,
+  __module__ = 'wifi_config_pb2'
+  # @@protoc_insertion_point(class_scope:RespApplyConfig)
+  ))
+_sym_db.RegisterMessage(RespApplyConfig)
+
+WiFiConfigPayload = _reflection.GeneratedProtocolMessageType('WiFiConfigPayload', (_message.Message,), dict(
+  DESCRIPTOR = _WIFICONFIGPAYLOAD,
+  __module__ = 'wifi_config_pb2'
+  # @@protoc_insertion_point(class_scope:WiFiConfigPayload)
+  ))
+_sym_db.RegisterMessage(WiFiConfigPayload)
+
+
+# @@protoc_insertion_point(module_scope)
diff --git a/components/wifi_provisioning/python/wifi_constants_pb2.py b/components/wifi_provisioning/python/wifi_constants_pb2.py
new file mode 100644 (file)
index 0000000..8090568
--- /dev/null
@@ -0,0 +1,207 @@
+# Generated by the protocol buffer compiler.  DO NOT EDIT!
+# source: wifi_constants.proto
+
+import sys
+_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
+from google.protobuf.internal import enum_type_wrapper
+from google.protobuf import descriptor as _descriptor
+from google.protobuf import message as _message
+from google.protobuf import reflection as _reflection
+from google.protobuf import symbol_database as _symbol_database
+from google.protobuf import descriptor_pb2
+# @@protoc_insertion_point(imports)
+
+_sym_db = _symbol_database.Default()
+
+
+
+
+DESCRIPTOR = _descriptor.FileDescriptor(
+  name='wifi_constants.proto',
+  package='',
+  syntax='proto3',
+  serialized_pb=_b('\n\x14wifi_constants.proto\"v\n\x12WifiConnectedState\x12\x10\n\x08ip4_addr\x18\x01 \x01(\t\x12 \n\tauth_mode\x18\x02 \x01(\x0e\x32\r.WifiAuthMode\x12\x0c\n\x04ssid\x18\x03 \x01(\x0c\x12\r\n\x05\x62ssid\x18\x04 \x01(\x0c\x12\x0f\n\x07\x63hannel\x18\x05 \x01(\x05*Y\n\x10WifiStationState\x12\r\n\tConnected\x10\x00\x12\x0e\n\nConnecting\x10\x01\x12\x10\n\x0c\x44isconnected\x10\x02\x12\x14\n\x10\x43onnectionFailed\x10\x03*=\n\x17WifiConnectFailedReason\x12\r\n\tAuthError\x10\x00\x12\x13\n\x0fNetworkNotFound\x10\x01*c\n\x0cWifiAuthMode\x12\x08\n\x04Open\x10\x00\x12\x07\n\x03WEP\x10\x01\x12\x0b\n\x07WPA_PSK\x10\x02\x12\x0c\n\x08WPA2_PSK\x10\x03\x12\x10\n\x0cWPA_WPA2_PSK\x10\x04\x12\x13\n\x0fWPA2_ENTERPRISE\x10\x05\x62\x06proto3')
+)
+
+_WIFISTATIONSTATE = _descriptor.EnumDescriptor(
+  name='WifiStationState',
+  full_name='WifiStationState',
+  filename=None,
+  file=DESCRIPTOR,
+  values=[
+    _descriptor.EnumValueDescriptor(
+      name='Connected', index=0, number=0,
+      options=None,
+      type=None),
+    _descriptor.EnumValueDescriptor(
+      name='Connecting', index=1, number=1,
+      options=None,
+      type=None),
+    _descriptor.EnumValueDescriptor(
+      name='Disconnected', index=2, number=2,
+      options=None,
+      type=None),
+    _descriptor.EnumValueDescriptor(
+      name='ConnectionFailed', index=3, number=3,
+      options=None,
+      type=None),
+  ],
+  containing_type=None,
+  options=None,
+  serialized_start=144,
+  serialized_end=233,
+)
+_sym_db.RegisterEnumDescriptor(_WIFISTATIONSTATE)
+
+WifiStationState = enum_type_wrapper.EnumTypeWrapper(_WIFISTATIONSTATE)
+_WIFICONNECTFAILEDREASON = _descriptor.EnumDescriptor(
+  name='WifiConnectFailedReason',
+  full_name='WifiConnectFailedReason',
+  filename=None,
+  file=DESCRIPTOR,
+  values=[
+    _descriptor.EnumValueDescriptor(
+      name='AuthError', index=0, number=0,
+      options=None,
+      type=None),
+    _descriptor.EnumValueDescriptor(
+      name='NetworkNotFound', index=1, number=1,
+      options=None,
+      type=None),
+  ],
+  containing_type=None,
+  options=None,
+  serialized_start=235,
+  serialized_end=296,
+)
+_sym_db.RegisterEnumDescriptor(_WIFICONNECTFAILEDREASON)
+
+WifiConnectFailedReason = enum_type_wrapper.EnumTypeWrapper(_WIFICONNECTFAILEDREASON)
+_WIFIAUTHMODE = _descriptor.EnumDescriptor(
+  name='WifiAuthMode',
+  full_name='WifiAuthMode',
+  filename=None,
+  file=DESCRIPTOR,
+  values=[
+    _descriptor.EnumValueDescriptor(
+      name='Open', index=0, number=0,
+      options=None,
+      type=None),
+    _descriptor.EnumValueDescriptor(
+      name='WEP', index=1, number=1,
+      options=None,
+      type=None),
+    _descriptor.EnumValueDescriptor(
+      name='WPA_PSK', index=2, number=2,
+      options=None,
+      type=None),
+    _descriptor.EnumValueDescriptor(
+      name='WPA2_PSK', index=3, number=3,
+      options=None,
+      type=None),
+    _descriptor.EnumValueDescriptor(
+      name='WPA_WPA2_PSK', index=4, number=4,
+      options=None,
+      type=None),
+    _descriptor.EnumValueDescriptor(
+      name='WPA2_ENTERPRISE', index=5, number=5,
+      options=None,
+      type=None),
+  ],
+  containing_type=None,
+  options=None,
+  serialized_start=298,
+  serialized_end=397,
+)
+_sym_db.RegisterEnumDescriptor(_WIFIAUTHMODE)
+
+WifiAuthMode = enum_type_wrapper.EnumTypeWrapper(_WIFIAUTHMODE)
+Connected = 0
+Connecting = 1
+Disconnected = 2
+ConnectionFailed = 3
+AuthError = 0
+NetworkNotFound = 1
+Open = 0
+WEP = 1
+WPA_PSK = 2
+WPA2_PSK = 3
+WPA_WPA2_PSK = 4
+WPA2_ENTERPRISE = 5
+
+
+
+_WIFICONNECTEDSTATE = _descriptor.Descriptor(
+  name='WifiConnectedState',
+  full_name='WifiConnectedState',
+  filename=None,
+  file=DESCRIPTOR,
+  containing_type=None,
+  fields=[
+    _descriptor.FieldDescriptor(
+      name='ip4_addr', full_name='WifiConnectedState.ip4_addr', index=0,
+      number=1, type=9, cpp_type=9, label=1,
+      has_default_value=False, default_value=_b("").decode('utf-8'),
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+    _descriptor.FieldDescriptor(
+      name='auth_mode', full_name='WifiConnectedState.auth_mode', index=1,
+      number=2, type=14, cpp_type=8, label=1,
+      has_default_value=False, default_value=0,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+    _descriptor.FieldDescriptor(
+      name='ssid', full_name='WifiConnectedState.ssid', index=2,
+      number=3, type=12, cpp_type=9, label=1,
+      has_default_value=False, default_value=_b(""),
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+    _descriptor.FieldDescriptor(
+      name='bssid', full_name='WifiConnectedState.bssid', index=3,
+      number=4, type=12, cpp_type=9, label=1,
+      has_default_value=False, default_value=_b(""),
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+    _descriptor.FieldDescriptor(
+      name='channel', full_name='WifiConnectedState.channel', index=4,
+      number=5, type=5, cpp_type=1, label=1,
+      has_default_value=False, default_value=0,
+      message_type=None, enum_type=None, containing_type=None,
+      is_extension=False, extension_scope=None,
+      options=None, file=DESCRIPTOR),
+  ],
+  extensions=[
+  ],
+  nested_types=[],
+  enum_types=[
+  ],
+  options=None,
+  is_extendable=False,
+  syntax='proto3',
+  extension_ranges=[],
+  oneofs=[
+  ],
+  serialized_start=24,
+  serialized_end=142,
+)
+
+_WIFICONNECTEDSTATE.fields_by_name['auth_mode'].enum_type = _WIFIAUTHMODE
+DESCRIPTOR.message_types_by_name['WifiConnectedState'] = _WIFICONNECTEDSTATE
+DESCRIPTOR.enum_types_by_name['WifiStationState'] = _WIFISTATIONSTATE
+DESCRIPTOR.enum_types_by_name['WifiConnectFailedReason'] = _WIFICONNECTFAILEDREASON
+DESCRIPTOR.enum_types_by_name['WifiAuthMode'] = _WIFIAUTHMODE
+_sym_db.RegisterFileDescriptor(DESCRIPTOR)
+
+WifiConnectedState = _reflection.GeneratedProtocolMessageType('WifiConnectedState', (_message.Message,), dict(
+  DESCRIPTOR = _WIFICONNECTEDSTATE,
+  __module__ = 'wifi_constants_pb2'
+  # @@protoc_insertion_point(class_scope:WifiConnectedState)
+  ))
+_sym_db.RegisterMessage(WifiConnectedState)
+
+
+# @@protoc_insertion_point(module_scope)
diff --git a/components/wifi_provisioning/src/wifi_config.c b/components/wifi_provisioning/src/wifi_config.c
new file mode 100644 (file)
index 0000000..6ce1798
--- /dev/null
@@ -0,0 +1,322 @@
+// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <stdio.h>
+#include <string.h>
+#include <esp_err.h>
+#include <esp_log.h>
+
+#include "wifi_constants.pb-c.h"
+#include "wifi_config.pb-c.h"
+
+#include <wifi_provisioning/wifi_config.h>
+
+static const char* TAG = "WiFiProvConfig";
+
+typedef struct wifi_prov_config_cmd {
+    int cmd_num;
+    esp_err_t (*command_handler)(WiFiConfigPayload *req,
+                                 WiFiConfigPayload *resp, void *priv_data);
+} wifi_prov_config_cmd_t;
+
+static esp_err_t cmd_get_status_handler(WiFiConfigPayload *req,
+                                        WiFiConfigPayload *resp, void *priv_data);
+
+static esp_err_t cmd_set_config_handler(WiFiConfigPayload *req,
+                                        WiFiConfigPayload *resp, void *priv_data);
+
+static esp_err_t cmd_apply_config_handler(WiFiConfigPayload *req,
+                                          WiFiConfigPayload *resp, void *priv_data);
+
+static wifi_prov_config_cmd_t cmd_table[] = {
+    {
+        .cmd_num = WI_FI_CONFIG_MSG_TYPE__TypeCmdGetStatus,
+        .command_handler = cmd_get_status_handler
+    },
+    {
+        .cmd_num = WI_FI_CONFIG_MSG_TYPE__TypeCmdSetConfig,
+        .command_handler = cmd_set_config_handler
+    },
+    {
+        .cmd_num = WI_FI_CONFIG_MSG_TYPE__TypeCmdApplyConfig,
+        .command_handler = cmd_apply_config_handler
+    }
+};
+
+static esp_err_t cmd_get_status_handler(WiFiConfigPayload *req,
+                                        WiFiConfigPayload *resp, void *priv_data)
+{
+    ESP_LOGD(TAG, "Enter cmd_get_status_handler");
+    wifi_prov_config_handlers_t *h = (wifi_prov_config_handlers_t *) priv_data;
+    if (!h) {
+        ESP_LOGE(TAG, "Command invoked without handlers");
+        return ESP_ERR_INVALID_STATE;
+    }
+
+    RespGetStatus *resp_payload = (RespGetStatus *) malloc(sizeof(RespGetStatus));
+    if (!resp_payload) {
+        ESP_LOGE(TAG, "Error allocating memory");
+        return ESP_ERR_NO_MEM;
+    }
+    resp_get_status__init(resp_payload);
+
+    wifi_prov_config_get_data_t resp_data;
+    if (h->get_status_handler(&resp_data) == ESP_OK) {
+        if (resp_data.wifi_state == WIFI_PROV_STA_CONNECTING) {
+            resp_payload->sta_state = WIFI_STATION_STATE__Connecting;
+            resp_payload->state_case = RESP_GET_STATUS__STATE_CONNECTED;
+        } else if (resp_data.wifi_state == WIFI_PROV_STA_CONNECTED) {
+            resp_payload->sta_state  = WIFI_STATION_STATE__Connected;
+            resp_payload->state_case = RESP_GET_STATUS__STATE_CONNECTED;
+            WifiConnectedState *connected = (WifiConnectedState *)(
+                                            malloc(sizeof(WifiConnectedState)));
+            if (!connected) {
+                ESP_LOGE(TAG, "Error allocating memory");
+                return ESP_ERR_NO_MEM;
+            }
+            resp_payload->connected  = connected;
+            wifi_connected_state__init(connected);
+
+            connected->ip4_addr = strdup(resp_data.conn_info.ip_addr);
+            if (connected->ip4_addr == NULL) {
+                free(resp_payload);
+                return ESP_ERR_NO_MEM;
+            }
+
+            connected->bssid.len  = sizeof(resp_data.conn_info.bssid);
+            connected->bssid.data = (uint8_t *) strndup(resp_data.conn_info.bssid,
+                                                        sizeof(resp_data.conn_info.bssid));
+            if (connected->bssid.data == NULL) {
+                free(connected->ip4_addr);
+                free(resp_payload);
+                return ESP_ERR_NO_MEM;
+            }
+
+            connected->ssid.len   = strlen(resp_data.conn_info.ssid);
+            connected->ssid.data  = (uint8_t *) strdup(resp_data.conn_info.ssid);
+            if (connected->ssid.data == NULL) {
+                free(connected->bssid.data);
+                free(connected->ip4_addr);
+                free(resp_payload);
+                return ESP_ERR_NO_MEM;
+            }
+
+            connected->channel    = resp_data.conn_info.channel;
+            connected->auth_mode  = resp_data.conn_info.auth_mode;
+        } else if (resp_data.wifi_state == WIFI_PROV_STA_DISCONNECTED) {
+            resp_payload->sta_state = WIFI_STATION_STATE__ConnectionFailed;
+            resp_payload->state_case = RESP_GET_STATUS__STATE_FAIL_REASON;
+
+            if (resp_data.fail_reason == WIFI_PROV_STA_AUTH_ERROR) {
+                resp_payload->fail_reason = WIFI_CONNECT_FAILED_REASON__AuthError;
+            } else if (resp_data.fail_reason == WIFI_PROV_STA_AP_NOT_FOUND) {
+                resp_payload->fail_reason = WIFI_CONNECT_FAILED_REASON__NetworkNotFound;
+            }
+        }
+        resp_payload->status = STATUS__Success;
+    }
+
+    resp->payload_case = WI_FI_CONFIG_PAYLOAD__PAYLOAD_RESP_GET_STATUS;
+    resp->resp_get_status = resp_payload;
+    return ESP_OK;
+}
+
+static esp_err_t cmd_set_config_handler(WiFiConfigPayload *req,
+                                        WiFiConfigPayload *resp, void  *priv_data)
+{
+    ESP_LOGD(TAG, "Enter cmd_set_config_handler");
+    wifi_prov_config_handlers_t *h = (wifi_prov_config_handlers_t *) priv_data;
+    if (!h) {
+        ESP_LOGE(TAG, "Command invoked without handlers");
+        return ESP_ERR_INVALID_STATE;
+    }
+
+    RespSetConfig *resp_payload = (RespSetConfig *) malloc(sizeof(RespSetConfig));
+    if (resp_payload == NULL) {
+        ESP_LOGE(TAG, "Error allocating memory");
+        return ESP_ERR_NO_MEM;
+    }
+    resp_set_config__init(resp_payload);
+
+    wifi_prov_config_set_data_t req_data;
+    memset(&req_data, 0, sizeof(req_data));
+    memcpy(req_data.ssid, req->cmd_set_config->ssid.data,
+           req->cmd_set_config->ssid.len);
+    memcpy(req_data.password, req->cmd_set_config->passphrase.data,
+           req->cmd_set_config->passphrase.len);
+    memcpy(req_data.bssid, req->cmd_set_config->bssid.data,
+           req->cmd_set_config->bssid.len);
+    req_data.channel = req->cmd_set_config->channel;
+    if (h->set_config_handler(&req_data) == ESP_OK) {
+        resp_payload->status = STATUS__Success;
+    }
+
+    resp->payload_case = WI_FI_CONFIG_PAYLOAD__PAYLOAD_RESP_SET_CONFIG;
+    resp->resp_set_config = resp_payload;
+    return ESP_OK;
+}
+
+static esp_err_t cmd_apply_config_handler(WiFiConfigPayload *req,
+                                          WiFiConfigPayload *resp, void  *priv_data)
+{
+    ESP_LOGD(TAG, "Enter cmd_apply_config_handler");
+    wifi_prov_config_handlers_t *h = (wifi_prov_config_handlers_t *) priv_data;
+    if (!h) {
+        ESP_LOGE(TAG, "Command invoked without handlers");
+        return ESP_ERR_INVALID_STATE;
+    }
+
+    RespApplyConfig *resp_payload = (RespApplyConfig *) malloc(sizeof(RespApplyConfig));
+    if (!resp_payload) {
+        ESP_LOGE(TAG, "Error allocating memory");
+        return ESP_ERR_NO_MEM;
+    }
+
+    resp_apply_config__init(resp_payload);
+
+    if (h->apply_config_handler() == ESP_OK) {
+        resp_payload->status = STATUS__Success;
+    } else {
+        resp_payload->status = STATUS__InvalidArgument;
+    }
+
+    resp->payload_case = WI_FI_CONFIG_PAYLOAD__PAYLOAD_RESP_APPLY_CONFIG;
+    resp->resp_apply_config = resp_payload;
+    return ESP_OK;
+}
+
+static int lookup_cmd_handler(int cmd_id)
+{
+    int i;
+
+    for (i = 0; i < sizeof(cmd_table)/sizeof(wifi_prov_config_cmd_t); i++) {
+        if (cmd_table[i].cmd_num == cmd_id) {
+            return i;
+        }
+    }
+
+    return -1;
+}
+static void wifi_prov_config_command_cleanup(WiFiConfigPayload *resp, void *priv_data)
+{
+    if (!resp) {
+        return;
+    }
+
+    switch (resp->msg) {
+        case WI_FI_CONFIG_MSG_TYPE__TypeRespGetStatus:
+            {
+                switch (resp->resp_get_status->sta_state) {
+                    case WIFI_STATION_STATE__Connecting:
+                        break;
+                    case WIFI_STATION_STATE__Connected:
+                        if (resp->resp_get_status->connected) {
+                            if (resp->resp_get_status->connected->ip4_addr) {
+                                free(resp->resp_get_status->connected->ip4_addr);
+                            }
+                            if (resp->resp_get_status->connected->bssid.data) {
+                                free(resp->resp_get_status->connected->bssid.data);
+                            }
+                            if (resp->resp_get_status->connected->ssid.data) {
+                                free(resp->resp_get_status->connected->ssid.data);
+                            }
+                            free(resp->resp_get_status->connected);
+                        }
+                        break;
+                    case WIFI_STATION_STATE__ConnectionFailed:
+                        break;
+                    default:
+                        break;
+                }
+                free(resp->resp_get_status);
+            }
+            break;
+        case WI_FI_CONFIG_MSG_TYPE__TypeRespSetConfig:
+            {
+                free(resp->resp_set_config);
+            }
+            break;
+        case WI_FI_CONFIG_MSG_TYPE__TypeRespApplyConfig:
+            {
+                free(resp->resp_apply_config);
+            }
+            break;
+        default:
+            ESP_LOGE(TAG, "Unsupported response type in cleanup_handler");
+            break;
+    }
+    return;
+}
+
+static esp_err_t wifi_prov_config_command_dispatcher(WiFiConfigPayload *req,
+                                                     WiFiConfigPayload *resp, void *priv_data)
+{
+    esp_err_t ret;
+
+    ESP_LOGD(TAG, "In wifi_prov_config_command_dispatcher Cmd=%d", req->msg);
+
+    int cmd_index = lookup_cmd_handler(req->msg);
+    if (cmd_index < 0) {
+        ESP_LOGE(TAG, "Invalid command handler lookup");
+        return ESP_FAIL;
+    }
+
+    ret = cmd_table[cmd_index].command_handler(req, resp, priv_data);
+    if (ret != ESP_OK) {
+        ESP_LOGE(TAG, "Error executing command handler");
+        return ESP_FAIL;
+    }
+
+    return ESP_OK;
+}
+
+esp_err_t wifi_prov_config_data_handler(uint32_t session_id, const uint8_t *inbuf, ssize_t inlen,
+                                        uint8_t **outbuf, ssize_t *outlen, void *priv_data)
+{
+    WiFiConfigPayload *req;
+    WiFiConfigPayload resp;
+    esp_err_t ret;
+
+    req = wi_fi_config_payload__unpack(NULL, inlen, inbuf);
+    if (!req) {
+        ESP_LOGE(TAG, "Unable to unpack config data");
+        return ESP_ERR_INVALID_ARG;
+    }
+
+    wi_fi_config_payload__init(&resp);
+    ret = wifi_prov_config_command_dispatcher(req, &resp, priv_data);
+    if (ret != ESP_OK) {
+        ESP_LOGE(TAG, "Proto command dispatcher error %d", ret);
+        return ESP_FAIL;
+    }
+
+    resp.msg = req->msg + 1; /* Response is request + 1 */
+    wi_fi_config_payload__free_unpacked(req, NULL);
+
+    *outlen = wi_fi_config_payload__get_packed_size(&resp);
+    if (*outlen <= 0) {
+        ESP_LOGE(TAG, "Invalid encoding for response");
+        return ESP_FAIL;
+    }
+
+    *outbuf = (uint8_t *) malloc(*outlen);
+    if (!*outbuf) {
+        ESP_LOGE(TAG, "System out of memory");
+        return ESP_ERR_NO_MEM;
+    }
+    wi_fi_config_payload__pack(&resp, *outbuf);
+    wifi_prov_config_command_cleanup(&resp, priv_data);
+
+    return ESP_OK;
+}