]> Git Repo - esp-hosted.git/commitdiff
`station_connect.py` `station_disconnect.py` `softap_config.py` python scripts are...
authorajita.chavan <[email protected]>
Mon, 23 Mar 2020 08:34:54 +0000 (14:04 +0530)
committerajita.chavan <[email protected]>
Mon, 6 Apr 2020 14:45:33 +0000 (20:15 +0530)
Signed-off-by: ajita.chavan <[email protected]>
20 files changed:
__init__.py [deleted file]
esp_at/at_commands/__init__.py [deleted file]
esp_at/at_commands/at_commands.py [deleted file]
esp_at/rpi_init.sh [deleted file]
esp_at/softap_config.py [deleted file]
esp_at/station_connect.py [deleted file]
esp_at/station_disconnect.py [deleted file]
host_comm/host_commands/__init__.py [new file with mode: 0644]
host_comm/host_commands/slave_comm.py
host_comm/host_commands/slave_config.proto [deleted file]
host_comm/rpi_init.sh [new file with mode: 0755]
host_comm/softap_config.py [new file with mode: 0644]
host_comm/station_connect.py [new file with mode: 0644]
host_comm/station_disconnect.py [new file with mode: 0644]
host_comm/test.py
proto/slave_config.proto [new file with mode: 0644]
slave_config.proto [deleted file]
slave_driver/sdio_slave_test/main/protocomm_pserial.h [new file with mode: 0644]
slave_driver/sdio_slave_test/main/slave_commands.c
slave_driver/sdio_slave_test/main/slave_commands.h [new file with mode: 0644]

diff --git a/__init__.py b/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/esp_at/at_commands/__init__.py b/esp_at/at_commands/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/esp_at/at_commands/at_commands.py b/esp_at/at_commands/at_commands.py
deleted file mode 100644 (file)
index 62652f9..0000000
+++ /dev/null
@@ -1,510 +0,0 @@
-# Copyright 2019 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.
-
-import serial
-import string
-import time
-
-# Default parameters
-success = 'success'
-failure = 'failure'
-
-f1 = open("/dev/esps0","w")
-f2 = open("/dev/esps0","r")
-
-def check_ok(string):
-    if (string == 'OK'):
-        return 1
-    else :
-        return 0
-
-def check_others(string,sub_string):
-    #print(string)
-    #print(sub_string)
-    x = string.find(sub_string)
-    #print(x)
-    if (x == -1):
-        return 0
-    else:
-        return 1
-
-def check(string, sub_string):
-    #print('Inside check function')
-    #print(string)
-    x = ' '.join([str(elem) for elem in string])
-    x = string.split('\n')
-    #print(x)
-    x = [s for s in x if sub_string in s]
-    #print(x)
-    x = ' '.join([str(elem) for elem in x])
-    #print(x)
-    if ('OK' == sub_string):
-        ret = check_ok(x)
-        return ret
-    else:
-        ret = check_others(x,sub_string)
-        return ret
-
-def file_flush():
-    f1.flush()
-    f2.flush()
-    return
-
-def get_response(command,wait):
-    file_flush()
-    s = f1.write((command+'\r\n'))
-    #print(s)
-    time.sleep(wait)
-    s = f2.read(2048)
-    #print(s)
-    return s
-
-def check_response(ip,sp):
-    ip = check(ip,sp)
-    #print(ip)
-    if (ip) :
-        return success
-    else :
-        return failure
-
-def test_at():
-    command = 'AT'
-    ret = get_response(command,0.2)
-    ret = check_response(ret,'OK')
-    return ret
-
-def restart():
-    command = 'AT+RST'
-    ret = get_response(command,0.2)
-    ret = check_response(ret,'OK')
-    return ret
-
-def get_version():
-    command = 'AT+GMR'
-    ret = get_response(command,0.2)
-    res = check(ret,'OK')
-    if (res == 1):
-        #print(ret)
-        #x = ' '.join([str(elem) for elem in ret])
-        ##print(x)
-        x = ret.split('\n')
-        at_version = [s for s in x if 'AT version' in s]
-        at_version = ' '.join([str(elem) for elem in at_version])
-        sdk_version = [s for s in x if 'SDK version' in s]
-        sdk_version = ' '.join([str(elem) for elem in sdk_version])
-        custom_version = [s for s in x if 'custom_version' in s]
-        custom_version = ' '.join([str(elem) for elem in custom_version])
-        return at_version,sdk_version,custom_version
-    else:
-        return failure
-
-def enter_deep_sleep_mode(sleep_in_ms):
-    command = 'AT+GSLP='+str(sleep_in_ms)
-    #print(command)
-    time.sleep(sleep_in_ms*0.001)
-    ret = get_response(command,0.2)
-    ret = check_response(ret,'ready')
-    return ret
-
-def echo_on():
-    command = 'ATE1'
-    #print(command)
-    ret = get_response(command,0.2)
-    ret = check_response(ret,'OK')
-    return ret
-
-def echo_off():
-    command = 'ATE0'
-    #print(command)
-    ret = get_response(command,0.2)
-    ret = check_response(ret,'OK')
-    return ret
-
-def restore_factory():
-    command = 'AT+RESTORE'
-    #print(command)
-    ret = get_response(command,0.2)
-    ret = check_response(ret,'OK')
-    return ret
-
-# Its a query command to get current uart configuration, not saved in flash
-# This function sends baudrate, data_bits, stop bit,parity,flow_control
-def get_current_uart_config():
-    command = 'AT+UART_CUR?'
-    ret = get_response(command,0.2)
-    res = check(ret,'OK')
-    if (res == 1):
-        res = check(ret,'UART_CUR:')
-        if (res == 1):
-            x = ret.split('\n')
-            #print(x)
-            uart_config = [s for s in x if 'UART_CUR:' in s]
-            x = ' '.join([str(elem) for elem in uart_config])
-            x = x.split(',')
-            flow_control = x[4]
-            parity = x[3]
-            stop_bit = x[2]
-            data_bits = x[1]
-            baudrate = x[0]
-            baudrate = baudrate[10:]
-            #print(x)
-            return baudrate,data_bits,stop_bit,parity,flow_control
-        else:
-            return 'OK'
-    else:
-        return failure
-
-# It sets current uart configuration, not saved in flash
-# This function needs baudrate, data_bits, stop bit,parity,flow_control as input parameter from user
-def set_current_uart_config(baudrate,data_bits,stop_bit,parity,flow_control):
-    command = 'AT+UART_CUR='+str(baudrate)+','+str(data_bits)+','+str(stop_bit)+','+str(parity)+','+str(flow_control)
-    ret = get_response(command,0.2)
-    ret = check_response(ret,'OK')
-    return ret
-
-# Its a query command to get default uart configuration, saved in flash
-# This function sends baudrate, data_bits, stop bit, parity, flow_control
-def get_default_uart_config():
-    command = 'AT+UART_DEF?'
-    ret = get_response(command,0.2)
-    res = check(ret,'OK')
-    if (res == 1):
-        res = check(ret,'UART_DEF:')
-        if (res == 1):
-            x = ret.split('\n')
-            #print(x)
-            uart_config = [s for s in x if 'UART_DEF:' in s]
-            x = ' '.join([str(elem) for elem in uart_config])
-            x = x.split(',')
-            flow_control = x[4]
-            parity = x[3]
-            stop_bit = x[2]
-            data_bits = x[1]
-            baudrate = x[0]
-            baudrate = baudrate[10:]
-            #print(x)
-            return baudrate,data_bits,stop_bit,parity,flow_control
-        else:
-            return 'OK'
-    else:
-        return failure
-
-# It sets current uart configuration, saved in flash
-# This function needs baudrate, data bits, stop bit,parity,flow control as input parameter from user
-def set_default_uart_config(baudrate,data_bits,stop_bit,parity,flow_control):
-    command = 'AT+UART_DEF='+str(baudrate)+','+str(data_bits)+','+str(stop_bit)+','+str(parity)+','+str(flow_control)
-    ret = get_response(command,0.2)
-    ret = check_response(ret,'OK')
-    return ret
-
-# Function sets sleep mode
-# User can disable or enable the user mode
-# 0: disable the sleep mode
-# 1: Modem-sleep mode
-def set_sleep_mode(val):
-    command = 'AT+SLEEP='+str(val)
-    ret = get_response(command,0.2)
-    ret = check_response(ret,'OK')
-    return ret
-
-# #print available space in RAM in bytes
-
-def check_free_ram_size():
-    command = 'AT+SYSRAM?'
-    ret = get_response(command,0.2)
-    res = check(ret,'OK')
-    if (res == 1):
-        res = check(ret, 'SYSRAM:')
-        if (res == 1):
-            x = ret.split('\n')
-            #print(x)
-            free_ram_size = [s for s in x if 'SYSRAM:' in s]
-            x = ' '.join([str(elem) for elem in free_ram_size])
-            free_ram_size = x[8:]
-            return free_ram_size
-        else:
-            return 'OK'
-    else:
-        return failure
-
-#wifi modes supported
-#0: null Mode, Wi-Fi RF will be disabled
-#1: station mode
-#2: softAP mode
-#3: softAP+station mode
-def wifi_test():
-    command = 'AT+CWMODE=?'
-    ret = get_response(command,0.2)
-    ret = check_response(ret,'OK')
-    return ret
-
-
-# send the configured wifi mode
-def wifi_get_mode():
-    command='AT+CWMODE?'
-    ret = get_response(command,0.2)
-    #print("in wifi_get_imode")
-    res = check(ret,'OK')
-    if (res == 1) :
-        res = check(ret, '+CWMODE:')
-        if (res == 1):
-            #print('OK received futher')
-            x = ret.split('\n')
-            #print('check x split'+str(x))
-            wifi_mode = [s for s in x if '+CWMODE:' in s]
-            #print(wifi_mode)
-            wifi_mode = ' '.join([str(elem) for elem in wifi_mode])
-            #print(wifi_mode)
-            wifi_mode = wifi_mode[8:]
-            #print(wifi_mode)
-            return wifi_mode
-        else:
-            return 'OK'
-    else :
-        return failure
-
-# set wifi_mode
-# 0: null Mode, Wi-Fi RF will be disabled
-# 1: station mode
-# 2: softAP mode
-# 3: softAP+station mode
-def wifi_set_mode(mode):
-    command = 'AT+CWMODE='+str(mode)
-    #print("In wifi_set_mode")
-    ret = get_response(command,0.2)
-    ret = check_response(ret,'OK')
-    return ret
-
-def wifi_get_ap_config():
-    command = 'AT+CWJAP?'
-    ret = get_response(command,1)
-    res = check(ret,'OK')
-    #print("wifi_get_ap_config")
-    if (res==1):
-        #print('OK detected')
-        res = check(ret,'+CWJAP:')
-        if (res==1):
-            x = ret.split('\n')
-            #print(x)
-            wifi_mode = [s for s in x if '+CWJAP:' in s]
-            wifi_mode = ' '.join([str(elem) for elem in wifi_mode])
-            wifi_mode = wifi_mode.split(',')
-            #print(wifi_mode)
-            rssi = wifi_mode[3]
-            #print(rssi)
-            channel = wifi_mode[2]
-            #print(channel)
-            bssid = wifi_mode[1]
-            #print(bssid)
-            wifi_mode = wifi_mode[0]
-            ssid = wifi_mode[7:]
-            #print(ssid)
-            return ssid,bssid,channel,rssi
-        else:
-            return 'OK'
-    else :
-        return failure
-
-# user can send bssid as 0, If its not in use
-#user must send ssid, pwd, bssid of AP // bssid needed
-def wifi_set_ap_config(ssid,pwd,bssid):
-    if (str(bssid) != '0'):
-        command = 'AT+CWJAP='+'"'+str(ssid)+'"'+','+'"'+str(pwd)+'"'+','+'"'+str(bssid)+'"'
-    else :
-        command = 'AT+CWJAP='+'"'+str(ssid)+'"'+','+'"'+str(pwd)+'"'
-    #print(command)
-    #print('wifi_set_ap_config')
-    ret = get_response(command,2)
-    ret = check_response(ret,'WIFI CONNECTED')
-    return ret
-
-#list of available access points
-def wifi_get_ap_list():
-    command = 'AT+CWLAP'
-    ret = get_response(command,0.2)
-    res = check(ret,'OK')
-    if (res == 1):
-        res = check(ret, '+CWLAP:')
-        if (res == 1):
-            #print(ret)
-            wifi_mode = ret.split('\n')
-            #print(wifi_mode)
-            wifi_mode = [s for s in  wifi_mode if '+CWLAP:' in s]
-            wifi_mode = ' '.join([str(elem) for elem in wifi_mode])
-            wifi_mode = wifi_mode.split(',')
-            return wifi_mode
-        else:
-            return 'OK'
-    else:
-        return failure
-
-# get a query from specific ap
-# bssid is mandatory parameter while mac_addr,channel are optional
-# user can set mac_addr,channel as 0 if its not required
-def wifi_get_spec_ap(ssid,mac_addr,chnl):
-    if (str(mac_addr) != '0' and str(chnl) != '0'):
-        command = 'AT+CWLAP='+'"'+str(ssid)+'"'+','+'"'+str(mac_addr)+'"'+','+str(chnl)
-    if (str(mac_addr) != '0' and str(chnl) == '0'):
-        command = 'AT+CWLAP='+'"'+str(ssid)+'"'+','+'"'+str(mac_addr)+'"'
-    if (str(mac_addr) == '0' and str(chnl) != '0'):
-        command = 'AT+CWLAP='+'"'+str(ssid)+'"'+','+','+'"'+str(chnl)+'"'
-    if (str(mac_addr) == '0' and str(chnl) == '0'):
-        command = 'AT+CWLAP='+'"'+str(ssid)+'"'
-    #print(command)
-    ret = get_response(command,0.2)
-    res = check_response(ret,'OK')
-    if (res == 1) :
-        #print(ret)
-        res = check_response(ret,'+CWLAP:')
-        if (res == 1) :
-            x = ret.split('\n')
-            return ret
-        else :
-            return 'OK'
-    else :
-        return failure
-
-# set config to list ap command
-def wifi_set_config_list_ap(sort_enable,mask):
-    command = 'AT+CWLAPOPT='+str(sort_enable)+','+str(mask)
-    #print(command)
-    ret = get_response(command,0.2)
-    ret = check_response(ret,'OK')
-    return ret
-
-# Disconnect AP
-def wifi_disconnect_ap():
-    command = 'AT+CWQAP'
-    #print(command)
-    ret = get_response(command,0.2)
-    ret = check_response(ret,'OK')
-    return ret
-
-# user will get configuration of ESP32 softAP
-# parameters will be ssid, password, channel ID, encription method,
-# max connection count of stations to which ESP32 softAP can be connected, ssid hidden
-def wifi_get_softap_config():
-    command = 'AT+CWSAP?'
-    ret = get_response(command,0.2)
-    #print(command)
-    res = check(ret,'OK')
-    if (res == 1):
-        res = check(ret,'+CWSAP:')
-        if (res == 1):
-            x = ret.split('\n')
-            #print(x)
-            ap_config = [s for s in x if '+CWSAP:' in s]
-            ap_config = ' '.join([str(elem) for elem in ap_config])
-            ap_config = ap_config.split(',')
-            #print(ap_config)
-            ssid_hidden = ap_config[5]
-            max_conn = ap_config[4]
-            encryp_mtd = ap_config[3]
-            channel = ap_config[2]
-            password = ap_config[1]
-            password = password[1:-1]
-            ap_config = ap_config[0]
-            ssid = ap_config[7:]
-            ssid = ssid[1:-1]
-            return ssid,password,channel,encryp_mtd,max_conn,ssid_hidden
-        else:
-            return 'OK'
-    else:
-        return failure
-
-# If no password needed then set it as 0
-# set softap configuration of ESP32
-# parameters should be ssid, password, channel ID, encription method,
-# max connection count of stations to which ESP32 softAP can be connected, ssid hiddeni
-# user can set max_con as 0 and ssid_hidden as 0 if they dont want to use
-def wifi_set_softap_config(ssid,pwd,chl,ecn,max_conn,ssid_hidden):
-    if (str(max_conn) != '0' and str(ssid_hidden) != '0'):
-        command = 'AT+CWSAP='+'"'+str(ssid)+'"'+','+'"'+str(pwd)+'"'+','+str(chl)+','+str(ecn)+','+str(max_conn)+','+str(ssid_hidden)
-    if (str(max_conn) != '0' and str(ssid_hidden) == '0'):
-        command = 'AT+CWSAP='+'"'+str(ssid)+'"'+','+'"'+str(pwd)+'"'+','+str(chl)+','+str(ecn)+','+str(max_conn)
-    if (str(max_conn) == '0' and str(ssid_hidden) != '0'):
-        command = 'AT+CWSAP='+'"'+str(ssid)+'"'+','+'"'+str(pwd)+'"'+','+str(chl)+','+str(ecn)+','+','+str(ssid_hidden)
-    #print(command)
-    ret = get_response(command,2)
-    ret = check_response(ret,'OK')
-    return ret
-
-#IP station to which ESP32 softAP is connected
-def wifi_get_station_details():
-    command = 'AT+CWLIF'
-    ret = get_response(command,0.2)
-    res = check(ret,'OK')
-    if(res == 1) :
-        res = check(ret,'+CWLIF:')
-        if (res == 1) :
-            x = ret.split('\n')
-            #print(x)
-            station_config = [s for s in x if '+CWLIF:' in s]
-            station_config = ' '.join([str(elem) for elem in station_config])
-            station_config = station_config.split(',')
-            mac_addr = station_config[1]
-            ip_addr = station_config[0]
-            ip_addr = ip_addr[7:]
-            #print(station_config)
-            return ip_addr, mac_addr
-        else:
-            return 'OK'
-    else:
-        return failure
-
-#get mac address of AP
-def get_ap_mac():
-    command = 'AT+CWAPMAC?'
-    ret = get_response(command,2)
-    res = check(ret,'OK')
-    if (res == 1):
-        res = check(ret,'+CWAPMAC:')
-        if (res == 1):
-            x = ret.split('\n')
-            #print(x)
-            mac_addr = [s for s in x if '+CWAPMAC:' in s]
-            mac_addr = ' '.join([str(elem) for elem in mac_addr])
-            #print(mac_addr)
-            mac_addr = mac_addr.split(',')
-            mac_addr = mac_addr[0]
-            mac_addr = mac_addr[9:]
-            mac_addr = mac_addr[1:-1]
-            return mac_addr
-        else:
-            return 'OK'
-    else:
-        return failure
-
-#get mac address of station
-def get_sta_mac():
-    command = 'AT+CWSTAMAC?'
-    ret = get_response(command,2)
-    res = check(ret,'OK')
-    if (res == 1):
-        res = check(ret,'+CWSTAMAC:')
-        if (res == 1):
-            x = ret.split('\n')
-            #print(x)
-            mac_addr = [s for s in x if '+CWSTAMAC:' in s]
-            mac_addr = ' '.join([str(elem) for elem in mac_addr])
-            mac_addr = mac_addr.split(',')
-            mac_addr = mac_addr[0]
-            mac_addr = mac_addr[10:]
-            mac_addr = mac_addr[1:-1]
-            #print("MAC"+str(mac_addr))
-            return mac_addr
-        else:
-            return 'OK'
-    else:
-        return failure
diff --git a/esp_at/rpi_init.sh b/esp_at/rpi_init.sh
deleted file mode 100755 (executable)
index 11fa6b9..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/sh
-
-wlan_init()
-{
-       cd ../host_driver/esp32/
-       make -j8
-       sudo insmod esp32.ko
-       sudo mknod /dev/esps0 c 221 0
-       sudo chmod 666 /dev/esps0
-}
-
-bt_init()
-{
-       sudo raspi-gpio set 16 a3 pu
-       sudo raspi-gpio set 17 a3 pn
-}
-
-if [ $# -eq 0 ]; then
-       wlan_init
-       bt_init
-fi
-
-if [ "$1" = "wlan" ]; then
-       wlan_init
-fi
-
-if [ "$1" = "bt" ]; then
-       bt_init
-fi
-
-if [ "$1" = "-h" ]; then
-       echo "Usage: ./rpi_init.sh [arguments]"
-       echo "\nArguments are optional and are as below"
-       echo "  wlan:   Insert and setup esp32 network driver"
-       echo "  bt:     Set GPIO pins on RPi for bluetooth operation"
-       echo "\nExample:"
-       echo "  - Prepare RPi for WLAN operation:               ./rpi_init.sh wlan"
-       echo "  - Prepare RPi for Bluetooth operation:          ./rpi_init.sh bt"
-       echo "  - Prepare RPi for both WLAN and Bluetoorh:      ./rpi_init.sh"
-fi
diff --git a/esp_at/softap_config.py b/esp_at/softap_config.py
deleted file mode 100644 (file)
index a7b5aad..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-# Copyright 2019 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.
-
-from at_commands import at_commands
-import argparse
-import time
-import os
-
-parser = argparse.ArgumentParser(description='softap_config.py script to configure ESP32 softAP mode. ex. python3 softap_config.py \'xyz\' \'xyz123456\' 1 3 --max_conn=4 --ssid_hidden=0 ')
-
-parser.add_argument("ssid", type=str, default='0', help="ssid")
-
-parser.add_argument("password", type=str, default='0', help="password(password length should be 8~64 bytes ASCII)")
-
-parser.add_argument("channel_id", type=int, default=1, help="channel ID (It can be any number between 1 to 11)")
-
-parser.add_argument("encrp_mthd", type=int, default=0, help="encryption method (0 : OPEN, 2: WPA_PSK, 3:WPA2_PSK, 4: WPA_WPA2_PSK)")
-
-parser.add_argument("--max_conn", type=int, default=1, help="max connection count( number of Stations to which ESP32 SoftAP can be connected, within the range of [1, 10])")
-
-parser.add_argument("--ssid_hidden", type=int, default=0, help="ssid hidden/broadcast (it can set to 1 if softAP shouldnt broadcast its ssid else 0)")
-
-args = parser.parse_args()
-
-flag = 'success'
-softap_config = 'failure'
-ssid = '0'
-pwd = '0'
-chnl = 0
-encrp_mthd = 0
-max_conn = 0
-ssid_hidden = 0
-wifi_mode = 0
-
-ap_mac = at_commands.get_ap_mac()
-print("AP MAC Address "+str(ap_mac))
-
-if (ap_mac == 'failure'):
-    flag = 'failure'
-
-if (flag == 'success'):
-    wifi_mode = at_commands.wifi_get_mode()
-    print("Current wifi mode "+str(wifi_mode))
-
-if (wifi_mode != '2' and wifi_mode != 'failure'):
-    print("set a wifi mode 2 (i.e. softap mode)")
-    wifi_mode = at_commands.wifi_set_mode(2)
-    print(wifi_mode)
-
-if (wifi_mode == 'failure'):
-    print("wifi get\set mode failed")
-    flag = 'failure'
-
-if (flag == 'success'):
-    print("check soft AP config")
-    softap_config = at_commands.wifi_get_softap_config()
-    if (softap_config == 'failure'):
-        flag = 'failure'
-        print("Failed to check current softap config")
-
-if (flag == 'success' and softap_config != 'OK'):
-    ssid = softap_config[0]
-    pwd = softap_config[1]
-    chnl = softap_config[2]
-    encrp_mthd = softap_config[3]
-    max_conn = softap_config[4]
-    ssid_hidden = softap_config[5]
-
-if (flag =='success' and args.ssid == ssid and args.password == pwd and args.channel_id == str(chnl) and args.encrp_mthd == str(encrp_mthd) and args.max_conn == str(max_conn) and args.ssid_hidden == str(ssid_hidden)):
-    print("already softAP config set")
-elif (flag == 'success'):
-    softap_config = at_commands.wifi_set_softap_config(args.ssid, args.password, args.channel_id, args.encrp_mthd, args.max_conn, args.ssid_hidden)
-    if (softap_config == 'failure'):
-        print("setting softap config failed")
-        flag = 'failure'
-if (flag == 'failure'):
-    print("failure in setting AP config")
-
-if (flag == 'success'):
-    command = 'sudo ifconfig ethap0 down'
-    os.system(command)
-    print(command)    
-    
-    command = 'sudo ifconfig ethap0 hw ether '+str(ap_mac)
-    os.system(command)
-    print(command)    
-    
-    command = 'ifconfig ethap0 up'
-    os.system(command)
-    print(command)
-    
-    time.sleep(5)
-    print("softAP config successfully set")
diff --git a/esp_at/station_connect.py b/esp_at/station_connect.py
deleted file mode 100644 (file)
index 5231a84..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-# Copyright 2019 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.
-
-from at_commands import at_commands
-import argparse
-import time
-import os
-
-parser = argparse.ArgumentParser(description='station_connect.py is a python script which connect ESPstation to AP. ex. python3 station_connect.py \'xyz\' \'xyz123456\' --bssid=\'e5:6c:67:3c:cf:65\'')
-
-parser.add_argument("ssid", type=str, default='0', help="ssid of AP")
-
-parser.add_argument("password", type=str, default='0', help="password of AP")
-
-parser.add_argument("--bssid", type=str, default='0', help="bssid i.e MAC address of AP in case of multiple AP has same ssid (default: '0')")
-
-args = parser.parse_args()
-
-flag = 'success'
-station_status = 'Nothing set'
-current_ssid = '0'
-wifi_mode = 0
-
-sta_mac = at_commands.get_sta_mac()
-print("station MAC address "+str(sta_mac))
-
-if (sta_mac == 'failure'):
-    flag = 'failure'
-
-if (flag == 'success'):
-    wifi_mode = at_commands.wifi_get_mode()
-    print("current wifi mode is "+str(wifi_mode))
-    if (wifi_mode != '1' and wifi_mode != 'failure'):
-       print("set wifi mode to 1 (i.e. station mode)")
-       wifi_mode = at_commands.wifi_set_mode(1)
-
-if (wifi_mode == 'failure'):
-    print("wifi get\set mode failed")
-    flag = 'failure'
-
-if (flag == 'success'):
-    print("Get previously entered AP configuration")
-    station_status = at_commands.wifi_get_ap_config()
-    if (station_status == 'failure'):    
-        print("Failed to get previous AP configuration ")
-        flag = 'failure'
-if (flag == 'success' and station_status != 'OK'):
-    current_ssid = station_status[0]
-    current_ssid = current_ssid[1:-1]
-    print("previous AP ssid "+str(current_ssid))
-if ((flag == 'success') and ((station_status == 'OK') or (current_ssid != args.ssid))):
-    print("set AP config")
-    station_status = at_commands.wifi_set_ap_config(args.ssid,args.password,args.bssid)
-    if (station_status == 'failure'):
-        flag = 'failure'
-        print("Failed to set AP config")
-elif((current_ssid == args.ssid) and flag == 'success'):
-    print("entered ssid is same as previous configuration")
-
-if (flag == 'failure'):
-    print("failure in setting AP config")
-
-if (flag == 'success'):
-    command = 'sudo ifconfig ethsta0 down'
-    os.system(command)
-    print(command)
-
-    command = 'sudo ifconfig ethsta0 hw ether '+str(sta_mac)
-    os.system(command)
-    print(command)
-
-    command = 'ifconfig ethsta0 up'
-    os.system(command)
-    print(command)
-
-    time.sleep(5)
-
-    command = 'dhclient ethsta0 -r'
-    os.system(command)
-    print(command)
-
-    command = 'dhclient ethsta0 -v'
-    os.system(command)
-    print(command)
-
-    print("Success in setting AP config")
-
diff --git a/esp_at/station_disconnect.py b/esp_at/station_disconnect.py
deleted file mode 100644 (file)
index 1be501f..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2019 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.
-
-from at_commands import at_commands
-import argparse
-
-parser = argparse.ArgumentParser(description='station_disconnect.py script will disconnect ESPStation from AP ex. python3 station_disconnect.py')
-
-wifi_mode = at_commands.wifi_get_mode()
-print(wifi_mode)
-
-if (wifi_mode == '1'):
-    disconnect = at_commands.wifi_disconnect_ap()
-    print(disconnect)
-    print("Disconnected from AP")
-elif (wifi_mode == 'failure'):
-    print("failure in disconnect")
-else :
-    print("station mode is not selected, current mode is "+str(wifi_mode))
-    print("0: null Mode, Wi-Fi RF will be disabled")
-    print("1: station mode")
-    print("2: softAP mode")
-    print("3: softAP+station mode")
diff --git a/host_comm/host_commands/__init__.py b/host_comm/host_commands/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
index 6a42f955f67dd2bcbf530412a2ee859c5fde2b24..82369a3f9c0364b13ddabbfbae81a2047430f6c5 100644 (file)
@@ -30,7 +30,9 @@ endpoint = "control"
 not_set = "0"
 
 #get mac address of station
-def get_sta_mac(): 
+# mode == 1 for station mac
+# mode == 2 for softAP mac
+def get_mac(mode):
     req_sta_mac = slave_config_pb2.SlaveConfigPayload()
     req_sta_mac.msg = slave_config_pb2.SlaveConfigMsgType.TypeCmdGetMACAddress
     #for station mode set cmd as 1
@@ -43,22 +45,6 @@ def get_sta_mac():
     req_sta_mac.ParseFromString(response)
     #print("parsed output "+str(req_sta_mac.resp_get_mac_address.resp))
     return req_sta_mac.resp_get_mac_address.resp
-    
-    
-#get mac address of softAP
-def get_ap_mac(): 
-    req_ap_mac = slave_config_pb2.SlaveConfigPayload()
-    req_ap_mac.msg = slave_config_pb2.SlaveConfigMsgType.TypeCmdGetMACAddress
-    #for softAP mode set cmd as 2
-    req_ap_mac.cmd_get_mac_address.cmd = '2';
-    protodata = req_ap_mac.SerializeToString()
-    #print("serialized data "+str(protodata))
-    tp = transport.Transport_pserial("/dev/esps0")
-    response = tp.send_data('control',protodata)
-    #print("response from slave "+str(response))
-    req_ap_mac.ParseFromString(response)
-    #print("parsed output "+str(req_ap_mac.resp_get_mac_address.resp))
-    return req_ap_mac.resp_get_mac_address.resp
 
 #get wifi mode
 # 0: null Mode, Wi-Fi mode not set
@@ -121,8 +107,7 @@ def wifi_set_ap_config(ssid, pwd, bssid):
     set_ap_config.msg = slave_config_pb2.SlaveConfigMsgType.TypeCmdSetAPConfig
     set_ap_config.cmd_set_ap_config.ssid = str(ssid)
     set_ap_config.cmd_set_ap_config.pwd = str(pwd)
-    if (str(bssid) != '0') :
-        set_ap_config.cmd_set_ap_config.bssid = str(bssid)
+    set_ap_config.cmd_set_ap_config.bssid = str(bssid)
     protodata = set_ap_config.SerializeToString()
     #print("serialized data "+str(protodata))
     tp = transport.Transport_pserial(interface)
@@ -203,7 +188,7 @@ def wifi_get_softap_config():
     ssid_hidden  = get_softap_config.resp_get_softap_config.ssid_hidden
     status  = str(get_softap_config.resp_get_softap_config.status)
     bw = get_softap_config.resp_get_softap_config.bw
-    return ssid,pwd,en,chnl,max_conn,ssid_hidden,status,bw
+    return ssid,pwd,chnl,ecn,max_conn,ssid_hidden,status,bw
 
 def wifi_ap_scan_list(scan_count):
     print(scan_count)
diff --git a/host_comm/host_commands/slave_config.proto b/host_comm/host_commands/slave_config.proto
deleted file mode 100644 (file)
index 7233a02..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-syntax = "proto3";
-
-message CmdGetStatus {
-       string cmd = 1;
-    int32 mode = 2;
-}
-
-message RespGetStatus {
-       string resp = 1;
-    int32 mode = 2;
-}
-
-enum EncryptionMode {
-    Type_Open = 0;
-    Type_WEP = 1;
-    Type_WPA_PSK = 2;
-    Type_WPA2_PSK = 3;
-    Type_WPA_WPA2_PSK = 4;
-    Type_WPA2_ENTERPRISE = 5;
-}
-
-message CmdConfig {
-    string ssid = 1;
-    string pwd = 2;
-    EncryptionMode ecn = 3;
-    int32 chnl = 4;
-    int32 max_conn = 5;
-    bool ssid_hidden = 6;
-    string bssid = 7;
-    int32 rssi = 8;
-    string status = 9;
-    int32 bw = 10;
-}
-
-message RespConfig {
-    string ssid = 1;
-    string pwd = 2;
-    EncryptionMode ecn = 3;
-    int32 chnl = 4;
-    int32 max_conn = 5;
-    bool ssid_hidden = 6;
-    string bssid = 7;
-    int32 rssi = 8;
-    string status = 9;
-    int32 bw = 10;
-}
-
-message ScanResult {
-    bytes ssid = 1;
-    uint32 chnl = 2;
-    int32 rssi = 3;
-    bytes bssid = 4;
-    EncryptionMode ecn = 5;
-}
-
-message CmdScanResult {
-    uint32 count = 1;
-}
-
-message RespScanResult {
-    uint32 count = 1;
-    repeated ScanResult entries = 2;
-}
-
-
-enum SlaveConfigMsgType {
-    TypeCmdGetMACAddress = 0;
-    TypeRespGetMACAddress = 1;
-    TypeCmdGetWiFiMode = 2;
-    TypeRespGetWiFiMode = 3;
-    TypeCmdSetWiFiMode = 4;
-    TypeRespSetWiFiMode = 5;
-    TypeCmdGetAPConfig = 6;
-    TypeRespGetAPConfig = 7;
-       TypeCmdSetAPConfig = 8;
-    TypeRespSetAPConfig = 9;
-    TypeCmdGetSoftAPConfig = 10;
-    TypeRespGetSoftAPConfig = 11;
-    TypeCmdSetSoftAPConfig = 12;
-    TypeRespSetSoftAPConfig = 13;
-    TypeCmdDisconnectAP = 14;
-    TypeRespDisconnectAP = 15;
-    TypeCmdGetAPScanList = 16;
-    TypeRespGetAPScanList = 17;
-}
-
-message SlaveConfigPayload {
-    SlaveConfigMsgType msg = 1;
-    oneof payload {
-        CmdGetStatus cmd_get_mac_address = 10;
-        RespGetStatus resp_get_mac_address = 11;
-        CmdGetStatus cmd_get_wifi_mode = 12;
-        RespGetStatus resp_get_wifi_mode = 13;
-        CmdGetStatus cmd_set_wifi_mode = 14;
-        RespGetStatus resp_set_wifi_mode = 15;
-        CmdConfig cmd_get_ap_config = 16;
-        RespConfig resp_get_ap_config = 17;
-               CmdConfig cmd_set_ap_config = 18;
-        RespConfig resp_set_ap_config = 19;
-        CmdConfig cmd_get_softap_config = 20;
-        RespConfig resp_get_softap_config = 21;
-        CmdConfig cmd_set_softap_config = 22;
-        RespConfig resp_set_softap_config = 23;
-        CmdGetStatus cmd_disconnect_ap = 24;
-        RespGetStatus resp_disconnect_ap = 25;
-        CmdScanResult cmd_scan_ap_list = 26;
-        RespScanResult resp_scan_ap_list = 27;
-    }
-}
diff --git a/host_comm/rpi_init.sh b/host_comm/rpi_init.sh
new file mode 100755 (executable)
index 0000000..11fa6b9
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+wlan_init()
+{
+       cd ../host_driver/esp32/
+       make -j8
+       sudo insmod esp32.ko
+       sudo mknod /dev/esps0 c 221 0
+       sudo chmod 666 /dev/esps0
+}
+
+bt_init()
+{
+       sudo raspi-gpio set 16 a3 pu
+       sudo raspi-gpio set 17 a3 pn
+}
+
+if [ $# -eq 0 ]; then
+       wlan_init
+       bt_init
+fi
+
+if [ "$1" = "wlan" ]; then
+       wlan_init
+fi
+
+if [ "$1" = "bt" ]; then
+       bt_init
+fi
+
+if [ "$1" = "-h" ]; then
+       echo "Usage: ./rpi_init.sh [arguments]"
+       echo "\nArguments are optional and are as below"
+       echo "  wlan:   Insert and setup esp32 network driver"
+       echo "  bt:     Set GPIO pins on RPi for bluetooth operation"
+       echo "\nExample:"
+       echo "  - Prepare RPi for WLAN operation:               ./rpi_init.sh wlan"
+       echo "  - Prepare RPi for Bluetooth operation:          ./rpi_init.sh bt"
+       echo "  - Prepare RPi for both WLAN and Bluetoorh:      ./rpi_init.sh"
+fi
diff --git a/host_comm/softap_config.py b/host_comm/softap_config.py
new file mode 100644 (file)
index 0000000..748e527
--- /dev/null
@@ -0,0 +1,76 @@
+# Copyright 2019 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.
+
+from host_commands import slave_comm
+import argparse
+import time
+import os
+
+parser = argparse.ArgumentParser(description='softap_config.py script to configure ESP32 softAP mode. ex. python3 softap_config.py \'xyz\' \'xyz123456\' 1 3 --max_conn=4 --ssid_hidden=0 --bw=0')
+
+parser.add_argument("ssid", type=str, default='0', help="ssid")
+
+parser.add_argument("password", type=str, default='0', help="password(password length should be 8~64 bytes ASCII)")
+
+parser.add_argument("channel_id", type=int, default=1, help="channel ID (It can be any number between 1 to 11)")
+
+parser.add_argument("encrp_mthd", type=int, default=0, help="encryption method (0 : OPEN, 2: WPA_PSK, 3:WPA2_PSK, 4: WPA_WPA2_PSK)")
+
+parser.add_argument("--max_conn", type=int, default=1, help="max connection count( number of Stations to which ESP32 SoftAP can be connected, within the range of [1, 10])")
+
+parser.add_argument("--ssid_hidden", type=int, default=0, help="ssid hidden/broadcast (it can set to 1 if softAP shouldnt broadcast its ssid else 0)")
+
+parser.add_argument("--bw", type=int, default=1, help="Bandwidth (1: WIFI_BW_HT20(20MHZ)) , (2: WIFI_BW_HT40(40MHZ)) default is 20MHZ")
+
+args = parser.parse_args()
+
+flag = 'success'
+softap_config = 'failure'
+ssid = '0'
+pwd = '0'
+chnl = 0
+encrp_mthd = 0
+max_conn = 0
+ssid_hidden = 0
+wifi_mode = 0
+
+ap_mac = slave_comm.get_mac(2)
+print("AP MAC Address "+str(ap_mac))
+
+softap_config = slave_comm.wifi_set_softap_config(args.ssid, args.password, args.channel_id, args.encrp_mthd, args.max_conn, args.ssid_hidden, args.bw)
+if (softap_config != 'success'):
+    print("setting softap config failed")
+    flag = 'failure'
+else:
+    print("setting softap config success")
+if (flag == 'failure'):
+    print("failure in setting AP config")
+
+if (flag == 'success'):
+    command = 'sudo ifconfig ethap0 down'
+    os.system(command)
+    print(command)    
+    
+    command = 'sudo ifconfig ethap0 hw ether '+str(ap_mac)
+    os.system(command)
+    print(command)    
+    
+    command = 'ifconfig ethap0 up'
+    os.system(command)
+    print(command)
+    
+    time.sleep(5)
+    print("softAP config successfully set")
diff --git a/host_comm/station_connect.py b/host_comm/station_connect.py
new file mode 100644 (file)
index 0000000..7b943d9
--- /dev/null
@@ -0,0 +1,69 @@
+# Copyright 2019 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.
+
+from host_commands import slave_comm
+import argparse
+import time
+import os
+
+parser = argparse.ArgumentParser(description='station_connect.py is a python script which connect ESPstation to AP. ex. python3 station_connect.py \'xyz\' \'xyz123456\' --bssid=\'e5:6c:67:3c:cf:65\'')
+
+parser.add_argument("ssid", type=str, default='0', help="ssid of AP")
+
+parser.add_argument("password", type=str, default='0', help="password of AP")
+
+parser.add_argument("--bssid", type=str, default='0', help="bssid i.e MAC address of AP in case of multiple AP has same ssid (default: '0')")
+
+args = parser.parse_args()
+
+flag = 'success'
+station_status = 'Nothing set'
+current_ssid = '0'
+wifi_mode = 0
+
+sta_mac = slave_comm.get_mac(1)
+print("station MAC address "+str(sta_mac))
+
+station_status = slave_comm.wifi_set_ap_config(args.ssid,args.password,args.bssid)
+if (station_status == 'failure'):
+    flag = 'failure'
+    print("Failed to set AP config")
+elif (station_status == 'success'):
+    print("Connected to given AP")
+
+if (flag == 'success'):
+    command = 'sudo ifconfig ethsta0 down'
+    os.system(command)
+    print(command)
+
+    command = 'sudo ifconfig ethsta0 hw ether '+str(sta_mac)
+    os.system(command)
+    print(command)
+
+    command = 'ifconfig ethsta0 up'
+    os.system(command)
+    print(command)
+
+    time.sleep(5)
+
+    command = 'dhclient ethsta0 -r'
+    os.system(command)
+    print(command)
+
+    command = 'dhclient ethsta0 -v'
+    os.system(command)
+    print(command)
+
+    print("Success in setting AP config")
+
diff --git a/host_comm/station_disconnect.py b/host_comm/station_disconnect.py
new file mode 100644 (file)
index 0000000..95aeace
--- /dev/null
@@ -0,0 +1,32 @@
+# Copyright 2019 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.
+
+from host_commands import slave_comm
+import argparse
+
+parser = argparse.ArgumentParser(description='station_disconnect.py script will disconnect ESPStation from AP ex. python3 station_disconnect.py')
+
+wifi_mode = slave_comm.get_wifi_mode()
+print(wifi_mode)
+
+if (wifi_mode == 1 or wifi_mode == 3):
+    disconnect = slave_comm.wifi_disconnect_ap()
+    print(disconnect)
+    print("Disconnected from AP")
+else :
+    print("wifi_disconnect_ap failed, current mode is "+str(wifi_mode))
+    print("0: null Mode, Wi-Fi RF will be disabled")
+    print("1: station mode")
+    print("2: softAP mode")
+    print("3: softAP+station mode")
index b6af16268d37f705ded9925f04d1cfc3e851de2b..e85015911a3bc013f5b52c9e2a9412d404432b58 100644 (file)
@@ -26,6 +26,7 @@ print("sta mac "+str(x))
 # 2: softAP mode
 # 3: softAP+station mode
 # or Failure 
+
 x = slave_comm.get_wifi_mode()
 print("wifi mode is "+str(x))
 
@@ -34,28 +35,32 @@ print("connected mode is "+str(x))
 
 x = slave_comm.get_wifi_mode()
 print("wifi mode is "+str(x))
-
+'''
 x = slave_comm.wifi_set_ap_config('Siddhesh','sid123456','0')
 print(x)
-
+'''
 x = slave_comm.wifi_get_ap_config()
 print(x)
 
 x = slave_comm.wifi_disconnect_ap()
 print(x)
-
+'''
 # need to accept default badwidth as 20 and make it as optional parameter
 x = slave_comm.wifi_set_softap_config('ESP12','0',4,0,5,0,1)
 print("output is here")
 print(x)
 
+x = slave_comm.get_wifi_mode()
+print("wifi mode is "+str(x))
+'''
 x = slave_comm.wifi_get_softap_config()
 print("get softap output here")
 print(x)
-'''
+
 # user should give number max scan AP count
 # output is list of Aplist class instances
 x = slave_comm.wifi_ap_scan_list(10)
 print(x)
 for obj in x:
     print(obj.ssid,obj.chnl,obj.rssi,obj.bssid,obj.ecn)
+'''
diff --git a/proto/slave_config.proto b/proto/slave_config.proto
new file mode 100644 (file)
index 0000000..8cbb14c
--- /dev/null
@@ -0,0 +1,109 @@
+syntax = "proto3";
+
+message CmdGetStatus {
+    string cmd = 1;
+    int32 mode = 2;
+}
+
+message RespGetStatus {
+    string resp = 1;
+    int32 mode = 2;
+}
+
+enum EncryptionMode {
+    Type_Open = 0;
+    Type_WEP = 1;
+    Type_WPA_PSK = 2;
+    Type_WPA2_PSK = 3;
+    Type_WPA_WPA2_PSK = 4;
+    Type_WPA2_ENTERPRISE = 5;
+}
+
+message CmdConfig {
+    string ssid = 1;
+    string pwd = 2;
+    EncryptionMode ecn = 3;
+    int32 chnl = 4;
+    int32 max_conn = 5;
+    bool ssid_hidden = 6;
+    string bssid = 7;
+    int32 rssi = 8;
+    string status = 9;
+    int32 bw = 10;
+}
+
+message RespConfig {
+    string ssid = 1;
+    string pwd = 2;
+    EncryptionMode ecn = 3;
+    int32 chnl = 4;
+    int32 max_conn = 5;
+    bool ssid_hidden = 6;
+    string bssid = 7;
+    int32 rssi = 8;
+    string status = 9;
+    int32 bw = 10;
+}
+
+message ScanResult {
+    bytes ssid = 1;
+    uint32 chnl = 2;
+    int32 rssi = 3;
+    bytes bssid = 4;
+    EncryptionMode ecn = 5;
+}
+
+message CmdScanResult {
+    uint32 count = 1;
+}
+
+message RespScanResult {
+    uint32 count = 1;
+    repeated ScanResult entries = 2;
+}
+
+
+enum SlaveConfigMsgType {
+    TypeCmdGetMACAddress = 0;
+    TypeRespGetMACAddress = 1;
+    TypeCmdGetWiFiMode = 2;
+    TypeRespGetWiFiMode = 3;
+    TypeCmdSetWiFiMode = 4;
+    TypeRespSetWiFiMode = 5;
+    TypeCmdGetAPConfig = 6;
+    TypeRespGetAPConfig = 7;
+    TypeCmdSetAPConfig = 8;
+    TypeRespSetAPConfig = 9;
+    TypeCmdGetSoftAPConfig = 10;
+    TypeRespGetSoftAPConfig = 11;
+    TypeCmdSetSoftAPConfig = 12;
+    TypeRespSetSoftAPConfig = 13;
+    TypeCmdDisconnectAP = 14;
+    TypeRespDisconnectAP = 15;
+    TypeCmdGetAPScanList = 16;
+    TypeRespGetAPScanList = 17;
+}
+
+message SlaveConfigPayload {
+    SlaveConfigMsgType msg = 1;
+    oneof payload {
+        CmdGetStatus cmd_get_mac_address = 10;
+        RespGetStatus resp_get_mac_address = 11;
+        CmdGetStatus cmd_get_wifi_mode = 12;
+        RespGetStatus resp_get_wifi_mode = 13;
+        CmdGetStatus cmd_set_wifi_mode = 14;
+        RespGetStatus resp_set_wifi_mode = 15;
+        CmdConfig cmd_get_ap_config = 16;
+        RespConfig resp_get_ap_config = 17;
+        CmdConfig cmd_set_ap_config = 18;
+        RespConfig resp_set_ap_config = 19;
+        CmdConfig cmd_get_softap_config = 20;
+        RespConfig resp_get_softap_config = 21;
+        CmdConfig cmd_set_softap_config = 22;
+        RespConfig resp_set_softap_config = 23;
+        CmdGetStatus cmd_disconnect_ap = 24;
+        RespGetStatus resp_disconnect_ap = 25;
+        CmdScanResult cmd_scan_ap_list = 26;
+        RespScanResult resp_scan_ap_list = 27;
+    }
+}
diff --git a/slave_config.proto b/slave_config.proto
deleted file mode 100644 (file)
index 8cbb14c..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-syntax = "proto3";
-
-message CmdGetStatus {
-    string cmd = 1;
-    int32 mode = 2;
-}
-
-message RespGetStatus {
-    string resp = 1;
-    int32 mode = 2;
-}
-
-enum EncryptionMode {
-    Type_Open = 0;
-    Type_WEP = 1;
-    Type_WPA_PSK = 2;
-    Type_WPA2_PSK = 3;
-    Type_WPA_WPA2_PSK = 4;
-    Type_WPA2_ENTERPRISE = 5;
-}
-
-message CmdConfig {
-    string ssid = 1;
-    string pwd = 2;
-    EncryptionMode ecn = 3;
-    int32 chnl = 4;
-    int32 max_conn = 5;
-    bool ssid_hidden = 6;
-    string bssid = 7;
-    int32 rssi = 8;
-    string status = 9;
-    int32 bw = 10;
-}
-
-message RespConfig {
-    string ssid = 1;
-    string pwd = 2;
-    EncryptionMode ecn = 3;
-    int32 chnl = 4;
-    int32 max_conn = 5;
-    bool ssid_hidden = 6;
-    string bssid = 7;
-    int32 rssi = 8;
-    string status = 9;
-    int32 bw = 10;
-}
-
-message ScanResult {
-    bytes ssid = 1;
-    uint32 chnl = 2;
-    int32 rssi = 3;
-    bytes bssid = 4;
-    EncryptionMode ecn = 5;
-}
-
-message CmdScanResult {
-    uint32 count = 1;
-}
-
-message RespScanResult {
-    uint32 count = 1;
-    repeated ScanResult entries = 2;
-}
-
-
-enum SlaveConfigMsgType {
-    TypeCmdGetMACAddress = 0;
-    TypeRespGetMACAddress = 1;
-    TypeCmdGetWiFiMode = 2;
-    TypeRespGetWiFiMode = 3;
-    TypeCmdSetWiFiMode = 4;
-    TypeRespSetWiFiMode = 5;
-    TypeCmdGetAPConfig = 6;
-    TypeRespGetAPConfig = 7;
-    TypeCmdSetAPConfig = 8;
-    TypeRespSetAPConfig = 9;
-    TypeCmdGetSoftAPConfig = 10;
-    TypeRespGetSoftAPConfig = 11;
-    TypeCmdSetSoftAPConfig = 12;
-    TypeRespSetSoftAPConfig = 13;
-    TypeCmdDisconnectAP = 14;
-    TypeRespDisconnectAP = 15;
-    TypeCmdGetAPScanList = 16;
-    TypeRespGetAPScanList = 17;
-}
-
-message SlaveConfigPayload {
-    SlaveConfigMsgType msg = 1;
-    oneof payload {
-        CmdGetStatus cmd_get_mac_address = 10;
-        RespGetStatus resp_get_mac_address = 11;
-        CmdGetStatus cmd_get_wifi_mode = 12;
-        RespGetStatus resp_get_wifi_mode = 13;
-        CmdGetStatus cmd_set_wifi_mode = 14;
-        RespGetStatus resp_set_wifi_mode = 15;
-        CmdConfig cmd_get_ap_config = 16;
-        RespConfig resp_get_ap_config = 17;
-        CmdConfig cmd_set_ap_config = 18;
-        RespConfig resp_set_ap_config = 19;
-        CmdConfig cmd_get_softap_config = 20;
-        RespConfig resp_get_softap_config = 21;
-        CmdConfig cmd_set_softap_config = 22;
-        RespConfig resp_set_softap_config = 23;
-        CmdGetStatus cmd_disconnect_ap = 24;
-        RespGetStatus resp_disconnect_ap = 25;
-        CmdScanResult cmd_scan_ap_list = 26;
-        RespScanResult resp_scan_ap_list = 27;
-    }
-}
diff --git a/slave_driver/sdio_slave_test/main/protocomm_pserial.h b/slave_driver/sdio_slave_test/main/protocomm_pserial.h
new file mode 100644 (file)
index 0000000..05a2666
--- /dev/null
@@ -0,0 +1,16 @@
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef esp_err_t (*pserial_xmit)(uint8_t *buf, ssize_t len);
+typedef ssize_t (*pserial_recv)(uint8_t *buf, ssize_t len);
+
+esp_err_t protocomm_pserial_start(protocomm_t *pc, pserial_xmit xmit, pserial_recv recv);
+esp_err_t protocomm_pserial_data_ready(protocomm_t *pc, int len);
+
+#ifdef __cplusplus
+}
+#endif
+
index fbdbeb5a3a76e0bb2282ad4fc3c5db916edd5341..9555c1042701d97d3234941d1ef61bc7df6ad106 100644 (file)
@@ -65,7 +65,6 @@ static credentials_t credentials;
 #define WIFI_FAIL_BIT      BIT1
 #define MAX_RETRY                      5
 
-// sattion got IP event is remain
 static int s_retry_num = 0;
 static bool scan_done = false;
 
@@ -74,7 +73,7 @@ static void ap_event_handler(void* arg, esp_event_base_t event_base,
 {
     if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
         esp_wifi_connect();
-               ESP_LOGI(TAG,"wifi connected");
+               ESP_LOGI(TAG,"wifi connect called");
 
     } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
         if (s_retry_num < MAX_RETRY) {
@@ -151,6 +150,7 @@ typedef struct slave_config_cmd {
 static esp_err_t cmd_get_mac_address_handler(SlaveConfigPayload *req,
                                         SlaveConfigPayload *resp, void *priv_data)
 {
+       ESP_LOGI(TAG,"Inside get MAC address");
        esp_err_t ret;
        uint8_t mac[6];
        char *mac_str = (char *)calloc(1,19);
@@ -163,6 +163,7 @@ static esp_err_t cmd_get_mac_address_handler(SlaveConfigPayload *req,
                ESP_LOGI(TAG,"get station mac address");
                if (ret != ESP_OK) {
                        ESP_LOGE(TAG,"Error in getting MAC of ESP Station %d", ret);
+                       free(mac_str);
                        return ESP_FAIL;
                }
        } else if (strcmp(req->cmd_get_mac_address->cmd,"2") == 0) {
@@ -170,10 +171,12 @@ static esp_err_t cmd_get_mac_address_handler(SlaveConfigPayload *req,
                ESP_LOGI(TAG,"get AP mac address");
                if (ret != ESP_OK) {
                        ESP_LOGE(TAG,"Error in getting MAC of ESP AP %d", ret);
+                       free(mac_str);
                        return ESP_FAIL;
                }
        } else {
                ESP_LOGI(TAG,"Invalid msg type");
+               free(mac_str);
                return ESP_FAIL;
        }
 
@@ -181,6 +184,7 @@ static esp_err_t cmd_get_mac_address_handler(SlaveConfigPayload *req,
        RespGetStatus *resp_payload = (RespGetStatus *)calloc(1,sizeof(RespGetStatus));
        if (resp_payload == NULL) {
                ESP_LOGE(TAG,"Failed to allocate memory");
+               free(mac_str);
                return ESP_ERR_NO_MEM;
        }
        resp_get_status__init(resp_payload);
@@ -221,7 +225,7 @@ static esp_err_t cmd_set_wifi_mode_handler (SlaveConfigPayload *req,
 {
        esp_err_t ret;
        wifi_mode_t num = req->cmd_set_wifi_mode->mode;
-       ESP_LOGI(TAG,"num %d ", num);
+       ESP_LOGI(TAG,"set wifi mode %d ", num);
        ret = esp_wifi_set_mode(num);
        if (ret != ESP_OK) {
                ESP_LOGE(TAG,"Failed to set mode");
@@ -250,7 +254,13 @@ static esp_err_t cmd_set_ap_config_handler (SlaveConfigPayload *req,
        esp_err_t ret;
        s_wifi_event_group = xEventGroupCreate();
        ap_event_register();
-       ret = esp_wifi_set_mode(WIFI_MODE_STA);
+       if (hosted_flags.is_softap_started) {
+               ret = esp_wifi_set_mode(WIFI_MODE_APSTA);
+               ESP_LOGI(TAG,"APSTA mode set");
+       } else {
+               ret = esp_wifi_set_mode(WIFI_MODE_STA);
+               ESP_LOGI(TAG,"STA mode set");
+       }
        if (ret != ESP_OK) {
                ESP_LOGE(TAG,"failed to set mode");
                return ESP_FAIL;
@@ -260,23 +270,23 @@ static esp_err_t cmd_set_ap_config_handler (SlaveConfigPayload *req,
                ESP_LOGE(TAG,"failed to allocate memory");
                return ESP_ERR_NO_MEM;
        }
-       memcpy(wifi_cfg->sta.ssid,req->cmd_set_ap_config->ssid,strlen(req->cmd_set_ap_config->ssid));
-       memcpy(wifi_cfg->sta.password,req->cmd_set_ap_config->pwd,strlen(req->cmd_set_ap_config->pwd));
-       if (strlen(req->cmd_set_ap_config->bssid)) {
+       memcpy(wifi_cfg->sta.ssid,req->cmd_set_ap_config->ssid,sizeof(wifi_cfg->sta.ssid));
+       memcpy(wifi_cfg->sta.password,req->cmd_set_ap_config->pwd,sizeof(wifi_cfg->sta.password));
+       if (strlen(req->cmd_set_ap_config->bssid) > 1) {
+               printf("bssid %s \n",req->cmd_set_ap_config->bssid);
                wifi_cfg->sta.bssid_set = true;
-               memcpy(wifi_cfg->sta.bssid,req->cmd_set_ap_config->bssid,6);
+               memcpy(wifi_cfg->sta.bssid,req->cmd_set_ap_config->bssid,sizeof(wifi_cfg->sta.bssid));
        }
-
-       ESP_LOGI(TAG,"final AP name %s ", wifi_cfg->sta.ssid);
-       ESP_LOGI(TAG,"final AP password %s", wifi_cfg->sta.password);
        ret = esp_wifi_set_config(ESP_IF_WIFI_STA, wifi_cfg);
        if (ret != ESP_OK) {
                ESP_LOGE(TAG,"Failed to set wifi softAP mode");
+               free(wifi_cfg);
                return ESP_FAIL;
        }
        ret = esp_wifi_start();
        if (ret != ESP_OK) {
                ESP_LOGE(TAG,"Failed to start wifi");
+               free(wifi_cfg);
                return ESP_FAIL;
        }
        ESP_LOGI(TAG,"wifi start is called");
@@ -297,6 +307,7 @@ static esp_err_t cmd_set_ap_config_handler (SlaveConfigPayload *req,
        ret = esp_wifi_sta_get_ap_info(&ap_info));
        if (ret != ESP_OK) {
                ESP_LOGE(TAG,"Failed to AP info to which ESP32 is connected");
+               free(wifi_cfg);
                return ESP_FAIL;
        }
        ESP_LOGI(TAG,"ssid %s", (char*)ap_info.ssid); */
@@ -304,6 +315,9 @@ static esp_err_t cmd_set_ap_config_handler (SlaveConfigPayload *req,
        RespConfig *resp_payload = (RespConfig *)calloc(1,sizeof(RespConfig));
        if (resp_payload == NULL) {
                ESP_LOGE(TAG,"Failed to allocate memory");
+               ap_event_unregister();
+               vEventGroupDelete(s_wifi_event_group);
+               free(wifi_cfg);
                return ESP_ERR_NO_MEM;
        }
        resp_config__init (resp_payload);
@@ -312,7 +326,7 @@ static esp_err_t cmd_set_ap_config_handler (SlaveConfigPayload *req,
        resp->resp_set_ap_config = resp_payload;
        ap_event_unregister();
 
-       ESP_LOGI(TAG,"connected to AP ssid");
+       ESP_LOGI(TAG,"connected to AP");
        vEventGroupDelete(s_wifi_event_group);
        free(wifi_cfg);
        return ESP_OK;
@@ -326,7 +340,7 @@ static esp_err_t cmd_get_ap_config_handler (SlaveConfigPayload *req,
                return ESP_FAIL;
        }
        esp_err_t ret;
-       ESP_LOGI(TAG,"get ap config");
+       ESP_LOGI(TAG,"Inside get ap config function");
        wifi_ap_record_t *ap_info = (wifi_ap_record_t *)calloc(1,sizeof(wifi_ap_record_t));
        if (ap_info == NULL) {
                ESP_LOGE(TAG,"Failed to allocate memory");
@@ -340,17 +354,16 @@ static esp_err_t cmd_get_ap_config_handler (SlaveConfigPayload *req,
                return ESP_FAIL;
        }
 
-       ESP_LOGI(TAG,"AP ssid %s AP bssid %s",ap_info->ssid,ap_info->bssid);
-       ESP_LOGI(TAG,"sizeof rssi %d channel %d ", sizeof(ap_info->rssi), sizeof(ap_info->primary));
        sprintf((char *)credentials.bssid,MACSTR,MAC2STR(ap_info->bssid));
-       memcpy(credentials.ssid,ap_info->ssid,strlen((char *)ap_info->ssid));
+       memcpy(credentials.ssid,ap_info->ssid,sizeof(credentials.ssid));
        credentials.rssi = ap_info->rssi;
        credentials.chnl = ap_info->primary;
-       ESP_LOGI(TAG,"afetr memcpy ssid %s bssid %s",credentials.ssid, credentials.bssid);
-       ESP_LOGI(TAG,"data present in rssi %d and channel field %d ", credentials.rssi, credentials.chnl);
+       ESP_LOGI(TAG,"ssid %s bssid %s",credentials.ssid, credentials.bssid);
+       ESP_LOGI(TAG,"rssi %d channel %d ", credentials.rssi, credentials.chnl);
        RespConfig *resp_payload = (RespConfig *)calloc(1,sizeof(RespConfig));
        if (resp_payload == NULL) {
                ESP_LOGE(TAG,"failed to allocate memory");
+               free(ap_info);
                return ESP_ERR_NO_MEM;
        }
        resp_config__init (resp_payload);
@@ -386,12 +399,10 @@ static esp_err_t cmd_disconnect_ap_handler (SlaveConfigPayload *req,
                return ESP_ERR_NO_MEM;
        }
        resp_get_status__init(resp_payload);
-       ESP_LOGI(TAG,"resp_payload address %p and resp also %p", resp_payload, resp_payload->resp);
        resp_payload->resp = SUCCESS;
-       ESP_LOGI(TAG,"response success string %s",resp_payload->resp);
        resp->payload_case = SLAVE_CONFIG_PAYLOAD__PAYLOAD_RESP_DISCONNECT_AP;
        resp->resp_disconnect_ap = resp_payload;
-       ESP_LOGI(TAG,"disconnect AP here");
+       ESP_LOGI(TAG,"disconnected from AP");
 
        return ESP_OK;
 }
@@ -403,7 +414,7 @@ static esp_err_t cmd_get_softap_config_handler (SlaveConfigPayload *req,
                ESP_LOGI(TAG,"ESP32 SoftAP mode aren't set, So can't get config");
                return ESP_FAIL;
        }
-       ESP_LOGI(TAG,"get soft AP handler");
+       ESP_LOGI(TAG,"Inside get soft AP function");
        esp_err_t ret;
        wifi_config_t *get_conf = (wifi_config_t *)calloc(1,sizeof(wifi_config_t));
        if (get_conf == NULL) {
@@ -413,30 +424,27 @@ static esp_err_t cmd_get_softap_config_handler (SlaveConfigPayload *req,
        wifi_bandwidth_t *get_bw = (wifi_bandwidth_t *)calloc(1,sizeof(wifi_bandwidth_t));
        if (get_bw == NULL) {
                ESP_LOGE(TAG,"Failed to allocate memory");
+               free(get_conf);
                return ESP_ERR_NO_MEM;
        }
        ret = esp_wifi_get_config(ESP_IF_WIFI_AP, get_conf);
        if (ret != ESP_OK) {
                ESP_LOGE(TAG,"Failed to get SoftAP config");
+               free(get_conf);
+               free(get_bw);
                return ESP_FAIL;
        }
        RespConfig *resp_payload = (RespConfig *)calloc(1,sizeof(RespConfig));
        if (resp_payload == NULL) {
                ESP_LOGE(TAG,"Failed to allocate memory");
+               free(get_conf);
+               free(get_bw);
                return ESP_ERR_NO_MEM;
        }
        resp_config__init (resp_payload);
-       ESP_LOGI(TAG,"ssid name %s",get_conf->ap.ssid);
-       ESP_LOGI(TAG,"pwd %s",get_conf->ap.password);
-       ESP_LOGI(TAG,"chnl %d",get_conf->ap.channel);
-       ESP_LOGI(TAG,"ecn %d",get_conf->ap.authmode);
-       ESP_LOGI(TAG,"max conn %d",get_conf->ap.max_connection);
-       ESP_LOGI(TAG,"ssid hidden %d",get_conf->ap.ssid_hidden);
-       ESP_LOGI(TAG,"len of ssid %d", strlen((char *)get_conf->ap.ssid));
-       ESP_LOGI(TAG,"len of pwd %d",strlen((char *)get_conf->ap.password));
-       memcpy(credentials.ssid,get_conf->ap.ssid,strlen((char *)get_conf->ap.ssid));
+       memcpy(credentials.ssid,get_conf->ap.ssid,sizeof(credentials.ssid));
        if (strlen((char*)get_conf->ap.password)) {
-               memcpy(credentials.pwd,get_conf->ap.password,strlen((char *)get_conf->ap.password));
+               memcpy(credentials.pwd,get_conf->ap.password,sizeof(credentials.pwd));
        }
        credentials.chnl = get_conf->ap.channel;
        credentials.max_conn = get_conf->ap.max_connection;
@@ -456,11 +464,10 @@ static esp_err_t cmd_get_softap_config_handler (SlaveConfigPayload *req,
        if (ret != ESP_OK) {
                ESP_LOGE(TAG,"Failed to get bandwidth");
        }
-       ESP_LOGI(TAG,"got bandwidth now %d", *get_bw);
+       ESP_LOGI(TAG,"got bandwidth now %d", *get_bw); //check here
        resp_payload->bw = *(int *)get_bw;
        resp_payload->status = SUCCESS;
-       ESP_LOGI(TAG,"response success string %s",resp_payload->status);
-       resp->payload_case = SLAVE_CONFIG_PAYLOAD__PAYLOAD_RESP_GET_SOFTAP_CONFIG  ;
+       resp->payload_case = SLAVE_CONFIG_PAYLOAD__PAYLOAD_RESP_GET_SOFTAP_CONFIG;
        resp->resp_get_softap_config = resp_payload;
        free(get_conf);
        free(get_bw);
@@ -470,11 +477,17 @@ static esp_err_t cmd_get_softap_config_handler (SlaveConfigPayload *req,
 static esp_err_t cmd_set_softap_config_handler (SlaveConfigPayload *req,
                                         SlaveConfigPayload *resp, void *priv_data)
 {
-       ESP_LOGI(TAG,"set soft AP handler");
+       ESP_LOGI(TAG,"Inside set soft AP function");
        esp_err_t ret;
        softap_event_register();
        ESP_LOGI(TAG,"event handler registered in set softap config ");
-       ret = esp_wifi_set_mode(WIFI_MODE_AP);
+       if (hosted_flags.is_ap_connected) {
+               ret = esp_wifi_set_mode(WIFI_MODE_APSTA);
+               ESP_LOGI(TAG,"APSTA mode set");
+       } else {
+               ret = esp_wifi_set_mode(WIFI_MODE_AP);
+               ESP_LOGI(TAG,"AP mode set");
+       }
        if (ret != ESP_OK) {
                ESP_LOGE(TAG,"Failed to set mode");
                return ESP_FAIL;
@@ -485,17 +498,14 @@ static esp_err_t cmd_set_softap_config_handler (SlaveConfigPayload *req,
                ESP_LOGE(TAG,"Failed to allocate memory");
                return ESP_ERR_NO_MEM;
        }
-       uint8_t ssid_length = strlen(req->cmd_set_softap_config->ssid);
        wifi_config->ap.authmode = req->cmd_set_softap_config->ecn;
-       uint8_t pwd_length = strlen(req->cmd_set_softap_config->pwd);
 
        if (wifi_config->ap.authmode != WIFI_AUTH_OPEN) {
-               memcpy(wifi_config->ap.password,req->cmd_set_softap_config->pwd,pwd_length);
+               memcpy(wifi_config->ap.password,req->cmd_set_softap_config->pwd,sizeof(wifi_config->ap.password));
        }
 
-       memcpy(wifi_config->ap.ssid,req->cmd_set_softap_config->ssid,ssid_length);
-       ESP_LOGI(TAG,"ssid len %d and password len %d",ssid_length, pwd_length);
-       wifi_config->ap.ssid_len = ssid_length;
+       memcpy(wifi_config->ap.ssid,req->cmd_set_softap_config->ssid,sizeof(wifi_config->ap.ssid));
+       wifi_config->ap.ssid_len = strlen(req->cmd_set_softap_config->ssid);
        wifi_config->ap.channel = req->cmd_set_softap_config->chnl;
 
        wifi_config->ap.max_connection = req->cmd_set_softap_config-> max_conn;
@@ -504,35 +514,38 @@ static esp_err_t cmd_set_softap_config_handler (SlaveConfigPayload *req,
        ret = esp_wifi_get_mac(WIFI_IF_AP, mac);
        if (ret != ESP_OK) {
                ESP_LOGE(TAG,"Failed to get MAC address");
+               free(wifi_config);
                return ESP_FAIL;
        }
        ret = esp_wifi_set_bandwidth(ESP_IF_WIFI_AP,req->cmd_set_softap_config->bw);
        if (ret != ESP_OK) {
                ESP_LOGE(TAG,"Failed to set MAC address");
+               free(wifi_config);
                return ESP_FAIL;
        }
        ESP_LOGI(TAG, MACSTR, MAC2STR(mac));
        ret = esp_wifi_set_config(ESP_IF_WIFI_AP, wifi_config);
        if (ret != ESP_OK) {
                ESP_LOGE(TAG,"Failed to set AP config");
+               free(wifi_config);
                return ESP_FAIL;
        }
        ret = esp_wifi_start();
        if (ret != ESP_OK) {
                ESP_LOGE(TAG,"Failed to start WiFi");
+               free(wifi_config);
                return ESP_FAIL;
        }
-       ESP_LOGI(TAG,"ssid %d %s pwd %d %s authmode %d ssid_hidden %d max_conn %d channel %d",ssid_length, wifi_config->ap.ssid, pwd_length, wifi_config->ap.password, wifi_config->ap.authmode,wifi_config->ap.ssid_hidden,wifi_config->ap.max_connection,wifi_config->ap.channel);
+       ESP_LOGI(TAG,"ssid %s pwd %s authmode %d ssid_hidden %d max_conn %d channel %d", wifi_config->ap.ssid, wifi_config->ap.password, wifi_config->ap.authmode,wifi_config->ap.ssid_hidden,wifi_config->ap.max_connection,wifi_config->ap.channel);
 
        RespConfig *resp_payload = (RespConfig *)calloc(1,sizeof(RespConfig));
        if (resp_payload == NULL) {
                ESP_LOGE(TAG,"Failed to allocate memory");
+               free(wifi_config);
                return ESP_ERR_NO_MEM;
        }
        resp_config__init (resp_payload);
-       ESP_LOGI(TAG,"resp_payload address %p and status also %p", resp_payload, resp_payload->status);
        resp_payload->status = SUCCESS;
-       ESP_LOGI(TAG,"response success string %s",resp_payload->status);
        resp->payload_case = SLAVE_CONFIG_PAYLOAD__PAYLOAD_RESP_SET_SOFTAP_CONFIG ;
        resp->resp_set_softap_config = resp_payload;
        ESP_LOGI(TAG,"ESp32 SoftAP is avaliable ");
@@ -580,7 +593,6 @@ static esp_err_t cmd_get_ap_scan_list_handler (SlaveConfigPayload *req,
                ESP_LOGE(TAG,"Failed To allocate memory");
                return ESP_ERR_NO_MEM;
        }
-       ESP_LOGI(TAG,"address of results %p",results);
        resp_payload->entries = results;
        for (int i = 0; i < credentials.count; i++ ) {
                ESP_LOGI(TAG,"SSID \t\t%s", ap_info[i].ssid);
@@ -600,15 +612,15 @@ static esp_err_t cmd_get_ap_scan_list_handler (SlaveConfigPayload *req,
                        ESP_LOGE(TAG,"Failed to allocate memory for scan result entry SSID");
                        return ESP_ERR_NO_MEM;
                }
-               ESP_LOGI(TAG,"ssid scan %s %d", results[i]->ssid.data,results[i]->ssid.len );
+               ESP_LOGI(TAG,"ssid %s ssid lenghth %d", results[i]->ssid.data,results[i]->ssid.len );
                results[i]->has_chnl = 1;
                credentials.chnl = ap_info[i].primary;
                results[i]->chnl = credentials.chnl;
-               ESP_LOGI(TAG,"chnl scan %d %d",results[i]->chnl,resp_payload->entries[i]->chnl );
+               ESP_LOGI(TAG,"chnl %d ",results[i]->chnl);
                results[i]->has_rssi = 1;
                credentials.rssi = ap_info[i].rssi;
                results[i]->rssi = credentials.rssi;
-               ESP_LOGI(TAG,"chnl scan %d",resp_payload->entries[i]->rssi );
+               ESP_LOGI(TAG,"rssi %d",results[i]->rssi );
                results[i]->has_bssid = 1;
                sprintf((char *)credentials.bssid,MACSTR,MAC2STR(ap_info[i].bssid));
                results[i]->bssid.len = strnlen((char *)credentials.bssid,19);
@@ -735,7 +747,7 @@ static void slave_config_cleanup(SlaveConfigPayload *resp)
                case (SLAVE_CONFIG_MSG_TYPE__TypeRespSetAPConfig ) : {
                        if (resp->resp_set_ap_config) {
                                free(resp->resp_set_ap_config);
-                               ESP_LOGI(TAG,"resp set ap config");
+                               ESP_LOGI(TAG,"resp set ap config freed");
                        }
                }
                break;
diff --git a/slave_driver/sdio_slave_test/main/slave_commands.h b/slave_driver/sdio_slave_test/main/slave_commands.h
new file mode 100644 (file)
index 0000000..f4a1af3
--- /dev/null
@@ -0,0 +1,18 @@
+// 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 <esp_err.h>
+
+esp_err_t data_transfer_handler(uint32_t session_id,const uint8_t *inbuf, ssize_t inlen,uint8_t **outbuf, ssize_t *outlen, void *priv_data);
+
This page took 0.117107 seconds and 4 git commands to generate.