# How to Run scripts on Raspberry-Pi(rpi)
## For Wi-Fi Connectivity
-There is `host/host_control` folder in which `host_commands` python library is present. It contains following functions.
+There is `host/linux/host_control` folder in which `host_commands` python library is present. It contains following functions.
```
get_mac(mode)
get_wifi_mode()
wifi_connected_stations_list()
```
-User can make use of these python functions to get access of wifi functionalities of ESP32. Also in `host/host_control/host_commands` folder `test.py` python script present to try those python functions. User can use it by running following command.
+User can make use of these python functions to get access of wifi functionalities of ESP32. Also in `host/linux/host_control/host_commands` folder `test.py` python script present to try those python functions. User can use it by running following command.
```
python test.py
```
-Go to `host/host_control/` folder and run `./rpi_init.sh` to compile and insert host driver on Raspberry-Pi. This script also creates `/dev/esps0` which is used as a WLAN control interface.
+Go to `host/linux/host_control/` folder and run `./rpi_init.sh` to compile and insert host driver on Raspberry-Pi. This script also creates `/dev/esps0` which is used as a WLAN control interface.
There are six python scripts for station connect to AP, station disconnect from AP ,start softAP, stop softAP, scan available APs and list stations connected to softAP.
- Ensure that bluez is installed on Raspberry-Pi and it is downloaded in source format as well. Please refer [Setup](docs/Setup.md) instructions for more details.
- In following test, Android device was used as a BT/BLE test device. For BLE testing, [nRF connect for mobile APP](https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp&hl=en_IN) was used.
-- Go to `host/host_control/` folder to run following script.
+- Go to `host/linux/host_control/` folder to run following script.
### UART based setup
1. Execute `./rpi_init.sh btuart` to prepare Raspberry-Pi for Bluetooth operation
+++ /dev/null
-GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Lesser General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- {description}
- Copyright (C) {year} {fullname}
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- {signature of Ty Coon}, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.
-
+++ /dev/null
-# Copyright 2015-2020 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 commands
-import argparse
-
-failure = "failure"
-ap_list = 'No APs Available'
-
-parser = argparse.ArgumentParser(description='ap_scan_list.py is a python script which gives scanned list of available APs. list contains ssid, channel number, rssi, mac address and authentication mode of AP. ex. python ap_scan_list.py')
-
-ap_list = commands.wifi_ap_scan_list()
-if (ap_list == failure):
- print("Failed to get AP scan list")
-else:
- for obj in ap_list:
- print(obj.ssid,obj.chnl,obj.rssi,obj.bssid,obj.ecn)
+++ /dev/null
-# Copyright 2015-2020 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 commands
-import argparse
-
-# WiFi Mode
-# NULL 0
-# Station 1
-# SoftAP 2
-# Station + SoftAP 3
-
-none = 0
-station = 1
-softap = 2
-station_softap = 3
-failure = "failure"
-stations_list = "No station is connected"
-
-parser = argparse.ArgumentParser(description='connected_stations_list.py is a python script which gives list of mac addresses of stations connected to softAP. ex. python connected_stations_list.py')
-
-get_mode = commands.get_wifi_mode()
-if (get_mode == softap or get_mode == station_softap):
- stations_list = commands.wifi_connected_stations_list()
- if (stations_list == failure):
- print("failure in getting connected stations list")
- else:
- for obj in stations_list:
- print(obj.mac)
-elif (get_mode == failure):
- print("failure in getting wifi mode")
-else :
- print("current mode is not station/station+softap")
+++ /dev/null
-# Copyright 2015-2020 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 transport
-import esp_hosted_config_pb2
-import binascii
-
-class Aplist:
- def __init__(self,ssid,chnl,rssi,bssid,ecn):
- self.ssid = ssid
- self.chnl = chnl
- self.rssi = rssi
- self.bssid = bssid
- self.ecn = ecn
-
-class Stationlist:
- def __init__(self,mac,rssi):
- self.mac = mac
- self.rssi = rssi
-
-#default parameters
-interface = "/dev/esps0"
-endpoint = "control"
-not_set = "0"
-failure = "failure"
-
-#get mac address
-# mode == 1 for station mac
-# mode == 2 for softAP mac
-def get_mac(mode):
- req_sta_mac = esp_hosted_config_pb2.EspHostedConfigPayload()
- req_sta_mac.msg = esp_hosted_config_pb2.EspHostedConfigMsgType.TypeCmdGetMACAddress
- #for station mode set cmd as 1
- req_sta_mac.cmd_get_mac_address.cmd = str(mode)
- protodata = req_sta_mac.SerializeToString()
- #print("serialized data "+str(protodata))
- tp = transport.Transport_pserial(interface)
- response = tp.send_data(endpoint,protodata,0.3)
- if response == failure :
- return failure
- #print("response from slave "+str(response))
- req_sta_mac.ParseFromString(response)
- return req_sta_mac.resp_get_mac_address.resp
-
-#get wifi mode
-# 0: null Mode, Wi-Fi mode not set
-# 1: station mode
-# 2: softAP mode
-# 3: softAP+station mode
-
-def get_wifi_mode():
- req_wifi_mode = esp_hosted_config_pb2.EspHostedConfigPayload()
- req_wifi_mode.msg = esp_hosted_config_pb2.EspHostedConfigMsgType.TypeCmdGetWiFiMode
- protodata = req_wifi_mode.SerializeToString()
- #print("serialized data "+str(protodata))
- tp = transport.Transport_pserial(interface)
- response = tp.send_data(endpoint,protodata,0.3)
- if response == failure :
- return failure
- #print("response from slave "+str(response))
- req_wifi_mode.ParseFromString(response)
- return req_wifi_mode.resp_get_wifi_mode.mode
-
-#set wifi mode
-# 0: null Mode, Wi-Fi mode not set
-# 1: station mode
-# 2: softAP mode
-# 3: softAP+station mode
-def set_wifi_mode(mode):
- set_wifi_mode = esp_hosted_config_pb2.EspHostedConfigPayload()
- set_wifi_mode.msg = esp_hosted_config_pb2.EspHostedConfigMsgType.TypeCmdSetWiFiMode
- set_wifi_mode.cmd_set_wifi_mode.mode = mode
- protodata = set_wifi_mode.SerializeToString()
- #print("serialized data "+str(protodata))
- tp = transport.Transport_pserial(interface)
- response = tp.send_data(endpoint,protodata,0.3)
- if response == failure :
- return failure
- #print("response from slave "+str(response))
- set_wifi_mode.ParseFromString(response)
- return set_wifi_mode.resp_set_wifi_mode.mode
-
-# get AP config to which ESP station is connected
-# It returns ssid, bssid, channel and rssi
-def wifi_get_ap_config():
- get_ap_config = esp_hosted_config_pb2.EspHostedConfigPayload()
- get_ap_config.msg = esp_hosted_config_pb2.EspHostedConfigMsgType.TypeCmdGetAPConfig
- protodata = get_ap_config.SerializeToString()
- #print("serialized data "+str(protodata))
- tp = transport.Transport_pserial(interface)
- response = tp.send_data(endpoint,protodata,1)
- if response == failure :
- return failure
- #print("response from slave "+str(response))
- get_ap_config.ParseFromString(response)
- ssid = str(get_ap_config.resp_get_ap_config.ssid)
- bssid = str(get_ap_config.resp_get_ap_config.bssid)
- channel = get_ap_config.resp_get_ap_config.chnl
- rssi = get_ap_config.resp_get_ap_config.rssi
- return ssid,bssid,channel,rssi
-
-# set AP config to which ESP station should connect
-# User should provide ssid, password, bssid
-def wifi_set_ap_config(ssid, pwd, bssid):
- set_ap_config = esp_hosted_config_pb2.EspHostedConfigPayload()
- set_ap_config.msg = esp_hosted_config_pb2.EspHostedConfigMsgType.TypeCmdSetAPConfig
- set_ap_config.cmd_set_ap_config.ssid = str(ssid)
- set_ap_config.cmd_set_ap_config.pwd = str(pwd)
- 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)
- response = tp.send_data(endpoint,protodata,10)
- if response == failure :
- return failure
- #print("response from slave "+str(response))
- set_ap_config.ParseFromString(response)
- status = set_ap_config.resp_set_ap_config.status
- return status
-
-# Disconnect from AP
-def wifi_disconnect_ap():
- disconnect_ap = esp_hosted_config_pb2.EspHostedConfigPayload()
- disconnect_ap.msg = esp_hosted_config_pb2.EspHostedConfigMsgType.TypeCmdDisconnectAP
- protodata = disconnect_ap.SerializeToString()
- #print("serialized data "+str(protodata))
- tp = transport.Transport_pserial(interface)
- response = tp.send_data(endpoint,protodata,0.3)
- if response == failure :
- return failure
- #print("response from slave "+str(response))
- disconnect_ap.ParseFromString(response)
- status = disconnect_ap.resp_disconnect_ap.resp
- return status
-
-
-# set softAP config
-# ssid : string parameter, ssid of SoftAP
-# pwd : string parameter, length of password should be 8~64 bytes ASCII
-# chnl : channel ID should be in range of 1 to 11
-# ecn : Encryption method
-# ( 0 : OPEN,
-# 2 : WPA_PSK,
-# 3 : WPA2_PSK,
-# 4 : WPA_WPA2_PSK)
-# max_conn : maximum number of stations can connect to ESP32 SoftAP (should be in range of 1 to 10)
-# ssid_hidden : softAP should broadcast its SSID or not
-# ( 0 : SSID is broadcast
-# 1 : SSID is not broadcast )
-# bw : set bandwidth of ESP32 softAP
-# ( 1 : WIFI_BW_HT20
-# 2 : WIFI_BW_HT40 )
-
-def wifi_set_softap_config(ssid, pwd, chnl, ecn, max_conn, ssid_hidden, bw):
- set_softap_config = esp_hosted_config_pb2.EspHostedConfigPayload()
- set_softap_config.msg = esp_hosted_config_pb2.EspHostedConfigMsgType.TypeCmdSetSoftAPConfig
- set_softap_config.cmd_set_softap_config.ssid = str(ssid)
- set_softap_config.cmd_set_softap_config.pwd = str(pwd)
- set_softap_config.cmd_set_softap_config.chnl = chnl
- set_softap_config.cmd_set_softap_config.ecn = ecn
- set_softap_config.cmd_set_softap_config.max_conn = max_conn
- set_softap_config.cmd_set_softap_config.ssid_hidden = ssid_hidden
- set_softap_config.cmd_set_softap_config.bw = bw
- protodata = set_softap_config.SerializeToString()
- #print("serialized data "+str(protodata))
- tp = transport.Transport_pserial(interface)
- response = tp.send_data(endpoint,protodata,3)
- if response == failure :
- return failure
- #print("response from slave "+str(response))
- set_softap_config.ParseFromString(response)
- status = set_softap_config.resp_set_softap_config.status
- return status
-
-# get softAP configuration
-# It returns ssid,pwd,chnl,ecn,max_conn,ssid_hidden,status,bw
-# ssid : string parameter, ssid of SoftAP
-# pwd : string parameter, length of password should be 8~64 bytes ASCII
-# chnl : channel ID will be in range of 1 to 11
-# ecn : Encryption method
-# ( 0 : OPEN,
-# 2 : WPA_PSK,
-# 3 : WPA2_PSK,
-# 4 : WPA_WPA2_PSK)
-# max_conn : maximum number of stations can connect to ESP32 SoftAP (will be in range of 1 to 10)
-# ssid_hidden : softAP should broadcast its SSID or not
-# ( 0 : SSID is broadcast
-# 1 : SSID is not broadcast )
-# status : return SUCCESS or FAILURE as result of read operation
-# bw : bandwidth of ESP32 softAP
-# ( 1 : WIFI_BW_HT20
-# 2 : WIFI_BW_HT40 )
-
-def wifi_get_softap_config():
- get_softap_config = esp_hosted_config_pb2.EspHostedConfigPayload()
- get_softap_config.msg = esp_hosted_config_pb2.EspHostedConfigMsgType.TypeCmdGetSoftAPConfig
- protodata = get_softap_config.SerializeToString()
- #print("serialized data "+str(protodata))
- tp = transport.Transport_pserial(interface)
- response = tp.send_data(endpoint,protodata,0.3)
- if response == failure :
- return failure
- #print("response from slave "+str(response))
- get_softap_config.ParseFromString(response)
- ssid = str(get_softap_config.resp_get_softap_config.ssid)
- pwd = str(get_softap_config.resp_get_softap_config.pwd)
- ecn = get_softap_config.resp_get_softap_config.ecn
- chnl = get_softap_config.resp_get_softap_config.chnl
- max_conn = get_softap_config.resp_get_softap_config.max_conn
- 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,chnl,ecn,max_conn,ssid_hidden,status,bw
-
-# Scan AP list
-# It scans the available APs
-# output is list of Aplist class instances(ssid,chnl,rssi,bssid,ecn)
-
-def wifi_ap_scan_list():
- get_ap_scan_list = esp_hosted_config_pb2.EspHostedConfigPayload()
- get_ap_scan_list.msg = esp_hosted_config_pb2.EspHostedConfigMsgType.TypeCmdGetAPScanList
- protodata = get_ap_scan_list.SerializeToString()
- #print("serialized data "+str(protodata))
- tp = transport.Transport_pserial(interface)
- response = tp.send_data(endpoint,protodata,10)
- if response == failure :
- return failure
- #print("response from slave "+str(response))
- get_ap_scan_list.ParseFromString(response)
- count = get_ap_scan_list.resp_scan_ap_list.count
- ap_list = []
- for i in range(count) :
- ssid = get_ap_scan_list.resp_scan_ap_list.entries[i].ssid
- chnl = get_ap_scan_list.resp_scan_ap_list.entries[i].chnl
- rssi = get_ap_scan_list.resp_scan_ap_list.entries[i].rssi
- bssid = get_ap_scan_list.resp_scan_ap_list.entries[i].bssid
- ecn = get_ap_scan_list.resp_scan_ap_list.entries[i].ecn
- ap_list.append(Aplist(ssid,chnl,rssi,bssid,ecn))
- return ap_list
-
-# This function returns the number of connected stations to softAP
-# Maximum 10 connected stations info can get
-# If no station is connected, failure return from slave
-# output is list of Stationlist class instances
-
-def wifi_connected_stations_list():
- get_connected_stations_list = esp_hosted_config_pb2.EspHostedConfigPayload()
- get_connected_stations_list.msg = esp_hosted_config_pb2.EspHostedConfigMsgType.TypeCmdGetConnectedSTAList
- protodata = get_connected_stations_list.SerializeToString()
- #print("serialized data "+str(protodata))
- tp = transport.Transport_pserial(interface)
- response = tp.send_data(endpoint,protodata,1)
- if response == failure :
- return failure
- #print("response from slave "+str(response))
- get_connected_stations_list.ParseFromString(response)
- num = get_connected_stations_list.resp_connected_stas_list.num
- if (num == 0) :
- print("No station is connected")
- return failure
- else :
- stas_list = []
- for i in range(num) :
- mac = get_connected_stations_list.resp_connected_stas_list.stations[i].mac
- rssi = get_connected_stations_list.resp_connected_stas_list.stations[i].rssi
- stas_list.append(Stationlist(mac,rssi))
- return stas_list
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: esp_hosted_config.proto
-
-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
-# @@protoc_insertion_point(imports)
-
-_sym_db = _symbol_database.Default()
-
-
-
-
-DESCRIPTOR = _descriptor.FileDescriptor(
- name='esp_hosted_config.proto',
- package='',
- syntax='proto3',
- serialized_options=None,
- serialized_pb=b'\n\x17\x65sp_hosted_config.proto\")\n\x0c\x43mdGetStatus\x12\x0b\n\x03\x63md\x18\x01 \x01(\t\x12\x0c\n\x04mode\x18\x02 \x01(\x05\"+\n\rRespGetStatus\x12\x0c\n\x04resp\x18\x01 \x01(\t\x12\x0c\n\x04mode\x18\x02 \x01(\x05\"\xb2\x01\n\tCmdConfig\x12\x0c\n\x04ssid\x18\x01 \x01(\t\x12\x0b\n\x03pwd\x18\x02 \x01(\t\x12\x1c\n\x03\x65\x63n\x18\x03 \x01(\x0e\x32\x0f.EncryptionMode\x12\x0c\n\x04\x63hnl\x18\x04 \x01(\x05\x12\x10\n\x08max_conn\x18\x05 \x01(\x05\x12\x13\n\x0bssid_hidden\x18\x06 \x01(\x08\x12\r\n\x05\x62ssid\x18\x07 \x01(\t\x12\x0c\n\x04rssi\x18\x08 \x01(\x05\x12\x0e\n\x06status\x18\t \x01(\t\x12\n\n\x02\x62w\x18\n \x01(\x05\"\xb3\x01\n\nRespConfig\x12\x0c\n\x04ssid\x18\x01 \x01(\t\x12\x0b\n\x03pwd\x18\x02 \x01(\t\x12\x1c\n\x03\x65\x63n\x18\x03 \x01(\x0e\x32\x0f.EncryptionMode\x12\x0c\n\x04\x63hnl\x18\x04 \x01(\x05\x12\x10\n\x08max_conn\x18\x05 \x01(\x05\x12\x13\n\x0bssid_hidden\x18\x06 \x01(\x08\x12\r\n\x05\x62ssid\x18\x07 \x01(\t\x12\x0c\n\x04rssi\x18\x08 \x01(\x05\x12\x0e\n\x06status\x18\t \x01(\t\x12\n\n\x02\x62w\x18\n \x01(\x05\"c\n\nScanResult\x12\x0c\n\x04ssid\x18\x01 \x01(\x0c\x12\x0c\n\x04\x63hnl\x18\x02 \x01(\r\x12\x0c\n\x04rssi\x18\x03 \x01(\x05\x12\r\n\x05\x62ssid\x18\x04 \x01(\x0c\x12\x1c\n\x03\x65\x63n\x18\x05 \x01(\x0e\x32\x0f.EncryptionMode\"\x0f\n\rCmdScanResult\"=\n\x0eRespScanResult\x12\r\n\x05\x63ount\x18\x01 \x01(\r\x12\x1c\n\x07\x65ntries\x18\x02 \x03(\x0b\x32\x0b.ScanResult\"-\n\x10\x43onnectedSTAList\x12\x0b\n\x03mac\x18\x01 \x01(\x0c\x12\x0c\n\x04rssi\x18\x02 \x01(\x05\"\x11\n\x0f\x43mdConnectedSTA\"D\n\x10RespConnectedSTA\x12\x0b\n\x03num\x18\x01 \x01(\r\x12#\n\x08stations\x18\x02 \x03(\x0b\x32\x11.ConnectedSTAList\"\xdb\x07\n\x16\x45spHostedConfigPayload\x12$\n\x03msg\x18\x01 \x01(\x0e\x32\x17.EspHostedConfigMsgType\x12,\n\x13\x63md_get_mac_address\x18\n \x01(\x0b\x32\r.CmdGetStatusH\x00\x12.\n\x14resp_get_mac_address\x18\x0b \x01(\x0b\x32\x0e.RespGetStatusH\x00\x12*\n\x11\x63md_get_wifi_mode\x18\x0c \x01(\x0b\x32\r.CmdGetStatusH\x00\x12,\n\x12resp_get_wifi_mode\x18\r \x01(\x0b\x32\x0e.RespGetStatusH\x00\x12*\n\x11\x63md_set_wifi_mode\x18\x0e \x01(\x0b\x32\r.CmdGetStatusH\x00\x12,\n\x12resp_set_wifi_mode\x18\x0f \x01(\x0b\x32\x0e.RespGetStatusH\x00\x12\'\n\x11\x63md_get_ap_config\x18\x10 \x01(\x0b\x32\n.CmdConfigH\x00\x12)\n\x12resp_get_ap_config\x18\x11 \x01(\x0b\x32\x0b.RespConfigH\x00\x12\'\n\x11\x63md_set_ap_config\x18\x12 \x01(\x0b\x32\n.CmdConfigH\x00\x12)\n\x12resp_set_ap_config\x18\x13 \x01(\x0b\x32\x0b.RespConfigH\x00\x12+\n\x15\x63md_get_softap_config\x18\x14 \x01(\x0b\x32\n.CmdConfigH\x00\x12-\n\x16resp_get_softap_config\x18\x15 \x01(\x0b\x32\x0b.RespConfigH\x00\x12+\n\x15\x63md_set_softap_config\x18\x16 \x01(\x0b\x32\n.CmdConfigH\x00\x12-\n\x16resp_set_softap_config\x18\x17 \x01(\x0b\x32\x0b.RespConfigH\x00\x12*\n\x11\x63md_disconnect_ap\x18\x18 \x01(\x0b\x32\r.CmdGetStatusH\x00\x12,\n\x12resp_disconnect_ap\x18\x19 \x01(\x0b\x32\x0e.RespGetStatusH\x00\x12*\n\x10\x63md_scan_ap_list\x18\x1a \x01(\x0b\x32\x0e.CmdScanResultH\x00\x12,\n\x11resp_scan_ap_list\x18\x1b \x01(\x0b\x32\x0f.RespScanResultH\x00\x12\x33\n\x17\x63md_connected_stas_list\x18\x1c \x01(\x0b\x32\x10.CmdConnectedSTAH\x00\x12\x35\n\x18resp_connected_stas_list\x18\x1d \x01(\x0b\x32\x11.RespConnectedSTAH\x00\x42\t\n\x07payload*\x83\x01\n\x0e\x45ncryptionMode\x12\r\n\tType_Open\x10\x00\x12\x0c\n\x08Type_WEP\x10\x01\x12\x10\n\x0cType_WPA_PSK\x10\x02\x12\x11\n\rType_WPA2_PSK\x10\x03\x12\x15\n\x11Type_WPA_WPA2_PSK\x10\x04\x12\x18\n\x14Type_WPA2_ENTERPRISE\x10\x05*\xac\x04\n\x16\x45spHostedConfigMsgType\x12\x18\n\x14TypeCmdGetMACAddress\x10\x00\x12\x19\n\x15TypeRespGetMACAddress\x10\x01\x12\x16\n\x12TypeCmdGetWiFiMode\x10\x02\x12\x17\n\x13TypeRespGetWiFiMode\x10\x03\x12\x16\n\x12TypeCmdSetWiFiMode\x10\x04\x12\x17\n\x13TypeRespSetWiFiMode\x10\x05\x12\x16\n\x12TypeCmdGetAPConfig\x10\x06\x12\x17\n\x13TypeRespGetAPConfig\x10\x07\x12\x16\n\x12TypeCmdSetAPConfig\x10\x08\x12\x17\n\x13TypeRespSetAPConfig\x10\t\x12\x1a\n\x16TypeCmdGetSoftAPConfig\x10\n\x12\x1b\n\x17TypeRespGetSoftAPConfig\x10\x0b\x12\x1a\n\x16TypeCmdSetSoftAPConfig\x10\x0c\x12\x1b\n\x17TypeRespSetSoftAPConfig\x10\r\x12\x17\n\x13TypeCmdDisconnectAP\x10\x0e\x12\x18\n\x14TypeRespDisconnectAP\x10\x0f\x12\x18\n\x14TypeCmdGetAPScanList\x10\x10\x12\x19\n\x15TypeRespGetAPScanList\x10\x11\x12\x1e\n\x1aTypeCmdGetConnectedSTAList\x10\x12\x12\x1f\n\x1bTypeRespGetConnectedSTAList\x10\x13\x62\x06proto3'
-)
-
-_ENCRYPTIONMODE = _descriptor.EnumDescriptor(
- name='EncryptionMode',
- full_name='EncryptionMode',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='Type_Open', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='Type_WEP', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='Type_WPA_PSK', index=2, number=2,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='Type_WPA2_PSK', index=3, number=3,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='Type_WPA_WPA2_PSK', index=4, number=4,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='Type_WPA2_ENTERPRISE', index=5, number=5,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=1786,
- serialized_end=1917,
-)
-_sym_db.RegisterEnumDescriptor(_ENCRYPTIONMODE)
-
-EncryptionMode = enum_type_wrapper.EnumTypeWrapper(_ENCRYPTIONMODE)
-_ESPHOSTEDCONFIGMSGTYPE = _descriptor.EnumDescriptor(
- name='EspHostedConfigMsgType',
- full_name='EspHostedConfigMsgType',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='TypeCmdGetMACAddress', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TypeRespGetMACAddress', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TypeCmdGetWiFiMode', index=2, number=2,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TypeRespGetWiFiMode', index=3, number=3,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TypeCmdSetWiFiMode', index=4, number=4,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TypeRespSetWiFiMode', index=5, number=5,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TypeCmdGetAPConfig', index=6, number=6,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TypeRespGetAPConfig', index=7, number=7,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TypeCmdSetAPConfig', index=8, number=8,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TypeRespSetAPConfig', index=9, number=9,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TypeCmdGetSoftAPConfig', index=10, number=10,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TypeRespGetSoftAPConfig', index=11, number=11,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TypeCmdSetSoftAPConfig', index=12, number=12,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TypeRespSetSoftAPConfig', index=13, number=13,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TypeCmdDisconnectAP', index=14, number=14,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TypeRespDisconnectAP', index=15, number=15,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TypeCmdGetAPScanList', index=16, number=16,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TypeRespGetAPScanList', index=17, number=17,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TypeCmdGetConnectedSTAList', index=18, number=18,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TypeRespGetConnectedSTAList', index=19, number=19,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=1920,
- serialized_end=2476,
-)
-_sym_db.RegisterEnumDescriptor(_ESPHOSTEDCONFIGMSGTYPE)
-
-EspHostedConfigMsgType = enum_type_wrapper.EnumTypeWrapper(_ESPHOSTEDCONFIGMSGTYPE)
-Type_Open = 0
-Type_WEP = 1
-Type_WPA_PSK = 2
-Type_WPA2_PSK = 3
-Type_WPA_WPA2_PSK = 4
-Type_WPA2_ENTERPRISE = 5
-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
-TypeCmdGetConnectedSTAList = 18
-TypeRespGetConnectedSTAList = 19
-
-
-
-_CMDGETSTATUS = _descriptor.Descriptor(
- name='CmdGetStatus',
- full_name='CmdGetStatus',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='cmd', full_name='CmdGetStatus.cmd', 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='mode', full_name='CmdGetStatus.mode', index=1,
- number=2, 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,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto3',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=27,
- serialized_end=68,
-)
-
-
-_RESPGETSTATUS = _descriptor.Descriptor(
- name='RespGetStatus',
- full_name='RespGetStatus',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='resp', full_name='RespGetStatus.resp', 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='mode', full_name='RespGetStatus.mode', index=1,
- number=2, 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,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto3',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=70,
- serialized_end=113,
-)
-
-
-_CMDCONFIG = _descriptor.Descriptor(
- name='CmdConfig',
- full_name='CmdConfig',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='ssid', full_name='CmdConfig.ssid', 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='pwd', full_name='CmdConfig.pwd', index=1,
- number=2, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='ecn', full_name='CmdConfig.ecn', index=2,
- number=3, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='chnl', full_name='CmdConfig.chnl', 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='max_conn', full_name='CmdConfig.max_conn', 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='ssid_hidden', full_name='CmdConfig.ssid_hidden', index=5,
- number=6, type=8, cpp_type=7, label=1,
- has_default_value=False, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='bssid', full_name='CmdConfig.bssid', index=6,
- number=7, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='rssi', full_name='CmdConfig.rssi', index=7,
- number=8, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='status', full_name='CmdConfig.status', index=8,
- number=9, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='bw', full_name='CmdConfig.bw', index=9,
- number=10, 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,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto3',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=116,
- serialized_end=294,
-)
-
-
-_RESPCONFIG = _descriptor.Descriptor(
- name='RespConfig',
- full_name='RespConfig',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='ssid', full_name='RespConfig.ssid', 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='pwd', full_name='RespConfig.pwd', index=1,
- number=2, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='ecn', full_name='RespConfig.ecn', index=2,
- number=3, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='chnl', full_name='RespConfig.chnl', 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='max_conn', full_name='RespConfig.max_conn', 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='ssid_hidden', full_name='RespConfig.ssid_hidden', index=5,
- number=6, type=8, cpp_type=7, label=1,
- has_default_value=False, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='bssid', full_name='RespConfig.bssid', index=6,
- number=7, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='rssi', full_name='RespConfig.rssi', index=7,
- number=8, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='status', full_name='RespConfig.status', index=8,
- number=9, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='bw', full_name='RespConfig.bw', index=9,
- number=10, 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,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto3',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=297,
- serialized_end=476,
-)
-
-
-_SCANRESULT = _descriptor.Descriptor(
- name='ScanResult',
- full_name='ScanResult',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='ssid', full_name='ScanResult.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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='chnl', full_name='ScanResult.chnl', index=1,
- number=2, type=13, cpp_type=3, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='rssi', full_name='ScanResult.rssi', index=2,
- number=3, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='bssid', full_name='ScanResult.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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='ecn', full_name='ScanResult.ecn', index=4,
- number=5, 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,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto3',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=478,
- serialized_end=577,
-)
-
-
-_CMDSCANRESULT = _descriptor.Descriptor(
- name='CmdScanResult',
- full_name='CmdScanResult',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto3',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=579,
- serialized_end=594,
-)
-
-
-_RESPSCANRESULT = _descriptor.Descriptor(
- name='RespScanResult',
- full_name='RespScanResult',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='count', full_name='RespScanResult.count', index=0,
- number=1, type=13, cpp_type=3, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='entries', full_name='RespScanResult.entries', index=1,
- number=2, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto3',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=596,
- serialized_end=657,
-)
-
-
-_CONNECTEDSTALIST = _descriptor.Descriptor(
- name='ConnectedSTAList',
- full_name='ConnectedSTAList',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='mac', full_name='ConnectedSTAList.mac', 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='rssi', full_name='ConnectedSTAList.rssi', index=1,
- number=2, 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,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto3',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=659,
- serialized_end=704,
-)
-
-
-_CMDCONNECTEDSTA = _descriptor.Descriptor(
- name='CmdConnectedSTA',
- full_name='CmdConnectedSTA',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto3',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=706,
- serialized_end=723,
-)
-
-
-_RESPCONNECTEDSTA = _descriptor.Descriptor(
- name='RespConnectedSTA',
- full_name='RespConnectedSTA',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='num', full_name='RespConnectedSTA.num', index=0,
- number=1, type=13, cpp_type=3, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='stations', full_name='RespConnectedSTA.stations', index=1,
- number=2, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto3',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=725,
- serialized_end=793,
-)
-
-
-_ESPHOSTEDCONFIGPAYLOAD = _descriptor.Descriptor(
- name='EspHostedConfigPayload',
- full_name='EspHostedConfigPayload',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='msg', full_name='EspHostedConfigPayload.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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='cmd_get_mac_address', full_name='EspHostedConfigPayload.cmd_get_mac_address', 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='resp_get_mac_address', full_name='EspHostedConfigPayload.resp_get_mac_address', 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='cmd_get_wifi_mode', full_name='EspHostedConfigPayload.cmd_get_wifi_mode', 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='resp_get_wifi_mode', full_name='EspHostedConfigPayload.resp_get_wifi_mode', 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='cmd_set_wifi_mode', full_name='EspHostedConfigPayload.cmd_set_wifi_mode', 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='resp_set_wifi_mode', full_name='EspHostedConfigPayload.resp_set_wifi_mode', 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='cmd_get_ap_config', full_name='EspHostedConfigPayload.cmd_get_ap_config', index=7,
- number=16, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='resp_get_ap_config', full_name='EspHostedConfigPayload.resp_get_ap_config', index=8,
- number=17, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='cmd_set_ap_config', full_name='EspHostedConfigPayload.cmd_set_ap_config', index=9,
- number=18, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='resp_set_ap_config', full_name='EspHostedConfigPayload.resp_set_ap_config', index=10,
- number=19, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='cmd_get_softap_config', full_name='EspHostedConfigPayload.cmd_get_softap_config', index=11,
- number=20, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='resp_get_softap_config', full_name='EspHostedConfigPayload.resp_get_softap_config', index=12,
- number=21, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='cmd_set_softap_config', full_name='EspHostedConfigPayload.cmd_set_softap_config', index=13,
- number=22, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='resp_set_softap_config', full_name='EspHostedConfigPayload.resp_set_softap_config', index=14,
- number=23, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='cmd_disconnect_ap', full_name='EspHostedConfigPayload.cmd_disconnect_ap', index=15,
- number=24, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='resp_disconnect_ap', full_name='EspHostedConfigPayload.resp_disconnect_ap', index=16,
- number=25, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='cmd_scan_ap_list', full_name='EspHostedConfigPayload.cmd_scan_ap_list', index=17,
- number=26, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='resp_scan_ap_list', full_name='EspHostedConfigPayload.resp_scan_ap_list', index=18,
- number=27, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='cmd_connected_stas_list', full_name='EspHostedConfigPayload.cmd_connected_stas_list', index=19,
- number=28, 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,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='resp_connected_stas_list', full_name='EspHostedConfigPayload.resp_connected_stas_list', index=20,
- number=29, 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,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto3',
- extension_ranges=[],
- oneofs=[
- _descriptor.OneofDescriptor(
- name='payload', full_name='EspHostedConfigPayload.payload',
- index=0, containing_type=None, fields=[]),
- ],
- serialized_start=796,
- serialized_end=1783,
-)
-
-_CMDCONFIG.fields_by_name['ecn'].enum_type = _ENCRYPTIONMODE
-_RESPCONFIG.fields_by_name['ecn'].enum_type = _ENCRYPTIONMODE
-_SCANRESULT.fields_by_name['ecn'].enum_type = _ENCRYPTIONMODE
-_RESPSCANRESULT.fields_by_name['entries'].message_type = _SCANRESULT
-_RESPCONNECTEDSTA.fields_by_name['stations'].message_type = _CONNECTEDSTALIST
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['msg'].enum_type = _ESPHOSTEDCONFIGMSGTYPE
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_mac_address'].message_type = _CMDGETSTATUS
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_mac_address'].message_type = _RESPGETSTATUS
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_wifi_mode'].message_type = _CMDGETSTATUS
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_wifi_mode'].message_type = _RESPGETSTATUS
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_wifi_mode'].message_type = _CMDGETSTATUS
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_wifi_mode'].message_type = _RESPGETSTATUS
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_ap_config'].message_type = _CMDCONFIG
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_ap_config'].message_type = _RESPCONFIG
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_ap_config'].message_type = _CMDCONFIG
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_ap_config'].message_type = _RESPCONFIG
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_softap_config'].message_type = _CMDCONFIG
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_softap_config'].message_type = _RESPCONFIG
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_softap_config'].message_type = _CMDCONFIG
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_softap_config'].message_type = _RESPCONFIG
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_disconnect_ap'].message_type = _CMDGETSTATUS
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_disconnect_ap'].message_type = _RESPGETSTATUS
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_scan_ap_list'].message_type = _CMDSCANRESULT
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_scan_ap_list'].message_type = _RESPSCANRESULT
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_connected_stas_list'].message_type = _CMDCONNECTEDSTA
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_connected_stas_list'].message_type = _RESPCONNECTEDSTA
-_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
- _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_mac_address'])
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_mac_address'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
-_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
- _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_mac_address'])
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_mac_address'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
-_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
- _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_wifi_mode'])
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_wifi_mode'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
-_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
- _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_wifi_mode'])
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_wifi_mode'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
-_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
- _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_wifi_mode'])
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_wifi_mode'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
-_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
- _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_wifi_mode'])
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_wifi_mode'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
-_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
- _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_ap_config'])
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_ap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
-_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
- _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_ap_config'])
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_ap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
-_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
- _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_ap_config'])
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_ap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
-_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
- _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_ap_config'])
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_ap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
-_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
- _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_softap_config'])
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_softap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
-_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
- _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_softap_config'])
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_softap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
-_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
- _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_softap_config'])
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_softap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
-_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
- _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_softap_config'])
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_softap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
-_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
- _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_disconnect_ap'])
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_disconnect_ap'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
-_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
- _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_disconnect_ap'])
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_disconnect_ap'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
-_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
- _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_scan_ap_list'])
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_scan_ap_list'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
-_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
- _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_scan_ap_list'])
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_scan_ap_list'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
-_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
- _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_connected_stas_list'])
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_connected_stas_list'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
-_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
- _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_connected_stas_list'])
-_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_connected_stas_list'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
-DESCRIPTOR.message_types_by_name['CmdGetStatus'] = _CMDGETSTATUS
-DESCRIPTOR.message_types_by_name['RespGetStatus'] = _RESPGETSTATUS
-DESCRIPTOR.message_types_by_name['CmdConfig'] = _CMDCONFIG
-DESCRIPTOR.message_types_by_name['RespConfig'] = _RESPCONFIG
-DESCRIPTOR.message_types_by_name['ScanResult'] = _SCANRESULT
-DESCRIPTOR.message_types_by_name['CmdScanResult'] = _CMDSCANRESULT
-DESCRIPTOR.message_types_by_name['RespScanResult'] = _RESPSCANRESULT
-DESCRIPTOR.message_types_by_name['ConnectedSTAList'] = _CONNECTEDSTALIST
-DESCRIPTOR.message_types_by_name['CmdConnectedSTA'] = _CMDCONNECTEDSTA
-DESCRIPTOR.message_types_by_name['RespConnectedSTA'] = _RESPCONNECTEDSTA
-DESCRIPTOR.message_types_by_name['EspHostedConfigPayload'] = _ESPHOSTEDCONFIGPAYLOAD
-DESCRIPTOR.enum_types_by_name['EncryptionMode'] = _ENCRYPTIONMODE
-DESCRIPTOR.enum_types_by_name['EspHostedConfigMsgType'] = _ESPHOSTEDCONFIGMSGTYPE
-_sym_db.RegisterFileDescriptor(DESCRIPTOR)
-
-CmdGetStatus = _reflection.GeneratedProtocolMessageType('CmdGetStatus', (_message.Message,), {
- 'DESCRIPTOR' : _CMDGETSTATUS,
- '__module__' : 'esp_hosted_config_pb2'
- # @@protoc_insertion_point(class_scope:CmdGetStatus)
- })
-_sym_db.RegisterMessage(CmdGetStatus)
-
-RespGetStatus = _reflection.GeneratedProtocolMessageType('RespGetStatus', (_message.Message,), {
- 'DESCRIPTOR' : _RESPGETSTATUS,
- '__module__' : 'esp_hosted_config_pb2'
- # @@protoc_insertion_point(class_scope:RespGetStatus)
- })
-_sym_db.RegisterMessage(RespGetStatus)
-
-CmdConfig = _reflection.GeneratedProtocolMessageType('CmdConfig', (_message.Message,), {
- 'DESCRIPTOR' : _CMDCONFIG,
- '__module__' : 'esp_hosted_config_pb2'
- # @@protoc_insertion_point(class_scope:CmdConfig)
- })
-_sym_db.RegisterMessage(CmdConfig)
-
-RespConfig = _reflection.GeneratedProtocolMessageType('RespConfig', (_message.Message,), {
- 'DESCRIPTOR' : _RESPCONFIG,
- '__module__' : 'esp_hosted_config_pb2'
- # @@protoc_insertion_point(class_scope:RespConfig)
- })
-_sym_db.RegisterMessage(RespConfig)
-
-ScanResult = _reflection.GeneratedProtocolMessageType('ScanResult', (_message.Message,), {
- 'DESCRIPTOR' : _SCANRESULT,
- '__module__' : 'esp_hosted_config_pb2'
- # @@protoc_insertion_point(class_scope:ScanResult)
- })
-_sym_db.RegisterMessage(ScanResult)
-
-CmdScanResult = _reflection.GeneratedProtocolMessageType('CmdScanResult', (_message.Message,), {
- 'DESCRIPTOR' : _CMDSCANRESULT,
- '__module__' : 'esp_hosted_config_pb2'
- # @@protoc_insertion_point(class_scope:CmdScanResult)
- })
-_sym_db.RegisterMessage(CmdScanResult)
-
-RespScanResult = _reflection.GeneratedProtocolMessageType('RespScanResult', (_message.Message,), {
- 'DESCRIPTOR' : _RESPSCANRESULT,
- '__module__' : 'esp_hosted_config_pb2'
- # @@protoc_insertion_point(class_scope:RespScanResult)
- })
-_sym_db.RegisterMessage(RespScanResult)
-
-ConnectedSTAList = _reflection.GeneratedProtocolMessageType('ConnectedSTAList', (_message.Message,), {
- 'DESCRIPTOR' : _CONNECTEDSTALIST,
- '__module__' : 'esp_hosted_config_pb2'
- # @@protoc_insertion_point(class_scope:ConnectedSTAList)
- })
-_sym_db.RegisterMessage(ConnectedSTAList)
-
-CmdConnectedSTA = _reflection.GeneratedProtocolMessageType('CmdConnectedSTA', (_message.Message,), {
- 'DESCRIPTOR' : _CMDCONNECTEDSTA,
- '__module__' : 'esp_hosted_config_pb2'
- # @@protoc_insertion_point(class_scope:CmdConnectedSTA)
- })
-_sym_db.RegisterMessage(CmdConnectedSTA)
-
-RespConnectedSTA = _reflection.GeneratedProtocolMessageType('RespConnectedSTA', (_message.Message,), {
- 'DESCRIPTOR' : _RESPCONNECTEDSTA,
- '__module__' : 'esp_hosted_config_pb2'
- # @@protoc_insertion_point(class_scope:RespConnectedSTA)
- })
-_sym_db.RegisterMessage(RespConnectedSTA)
-
-EspHostedConfigPayload = _reflection.GeneratedProtocolMessageType('EspHostedConfigPayload', (_message.Message,), {
- 'DESCRIPTOR' : _ESPHOSTEDCONFIGPAYLOAD,
- '__module__' : 'esp_hosted_config_pb2'
- # @@protoc_insertion_point(class_scope:EspHostedConfigPayload)
- })
-_sym_db.RegisterMessage(EspHostedConfigPayload)
-
-
-# @@protoc_insertion_point(module_scope)
+++ /dev/null
-# Copyright 2015-2020 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 .transport_pserial import * # noqa: F403, F401
+++ /dev/null
-# Copyright 2015-2020 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.
-#
-
-# Base class for protocomm transport
-
-import abc
-
-
-class Transport():
-
- @abc.abstractmethod
- def send_session_data(self, data):
- pass
-
- @abc.abstractmethod
- def send_config_data(self, data):
- pass
+++ /dev/null
-# Copyright 2015-2020 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 struct import *
-from .transport import Transport
-import binascii
-import time
-import utils
-
-failure = "failure"
-
-class Transport_pserial(Transport):
- def __init__(self, devname):
- self.f1 = open(devname, "wb",buffering = 1024)
- self.f2 = open(devname, "rb",buffering = 1024)
-
- def send_data(self, ep_name, data, wait):
- buf = bytearray([0x01])
- buf.extend(pack('<H', len(ep_name)))
- buf.extend(map(ord,ep_name))
- buf.extend(b'\x02')
- buf.extend(pack('<H', len(data)))
- #print(bytearray(data))
- buf.extend(bytearray(data))
- s = self.f1.write(buf)
- self.f1.flush()
- time.sleep(wait)
- try:
- s = self.f2.read()
- except IOError:
- return failure
- self.f2.flush()
- return s
-
+++ /dev/null
-#!/bin/sh
-
-# Copyright 2015-2020 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.
-
-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 [ "$1" = "-h" ]; then
- echo "This script prepares RPI for wlan and bt/ble operation over esp32 device"
- echo "\nUsage: ./rpi_init.sh [arguments]"
- echo "\nArguments are optional and are as below"
- echo " btuart: Set GPIO pins on RPi for HCI UART operations"
- echo "\nExample:"
- echo " - Prepare RPi for WLAN and bt/ble operation on SDIO"
- echo " # ./rpi_init.sh"
- echo "\n - Prepare RPi for bt/ble operation over UART and WLAN over SDIO"
- echo " # ./rpi_init.sh btuart"
- exit 0
-fi
-
-sudo modprobe bluetooth
-wlan_init
-
-if [ "$1" = "btuart" ]; then
- bt_init
-fi
-
+++ /dev/null
-# Copyright 2015-2020 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 commands
-import argparse
-import time
-import os
-
-# WiFi Mode
-# NULL 0
-# Station 1
-# SoftAP 2
-# Station+SoftAP 3
-
-none = 0
-station = 1
-softap = 2
-station_softap = 3
-success = 'success'
-failure = 'failure'
-flag = success
-softap_config = 'Not set'
-
-parser = argparse.ArgumentParser(description='softap_config.py script to configure ESP32 softAP mode. ex. python softap_config.py \'xyz\' \'xyz123456\' 1 3 --max_conn=4 --ssid_hidden=0 --bw=1')
-
-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()
-
-ap_mac = commands.get_mac(softap)
-if (ap_mac == failure):
- print("Failed to get is SoftAP mac address")
- flag = failure
-else :
- print("SoftAP MAC Address "+str(ap_mac))
-
-if (flag == success):
- softap_config = commands.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 == failure):
- print("setting softap config failed")
- flag = failure
- else:
- print("setting softap config success")
-
-if (flag == failure):
- print("failure in setting SoftAP 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 = 'sudo ifconfig ethap0 up'
- os.system(command)
- print(command)
-
- time.sleep(1)
-
- print("softAP config successfully set")
+++ /dev/null
-# Copyright 2015-2020 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 commands
-import argparse
-import os
-
-# WiFi Mode
-# NULL 0
-# Station 1
-# SoftAP 2
-# Station + SoftAP 3
-
-none = 0
-station = 1
-softap = 2
-station_softap = 3
-failure = "failure"
-success = "success"
-stop = "Not set"
-flag = success
-
-parser = argparse.ArgumentParser(description='softap_stop.py script will stop ESP32 softap ex. python softap_close.py')
-
-wifi_mode = commands.get_wifi_mode()
-print("WiFi Mode: "+str(wifi_mode))
-
-if (wifi_mode == failure):
- print("Failed to get wifi mode")
- flag = failure
-elif (wifi_mode == softap):
- wifi_mode = commands.set_wifi_mode(none)
- if (wifi_mode == failure):
- print("Failed to stop softap")
- flag = failure
- else :
- print("SoftAP stopped")
-elif (wifi_mode == station_softap):
- wifi_mode = commands.set_wifi_mode(station)
- if (wifi_mode == failure):
- print("failure in stopping softap")
- flag = failure
- else :
- print("SoftAP stopped")
-
-if (flag == success):
- command = 'sudo ifconfig ethap0 down'
- os.system(command)
- print(command)
- print("SoftAP interface down")
+++ /dev/null
-# Copyright 2015-2020 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 commands
-import argparse
-import time
-import os
-
-# WiFi Mode
-# NULL 0
-# Station 1
-# SoftAP 2
-# Station + SoftAP 3
-
-none = 0
-station = 1
-softap = 2
-station_softap = 3
-failure = "failure"
-success = "success"
-flag = success
-station_status = 'Nothing set'
-
-parser = argparse.ArgumentParser(description='station_connect.py is a python script which connect ESPstation to AP. ex. python 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()
-
-sta_mac = commands.get_mac(station)
-if (sta_mac == failure):
- flag = failure
- print("Failed to get station MAC address")
-else :
- print("station MAC address "+str(sta_mac))
-
-if (flag == success):
- station_status = commands.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 "+args.ssid)
-
-if (flag == failure):
- print("Failed to connect with 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 = 'sudo ifconfig ethsta0 up'
- os.system(command)
- print(command)
-
- time.sleep(1)
-
- command = 'sudo dhclient ethsta0 -r'
- os.system(command)
- print(command)
-
- command = 'sudo dhclient ethsta0 -v'
- os.system(command)
- print(command)
-
- print("Success in setting AP config")
-
+++ /dev/null
-# Copyright 2015-2020 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 commands
-import argparse
-import os
-
-# WiFi Mode
-# NULL 0
-# Station 1
-# SoftAP 2
-# Station + SoftAP 3
-
-none = 0
-station = 1
-softap = 2
-station_softap = 3
-failure = "failure"
-success = "success"
-flag = success
-disconnect = "Not set"
-
-parser = argparse.ArgumentParser(description='station_disconnect.py script will disconnect ESPStation from AP ex. python station_disconnect.py')
-
-wifi_mode = commands.get_wifi_mode()
-print("WiFi Mode: "+str(wifi_mode))
-
-if (wifi_mode == failure):
- print("Failed to get WiFi Mode")
- flag = failure
-elif (wifi_mode == station or wifi_mode == station_softap):
- disconnect = commands.wifi_disconnect_ap()
- if (disconnect == failure):
- print("Failed to Disconnected from AP")
- flag = failure
- else :
- print("Success in Disconnecting from AP")
-else :
- print("Station is not enabled")
- flag = failure
-
-if (flag == success):
- command = 'sudo dhclient ethsta0 -r'
- print('$ '+command)
- os.system(command)
-
- command = 'sudo ifconfig ethsta0 down'
- print('$ '+command)
- os.system(command)
-
+++ /dev/null
-# Copyright 2015-2020 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 commands
-failure = 'failure'
-# get mac address
-
-# 1 : station
-# 2 : softAP
-'''
-x = commands.get_mac(2)
-print("sta mac "+str(x))
-
-# 0: null Mode, Wi-Fi mode not set
-# 1: station mode
-# 2: softAP mode
-# 3: softAP+station mode
-# or Failure
-
-x = commands.get_wifi_mode()
-print("wifi mode is "+str(x))
-
-x = commands.set_wifi_mode(2)
-print("connected mode is "+str(x))
-
-x = commands.wifi_set_ap_config('xyz','xyz123456','0')
-print(x)
-
-x = commands.wifi_get_ap_config()
-print(x)
-
-x = commands.wifi_disconnect_ap()
-print(x)
-
-x = commands.wifi_set_softap_config('ESP12','0',4,0,5,0,1)
-print(x)
-
-x = commands.wifi_get_softap_config()
-print(x)
-
-# output is list of Aplist class instances
-x = commands.wifi_ap_scan_list()
-print(x)
-if (x == failure):
- print(failure)
-else:
- for obj in x:
- print(obj.ssid,obj.chnl,obj.rssi,obj.bssid,obj.ecn)
-
-
-# output is list of Stationlist class instances
-x = commands.wifi_connected_stations_list()
-print(x)
-if (x == failure):
- print(failure)
-else :
- for obj in x:
- print(obj.mac)
-'''
+++ /dev/null
-GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Lesser General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- {description}
- Copyright (C) {year} {fullname}
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- {signature of Ty Coon}, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.
-
+++ /dev/null
-CONFIG_SUPPORT_ESP_SERIAL = y
-CONFIG_ENABLE_MONITOR_PROCESS = n
-
-ifeq ($(CONFIG_SUPPORT_ESP_SERIAL), y)
- EXTRA_CFLAGS += -DCONFIG_SUPPORT_ESP_SERIAL
-endif
-
-ifeq ($(CONFIG_ENABLE_MONITOR_PROCESS), y)
- EXTRA_CFLAGS += -DCONFIG_ENABLE_MONITOR_PROCESS
-endif
-
-EXTRA_CFLAGS += -I$(PWD)/../../../common/include
-
-CR_C := arm-linux-gnueabihf-
-PWD := $(shell pwd)
-obj-m := esp32.o
-
-esp32-y := esp_sdio.o esp_sdio_api.o esp_bt.o main.o
-ifeq ($(CONFIG_SUPPORT_ESP_SERIAL), y)
-esp32-y += esp_serial.o esp_rb.o
-endif
-
-all:
- make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
-
-clean:
- make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
-
+++ /dev/null
-/*
- * Espressif Systems Wireless LAN device driver
- *
- * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
- *
- * This software file (the "File") is distributed by Espressif Systems (Shanghai)
- * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
- * (the "License"). You may use, redistribute and/or modify this File in
- * accordance with the terms and conditions of the License, a copy of which
- * is available by writing to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
- * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
- *
- * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
- * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
- * this warranty disclaimer.
- */
-
-#ifndef __esp__h_
-#define __esp__h_
-
-#include <linux/workqueue.h>
-#include <linux/interrupt.h>
-#include <linux/netdevice.h>
-#include <net/bluetooth/bluetooth.h>
-#include <net/bluetooth/hci_core.h>
-#include "adapter.h"
-
-#define ESP_IF_TYPE_SDIO 1
-
-/* Network link status */
-#define ESP_LINK_DOWN 0
-#define ESP_LINK_UP 1
-
-#define ESP_MAX_INTERFACE 2
-
-#define ESP_PAYLOAD_HEADER 8
-struct esp_private;
-struct esp_adapter;
-
-#define ACQUIRE_LOCK 1
-#define LOCK_ALREADY_ACQUIRED 0
-
-struct esp_adapter {
- u8 if_type;
- u32 capabilities;
-
- /* Possible types:
- * struct esp_sdio_context */
- void *if_context;
-
- struct esp_if_ops *if_ops;
-
- /* Private for each interface */
- struct esp_private *priv[ESP_MAX_INTERFACE];
- struct hci_dev *hcidev;
-
- struct workqueue_struct *if_rx_workqueue;
- struct work_struct if_rx_work;
-
- /* Process TX work */
- struct workqueue_struct *tx_workqueue;
- struct work_struct tx_work;
-
- /* TX queue */
- struct sk_buff_head tx_q;
-
- /* RX Queue */
- struct sk_buff_head rx_q;
-
- /* Counters */
- atomic_t tx_pending;
- atomic_t rx_pending;
-};
-
-
-struct esp_private {
- struct esp_adapter *adapter;
- struct net_device *ndev;
- struct net_device_stats stats;
- u8 link_state;
- u8 mac_address[6];
- u8 if_type;
- u8 if_num;
-};
-
-struct esp_skb_cb {
- struct esp_private *priv;
-};
-#endif
+++ /dev/null
-/*
- * Espressif Systems Wireless LAN device driver
- *
- * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
- *
- * This software file (the "File") is distributed by Espressif Systems (Shanghai)
- * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
- * (the "License"). You may use, redistribute and/or modify this File in
- * accordance with the terms and conditions of the License, a copy of which
- * is available by writing to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
- * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
- *
- * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
- * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
- * this warranty disclaimer.
- */
-
-#ifndef _esp_api__h_
-#define _esp_api__h_
-
-#include "esp.h"
-
-int esp_add_card(struct esp_adapter *adapter);
-int esp_remove_card(struct esp_adapter *adapter);
-void esp_process_new_packet_intr(struct esp_adapter *adapter);
-struct esp_adapter * esp_get_adapter(void);
-struct sk_buff * esp_alloc_skb(u32 len);
-int esp_send_packet(struct esp_adapter *adapter, u8 *buf, u32 size);
-u8 esp_is_bt_supported_over_sdio(u32 cap);
-
-#endif
+++ /dev/null
-/*
- * Espressif Systems Wireless LAN device driver
- *
- * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
- *
- * This software file (the "File") is distributed by Espressif Systems (Shanghai)
- * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
- * (the "License"). You may use, redistribute and/or modify this File in
- * accordance with the terms and conditions of the License, a copy of which
- * is available by writing to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
- * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
- *
- * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
- * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
- * this warranty disclaimer.
- */
-#include "esp_bt_api.h"
-#include "esp_api.h"
-
-void esp_hci_update_tx_counter(struct hci_dev *hdev, u8 pkt_type, size_t len)
-{
- if (hdev) {
- if (pkt_type == HCI_COMMAND_PKT) {
- hdev->stat.cmd_tx++;
- } else if (pkt_type == HCI_ACLDATA_PKT) {
- hdev->stat.acl_tx++;
- } else if (pkt_type == HCI_SCODATA_PKT) {
- hdev->stat.sco_tx++;
- }
-
- hdev->stat.byte_tx += len;
- }
-}
-
-void esp_hci_update_rx_counter(struct hci_dev *hdev, u8 pkt_type, size_t len)
-{
- if (hdev) {
- if (pkt_type == HCI_EVENT_PKT) {
- hdev->stat.evt_rx++;
- } else if (pkt_type == HCI_ACLDATA_PKT) {
- hdev->stat.acl_rx++;
- } else if (pkt_type == HCI_SCODATA_PKT) {
- hdev->stat.sco_rx++;
- }
-
- hdev->stat.byte_rx += len;
- }
-}
-
-static int esp_bt_open(struct hci_dev *hdev)
-{
- return 0;
-}
-
-static int esp_bt_close(struct hci_dev *hdev)
-{
- return 0;
-}
-
-static int esp_bt_flush(struct hci_dev *hdev)
-{
- return 0;
-}
-
-static int esp_bt_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
-{
- struct esp_payload_header *hdr;
- size_t total_len, len = skb->len;
- int ret = 0;
- struct esp_adapter *adapter = hci_get_drvdata(hdev);
- struct sk_buff *new_skb;
-
- if (!adapter) {
- printk(KERN_ERR "%s: invalid args", __func__);
- return -EINVAL;
- }
-
- total_len = len + sizeof(struct esp_payload_header);
-
- if (skb_headroom(skb) < sizeof(struct esp_payload_header)) {
- /* insufficent headroom to add payload header */
- new_skb = skb_realloc_headroom(skb, sizeof(struct esp_payload_header));
-
- if(!new_skb) {
- printk(KERN_ERR "%s: Failed to allocate SKB", __func__);
- dev_kfree_skb(skb);
- hdev->stat.err_tx++;
- return -ENOMEM;
- }
-
- dev_kfree_skb(skb);
-
- skb = new_skb;
- }
-
- skb_push(skb, sizeof(struct esp_payload_header));
-
- hdr = (struct esp_payload_header *) skb->data;
-
- memset (hdr, 0, sizeof(struct esp_payload_header));
-
- hdr->if_type = ESP_HCI_IF;
- hdr->if_num = 0;
- hdr->len = cpu_to_le16(len);
- hdr->offset = cpu_to_le16(sizeof(struct esp_payload_header));
- hdr->hci_pkt_type = hci_skb_pkt_type(skb);
-
-/* print_hex_dump_bytes("Tx:", DUMP_PREFIX_NONE, skb->data, skb->len);*/
- ret = esp_send_packet(adapter, skb->data, skb->len);
-
- if (ret) {
- hdev->stat.err_tx++;
- } else {
- esp_hci_update_tx_counter(hdev, hdr->hci_pkt_type, skb->len);
- }
-
- dev_kfree_skb(skb);
-
- return 0;
-}
-
-static int esp_bt_setup(struct hci_dev *hdev)
-{
- return 0;
-}
-
-static int esp_bt_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
-{
- return 0;
-}
-
-int esp_deinit_bt(struct esp_adapter *adapter)
-{
- struct hci_dev *hdev = NULL;
-
- hdev = adapter->hcidev;
-
- hci_unregister_dev(hdev);
- hci_free_dev(hdev);
-
- adapter->hcidev = NULL;
-
- return 0;
-}
-
-int esp_init_bt(struct esp_adapter *adapter)
-{
- int ret = 0;
- struct hci_dev *hdev = NULL;
-
- if (!adapter) {
- return -EINVAL;
- }
-
- if (adapter->hcidev) {
- return -EEXIST;
- }
-
- hdev = hci_alloc_dev();
-
- if (!hdev) {
- BT_ERR("Can not allocate HCI device");
- return -ENOMEM;
- }
-
- adapter->hcidev = hdev;
- hci_set_drvdata(hdev, adapter);
-
- hdev->bus = HCI_SDIO;
- hdev->open = esp_bt_open;
- hdev->close = esp_bt_close;
- hdev->flush = esp_bt_flush;
- hdev->send = esp_bt_send_frame;
- hdev->setup = esp_bt_setup;
- hdev->set_bdaddr = esp_bt_set_bdaddr;
-
- hdev->dev_type = HCI_PRIMARY;
-
- ret = hci_register_dev(hdev);
- if (ret < 0) {
- BT_ERR("Can not register HCI device");
- hci_free_dev(hdev);
- return -ENOMEM;
- }
-
- return 0;
-}
+++ /dev/null
-/*
- * Espressif Systems Wireless LAN device driver
- *
- * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
- *
- * This software file (the "File") is distributed by Espressif Systems (Shanghai)
- * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
- * (the "License"). You may use, redistribute and/or modify this File in
- * accordance with the terms and conditions of the License, a copy of which
- * is available by writing to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
- * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
- *
- * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
- * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
- * this warranty disclaimer.
- */
-
-#ifndef __esp_bt_api_h_
-#define __esp_bt_api_h_
-
-#include "esp.h"
-
-int esp_init_bt(struct esp_adapter *adapter);
-int esp_deinit_bt(struct esp_adapter *adapter);
-void esp_hci_update_tx_counter(struct hci_dev *hdev, u8 pkt_type, size_t len);
-void esp_hci_update_rx_counter(struct hci_dev *hdev, u8 pkt_type, size_t len);
-
-#endif
+++ /dev/null
-/*
- * Espressif Systems Wireless LAN device driver
- *
- * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
- *
- * This software file (the "File") is distributed by Espressif Systems (Shanghai)
- * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
- * (the "License"). You may use, redistribute and/or modify this File in
- * accordance with the terms and conditions of the License, a copy of which
- * is available by writing to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
- * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
- *
- * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
- * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
- * this warranty disclaimer.
- */
-
-#ifndef __ESP_IF__H_
-#define __ESP_IF__H_
-
-#include "esp.h"
-
-struct esp_if_ops {
- int (*init)(struct esp_adapter *adapter);
- struct sk_buff* (*read)(struct esp_adapter *adapter);
- int (*write)(struct esp_adapter *adapter, u8 *buf, u32 size);
- int (*deinit)(struct esp_adapter *adapter);
-};
-
-int esp_init_interface_layer(struct esp_adapter *adapter);
-void esp_deinit_interface_layer(void);
-
-#endif
+++ /dev/null
-/*
- * The citation should list that the code comes from the book "Linux Device
- * Drivers" by Alessandro Rubini and Jonathan Corbet, published
- * by O'Reilly & Associates.No warranty is attached;
- *
- * */
-
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/semaphore.h>
-#include <linux/uaccess.h>
-
-#include "esp_rb.h"
-
-int esp_rb_init(esp_rb_t *rb, size_t sz)
-{
- init_waitqueue_head(&(rb->wq));
-
- rb->buf = kmalloc(sz, GFP_KERNEL);
- if (!rb->buf) {
- printk(KERN_ERR "Failed to allocate memory for rb\n");
- return -ENOMEM;
- }
-
- rb->end = rb->buf + sz;
- rb->rp = rb->wp = rb->buf;
- rb->size = sz;
-
- sema_init(&(rb->sem), 1);
- return 0;
-}
-
-ssize_t esp_rb_read_by_user(esp_rb_t *rb, const char __user *buf, size_t sz, int block)
-{
- if (down_interruptible(&rb->sem)) {
- return -ERESTARTSYS; /* Signal interruption */
- }
-
- while(rb->rp == rb->wp) {
- up(&rb->sem);
- if (block == 0) {
- return -EAGAIN;
- }
- if (wait_event_interruptible(rb->wq, (rb->rp != rb->wp))) {
- return -ERESTARTSYS; /* Signal interruption */
- }
- if (down_interruptible(&rb->sem)) {
- return -ERESTARTSYS;
- }
- }
-
- if (rb->wp > rb->rp) {
- sz = min(sz, (size_t)(rb->wp - rb->rp));
- } else {
- sz = min(sz, (size_t)(rb->end - rb->rp));
- }
- if (copy_to_user((void *)buf, rb->rp, sz)) {
- up(&rb->sem);
- return -EFAULT;
- }
- rb->rp += sz;
- if (rb->rp == rb->end) {
- rb->rp = rb->buf;
- }
- up(&rb->sem);
-
- return sz;
-}
-
-static size_t get_free_space(esp_rb_t *rb)
-{
- if (rb->rp == rb->wp) {
- return rb->size - 1;
- } else {
- return ((rb->rp + rb->size - rb->wp) % rb->size) - 1;
- }
-}
-
-ssize_t esp_rb_write_by_kernel(esp_rb_t *rb, const char *buf, size_t sz)
-{
- if (down_interruptible(&rb->sem)) {
- return -ERESTARTSYS;
- }
-
- if (get_free_space(rb) == 0) {
- up(&rb->sem);
- printk(KERN_ERR "Ringbuffer full, no space to write\n");
- return 0;
- }
-
- sz = min(sz, get_free_space(rb));
- if (rb->wp >= rb->rp) {
- sz = min(sz, (size_t)(rb->end - rb->wp));
- } else {
- sz = min(sz, (size_t)(rb->rp - rb->wp - 1));
- }
-
- memcpy(rb->wp, buf, sz);
- rb->wp += sz;
- if (rb->wp == rb->end) {
- rb->wp = rb->buf;
- }
- up(&rb->sem);
-
- wake_up_interruptible(&rb->wq);
-
- return sz;
-}
-
-void esp_rb_cleanup(esp_rb_t *rb)
-{
- kfree(rb->buf);
- rb->buf = rb->end = rb->rp = rb->wp = NULL;
- rb->size = 0;
- return;
-}
+++ /dev/null
-/*
- * The citation should list that the code comes from the book "Linux Device
- * Drivers" by Alessandro Rubini and Jonathan Corbet, published
- * by O'Reilly & Associates.No warranty is attached;
- *
- * */
-
-#ifndef _ESP_RB_H_
-#define _ESP_RB_H_
-
-typedef struct esp_rb {
- wait_queue_head_t wq; /* waitqueue to wait for data */
- unsigned char *buf, *end; /* actual queue start and end */
- size_t size;
- unsigned char *rp, *wp; /* current read/write pointers */
- struct semaphore sem; /* Mutex to protect rb */
-} esp_rb_t;
-
-int esp_rb_init(esp_rb_t *rb, size_t sz);
-void esp_rb_cleanup(esp_rb_t *rb);
-ssize_t esp_rb_read_by_user(esp_rb_t *rb, const char __user *buf, size_t sz, int block);
-ssize_t esp_rb_write_by_kernel(esp_rb_t *rb, const char *buf, size_t sz);
-
-#endif
+++ /dev/null
-/*
- * Espressif Systems Wireless LAN device driver
- *
- * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
- *
- * This software file (the "File") is distributed by Espressif Systems (Shanghai)
- * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
- * (the "License"). You may use, redistribute and/or modify this File in
- * accordance with the terms and conditions of the License, a copy of which
- * is available by writing to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
- * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
- *
- * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
- * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
- * this warranty disclaimer.
- */
-
-#include <linux/mutex.h>
-#include <linux/mmc/sdio.h>
-#include <linux/mmc/sdio_func.h>
-#include <linux/mmc/sdio_ids.h>
-#include <linux/mmc/card.h>
-#include <linux/mmc/host.h>
-#include "esp_if.h"
-#include "esp_sdio_api.h"
-#include "esp_api.h"
-#include "esp_bt_api.h"
-#ifdef CONFIG_SUPPORT_ESP_SERIAL
-#include "esp_serial.h"
-#endif
-#include <linux/kthread.h>
-
-#define CHECK_SDIO_RW_ERROR(ret) do { \
- if (ret) \
- printk(KERN_ERR "%s: CMD53 read/write error at %d\n", __func__, __LINE__); \
-} while (0);
-
-struct esp_sdio_context sdio_context;
-
-#ifdef CONFIG_ENABLE_MONITOR_PROCESS
-struct task_struct *monitor_thread;
-#endif
-
-static int init_context(struct esp_sdio_context *context);
-static struct sk_buff * read_packet(struct esp_adapter *adapter);
-static int write_packet(struct esp_adapter *adapter, u8 *buf, u32 size);
-/*int deinit_context(struct esp_adapter *adapter);*/
-
-static const struct sdio_device_id esp_devices[] = {
- { SDIO_DEVICE(ESP_VENDOR_ID, ESP_DEVICE_ID_1) },
- { SDIO_DEVICE(ESP_VENDOR_ID, ESP_DEVICE_ID_2) },
- {}
-};
-
-static void print_capabilities(u32 cap)
-{
- printk(KERN_INFO "Features supported are:\n");
- if (cap & ESP_WLAN_SUPPORT)
- printk(KERN_INFO "\t * WLAN\n");
- if ((cap & ESP_BT_UART_SUPPORT) || (cap & ESP_BT_SDIO_SUPPORT)) {
- printk(KERN_INFO "\t * BT/BLE\n");
- if (cap & ESP_BT_UART_SUPPORT)
- printk(KERN_INFO "\t - HCI over UART\n");
- if (cap & ESP_BT_SDIO_SUPPORT)
- printk(KERN_INFO "\t - HCI over SDIO\n");
-
- if ((cap & ESP_BLE_ONLY_SUPPORT) && (cap & ESP_BR_EDR_ONLY_SUPPORT))
- printk(KERN_INFO "\t - BT/BLE dual mode\n");
- else if (cap & ESP_BLE_ONLY_SUPPORT)
- printk(KERN_INFO "\t - BLE only\n");
- else if (cap & ESP_BR_EDR_ONLY_SUPPORT)
- printk(KERN_INFO "\t - BR EDR only\n");
- }
-}
-
-static void esp_process_interrupt(struct esp_sdio_context *context, u32 int_status)
-{
- if (!context) {
- return;
- }
-
- if (int_status & ESP_SLAVE_RX_NEW_PACKET_INT) {
- esp_process_new_packet_intr(context->adapter);
- }
-}
-
-static void esp_handle_isr(struct sdio_func *func)
-{
- struct esp_sdio_context *context = NULL;
- u32 int_status = 0;
- int ret;
-
- if (!func) {
- return;
- }
-
- context = sdio_get_drvdata(func);
-
- if (!context) {
- return;
- }
-
- /* Read interrupt status register */
- ret = esp_read_reg(context, ESP_SLAVE_INT_ST_REG,
- (u8 *) &int_status, sizeof(int_status), ACQUIRE_LOCK);
- CHECK_SDIO_RW_ERROR(ret);
-
- esp_process_interrupt(context, int_status);
-
- /* Clear interrupt status */
- ret = esp_write_reg(context, ESP_SLAVE_INT_CLR_REG,
- (u8 *) &int_status, sizeof(int_status), ACQUIRE_LOCK);
- CHECK_SDIO_RW_ERROR(ret);
-}
-
-int generate_slave_intr(struct esp_sdio_context *context, u8 data)
-{
- if (!context)
- return -EINVAL;
-
- return esp_write_reg(context, ESP_SLAVE_SCRATCH_REG_7, &data,
- sizeof(data), ACQUIRE_LOCK);
-}
-
-static void deinit_sdio_func(struct sdio_func *func)
-{
- sdio_claim_host(func);
- /* Release IRQ */
- sdio_release_irq(func);
- /* Disable sdio function */
- sdio_disable_func(func);
- sdio_release_host(func);
- sdio_set_drvdata(func, NULL);
-}
-
-static int esp_slave_get_tx_buffer_num(struct esp_sdio_context *context, u32 *tx_num, u8 is_lock_needed)
-{
- u32 len;
- int ret = 0;
-
- ret = esp_read_reg(context, ESP_SLAVE_TOKEN_RDATA, (uint8_t*)&len, 4, is_lock_needed);
-
- if (ret)
- return ret;
-
- len = (len >> 16) & ESP_TX_BUFFER_MASK;
- len = (len + ESP_TX_BUFFER_MAX - context->tx_buffer_count) % ESP_TX_BUFFER_MAX;
-
- *tx_num = len;
-
- return ret;
-}
-
-static int esp_get_len_from_slave(struct esp_sdio_context *context, u32 *rx_size, u8 is_lock_needed)
-{
- u32 len, temp;
- int ret = 0;
-
- ret = esp_read_reg(context, ESP_SLAVE_PACKET_LEN_REG,
- (u8 *) &len, sizeof(len), is_lock_needed);
-
- if (ret)
- return ret;
-
- len &= ESP_SLAVE_LEN_MASK;
-
- if (len >= context->rx_byte_count)
- len = (len + ESP_RX_BYTE_MAX - context->rx_byte_count) % ESP_RX_BYTE_MAX;
- else {
- /* Handle a case of roll over */
- temp = ESP_RX_BYTE_MAX - context->rx_byte_count;
- len = temp + len;
-
- if (len > ESP_RX_BUFFER_SIZE) {
- printk(KERN_INFO "%s: Len from slave[%d] exceeds max [%d]\n",
- __func__, len, ESP_RX_BUFFER_SIZE);
- }
- }
- *rx_size = len;
-
- return 0;
-}
-
-
-static void flush_sdio(struct esp_sdio_context *context)
-{
- struct sk_buff *skb;
-
- if (!context || !context->adapter)
- return;
-
- while (1) {
- skb = read_packet(context->adapter);
-
- if (!skb) {
- break;
- }
-
- if (skb->len)
- printk (KERN_INFO "%s: Flushed %d bytes\n", __func__, skb->len);
- dev_kfree_skb(skb);
- }
-}
-
-static void esp_remove(struct sdio_func *func)
-{
- struct esp_sdio_context *context;
- context = sdio_get_drvdata(func);
-
- printk(KERN_INFO "%s -> Remove card", __func__);
-
-#ifdef CONFIG_SUPPORT_ESP_SERIAL
- esp_serial_cleanup();
-#endif
-
-#ifdef CONFIG_ENABLE_MONITOR_PROCESS
- if (monitor_thread)
- kthread_stop(monitor_thread);
-#endif
-
- if (context) {
- generate_slave_intr(context, BIT(ESP_CLOSE_DATA_PATH));
- msleep(100);
-
- flush_sdio(context);
-
- if (context->adapter) {
- esp_remove_card(context->adapter);
-
- if (context->adapter->hcidev) {
- esp_deinit_bt(context->adapter);
- }
-
- }
-
- memset(context, 0, sizeof(struct esp_sdio_context));
- }
-
- deinit_sdio_func(func);
-
- printk (KERN_INFO "%s: Context deinit %d - %d\n", __func__, context->rx_byte_count,
- context->tx_buffer_count);
-
-}
-
-static struct esp_if_ops if_ops = {
- .read = read_packet,
- .write = write_packet,
-};
-
-static int init_context(struct esp_sdio_context *context)
-{
- int ret = 0;
- u32 val = 0;
-
- if (!context) {
- return -EINVAL;
- }
-
- /* Initialize rx_byte_count */
- ret = esp_read_reg(context, ESP_SLAVE_PACKET_LEN_REG,
- (u8 *) &val, sizeof(val), ACQUIRE_LOCK);
- if (ret)
- return ret;
-
-/* printk(KERN_DEBUG "%s: LEN %d\n", __func__, (val & ESP_SLAVE_LEN_MASK));*/
-
- context->rx_byte_count = val & ESP_SLAVE_LEN_MASK;
-
- /* Initialize tx_buffer_count */
- ret = esp_read_reg(context, ESP_SLAVE_TOKEN_RDATA, (u8 *) &val,
- sizeof(val), ACQUIRE_LOCK);
-
- if (ret)
- return ret;
-
- val = ((val >> 16) & ESP_TX_BUFFER_MASK);
-
-/* printk(KERN_DEBUG "%s: BUF_CNT %d\n", __func__, val);*/
-
- if (val >= ESP_MAX_BUF_CNT)
- context->tx_buffer_count = val - ESP_MAX_BUF_CNT;
- else
- context->tx_buffer_count = 0;
-
-/* printk(KERN_DEBUG "%s: Context init %d - %d\n", __func__, context->rx_byte_count,*/
-/* context->tx_buffer_count);*/
-
- context->adapter = esp_get_adapter();
-
- if (!context->adapter)
- printk (KERN_ERR "%s: Failed to get adapter\n", __func__);
-
- return ret;
-}
-
-static struct sk_buff * read_packet(struct esp_adapter *adapter)
-{
- u32 len_from_slave, data_left, len_to_read, size, num_blocks;
- int ret = 0;
- struct sk_buff *skb;
- u8 *pos;
- struct esp_sdio_context *context;
-
- if (!adapter || !adapter->if_context) {
- printk (KERN_ERR "%s: INVALID args\n", __func__);
- return NULL;
- }
-
- context = adapter->if_context;
-
- sdio_claim_host(context->func);
-
- data_left = len_to_read = len_from_slave = num_blocks = 0;
-
- /* Read length */
- ret = esp_get_len_from_slave(context, &len_from_slave, LOCK_ALREADY_ACQUIRED);
-
-/* printk (KERN_DEBUG "LEN FROM SLAVE: %d\n", len_from_slave);*/
-
- if (ret || !len_from_slave) {
- sdio_release_host(context->func);
- return NULL;
- }
-
- size = ESP_BLOCK_SIZE * 4;
-
- if (len_from_slave > size) {
- printk(KERN_INFO "Rx large packet: %d\n", len_from_slave);
- }
-
- skb = esp_alloc_skb(len_from_slave);
-
- if (!skb) {
- printk (KERN_ERR "%s: SKB alloc failed\n", __func__);
- sdio_release_host(context->func);
- return NULL;
- }
-
- skb_put(skb, len_from_slave);
- pos = skb->data;
-
- data_left = len_from_slave;
-
- do {
- num_blocks = data_left/ESP_BLOCK_SIZE;
-
-#if 0
- if (!context->rx_byte_count) {
- start_time = ktime_get_ns();
- }
-#endif
-
- if (num_blocks) {
- len_to_read = num_blocks * ESP_BLOCK_SIZE;
- ret = esp_read_block(context,
- ESP_SLAVE_CMD53_END_ADDR - len_to_read,
- pos, len_to_read, LOCK_ALREADY_ACQUIRED);
- } else {
- len_to_read = data_left;
- /* 4 byte aligned length */
- ret = esp_read_block(context,
- ESP_SLAVE_CMD53_END_ADDR - len_to_read,
- pos, (len_to_read + 3) & (~3), LOCK_ALREADY_ACQUIRED);
- }
-
- if (ret) {
- printk (KERN_ERR "%s: Failed to read data\n", __func__);
- dev_kfree_skb(skb);
- sdio_release_host(context->func);
- return NULL;
- }
-
- data_left -= len_to_read;
- pos += len_to_read;
- context->rx_byte_count += len_to_read;
- context->rx_byte_count = context->rx_byte_count % ESP_RX_BYTE_MAX;
-
- } while (data_left > 0);
-
- sdio_release_host(context->func);
-
- return skb;
-}
-
-static int write_packet(struct esp_adapter *adapter, u8 *buf, u32 size)
-{
- u32 block_cnt = 0, buf_needed = 0;
- u32 buf_available = 0;
- int ret = 0;
- u8 *pos = NULL;
- u32 data_left, len_to_send, pad;
- struct esp_sdio_context *context;
-
- if (!adapter || !adapter->if_context || !buf || !size) {
- printk (KERN_ERR "%s: Invalid args\n", __func__);
- return -EINVAL;
- }
-
- context = adapter->if_context;
-
- sdio_claim_host(context->func);
-
- buf_needed = (size + ESP_RX_BUFFER_SIZE - 1) / ESP_RX_BUFFER_SIZE;
-
- ret = esp_slave_get_tx_buffer_num(context, &buf_available, LOCK_ALREADY_ACQUIRED);
-
-/* printk(KERN_ERR "%s: TX -> Available [%d], needed [%d]\n", __func__, buf_available, buf_needed);*/
-
- if (buf_available < buf_needed) {
- printk(KERN_DEBUG "%s: Not enough buffers available: availabale [%d], needed [%d]\n", __func__,
- buf_available, buf_needed);
- sdio_release_host(context->func);
- return -ENOMEM;
- }
-
- pos = buf;
- data_left = len_to_send = 0;
-
- data_left = size;
- pad = ESP_BLOCK_SIZE - (data_left % ESP_BLOCK_SIZE);
- data_left += pad;
-
-
- do {
- block_cnt = data_left / ESP_BLOCK_SIZE;
- len_to_send = data_left;
- ret = esp_write_block(context, ESP_SLAVE_CMD53_END_ADDR - len_to_send,
- pos, (len_to_send + 3) & (~3), LOCK_ALREADY_ACQUIRED);
-
- if (ret) {
- printk (KERN_ERR "%s: Failed to send data\n", __func__);
- sdio_release_host(context->func);
- return ret;
- }
-/* printk (KERN_ERR "--> %d %d %d\n", block_cnt, data_left, len_to_send);*/
-
- data_left -= len_to_send;
- pos += len_to_send;
- } while (data_left);
-
- context->tx_buffer_count += buf_needed;
- context->tx_buffer_count = context->tx_buffer_count % ESP_TX_BUFFER_MAX;
-
- sdio_release_host(context->func);
-
- return 0;
-}
-
-static struct esp_sdio_context * init_sdio_func(struct sdio_func *func)
-{
- struct esp_sdio_context *context = NULL;
- int ret = 0;
-
- if (!func)
- return NULL;
-
- context = &sdio_context;
-
- context->func = func;
-
- sdio_claim_host(func);
-
- /* Enable Function */
- ret = sdio_enable_func(func);
- if (ret) {
- return NULL;
- }
-
- /* Register IRQ */
- ret = sdio_claim_irq(func, esp_handle_isr);
- if (ret) {
- sdio_disable_func(func);
- return NULL;
- }
-
- /* Set private data */
- sdio_set_drvdata(func, context);
-
- context->state = ESP_CONTEXT_INIT;
-
- sdio_release_host(func);
-
- return context;
-}
-
-#ifdef CONFIG_ENABLE_MONITOR_PROCESS
-static int monitor_process(void *data)
-{
- u32 val, intr, len_reg, rdata, old_len = 0;
- struct esp_sdio_context *context = (struct esp_sdio_context *) data;
- struct sk_buff *skb;
-
- while (!kthread_should_stop()) {
- msleep(5000);
-
- val = intr = len_reg = rdata = 0;
-
- esp_read_reg(context, ESP_SLAVE_PACKET_LEN_REG,
- (u8 *) &val, sizeof(val), ACQUIRE_LOCK);
-
- len_reg = val & ESP_SLAVE_LEN_MASK;
-
- val = 0;
- esp_read_reg(context, ESP_SLAVE_TOKEN_RDATA, (u8 *) &val,
- sizeof(val), ACQUIRE_LOCK);
-
- rdata = ((val >> 16) & ESP_TX_BUFFER_MASK);
-
- esp_read_reg(context, ESP_SLAVE_INT_ST_REG,
- (u8 *) &intr, sizeof(intr), ACQUIRE_LOCK);
-
-
- if (len_reg > context->rx_byte_count) {
- if (old_len && (context->rx_byte_count == old_len)) {
- printk (KERN_DEBUG "Monitor thread ----> [%d - %d] [%d - %d] %d\n",
- len_reg, context->rx_byte_count,
- rdata, context->tx_buffer_count, intr);
-
- skb = read_packet(context->adapter);
-
- if (!skb)
- continue;
-
- if (skb->len)
- printk (KERN_DEBUG "%s: Flushed %d bytes\n", __func__, skb->len);
-
- /* drop the packet */
- dev_kfree_skb(skb);
- }
- }
-
- old_len = context->rx_byte_count;
- }
-
- do_exit(0);
- return 0;
-}
-#endif
-
-static int esp_probe(struct sdio_func *func,
- const struct sdio_device_id *id)
-{
- struct esp_sdio_context *context = NULL;
- int ret = 0;
- uint32_t cap = 0;
-
- if (func->num != 1) {
- return -EINVAL;
- }
-
- printk(KERN_INFO "%s: ESP network device detected\n", __func__);
-
- context = init_sdio_func(func);
-
- if (!context) {
- return -ENOMEM;
- }
-
- generate_slave_intr(context, BIT(ESP_RESET));
-
- msleep(200);
-
- ret = init_context(context);
- if (ret) {
- deinit_sdio_func(func);
- return ret;
- }
-
-#ifdef CONFIG_SUPPORT_ESP_SERIAL
- ret = esp_serial_init((void *) context->adapter);
- if (ret != 0) {
- esp_remove(func);
- printk(KERN_ERR "Error initialising serial interface\n");
- return ret;
- }
-#endif
-
- ret = esp_add_card(context->adapter);
- if (ret) {
- esp_remove(func);
- printk (KERN_ERR "Failed to add card\n");
- deinit_sdio_func(func);
- return ret;
- }
-
- /* Read slave capabilities */
- esp_read_reg(context, ESP_SLAVE_SCRATCH_REG_0,
- (u8 *) &cap, sizeof(cap), ACQUIRE_LOCK);
-
- context->adapter->capabilities = cap;
-
- print_capabilities(cap);
-
- if (esp_is_bt_supported_over_sdio(cap)) {
- ret = esp_init_bt(context->adapter);
- if (ret) {
- esp_remove(func);
- printk (KERN_ERR "Failed to init BT\n");
- deinit_sdio_func(func);
- return ret;
- }
- }
-
- context->state = ESP_CONTEXT_READY;
-
-#ifdef CONFIG_ENABLE_MONITOR_PROCESS
- monitor_thread = kthread_run(monitor_process, context, "Monitor process");
-
- if (!monitor_thread)
- printk (KERN_ERR "Failed to create monitor thread\n");
-#endif
-
-
- msleep(200);
- generate_slave_intr(context, BIT(ESP_OPEN_DATA_PATH));
- return ret;
-}
-
-/* SDIO driver structure to be registered with kernel */
-static struct sdio_driver esp_sdio_driver = {
- .name = "esp_sdio",
- .id_table = esp_devices,
- .probe = esp_probe,
- .remove = esp_remove,
-};
-
-int esp_init_interface_layer(struct esp_adapter *adapter)
-{
- if (!adapter)
- return -EINVAL;
-
- adapter->if_context = &sdio_context;
- adapter->if_ops = &if_ops;
- sdio_context.adapter = adapter;
-
- return sdio_register_driver(&esp_sdio_driver);
-}
-
-void esp_deinit_interface_layer(void)
-{
- sdio_unregister_driver(&esp_sdio_driver);
-}
+++ /dev/null
-/*
- * Espressif Systems Wireless LAN device driver
- *
- * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
- *
- * This software file (the "File") is distributed by Espressif Systems (Shanghai)
- * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
- * (the "License"). You may use, redistribute and/or modify this File in
- * accordance with the terms and conditions of the License, a copy of which
- * is available by writing to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
- * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
- *
- * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
- * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
- * this warranty disclaimer.
- */
-
-#include <linux/mmc/sdio.h>
-#include <linux/mmc/sdio_func.h>
-#include <linux/mmc/sdio_ids.h>
-#include <linux/mmc/card.h>
-#include <linux/mmc/host.h>
-#include "esp_sdio_api.h"
-
-static int esp_read_byte(struct esp_sdio_context *context, u32 reg, u8 *data, u8 is_lock_needed)
-{
- struct sdio_func *func = NULL;
- int ret;
-
- if (!context || !context->func || !data) {
- printk (KERN_ERR "%s: Invalid or incomplete arguments!\n", __func__);
- return -1;
- }
-
- func = context->func;
-
- if (is_lock_needed)
- sdio_claim_host(func);
-
- *data = sdio_readb(func, reg, &ret);
-
- if (is_lock_needed)
- sdio_release_host(func);
-
- return ret;
-}
-
-static int esp_write_byte(struct esp_sdio_context *context, u32 reg, u8 data, u8 is_lock_needed)
-{
- struct sdio_func *func = NULL;
- int ret;
-
- if (!context || !context->func) {
- printk (KERN_ERR "%s: Invalid or incomplete arguments!\n", __func__);
- return -1;
- }
-
- func = context->func;
-
- if (is_lock_needed)
- sdio_claim_host(func);
-
- sdio_writeb(func, data, reg, &ret);
-
- if (is_lock_needed)
- sdio_release_host(func);
-
- return ret;
-}
-
-static int esp_read_multi_byte(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed)
-{
- struct sdio_func *func = NULL;
- int ret;
-
- if (!context || !context->func || !data) {
- printk (KERN_ERR "%s: Invalid or incomplete arguments!\n", __func__);
- return -1;
- }
-
- func = context->func;
-
- if (is_lock_needed)
- sdio_claim_host(func);
-
- ret = sdio_memcpy_fromio(func, data, reg, size);
-
- if (is_lock_needed)
- sdio_release_host(func);
-
- return ret;
-}
-
-static int esp_write_multi_byte(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed)
-{
- struct sdio_func *func = NULL;
- int ret;
-
- if (!context || !context->func || !data) {
- printk (KERN_ERR "%s: Invalid or incomplete arguments!\n", __func__);
- return -1;
- }
-
- func = context->func;
-
- if (is_lock_needed)
- sdio_claim_host(func);
-
- ret = sdio_memcpy_toio(func, reg, data, size);
-
- if (is_lock_needed)
- sdio_release_host(func);
-
- return ret;
-}
-
-int esp_read_reg(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed)
-{
- /* Need to apply address mask when reading/writing slave registers */
- reg &= ESP_ADDRESS_MASK;
-
- if (size <= 1) {
- return esp_read_byte(context, reg, data, is_lock_needed);
- } else {
- return esp_read_multi_byte(context, reg, data, size, is_lock_needed);
- }
-}
-
-int esp_read_block(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed)
-{
- if (size <= 1) {
- return esp_read_byte(context, reg, data, is_lock_needed);
- } else {
- return esp_read_multi_byte(context, reg, data, size, is_lock_needed);
- }
-}
-
-int esp_write_reg(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed)
-{
- /* Need to apply address mask when reading/writing slave registers */
- reg &= ESP_ADDRESS_MASK;
-
- if (size <= 1) {
- return esp_write_byte(context, reg, *data, is_lock_needed);
- } else {
- return esp_write_multi_byte(context, reg, data, size, is_lock_needed);
- }
-}
-
-int esp_write_block(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed)
-{
- if (size <= 1) {
- return esp_write_byte(context, reg, *data, is_lock_needed);
- } else {
- return esp_write_multi_byte(context, reg, data, size, is_lock_needed);
- }
-}
-
+++ /dev/null
-/*
- * Espressif Systems Wireless LAN device driver
- *
- * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
- *
- * This software file (the "File") is distributed by Espressif Systems (Shanghai)
- * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
- * (the "License"). You may use, redistribute and/or modify this File in
- * accordance with the terms and conditions of the License, a copy of which
- * is available by writing to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
- * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
- *
- * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
- * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
- * this warranty disclaimer.
- */
-
-#ifndef _ESP_SDIO_API_H_
-#define _ESP_SDIO_API_H_
-#include "esp_sdio_decl.h"
-
-int esp_read_reg(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed);
-int esp_read_block(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed);
-int esp_write_reg(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed);
-int esp_write_block(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed);
-
-#endif
+++ /dev/null
-/*
- * Espressif Systems Wireless LAN device driver
- *
- * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
- *
- * This software file (the "File") is distributed by Espressif Systems (Shanghai)
- * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
- * (the "License"). You may use, redistribute and/or modify this File in
- * accordance with the terms and conditions of the License, a copy of which
- * is available by writing to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
- * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
- *
- * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
- * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
- * this warranty disclaimer.
- */
-
-#ifndef _ESP_DECL_H_
-#define _ESP_DECL_H_
-
-#include <linux/bits.h>
-#include "esp.h"
-
-/* Interrupt Status */
-#define ESP_SLAVE_BIT0_INT BIT(0)
-#define ESP_SLAVE_BIT1_INT BIT(1)
-#define ESP_SLAVE_BIT2_INT BIT(2)
-#define ESP_SLAVE_BIT3_INT BIT(3)
-#define ESP_SLAVE_BIT4_INT BIT(4)
-#define ESP_SLAVE_BIT5_INT BIT(5)
-#define ESP_SLAVE_BIT6_INT BIT(6)
-#define ESP_SLAVE_BIT7_INT BIT(7)
-#define ESP_SLAVE_RX_UNDERFLOW_INT BIT(16)
-#define ESP_SLAVE_TX_OVERFLOW_INT BIT(17)
-#define ESP_SLAVE_RX_NEW_PACKET_INT BIT(23)
-
-
-#define ESP_SLAVE_CMD53_END_ADDR 0x1F800
-#define ESP_SLAVE_LEN_MASK 0xFFFFF
-#define ESP_BLOCK_SIZE 512
-#define ESP_RX_BYTE_MAX 0x100000
-#define ESP_RX_BUFFER_SIZE 2048
-
-#define ESP_TX_BUFFER_MASK 0xFFF
-#define ESP_TX_BUFFER_MAX 0x1000
-#define ESP_MAX_BUF_CNT 10
-
-#define ESP_SLAVE_SLCHOST_BASE 0x3FF55000
-
-#define ESP_SLAVE_SCRATCH_REG_7 (ESP_SLAVE_SLCHOST_BASE + 0x8C)
-/* SLAVE registers */
-/* Interrupt Registers */
-#define ESP_SLAVE_INT_RAW_REG (ESP_SLAVE_SLCHOST_BASE + 0x50)
-#define ESP_SLAVE_INT_ST_REG (ESP_SLAVE_SLCHOST_BASE + 0x58)
-#define ESP_SLAVE_INT_CLR_REG (ESP_SLAVE_SLCHOST_BASE + 0xD4)
-
-/* Data path registers*/
-#define ESP_SLAVE_PACKET_LEN_REG (ESP_SLAVE_SLCHOST_BASE + 0x60)
-#define ESP_SLAVE_TOKEN_RDATA (ESP_SLAVE_SLCHOST_BASE + 0x44)
-
-/* Scratch registers*/
-#define ESP_SLAVE_SCRATCH_REG_0 (ESP_SLAVE_SLCHOST_BASE + 0x6C)
-#define ESP_SLAVE_SCRATCH_REG_1 (ESP_SLAVE_SLCHOST_BASE + 0x70)
-#define ESP_SLAVE_SCRATCH_REG_2 (ESP_SLAVE_SLCHOST_BASE + 0x74)
-#define ESP_SLAVE_SCRATCH_REG_3 (ESP_SLAVE_SLCHOST_BASE + 0x78)
-#define ESP_SLAVE_SCRATCH_REG_4 (ESP_SLAVE_SLCHOST_BASE + 0x7C)
-#define ESP_SLAVE_SCRATCH_REG_6 (ESP_SLAVE_SLCHOST_BASE + 0x88)
-#define ESP_SLAVE_SCRATCH_REG_8 (ESP_SLAVE_SLCHOST_BASE + 0x9C)
-#define ESP_SLAVE_SCRATCH_REG_9 (ESP_SLAVE_SLCHOST_BASE + 0xA0)
-#define ESP_SLAVE_SCRATCH_REG_10 (ESP_SLAVE_SLCHOST_BASE + 0xA4)
-#define ESP_SLAVE_SCRATCH_REG_11 (ESP_SLAVE_SLCHOST_BASE + 0xA8)
-#define ESP_SLAVE_SCRATCH_REG_12 (ESP_SLAVE_SLCHOST_BASE + 0xAC)
-#define ESP_SLAVE_SCRATCH_REG_13 (ESP_SLAVE_SLCHOST_BASE + 0xB0)
-#define ESP_SLAVE_SCRATCH_REG_14 (ESP_SLAVE_SLCHOST_BASE + 0xB4)
-#define ESP_SLAVE_SCRATCH_REG_15 (ESP_SLAVE_SLCHOST_BASE + 0xB8)
-
-#define ESP_ADDRESS_MASK 0x3FF
-
-#define ESP_VENDOR_ID 0x6666
-#define ESP_DEVICE_ID_1 0x2222
-#define ESP_DEVICE_ID_2 0x3333
-
-
-enum context_state {
- ESP_CONTEXT_DISABLED = 0,
- ESP_CONTEXT_INIT,
- ESP_CONTEXT_READY
-};
-
-struct esp_sdio_context {
- struct esp_adapter *adapter;
- struct sdio_func *func;
- enum context_state state;
- u32 rx_byte_count;
- u32 tx_buffer_count;
-};
-
-#endif
+++ /dev/null
-/*
- * Espressif Systems Wireless LAN device driver
- *
- * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
- *
- * This software file (the "File") is distributed by Espressif Systems (Shanghai)
- * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
- * (the "License"). You may use, redistribute and/or modify this File in
- * accordance with the terms and conditions of the License, a copy of which
- * is available by writing to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
- * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
- *
- * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
- * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
- * this warranty disclaimer.
- */
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/delay.h>
-#include <linux/cdev.h>
-#include <linux/fs.h>
-#include <linux/kthread.h>
-#include <linux/delay.h>
-#include <linux/slab.h>
-
-#include "esp.h"
-#include "esp_rb.h"
-#include "esp_api.h"
-
-#define ESP_SERIAL_MAJOR 221
-#define ESP_SERIAL_MINOR_MAX 2
-#define ESP_RX_RB_SIZE 4096
-
-//#define ESP_SERIAL_TEST
-
-
-static struct esp_serial_devs {
- struct cdev cdev;
- int dev_index;
- esp_rb_t rb;
- void *priv;
-} devs[ESP_SERIAL_MINOR_MAX];
-
-static int esp_serial_read(struct file *file, char __user *user_buffer, size_t size, loff_t *offset)
-{
- struct esp_serial_devs *dev;
- dev = (struct esp_serial_devs *) file->private_data;
- size = esp_rb_read_by_user(&dev->rb, user_buffer, size, file->f_flags & O_NONBLOCK);
-/* print_hex_dump_bytes("Rx:", DUMP_PREFIX_NONE, user_buffer, size);*/
- if (size == 0) {
- return -EAGAIN;
- }
-
- return size;
-}
-
-static int esp_serial_write(struct file *file, const char __user *user_buffer, size_t size, loff_t * offset)
-{
- struct esp_payload_header *hdr;
- char *buf;
- struct esp_serial_devs *dev;
- int ret;
- size_t total_len;
-
- dev = (struct esp_serial_devs *) file->private_data;
- total_len = size + sizeof(struct esp_payload_header);
-
- buf = kmalloc(total_len, GFP_KERNEL);
- if (!buf) {
- printk(KERN_ERR "Error allocating buffer to send serial data\n");
- return -ENOMEM;
- }
-
- hdr = (struct esp_payload_header *) buf;
-
- hdr->if_type = ESP_SERIAL_IF;
- hdr->if_num = dev->dev_index;
- hdr->len = cpu_to_le16(size);
- hdr->offset = cpu_to_le16(sizeof(struct esp_payload_header));
-
- ret = copy_from_user(buf + hdr->offset, user_buffer, size);
- if (ret != 0) {
- kfree(buf);
- printk(KERN_ERR "Error copying buffer to send serial data\n");
- return -EFAULT;
- }
-
- print_hex_dump_bytes("Tx:", DUMP_PREFIX_NONE, buf, total_len);
- ret = esp_send_packet(dev->priv, buf, total_len);
- if (ret) {
- printk (KERN_ERR "%s: Failed to transmit data\n", __func__);
- }
-
- kfree(buf);
- return size;
-}
-
-static long esp_serial_ioctl (struct file *file, unsigned int cmd, unsigned long arg)
-{
- printk(KERN_INFO "%s IOCTL %d\n", __func__, cmd);
- return 0;
-}
-
-static int esp_serial_open(struct inode *inode, struct file *file)
-{
- struct esp_serial_devs *devs;
-
- devs = container_of(inode->i_cdev, struct esp_serial_devs, cdev);
- file->private_data = devs;
- printk(KERN_INFO "%s on device %d\n", __func__, devs->dev_index);
-
- return 0;
-}
-
-const struct file_operations esp_serial_fops = {
- .owner = THIS_MODULE,
- .open = esp_serial_open,
- .read = esp_serial_read,
- .write = esp_serial_write,
- .unlocked_ioctl = esp_serial_ioctl
-};
-
-int esp_serial_data_received(int dev_index, const char *data, size_t len)
-{
- int ret;
- size_t ret_len = 0;
-
- while (ret_len != len) {
- ret = esp_rb_write_by_kernel(&devs[dev_index].rb, data, len);
- ret_len += ret;
- if (ret == 0) {
- break;
- }
- }
- if (ret_len != len) {
- printk(KERN_ERR "RB full, no space to receive. Dropping packet");
- }
-
- return ret_len;
-}
-
-#ifdef ESP_SERIAL_TEST
-static int thread_fn(void *unused)
-{
- int i = 100;
-
- while(i--) {
- esp_rb_write_by_kernel(&devs[0].rb, "alphabetagamma", 14);
- ssleep(1);
- }
- printk(KERN_INFO "Thread stopping\n");
- do_exit(0);
- return 0;
-}
-#endif
-
-int esp_serial_init(void *priv)
-{
- int err;
- int i;
-
- err = register_chrdev_region(MKDEV(ESP_SERIAL_MAJOR, 0), ESP_SERIAL_MINOR_MAX, "esp_serial_driver");
- if (err) {
- printk(KERN_ERR "Error registering chrdev region %d\n", err);
- return -1;
- }
-
- for (i = 0; i < ESP_SERIAL_MINOR_MAX; i++) {
- cdev_init(&devs[i].cdev, &esp_serial_fops);
- devs[i].dev_index = i;
- cdev_add(&devs[i].cdev, MKDEV(ESP_SERIAL_MAJOR, i), 1);
- esp_rb_init(&devs[i].rb, ESP_RX_RB_SIZE);
- devs[i].priv = priv;
- }
-
-#ifdef ESP_SERIAL_TEST
- kthread_run(thread_fn, NULL, "esptest-thread");
-#endif
- return 0;
-}
-
-void esp_serial_cleanup(void)
-{
- int i;
- for (i = 0; i < ESP_SERIAL_MINOR_MAX; i++) {
- cdev_del(&devs[i].cdev);
- esp_rb_cleanup(&devs[i].rb);
- }
- unregister_chrdev_region(MKDEV(ESP_SERIAL_MAJOR, 0), ESP_SERIAL_MINOR_MAX);
- return;
-}
+++ /dev/null
-/*
- * Espressif Systems Wireless LAN device driver
- *
- * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
- *
- * This software file (the "File") is distributed by Espressif Systems (Shanghai)
- * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
- * (the "License"). You may use, redistribute and/or modify this File in
- * accordance with the terms and conditions of the License, a copy of which
- * is available by writing to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
- * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
- *
- * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
- * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
- * this warranty disclaimer.
- */
-
-#ifndef _ESP_SERIAL_H_
-#define _ESP_SERIAL_H_
-
-int esp_serial_init(void * priv);
-void esp_serial_cleanup(void);
-
-int esp_serial_data_received(int dev_index, const char *data, size_t len);
-#endif
+++ /dev/null
-/*
- * Espressif Systems Wireless LAN device driver
- *
- * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
- *
- * This software file (the "File") is distributed by Espressif Systems (Shanghai)
- * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
- * (the "License"). You may use, redistribute and/or modify this File in
- * accordance with the terms and conditions of the License, a copy of which
- * is available by writing to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
- * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
- *
- * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
- * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
- * this warranty disclaimer.
- */
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/delay.h>
-#include <linux/slab.h>
-#include <linux/timekeeping.h>
-#include <linux/etherdevice.h>
-#include <linux/netdevice.h>
-
-#include "esp.h"
-#include "esp_if.h"
-#ifdef CONFIG_SUPPORT_ESP_SERIAL
-#include "esp_serial.h"
-#endif
-#include "esp_bt_api.h"
-
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("WLAN device driver for ESP32 module");
-MODULE_VERSION("0.01");
-
-struct esp_adapter adapter;
-volatile u8 stop_data = 0;
-
-#define ACTION_DROP 1
-
-static int esp_open(struct net_device *ndev);
-static int esp_stop(struct net_device *ndev);
-static int esp_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev);
-static int esp_set_mac_address(struct net_device *ndev, void *addr);
-static void esp_tx_timeout(struct net_device *ndev);
-static struct net_device_stats* esp_get_stats(struct net_device *ndev);
-static void esp_set_rx_mode(struct net_device *ndev);
-int esp_send_packet(struct esp_adapter *adapter, u8 *buf, u32 size);
-
-static const struct net_device_ops esp_netdev_ops = {
- .ndo_open = esp_open,
- .ndo_stop = esp_stop,
- .ndo_start_xmit = esp_hard_start_xmit,
- .ndo_set_mac_address = esp_set_mac_address,
- .ndo_validate_addr = eth_validate_addr,
- .ndo_tx_timeout = esp_tx_timeout,
- .ndo_get_stats = esp_get_stats,
- .ndo_set_rx_mode = esp_set_rx_mode,
-};
-
-#if 0
-u64 start_time, end_time;
-#endif
-
-struct esp_adapter * esp_get_adapter(void)
-{
- return &adapter;
-}
-
-static int esp_open(struct net_device *ndev)
-{
- netif_start_queue(ndev);
- return 0;
-}
-
-static int esp_stop(struct net_device *ndev)
-{
- netif_stop_queue(ndev);
- return 0;
-}
-
-static struct net_device_stats* esp_get_stats(struct net_device *ndev)
-{
- struct esp_private *priv = netdev_priv(ndev);
- return &priv->stats;
-}
-
-static int esp_set_mac_address(struct net_device *ndev, void *data)
-{
- struct esp_private *priv = netdev_priv(ndev);
- struct sockaddr *mac_addr = data;
-
- if (!priv)
- return -EINVAL;
-
- ether_addr_copy(priv->mac_address, mac_addr->sa_data);
- ether_addr_copy(ndev->dev_addr, mac_addr->sa_data);
- return 0;
-}
-
-static void esp_tx_timeout(struct net_device *ndev)
-{
-}
-
-static void esp_set_rx_mode(struct net_device *ndev)
-{
-}
-
-static int esp_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
-{
- struct sk_buff *new_skb;
- struct esp_private *priv = netdev_priv(ndev);
- struct esp_skb_cb *cb;
-
- if (!priv) {
- dev_kfree_skb(skb);
- return -EINVAL;
- }
-
- if (!skb->len || (skb->len > ETH_FRAME_LEN)) {
- printk (KERN_ERR "%s: Bad len %d\n", __func__, skb->len);
- priv->stats.tx_dropped++;
- dev_kfree_skb(skb);
- return -EINVAL;
- }
-
- if (skb_headroom(skb) < ESP_PAYLOAD_HEADER) {
- /* Insufficient space. Realloc skb. */
- new_skb = skb_realloc_headroom(skb, ESP_PAYLOAD_HEADER);
-
- if (unlikely(!new_skb)) {
- printk (KERN_ERR "%s: Failed to allocate SKB\n", __func__);
- priv->stats.tx_dropped++;
- dev_kfree_skb(skb);
- return -ENOMEM;
- }
-
- /* Free old SKB */
- dev_kfree_skb(skb);
-
- skb = new_skb;
- }
-
- cb = (struct esp_skb_cb *) skb->cb;
- cb->priv = priv;
-
-/* print_hex_dump_bytes("Tx:", DUMP_PREFIX_NONE, skb->data, 8);*/
-
- skb_queue_tail(&adapter.tx_q, skb);
- atomic_inc(&adapter.tx_pending);
- queue_work(adapter.tx_workqueue, &adapter.tx_work);
-
- return 0;
-}
-
-u8 esp_is_bt_supported_over_sdio(u32 cap)
-{
- return (cap & ESP_BT_SDIO_SUPPORT);
-}
-
-static struct esp_private * get_priv_from_payload_header(struct esp_payload_header *header)
-{
- struct esp_private *priv;
- u8 i;
-
- if (!header)
- return NULL;
-
- for (i = 0; i < ESP_MAX_INTERFACE; i++) {
- priv = adapter.priv[i];
-
- if (!priv)
- continue;
-
- if (priv->if_type == header->if_type &&
- priv->if_num == header->if_num) {
- return priv;
- }
- }
-
- return NULL;
-}
-
-void esp_process_new_packet_intr(struct esp_adapter *adapter)
-{
- if(adapter)
- queue_work(adapter->if_rx_workqueue, &adapter->if_rx_work);
-}
-
-static void process_tx_packet (void)
-{
- struct sk_buff *skb;
- struct esp_private *priv;
- struct esp_skb_cb *cb;
- struct esp_payload_header *payload_header;
- struct sk_buff *new_skb;
- int ret = 0;
- u8 pad_len = 0;
- u16 len = 0;
- static u32 c = 0;
-
- while ((skb = skb_dequeue(&adapter.tx_q))) {
- c++;
- /* Get the priv */
- cb = (struct esp_skb_cb *) skb->cb;
- priv = cb->priv;
-
- if (!priv) {
- dev_kfree_skb_any(skb);
- atomic_dec(&adapter.tx_pending);
- continue;
- }
-
- len = skb->len;
-
- /* Create space for payload header */
- pad_len = sizeof(struct esp_payload_header);
-
- if (skb_headroom(skb) < pad_len) {
- /* insufficent headroom to add payload header */
- new_skb = skb_realloc_headroom(skb, pad_len);
-
- if(!new_skb) {
- printk(KERN_ERR "%s: Failed to allocate SKB", __func__);
- dev_kfree_skb(skb);
- atomic_dec(&adapter.tx_pending);
- continue;
- }
-
- dev_kfree_skb(skb);
-
- skb = new_skb;
- }
-
- skb_push(skb, pad_len);
-
- /* Set payload header */
- payload_header = (struct esp_payload_header *) skb->data;
- memset(payload_header, 0, pad_len);
-
- payload_header->if_type = priv->if_type;
- payload_header->if_num = priv->if_num;
- payload_header->len = cpu_to_le16(skb->len - pad_len);
- payload_header->offset = cpu_to_le16(pad_len);
- payload_header->reserved1 = c % 255;
-
-/* printk (KERN_ERR "H -> S: %d %d %d %d", len, payload_header->offset,*/
-/* payload_header->len, payload_header->reserved1);*/
-
- if (!stop_data) {
- ret = esp_send_packet(priv->adapter, skb->data, skb->len);
-
- if (ret) {
- priv->stats.tx_errors++;
- } else {
- priv->stats.tx_packets++;
- priv->stats.tx_bytes += skb->len;
- }
- } else {
- priv->stats.tx_dropped++;
- }
-
- dev_kfree_skb_any(skb);
- atomic_dec(&adapter.tx_pending);
- }
-}
-
-static void process_rx_packet(struct sk_buff *skb)
-{
- struct esp_private *priv;
- struct esp_payload_header *payload_header;
- u16 len, offset;
- struct hci_dev *hdev = adapter.hcidev;
- u8 *type;
-
- if (!skb)
- return;
-
- /* get the paload header */
- payload_header = (struct esp_payload_header *) skb->data;
- /* print_hex_dump_bytes("Rx:", DUMP_PREFIX_NONE, (skb->data + 8), 32);*/
-
- len = le16_to_cpu(payload_header->len);
- offset = le16_to_cpu(payload_header->offset);
-
- if (payload_header->if_type == ESP_SERIAL_IF) {
- print_hex_dump_bytes("Rx:", DUMP_PREFIX_NONE, (skb->data + offset), len);
-#ifdef CONFIG_SUPPORT_ESP_SERIAL
- esp_serial_data_received(payload_header->if_num, skb->data + offset, len);
-#else
- printk(KERN_ERR "Dropping unsupported serial frame\n");
-#endif
- dev_kfree_skb_any(skb);
- } else if (payload_header->if_type == ESP_STA_IF || payload_header->if_type == ESP_AP_IF) {
- /* chop off the header from skb */
- skb_pull(skb, offset);
-
- /* retrieve priv based on payload header contents */
- priv = get_priv_from_payload_header(payload_header);
-
- if (!priv) {
- printk (KERN_ERR "%s: empty priv\n", __func__);
- dev_kfree_skb_any(skb);
-/* atomic_dec(&adapter.rx_pending);*/
- return;
- }
-
- skb->dev = priv->ndev;
- skb->protocol = eth_type_trans(skb, priv->ndev);
- skb->ip_summed = CHECKSUM_NONE;
- /* print_hex_dump_bytes("Rx:", DUMP_PREFIX_NONE, skb->data, 8);*/
-
- /* Forward skb to kernel */
- netif_rx(skb);
-
- priv->stats.rx_bytes += skb->len;
- priv->stats.rx_packets++;
- } else if (payload_header->if_type == ESP_HCI_IF) {
- if (hdev) {
- /* chop off the header from skb */
- skb_pull(skb, offset);
-
-/* print_hex_dump_bytes("Rx:", DUMP_PREFIX_NONE, skb->data, skb->len);*/
- type = skb->data;
- hci_skb_pkt_type(skb) = *type;
- skb_pull(skb, 1);
-
- if (hci_recv_frame(hdev, skb)) {
- hdev->stat.err_rx++;
- } else {
- esp_hci_update_rx_counter(hdev, *type, skb->len);
- }
- }
- }
-}
-
-struct sk_buff * esp_alloc_skb(u32 len)
-{
- struct sk_buff *skb;
-
- skb = netdev_alloc_skb(NULL, len);
- return skb;
-}
-
-
-static int esp_get_packets(struct esp_adapter *adapter)
-{
- struct sk_buff *skb;
-
- if (!adapter || !adapter->if_ops || !adapter->if_ops->read)
- return -EINVAL;
-
- skb = adapter->if_ops->read(adapter);
-
- if (!skb)
- return -EFAULT;
-
- process_rx_packet(skb);
-
- return 0;
-}
-
-int esp_send_packet(struct esp_adapter *adapter, u8 *buf, u32 size)
-{
- if (!adapter || !adapter->if_ops || !adapter->if_ops->write)
- return -EINVAL;
-
- return adapter->if_ops->write(adapter, buf, size);
-}
-
-static int insert_priv_to_adapter(struct esp_private *priv)
-{
- int i = 0;
-
- for (i = 0; i < ESP_MAX_INTERFACE; i++) {
- /* Check if priv can be added */
- if (adapter.priv[i] == NULL) {
- adapter.priv[i] = priv;
- return 0;
- }
- }
-
- return -1;
-}
-
-static int esp_init_priv(struct esp_private *priv, struct net_device *dev,
- u8 if_type, u8 if_num)
-{
- int ret = 0;
-
- if (!priv || !dev)
- return -EINVAL;
-
- ret = insert_priv_to_adapter(priv);
- if (ret)
- return ret;
-
- priv->ndev = dev;
- priv->if_type = if_type;
- priv->if_num = if_num;
- priv->link_state = ESP_LINK_DOWN;
- priv->adapter = &adapter;
- memset(&priv->stats, 0, sizeof(priv->stats));
-
- return 0;
-}
-
-static int esp_init_net_dev(struct net_device *ndev, struct esp_private *priv)
-{
- int ret = 0;
- /* Set netdev */
-/* SET_NETDEV_DEV(ndev, &adapter->context.func->dev);*/
-
- /* set net dev ops */
- ndev->netdev_ops = &esp_netdev_ops;
-
- ether_addr_copy(ndev->dev_addr, priv->mac_address);
- /* set ethtool ops */
-
- /* update features supported */
-
- /* min mtu */
-
- /* register netdev */
- ret = register_netdev(ndev);
-
-/* netif_start_queue(ndev);*/
- /* ndev->needs_free_netdev = true; */
-
- /* set watchdog timeout */
-
- return ret;
-}
-
-static int esp_add_interface(struct esp_adapter *adapter, u8 if_type, u8 if_num, char *name)
-{
- struct net_device *ndev = NULL;
- struct esp_private *priv = NULL;
- int ret = 0;
-
- ndev = alloc_netdev_mqs(sizeof(struct esp_private), name,
- NET_NAME_ENUM, ether_setup, 1, 1);
-
- if (!ndev) {
- printk(KERN_ERR "%s: alloc failed\n", __func__);
- return -ENOMEM;
- }
-
- priv = netdev_priv(ndev);
-
- /* Init priv */
- ret = esp_init_priv(priv, ndev, if_type, if_num);
- if (ret) {
- printk(KERN_ERR "%s: Init priv failed\n", __func__);
- goto error_exit;
- }
-
- ret = esp_init_net_dev(ndev, priv);
- if (ret) {
- printk(KERN_ERR "%s: Init netdev failed\n", __func__);
- goto error_exit;
- }
-
- return ret;
-
-error_exit:
- free_netdev(ndev);
- return ret;
-}
-
-static void flush_ring_buffers(struct esp_adapter *adapter)
-{
- struct sk_buff *skb;
-
- printk (KERN_INFO "%s: Flush Pending SKBs: %d %d\n", __func__,
- atomic_read(&adapter->tx_pending),
- atomic_read(&adapter->rx_pending));
-
- while ((skb = skb_dequeue(&adapter->tx_q))) {
- dev_kfree_skb_any(skb);
- atomic_dec(&adapter->tx_pending);
- }
-
- while ((skb = skb_dequeue(&adapter->rx_q))) {
- dev_kfree_skb_any(skb);
- atomic_dec(&adapter->rx_pending);
- }
-}
-
-static void esp_remove_network_interfaces(struct esp_adapter *adapter)
-{
- if (adapter->priv[0]->ndev) {
- netif_stop_queue(adapter->priv[0]->ndev);
- unregister_netdev(adapter->priv[0]->ndev);
- free_netdev(adapter->priv[0]->ndev);
- }
-
- if (adapter->priv[1]->ndev) {
- netif_stop_queue(adapter->priv[1]->ndev);
- unregister_netdev(adapter->priv[1]->ndev);
- free_netdev(adapter->priv[1]->ndev);
- }
-}
-
-int esp_add_card(struct esp_adapter *adapter)
-{
- int ret = 0;
-
- if (!adapter) {
- printk(KERN_ERR "%s: Invalid args\n", __func__);
- return -EINVAL;
- }
-
- stop_data = 0;
-
- /* Add interface STA and AP */
- ret = esp_add_interface(adapter, ESP_STA_IF, 0, "ethsta%d");
- if (ret) {
- printk(KERN_ERR "%s: Failed to add STA\n", __func__);
- return ret;
- }
-
- ret = esp_add_interface(adapter, ESP_AP_IF, 0, "ethap%d");
- if (ret) {
- printk(KERN_ERR "%s: Failed to add AP\n", __func__);
- esp_remove_network_interfaces(adapter);
- }
-
- return ret;
-}
-
-int esp_remove_card(struct esp_adapter *adapter)
-{
- stop_data = 1;
-
- if (!adapter)
- return 0;
-
- /* Flush workqueues */
- if (adapter->if_rx_workqueue)
- flush_workqueue(adapter->if_rx_workqueue);
-
- if (adapter->tx_workqueue)
- flush_workqueue(adapter->tx_workqueue);
-
- esp_remove_network_interfaces(adapter);
-
- flush_ring_buffers(adapter);
-
- adapter->priv[0] = NULL;
- adapter->priv[1] = NULL;
-
- atomic_set(&adapter->tx_pending, 0);
- atomic_set(&adapter->rx_pending, 0);
-
- return 0;
-}
-
-
-static void esp_tx_work (struct work_struct *work)
-{
- process_tx_packet();
-}
-
-static void esp_if_rx_work (struct work_struct *work)
-{
- /* read inbound packet and forward it to network/serial interface */
- esp_get_packets(&adapter);
-}
-
-static void deinit_adapter(void)
-{
- if (adapter.if_rx_workqueue)
- destroy_workqueue(adapter.if_rx_workqueue);
-
- if (adapter.tx_workqueue)
- destroy_workqueue(adapter.tx_workqueue);
-}
-
-static struct esp_adapter * init_adapter(void)
-{
- memset(&adapter, 0, sizeof(adapter));
-
- /* Prepare interface RX work */
- adapter.if_rx_workqueue = create_workqueue("ESP_IF_RX_WORK_QUEUE");
-
- if (!adapter.if_rx_workqueue) {
- deinit_adapter();
- return NULL;
- }
-
- INIT_WORK(&adapter.if_rx_work, esp_if_rx_work);
-
- /* Prepare TX work */
- adapter.tx_workqueue = create_workqueue("ESP_TX_WORK_QUEUE");
-
- if (!adapter.tx_workqueue) {
- deinit_adapter();
- return NULL;
- }
-
- INIT_WORK(&adapter.tx_work, esp_tx_work);
-
- /* Prepare TX work */
- skb_queue_head_init(&adapter.tx_q);
- skb_queue_head_init(&adapter.rx_q);
-
- atomic_set(&adapter.tx_pending, 0);
- atomic_set(&adapter.rx_pending, 0);
-
- return &adapter;
-}
-
-
-static int __init esp_init(void)
-{
- int ret = 0;
- struct esp_adapter *adapter;
-
- /* Init adapter */
- adapter = init_adapter();
-
- if (!adapter)
- return -EFAULT;
-
- /* Init transport layer */
- ret = esp_init_interface_layer(adapter);
-
- if (ret != 0) {
- deinit_adapter();
- }
-
- return ret;
-}
-
-static void __exit esp_exit(void)
-{
- esp_deinit_interface_layer();
- deinit_adapter();
-}
-
-module_init(esp_init);
-module_exit(esp_exit);
--- /dev/null
+GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ {description}
+ Copyright (C) {year} {fullname}
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ {signature of Ty Coon}, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
+
--- /dev/null
+# Copyright 2015-2020 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 commands
+import argparse
+
+failure = "failure"
+ap_list = 'No APs Available'
+
+parser = argparse.ArgumentParser(description='ap_scan_list.py is a python script which gives scanned list of available APs. list contains ssid, channel number, rssi, mac address and authentication mode of AP. ex. python ap_scan_list.py')
+
+ap_list = commands.wifi_ap_scan_list()
+if (ap_list == failure):
+ print("Failed to get AP scan list")
+else:
+ for obj in ap_list:
+ print(obj.ssid,obj.chnl,obj.rssi,obj.bssid,obj.ecn)
--- /dev/null
+# Copyright 2015-2020 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 commands
+import argparse
+
+# WiFi Mode
+# NULL 0
+# Station 1
+# SoftAP 2
+# Station + SoftAP 3
+
+none = 0
+station = 1
+softap = 2
+station_softap = 3
+failure = "failure"
+stations_list = "No station is connected"
+
+parser = argparse.ArgumentParser(description='connected_stations_list.py is a python script which gives list of mac addresses of stations connected to softAP. ex. python connected_stations_list.py')
+
+get_mode = commands.get_wifi_mode()
+if (get_mode == softap or get_mode == station_softap):
+ stations_list = commands.wifi_connected_stations_list()
+ if (stations_list == failure):
+ print("failure in getting connected stations list")
+ else:
+ for obj in stations_list:
+ print(obj.mac)
+elif (get_mode == failure):
+ print("failure in getting wifi mode")
+else :
+ print("current mode is not station/station+softap")
--- /dev/null
+# Copyright 2015-2020 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 transport
+import esp_hosted_config_pb2
+import binascii
+
+class Aplist:
+ def __init__(self,ssid,chnl,rssi,bssid,ecn):
+ self.ssid = ssid
+ self.chnl = chnl
+ self.rssi = rssi
+ self.bssid = bssid
+ self.ecn = ecn
+
+class Stationlist:
+ def __init__(self,mac,rssi):
+ self.mac = mac
+ self.rssi = rssi
+
+#default parameters
+interface = "/dev/esps0"
+endpoint = "control"
+not_set = "0"
+failure = "failure"
+
+#get mac address
+# mode == 1 for station mac
+# mode == 2 for softAP mac
+def get_mac(mode):
+ req_sta_mac = esp_hosted_config_pb2.EspHostedConfigPayload()
+ req_sta_mac.msg = esp_hosted_config_pb2.EspHostedConfigMsgType.TypeCmdGetMACAddress
+ #for station mode set cmd as 1
+ req_sta_mac.cmd_get_mac_address.cmd = str(mode)
+ protodata = req_sta_mac.SerializeToString()
+ #print("serialized data "+str(protodata))
+ tp = transport.Transport_pserial(interface)
+ response = tp.send_data(endpoint,protodata,0.3)
+ if response == failure :
+ return failure
+ #print("response from slave "+str(response))
+ req_sta_mac.ParseFromString(response)
+ return req_sta_mac.resp_get_mac_address.resp
+
+#get wifi mode
+# 0: null Mode, Wi-Fi mode not set
+# 1: station mode
+# 2: softAP mode
+# 3: softAP+station mode
+
+def get_wifi_mode():
+ req_wifi_mode = esp_hosted_config_pb2.EspHostedConfigPayload()
+ req_wifi_mode.msg = esp_hosted_config_pb2.EspHostedConfigMsgType.TypeCmdGetWiFiMode
+ protodata = req_wifi_mode.SerializeToString()
+ #print("serialized data "+str(protodata))
+ tp = transport.Transport_pserial(interface)
+ response = tp.send_data(endpoint,protodata,0.3)
+ if response == failure :
+ return failure
+ #print("response from slave "+str(response))
+ req_wifi_mode.ParseFromString(response)
+ return req_wifi_mode.resp_get_wifi_mode.mode
+
+#set wifi mode
+# 0: null Mode, Wi-Fi mode not set
+# 1: station mode
+# 2: softAP mode
+# 3: softAP+station mode
+def set_wifi_mode(mode):
+ set_wifi_mode = esp_hosted_config_pb2.EspHostedConfigPayload()
+ set_wifi_mode.msg = esp_hosted_config_pb2.EspHostedConfigMsgType.TypeCmdSetWiFiMode
+ set_wifi_mode.cmd_set_wifi_mode.mode = mode
+ protodata = set_wifi_mode.SerializeToString()
+ #print("serialized data "+str(protodata))
+ tp = transport.Transport_pserial(interface)
+ response = tp.send_data(endpoint,protodata,0.3)
+ if response == failure :
+ return failure
+ #print("response from slave "+str(response))
+ set_wifi_mode.ParseFromString(response)
+ return set_wifi_mode.resp_set_wifi_mode.mode
+
+# get AP config to which ESP station is connected
+# It returns ssid, bssid, channel and rssi
+def wifi_get_ap_config():
+ get_ap_config = esp_hosted_config_pb2.EspHostedConfigPayload()
+ get_ap_config.msg = esp_hosted_config_pb2.EspHostedConfigMsgType.TypeCmdGetAPConfig
+ protodata = get_ap_config.SerializeToString()
+ #print("serialized data "+str(protodata))
+ tp = transport.Transport_pserial(interface)
+ response = tp.send_data(endpoint,protodata,1)
+ if response == failure :
+ return failure
+ #print("response from slave "+str(response))
+ get_ap_config.ParseFromString(response)
+ ssid = str(get_ap_config.resp_get_ap_config.ssid)
+ bssid = str(get_ap_config.resp_get_ap_config.bssid)
+ channel = get_ap_config.resp_get_ap_config.chnl
+ rssi = get_ap_config.resp_get_ap_config.rssi
+ return ssid,bssid,channel,rssi
+
+# set AP config to which ESP station should connect
+# User should provide ssid, password, bssid
+def wifi_set_ap_config(ssid, pwd, bssid):
+ set_ap_config = esp_hosted_config_pb2.EspHostedConfigPayload()
+ set_ap_config.msg = esp_hosted_config_pb2.EspHostedConfigMsgType.TypeCmdSetAPConfig
+ set_ap_config.cmd_set_ap_config.ssid = str(ssid)
+ set_ap_config.cmd_set_ap_config.pwd = str(pwd)
+ 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)
+ response = tp.send_data(endpoint,protodata,10)
+ if response == failure :
+ return failure
+ #print("response from slave "+str(response))
+ set_ap_config.ParseFromString(response)
+ status = set_ap_config.resp_set_ap_config.status
+ return status
+
+# Disconnect from AP
+def wifi_disconnect_ap():
+ disconnect_ap = esp_hosted_config_pb2.EspHostedConfigPayload()
+ disconnect_ap.msg = esp_hosted_config_pb2.EspHostedConfigMsgType.TypeCmdDisconnectAP
+ protodata = disconnect_ap.SerializeToString()
+ #print("serialized data "+str(protodata))
+ tp = transport.Transport_pserial(interface)
+ response = tp.send_data(endpoint,protodata,0.3)
+ if response == failure :
+ return failure
+ #print("response from slave "+str(response))
+ disconnect_ap.ParseFromString(response)
+ status = disconnect_ap.resp_disconnect_ap.resp
+ return status
+
+
+# set softAP config
+# ssid : string parameter, ssid of SoftAP
+# pwd : string parameter, length of password should be 8~64 bytes ASCII
+# chnl : channel ID should be in range of 1 to 11
+# ecn : Encryption method
+# ( 0 : OPEN,
+# 2 : WPA_PSK,
+# 3 : WPA2_PSK,
+# 4 : WPA_WPA2_PSK)
+# max_conn : maximum number of stations can connect to ESP32 SoftAP (should be in range of 1 to 10)
+# ssid_hidden : softAP should broadcast its SSID or not
+# ( 0 : SSID is broadcast
+# 1 : SSID is not broadcast )
+# bw : set bandwidth of ESP32 softAP
+# ( 1 : WIFI_BW_HT20
+# 2 : WIFI_BW_HT40 )
+
+def wifi_set_softap_config(ssid, pwd, chnl, ecn, max_conn, ssid_hidden, bw):
+ set_softap_config = esp_hosted_config_pb2.EspHostedConfigPayload()
+ set_softap_config.msg = esp_hosted_config_pb2.EspHostedConfigMsgType.TypeCmdSetSoftAPConfig
+ set_softap_config.cmd_set_softap_config.ssid = str(ssid)
+ set_softap_config.cmd_set_softap_config.pwd = str(pwd)
+ set_softap_config.cmd_set_softap_config.chnl = chnl
+ set_softap_config.cmd_set_softap_config.ecn = ecn
+ set_softap_config.cmd_set_softap_config.max_conn = max_conn
+ set_softap_config.cmd_set_softap_config.ssid_hidden = ssid_hidden
+ set_softap_config.cmd_set_softap_config.bw = bw
+ protodata = set_softap_config.SerializeToString()
+ #print("serialized data "+str(protodata))
+ tp = transport.Transport_pserial(interface)
+ response = tp.send_data(endpoint,protodata,3)
+ if response == failure :
+ return failure
+ #print("response from slave "+str(response))
+ set_softap_config.ParseFromString(response)
+ status = set_softap_config.resp_set_softap_config.status
+ return status
+
+# get softAP configuration
+# It returns ssid,pwd,chnl,ecn,max_conn,ssid_hidden,status,bw
+# ssid : string parameter, ssid of SoftAP
+# pwd : string parameter, length of password should be 8~64 bytes ASCII
+# chnl : channel ID will be in range of 1 to 11
+# ecn : Encryption method
+# ( 0 : OPEN,
+# 2 : WPA_PSK,
+# 3 : WPA2_PSK,
+# 4 : WPA_WPA2_PSK)
+# max_conn : maximum number of stations can connect to ESP32 SoftAP (will be in range of 1 to 10)
+# ssid_hidden : softAP should broadcast its SSID or not
+# ( 0 : SSID is broadcast
+# 1 : SSID is not broadcast )
+# status : return SUCCESS or FAILURE as result of read operation
+# bw : bandwidth of ESP32 softAP
+# ( 1 : WIFI_BW_HT20
+# 2 : WIFI_BW_HT40 )
+
+def wifi_get_softap_config():
+ get_softap_config = esp_hosted_config_pb2.EspHostedConfigPayload()
+ get_softap_config.msg = esp_hosted_config_pb2.EspHostedConfigMsgType.TypeCmdGetSoftAPConfig
+ protodata = get_softap_config.SerializeToString()
+ #print("serialized data "+str(protodata))
+ tp = transport.Transport_pserial(interface)
+ response = tp.send_data(endpoint,protodata,0.3)
+ if response == failure :
+ return failure
+ #print("response from slave "+str(response))
+ get_softap_config.ParseFromString(response)
+ ssid = str(get_softap_config.resp_get_softap_config.ssid)
+ pwd = str(get_softap_config.resp_get_softap_config.pwd)
+ ecn = get_softap_config.resp_get_softap_config.ecn
+ chnl = get_softap_config.resp_get_softap_config.chnl
+ max_conn = get_softap_config.resp_get_softap_config.max_conn
+ 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,chnl,ecn,max_conn,ssid_hidden,status,bw
+
+# Scan AP list
+# It scans the available APs
+# output is list of Aplist class instances(ssid,chnl,rssi,bssid,ecn)
+
+def wifi_ap_scan_list():
+ get_ap_scan_list = esp_hosted_config_pb2.EspHostedConfigPayload()
+ get_ap_scan_list.msg = esp_hosted_config_pb2.EspHostedConfigMsgType.TypeCmdGetAPScanList
+ protodata = get_ap_scan_list.SerializeToString()
+ #print("serialized data "+str(protodata))
+ tp = transport.Transport_pserial(interface)
+ response = tp.send_data(endpoint,protodata,10)
+ if response == failure :
+ return failure
+ #print("response from slave "+str(response))
+ get_ap_scan_list.ParseFromString(response)
+ count = get_ap_scan_list.resp_scan_ap_list.count
+ ap_list = []
+ for i in range(count) :
+ ssid = get_ap_scan_list.resp_scan_ap_list.entries[i].ssid
+ chnl = get_ap_scan_list.resp_scan_ap_list.entries[i].chnl
+ rssi = get_ap_scan_list.resp_scan_ap_list.entries[i].rssi
+ bssid = get_ap_scan_list.resp_scan_ap_list.entries[i].bssid
+ ecn = get_ap_scan_list.resp_scan_ap_list.entries[i].ecn
+ ap_list.append(Aplist(ssid,chnl,rssi,bssid,ecn))
+ return ap_list
+
+# This function returns the number of connected stations to softAP
+# Maximum 10 connected stations info can get
+# If no station is connected, failure return from slave
+# output is list of Stationlist class instances
+
+def wifi_connected_stations_list():
+ get_connected_stations_list = esp_hosted_config_pb2.EspHostedConfigPayload()
+ get_connected_stations_list.msg = esp_hosted_config_pb2.EspHostedConfigMsgType.TypeCmdGetConnectedSTAList
+ protodata = get_connected_stations_list.SerializeToString()
+ #print("serialized data "+str(protodata))
+ tp = transport.Transport_pserial(interface)
+ response = tp.send_data(endpoint,protodata,1)
+ if response == failure :
+ return failure
+ #print("response from slave "+str(response))
+ get_connected_stations_list.ParseFromString(response)
+ num = get_connected_stations_list.resp_connected_stas_list.num
+ if (num == 0) :
+ print("No station is connected")
+ return failure
+ else :
+ stas_list = []
+ for i in range(num) :
+ mac = get_connected_stations_list.resp_connected_stas_list.stations[i].mac
+ rssi = get_connected_stations_list.resp_connected_stas_list.stations[i].rssi
+ stas_list.append(Stationlist(mac,rssi))
+ return stas_list
--- /dev/null
+# -*- coding: utf-8 -*-
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# source: esp_hosted_config.proto
+
+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
+# @@protoc_insertion_point(imports)
+
+_sym_db = _symbol_database.Default()
+
+
+
+
+DESCRIPTOR = _descriptor.FileDescriptor(
+ name='esp_hosted_config.proto',
+ package='',
+ syntax='proto3',
+ serialized_options=None,
+ serialized_pb=b'\n\x17\x65sp_hosted_config.proto\")\n\x0c\x43mdGetStatus\x12\x0b\n\x03\x63md\x18\x01 \x01(\t\x12\x0c\n\x04mode\x18\x02 \x01(\x05\"+\n\rRespGetStatus\x12\x0c\n\x04resp\x18\x01 \x01(\t\x12\x0c\n\x04mode\x18\x02 \x01(\x05\"\xb2\x01\n\tCmdConfig\x12\x0c\n\x04ssid\x18\x01 \x01(\t\x12\x0b\n\x03pwd\x18\x02 \x01(\t\x12\x1c\n\x03\x65\x63n\x18\x03 \x01(\x0e\x32\x0f.EncryptionMode\x12\x0c\n\x04\x63hnl\x18\x04 \x01(\x05\x12\x10\n\x08max_conn\x18\x05 \x01(\x05\x12\x13\n\x0bssid_hidden\x18\x06 \x01(\x08\x12\r\n\x05\x62ssid\x18\x07 \x01(\t\x12\x0c\n\x04rssi\x18\x08 \x01(\x05\x12\x0e\n\x06status\x18\t \x01(\t\x12\n\n\x02\x62w\x18\n \x01(\x05\"\xb3\x01\n\nRespConfig\x12\x0c\n\x04ssid\x18\x01 \x01(\t\x12\x0b\n\x03pwd\x18\x02 \x01(\t\x12\x1c\n\x03\x65\x63n\x18\x03 \x01(\x0e\x32\x0f.EncryptionMode\x12\x0c\n\x04\x63hnl\x18\x04 \x01(\x05\x12\x10\n\x08max_conn\x18\x05 \x01(\x05\x12\x13\n\x0bssid_hidden\x18\x06 \x01(\x08\x12\r\n\x05\x62ssid\x18\x07 \x01(\t\x12\x0c\n\x04rssi\x18\x08 \x01(\x05\x12\x0e\n\x06status\x18\t \x01(\t\x12\n\n\x02\x62w\x18\n \x01(\x05\"c\n\nScanResult\x12\x0c\n\x04ssid\x18\x01 \x01(\x0c\x12\x0c\n\x04\x63hnl\x18\x02 \x01(\r\x12\x0c\n\x04rssi\x18\x03 \x01(\x05\x12\r\n\x05\x62ssid\x18\x04 \x01(\x0c\x12\x1c\n\x03\x65\x63n\x18\x05 \x01(\x0e\x32\x0f.EncryptionMode\"\x0f\n\rCmdScanResult\"=\n\x0eRespScanResult\x12\r\n\x05\x63ount\x18\x01 \x01(\r\x12\x1c\n\x07\x65ntries\x18\x02 \x03(\x0b\x32\x0b.ScanResult\"-\n\x10\x43onnectedSTAList\x12\x0b\n\x03mac\x18\x01 \x01(\x0c\x12\x0c\n\x04rssi\x18\x02 \x01(\x05\"\x11\n\x0f\x43mdConnectedSTA\"D\n\x10RespConnectedSTA\x12\x0b\n\x03num\x18\x01 \x01(\r\x12#\n\x08stations\x18\x02 \x03(\x0b\x32\x11.ConnectedSTAList\"\xdb\x07\n\x16\x45spHostedConfigPayload\x12$\n\x03msg\x18\x01 \x01(\x0e\x32\x17.EspHostedConfigMsgType\x12,\n\x13\x63md_get_mac_address\x18\n \x01(\x0b\x32\r.CmdGetStatusH\x00\x12.\n\x14resp_get_mac_address\x18\x0b \x01(\x0b\x32\x0e.RespGetStatusH\x00\x12*\n\x11\x63md_get_wifi_mode\x18\x0c \x01(\x0b\x32\r.CmdGetStatusH\x00\x12,\n\x12resp_get_wifi_mode\x18\r \x01(\x0b\x32\x0e.RespGetStatusH\x00\x12*\n\x11\x63md_set_wifi_mode\x18\x0e \x01(\x0b\x32\r.CmdGetStatusH\x00\x12,\n\x12resp_set_wifi_mode\x18\x0f \x01(\x0b\x32\x0e.RespGetStatusH\x00\x12\'\n\x11\x63md_get_ap_config\x18\x10 \x01(\x0b\x32\n.CmdConfigH\x00\x12)\n\x12resp_get_ap_config\x18\x11 \x01(\x0b\x32\x0b.RespConfigH\x00\x12\'\n\x11\x63md_set_ap_config\x18\x12 \x01(\x0b\x32\n.CmdConfigH\x00\x12)\n\x12resp_set_ap_config\x18\x13 \x01(\x0b\x32\x0b.RespConfigH\x00\x12+\n\x15\x63md_get_softap_config\x18\x14 \x01(\x0b\x32\n.CmdConfigH\x00\x12-\n\x16resp_get_softap_config\x18\x15 \x01(\x0b\x32\x0b.RespConfigH\x00\x12+\n\x15\x63md_set_softap_config\x18\x16 \x01(\x0b\x32\n.CmdConfigH\x00\x12-\n\x16resp_set_softap_config\x18\x17 \x01(\x0b\x32\x0b.RespConfigH\x00\x12*\n\x11\x63md_disconnect_ap\x18\x18 \x01(\x0b\x32\r.CmdGetStatusH\x00\x12,\n\x12resp_disconnect_ap\x18\x19 \x01(\x0b\x32\x0e.RespGetStatusH\x00\x12*\n\x10\x63md_scan_ap_list\x18\x1a \x01(\x0b\x32\x0e.CmdScanResultH\x00\x12,\n\x11resp_scan_ap_list\x18\x1b \x01(\x0b\x32\x0f.RespScanResultH\x00\x12\x33\n\x17\x63md_connected_stas_list\x18\x1c \x01(\x0b\x32\x10.CmdConnectedSTAH\x00\x12\x35\n\x18resp_connected_stas_list\x18\x1d \x01(\x0b\x32\x11.RespConnectedSTAH\x00\x42\t\n\x07payload*\x83\x01\n\x0e\x45ncryptionMode\x12\r\n\tType_Open\x10\x00\x12\x0c\n\x08Type_WEP\x10\x01\x12\x10\n\x0cType_WPA_PSK\x10\x02\x12\x11\n\rType_WPA2_PSK\x10\x03\x12\x15\n\x11Type_WPA_WPA2_PSK\x10\x04\x12\x18\n\x14Type_WPA2_ENTERPRISE\x10\x05*\xac\x04\n\x16\x45spHostedConfigMsgType\x12\x18\n\x14TypeCmdGetMACAddress\x10\x00\x12\x19\n\x15TypeRespGetMACAddress\x10\x01\x12\x16\n\x12TypeCmdGetWiFiMode\x10\x02\x12\x17\n\x13TypeRespGetWiFiMode\x10\x03\x12\x16\n\x12TypeCmdSetWiFiMode\x10\x04\x12\x17\n\x13TypeRespSetWiFiMode\x10\x05\x12\x16\n\x12TypeCmdGetAPConfig\x10\x06\x12\x17\n\x13TypeRespGetAPConfig\x10\x07\x12\x16\n\x12TypeCmdSetAPConfig\x10\x08\x12\x17\n\x13TypeRespSetAPConfig\x10\t\x12\x1a\n\x16TypeCmdGetSoftAPConfig\x10\n\x12\x1b\n\x17TypeRespGetSoftAPConfig\x10\x0b\x12\x1a\n\x16TypeCmdSetSoftAPConfig\x10\x0c\x12\x1b\n\x17TypeRespSetSoftAPConfig\x10\r\x12\x17\n\x13TypeCmdDisconnectAP\x10\x0e\x12\x18\n\x14TypeRespDisconnectAP\x10\x0f\x12\x18\n\x14TypeCmdGetAPScanList\x10\x10\x12\x19\n\x15TypeRespGetAPScanList\x10\x11\x12\x1e\n\x1aTypeCmdGetConnectedSTAList\x10\x12\x12\x1f\n\x1bTypeRespGetConnectedSTAList\x10\x13\x62\x06proto3'
+)
+
+_ENCRYPTIONMODE = _descriptor.EnumDescriptor(
+ name='EncryptionMode',
+ full_name='EncryptionMode',
+ filename=None,
+ file=DESCRIPTOR,
+ values=[
+ _descriptor.EnumValueDescriptor(
+ name='Type_Open', index=0, number=0,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='Type_WEP', index=1, number=1,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='Type_WPA_PSK', index=2, number=2,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='Type_WPA2_PSK', index=3, number=3,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='Type_WPA_WPA2_PSK', index=4, number=4,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='Type_WPA2_ENTERPRISE', index=5, number=5,
+ serialized_options=None,
+ type=None),
+ ],
+ containing_type=None,
+ serialized_options=None,
+ serialized_start=1786,
+ serialized_end=1917,
+)
+_sym_db.RegisterEnumDescriptor(_ENCRYPTIONMODE)
+
+EncryptionMode = enum_type_wrapper.EnumTypeWrapper(_ENCRYPTIONMODE)
+_ESPHOSTEDCONFIGMSGTYPE = _descriptor.EnumDescriptor(
+ name='EspHostedConfigMsgType',
+ full_name='EspHostedConfigMsgType',
+ filename=None,
+ file=DESCRIPTOR,
+ values=[
+ _descriptor.EnumValueDescriptor(
+ name='TypeCmdGetMACAddress', index=0, number=0,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='TypeRespGetMACAddress', index=1, number=1,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='TypeCmdGetWiFiMode', index=2, number=2,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='TypeRespGetWiFiMode', index=3, number=3,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='TypeCmdSetWiFiMode', index=4, number=4,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='TypeRespSetWiFiMode', index=5, number=5,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='TypeCmdGetAPConfig', index=6, number=6,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='TypeRespGetAPConfig', index=7, number=7,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='TypeCmdSetAPConfig', index=8, number=8,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='TypeRespSetAPConfig', index=9, number=9,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='TypeCmdGetSoftAPConfig', index=10, number=10,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='TypeRespGetSoftAPConfig', index=11, number=11,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='TypeCmdSetSoftAPConfig', index=12, number=12,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='TypeRespSetSoftAPConfig', index=13, number=13,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='TypeCmdDisconnectAP', index=14, number=14,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='TypeRespDisconnectAP', index=15, number=15,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='TypeCmdGetAPScanList', index=16, number=16,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='TypeRespGetAPScanList', index=17, number=17,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='TypeCmdGetConnectedSTAList', index=18, number=18,
+ serialized_options=None,
+ type=None),
+ _descriptor.EnumValueDescriptor(
+ name='TypeRespGetConnectedSTAList', index=19, number=19,
+ serialized_options=None,
+ type=None),
+ ],
+ containing_type=None,
+ serialized_options=None,
+ serialized_start=1920,
+ serialized_end=2476,
+)
+_sym_db.RegisterEnumDescriptor(_ESPHOSTEDCONFIGMSGTYPE)
+
+EspHostedConfigMsgType = enum_type_wrapper.EnumTypeWrapper(_ESPHOSTEDCONFIGMSGTYPE)
+Type_Open = 0
+Type_WEP = 1
+Type_WPA_PSK = 2
+Type_WPA2_PSK = 3
+Type_WPA_WPA2_PSK = 4
+Type_WPA2_ENTERPRISE = 5
+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
+TypeCmdGetConnectedSTAList = 18
+TypeRespGetConnectedSTAList = 19
+
+
+
+_CMDGETSTATUS = _descriptor.Descriptor(
+ name='CmdGetStatus',
+ full_name='CmdGetStatus',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='cmd', full_name='CmdGetStatus.cmd', 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='mode', full_name='CmdGetStatus.mode', index=1,
+ number=2, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ serialized_options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=27,
+ serialized_end=68,
+)
+
+
+_RESPGETSTATUS = _descriptor.Descriptor(
+ name='RespGetStatus',
+ full_name='RespGetStatus',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='resp', full_name='RespGetStatus.resp', 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='mode', full_name='RespGetStatus.mode', index=1,
+ number=2, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ serialized_options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=70,
+ serialized_end=113,
+)
+
+
+_CMDCONFIG = _descriptor.Descriptor(
+ name='CmdConfig',
+ full_name='CmdConfig',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='ssid', full_name='CmdConfig.ssid', 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='pwd', full_name='CmdConfig.pwd', index=1,
+ number=2, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='ecn', full_name='CmdConfig.ecn', index=2,
+ number=3, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='chnl', full_name='CmdConfig.chnl', 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='max_conn', full_name='CmdConfig.max_conn', 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='ssid_hidden', full_name='CmdConfig.ssid_hidden', index=5,
+ number=6, type=8, cpp_type=7, label=1,
+ has_default_value=False, default_value=False,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='bssid', full_name='CmdConfig.bssid', index=6,
+ number=7, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='rssi', full_name='CmdConfig.rssi', index=7,
+ number=8, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='status', full_name='CmdConfig.status', index=8,
+ number=9, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='bw', full_name='CmdConfig.bw', index=9,
+ number=10, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ serialized_options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=116,
+ serialized_end=294,
+)
+
+
+_RESPCONFIG = _descriptor.Descriptor(
+ name='RespConfig',
+ full_name='RespConfig',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='ssid', full_name='RespConfig.ssid', 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='pwd', full_name='RespConfig.pwd', index=1,
+ number=2, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='ecn', full_name='RespConfig.ecn', index=2,
+ number=3, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='chnl', full_name='RespConfig.chnl', 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='max_conn', full_name='RespConfig.max_conn', 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='ssid_hidden', full_name='RespConfig.ssid_hidden', index=5,
+ number=6, type=8, cpp_type=7, label=1,
+ has_default_value=False, default_value=False,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='bssid', full_name='RespConfig.bssid', index=6,
+ number=7, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='rssi', full_name='RespConfig.rssi', index=7,
+ number=8, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='status', full_name='RespConfig.status', index=8,
+ number=9, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='bw', full_name='RespConfig.bw', index=9,
+ number=10, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ serialized_options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=297,
+ serialized_end=476,
+)
+
+
+_SCANRESULT = _descriptor.Descriptor(
+ name='ScanResult',
+ full_name='ScanResult',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='ssid', full_name='ScanResult.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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='chnl', full_name='ScanResult.chnl', index=1,
+ number=2, type=13, cpp_type=3, label=1,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='rssi', full_name='ScanResult.rssi', index=2,
+ number=3, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='bssid', full_name='ScanResult.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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='ecn', full_name='ScanResult.ecn', index=4,
+ number=5, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ serialized_options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=478,
+ serialized_end=577,
+)
+
+
+_CMDSCANRESULT = _descriptor.Descriptor(
+ name='CmdScanResult',
+ full_name='CmdScanResult',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ serialized_options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=579,
+ serialized_end=594,
+)
+
+
+_RESPSCANRESULT = _descriptor.Descriptor(
+ name='RespScanResult',
+ full_name='RespScanResult',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='count', full_name='RespScanResult.count', index=0,
+ number=1, type=13, cpp_type=3, label=1,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='entries', full_name='RespScanResult.entries', index=1,
+ number=2, type=11, cpp_type=10, label=3,
+ has_default_value=False, default_value=[],
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ serialized_options=None, file=DESCRIPTOR),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ serialized_options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=596,
+ serialized_end=657,
+)
+
+
+_CONNECTEDSTALIST = _descriptor.Descriptor(
+ name='ConnectedSTAList',
+ full_name='ConnectedSTAList',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='mac', full_name='ConnectedSTAList.mac', 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='rssi', full_name='ConnectedSTAList.rssi', index=1,
+ number=2, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ serialized_options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=659,
+ serialized_end=704,
+)
+
+
+_CMDCONNECTEDSTA = _descriptor.Descriptor(
+ name='CmdConnectedSTA',
+ full_name='CmdConnectedSTA',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ serialized_options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=706,
+ serialized_end=723,
+)
+
+
+_RESPCONNECTEDSTA = _descriptor.Descriptor(
+ name='RespConnectedSTA',
+ full_name='RespConnectedSTA',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='num', full_name='RespConnectedSTA.num', index=0,
+ number=1, type=13, cpp_type=3, label=1,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='stations', full_name='RespConnectedSTA.stations', index=1,
+ number=2, type=11, cpp_type=10, label=3,
+ has_default_value=False, default_value=[],
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ serialized_options=None, file=DESCRIPTOR),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ serialized_options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=725,
+ serialized_end=793,
+)
+
+
+_ESPHOSTEDCONFIGPAYLOAD = _descriptor.Descriptor(
+ name='EspHostedConfigPayload',
+ full_name='EspHostedConfigPayload',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='msg', full_name='EspHostedConfigPayload.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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='cmd_get_mac_address', full_name='EspHostedConfigPayload.cmd_get_mac_address', 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='resp_get_mac_address', full_name='EspHostedConfigPayload.resp_get_mac_address', 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='cmd_get_wifi_mode', full_name='EspHostedConfigPayload.cmd_get_wifi_mode', 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='resp_get_wifi_mode', full_name='EspHostedConfigPayload.resp_get_wifi_mode', 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='cmd_set_wifi_mode', full_name='EspHostedConfigPayload.cmd_set_wifi_mode', 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='resp_set_wifi_mode', full_name='EspHostedConfigPayload.resp_set_wifi_mode', 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='cmd_get_ap_config', full_name='EspHostedConfigPayload.cmd_get_ap_config', index=7,
+ number=16, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='resp_get_ap_config', full_name='EspHostedConfigPayload.resp_get_ap_config', index=8,
+ number=17, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='cmd_set_ap_config', full_name='EspHostedConfigPayload.cmd_set_ap_config', index=9,
+ number=18, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='resp_set_ap_config', full_name='EspHostedConfigPayload.resp_set_ap_config', index=10,
+ number=19, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='cmd_get_softap_config', full_name='EspHostedConfigPayload.cmd_get_softap_config', index=11,
+ number=20, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='resp_get_softap_config', full_name='EspHostedConfigPayload.resp_get_softap_config', index=12,
+ number=21, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='cmd_set_softap_config', full_name='EspHostedConfigPayload.cmd_set_softap_config', index=13,
+ number=22, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='resp_set_softap_config', full_name='EspHostedConfigPayload.resp_set_softap_config', index=14,
+ number=23, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='cmd_disconnect_ap', full_name='EspHostedConfigPayload.cmd_disconnect_ap', index=15,
+ number=24, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='resp_disconnect_ap', full_name='EspHostedConfigPayload.resp_disconnect_ap', index=16,
+ number=25, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='cmd_scan_ap_list', full_name='EspHostedConfigPayload.cmd_scan_ap_list', index=17,
+ number=26, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='resp_scan_ap_list', full_name='EspHostedConfigPayload.resp_scan_ap_list', index=18,
+ number=27, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='cmd_connected_stas_list', full_name='EspHostedConfigPayload.cmd_connected_stas_list', index=19,
+ number=28, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='resp_connected_stas_list', full_name='EspHostedConfigPayload.resp_connected_stas_list', index=20,
+ number=29, 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,
+ serialized_options=None, file=DESCRIPTOR),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ serialized_options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ _descriptor.OneofDescriptor(
+ name='payload', full_name='EspHostedConfigPayload.payload',
+ index=0, containing_type=None, fields=[]),
+ ],
+ serialized_start=796,
+ serialized_end=1783,
+)
+
+_CMDCONFIG.fields_by_name['ecn'].enum_type = _ENCRYPTIONMODE
+_RESPCONFIG.fields_by_name['ecn'].enum_type = _ENCRYPTIONMODE
+_SCANRESULT.fields_by_name['ecn'].enum_type = _ENCRYPTIONMODE
+_RESPSCANRESULT.fields_by_name['entries'].message_type = _SCANRESULT
+_RESPCONNECTEDSTA.fields_by_name['stations'].message_type = _CONNECTEDSTALIST
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['msg'].enum_type = _ESPHOSTEDCONFIGMSGTYPE
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_mac_address'].message_type = _CMDGETSTATUS
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_mac_address'].message_type = _RESPGETSTATUS
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_wifi_mode'].message_type = _CMDGETSTATUS
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_wifi_mode'].message_type = _RESPGETSTATUS
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_wifi_mode'].message_type = _CMDGETSTATUS
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_wifi_mode'].message_type = _RESPGETSTATUS
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_ap_config'].message_type = _CMDCONFIG
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_ap_config'].message_type = _RESPCONFIG
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_ap_config'].message_type = _CMDCONFIG
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_ap_config'].message_type = _RESPCONFIG
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_softap_config'].message_type = _CMDCONFIG
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_softap_config'].message_type = _RESPCONFIG
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_softap_config'].message_type = _CMDCONFIG
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_softap_config'].message_type = _RESPCONFIG
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_disconnect_ap'].message_type = _CMDGETSTATUS
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_disconnect_ap'].message_type = _RESPGETSTATUS
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_scan_ap_list'].message_type = _CMDSCANRESULT
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_scan_ap_list'].message_type = _RESPSCANRESULT
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_connected_stas_list'].message_type = _CMDCONNECTEDSTA
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_connected_stas_list'].message_type = _RESPCONNECTEDSTA
+_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+ _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_mac_address'])
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_mac_address'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
+_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+ _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_mac_address'])
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_mac_address'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
+_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+ _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_wifi_mode'])
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_wifi_mode'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
+_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+ _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_wifi_mode'])
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_wifi_mode'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
+_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+ _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_wifi_mode'])
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_wifi_mode'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
+_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+ _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_wifi_mode'])
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_wifi_mode'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
+_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+ _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_ap_config'])
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_ap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
+_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+ _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_ap_config'])
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_ap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
+_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+ _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_ap_config'])
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_ap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
+_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+ _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_ap_config'])
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_ap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
+_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+ _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_softap_config'])
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_get_softap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
+_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+ _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_softap_config'])
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_get_softap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
+_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+ _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_softap_config'])
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_set_softap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
+_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+ _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_softap_config'])
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_set_softap_config'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
+_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+ _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_disconnect_ap'])
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_disconnect_ap'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
+_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+ _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_disconnect_ap'])
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_disconnect_ap'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
+_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+ _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_scan_ap_list'])
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_scan_ap_list'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
+_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+ _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_scan_ap_list'])
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_scan_ap_list'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
+_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+ _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_connected_stas_list'])
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['cmd_connected_stas_list'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
+_ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload'].fields.append(
+ _ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_connected_stas_list'])
+_ESPHOSTEDCONFIGPAYLOAD.fields_by_name['resp_connected_stas_list'].containing_oneof = _ESPHOSTEDCONFIGPAYLOAD.oneofs_by_name['payload']
+DESCRIPTOR.message_types_by_name['CmdGetStatus'] = _CMDGETSTATUS
+DESCRIPTOR.message_types_by_name['RespGetStatus'] = _RESPGETSTATUS
+DESCRIPTOR.message_types_by_name['CmdConfig'] = _CMDCONFIG
+DESCRIPTOR.message_types_by_name['RespConfig'] = _RESPCONFIG
+DESCRIPTOR.message_types_by_name['ScanResult'] = _SCANRESULT
+DESCRIPTOR.message_types_by_name['CmdScanResult'] = _CMDSCANRESULT
+DESCRIPTOR.message_types_by_name['RespScanResult'] = _RESPSCANRESULT
+DESCRIPTOR.message_types_by_name['ConnectedSTAList'] = _CONNECTEDSTALIST
+DESCRIPTOR.message_types_by_name['CmdConnectedSTA'] = _CMDCONNECTEDSTA
+DESCRIPTOR.message_types_by_name['RespConnectedSTA'] = _RESPCONNECTEDSTA
+DESCRIPTOR.message_types_by_name['EspHostedConfigPayload'] = _ESPHOSTEDCONFIGPAYLOAD
+DESCRIPTOR.enum_types_by_name['EncryptionMode'] = _ENCRYPTIONMODE
+DESCRIPTOR.enum_types_by_name['EspHostedConfigMsgType'] = _ESPHOSTEDCONFIGMSGTYPE
+_sym_db.RegisterFileDescriptor(DESCRIPTOR)
+
+CmdGetStatus = _reflection.GeneratedProtocolMessageType('CmdGetStatus', (_message.Message,), {
+ 'DESCRIPTOR' : _CMDGETSTATUS,
+ '__module__' : 'esp_hosted_config_pb2'
+ # @@protoc_insertion_point(class_scope:CmdGetStatus)
+ })
+_sym_db.RegisterMessage(CmdGetStatus)
+
+RespGetStatus = _reflection.GeneratedProtocolMessageType('RespGetStatus', (_message.Message,), {
+ 'DESCRIPTOR' : _RESPGETSTATUS,
+ '__module__' : 'esp_hosted_config_pb2'
+ # @@protoc_insertion_point(class_scope:RespGetStatus)
+ })
+_sym_db.RegisterMessage(RespGetStatus)
+
+CmdConfig = _reflection.GeneratedProtocolMessageType('CmdConfig', (_message.Message,), {
+ 'DESCRIPTOR' : _CMDCONFIG,
+ '__module__' : 'esp_hosted_config_pb2'
+ # @@protoc_insertion_point(class_scope:CmdConfig)
+ })
+_sym_db.RegisterMessage(CmdConfig)
+
+RespConfig = _reflection.GeneratedProtocolMessageType('RespConfig', (_message.Message,), {
+ 'DESCRIPTOR' : _RESPCONFIG,
+ '__module__' : 'esp_hosted_config_pb2'
+ # @@protoc_insertion_point(class_scope:RespConfig)
+ })
+_sym_db.RegisterMessage(RespConfig)
+
+ScanResult = _reflection.GeneratedProtocolMessageType('ScanResult', (_message.Message,), {
+ 'DESCRIPTOR' : _SCANRESULT,
+ '__module__' : 'esp_hosted_config_pb2'
+ # @@protoc_insertion_point(class_scope:ScanResult)
+ })
+_sym_db.RegisterMessage(ScanResult)
+
+CmdScanResult = _reflection.GeneratedProtocolMessageType('CmdScanResult', (_message.Message,), {
+ 'DESCRIPTOR' : _CMDSCANRESULT,
+ '__module__' : 'esp_hosted_config_pb2'
+ # @@protoc_insertion_point(class_scope:CmdScanResult)
+ })
+_sym_db.RegisterMessage(CmdScanResult)
+
+RespScanResult = _reflection.GeneratedProtocolMessageType('RespScanResult', (_message.Message,), {
+ 'DESCRIPTOR' : _RESPSCANRESULT,
+ '__module__' : 'esp_hosted_config_pb2'
+ # @@protoc_insertion_point(class_scope:RespScanResult)
+ })
+_sym_db.RegisterMessage(RespScanResult)
+
+ConnectedSTAList = _reflection.GeneratedProtocolMessageType('ConnectedSTAList', (_message.Message,), {
+ 'DESCRIPTOR' : _CONNECTEDSTALIST,
+ '__module__' : 'esp_hosted_config_pb2'
+ # @@protoc_insertion_point(class_scope:ConnectedSTAList)
+ })
+_sym_db.RegisterMessage(ConnectedSTAList)
+
+CmdConnectedSTA = _reflection.GeneratedProtocolMessageType('CmdConnectedSTA', (_message.Message,), {
+ 'DESCRIPTOR' : _CMDCONNECTEDSTA,
+ '__module__' : 'esp_hosted_config_pb2'
+ # @@protoc_insertion_point(class_scope:CmdConnectedSTA)
+ })
+_sym_db.RegisterMessage(CmdConnectedSTA)
+
+RespConnectedSTA = _reflection.GeneratedProtocolMessageType('RespConnectedSTA', (_message.Message,), {
+ 'DESCRIPTOR' : _RESPCONNECTEDSTA,
+ '__module__' : 'esp_hosted_config_pb2'
+ # @@protoc_insertion_point(class_scope:RespConnectedSTA)
+ })
+_sym_db.RegisterMessage(RespConnectedSTA)
+
+EspHostedConfigPayload = _reflection.GeneratedProtocolMessageType('EspHostedConfigPayload', (_message.Message,), {
+ 'DESCRIPTOR' : _ESPHOSTEDCONFIGPAYLOAD,
+ '__module__' : 'esp_hosted_config_pb2'
+ # @@protoc_insertion_point(class_scope:EspHostedConfigPayload)
+ })
+_sym_db.RegisterMessage(EspHostedConfigPayload)
+
+
+# @@protoc_insertion_point(module_scope)
--- /dev/null
+# Copyright 2015-2020 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 .transport_pserial import * # noqa: F403, F401
--- /dev/null
+# Copyright 2015-2020 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.
+#
+
+# Base class for protocomm transport
+
+import abc
+
+
+class Transport():
+
+ @abc.abstractmethod
+ def send_session_data(self, data):
+ pass
+
+ @abc.abstractmethod
+ def send_config_data(self, data):
+ pass
--- /dev/null
+# Copyright 2015-2020 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 struct import *
+from .transport import Transport
+import binascii
+import time
+import utils
+
+failure = "failure"
+
+class Transport_pserial(Transport):
+ def __init__(self, devname):
+ self.f1 = open(devname, "wb",buffering = 1024)
+ self.f2 = open(devname, "rb",buffering = 1024)
+
+ def send_data(self, ep_name, data, wait):
+ buf = bytearray([0x01])
+ buf.extend(pack('<H', len(ep_name)))
+ buf.extend(map(ord,ep_name))
+ buf.extend(b'\x02')
+ buf.extend(pack('<H', len(data)))
+ #print(bytearray(data))
+ buf.extend(bytearray(data))
+ s = self.f1.write(buf)
+ self.f1.flush()
+ time.sleep(wait)
+ try:
+ s = self.f2.read()
+ except IOError:
+ return failure
+ self.f2.flush()
+ return s
+
--- /dev/null
+#!/bin/sh
+
+# Copyright 2015-2020 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.
+
+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 [ "$1" = "-h" ]; then
+ echo "This script prepares RPI for wlan and bt/ble operation over esp32 device"
+ echo "\nUsage: ./rpi_init.sh [arguments]"
+ echo "\nArguments are optional and are as below"
+ echo " btuart: Set GPIO pins on RPi for HCI UART operations"
+ echo "\nExample:"
+ echo " - Prepare RPi for WLAN and bt/ble operation on SDIO"
+ echo " # ./rpi_init.sh"
+ echo "\n - Prepare RPi for bt/ble operation over UART and WLAN over SDIO"
+ echo " # ./rpi_init.sh btuart"
+ exit 0
+fi
+
+sudo modprobe bluetooth
+wlan_init
+
+if [ "$1" = "btuart" ]; then
+ bt_init
+fi
+
--- /dev/null
+# Copyright 2015-2020 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 commands
+import argparse
+import time
+import os
+
+# WiFi Mode
+# NULL 0
+# Station 1
+# SoftAP 2
+# Station+SoftAP 3
+
+none = 0
+station = 1
+softap = 2
+station_softap = 3
+success = 'success'
+failure = 'failure'
+flag = success
+softap_config = 'Not set'
+
+parser = argparse.ArgumentParser(description='softap_config.py script to configure ESP32 softAP mode. ex. python softap_config.py \'xyz\' \'xyz123456\' 1 3 --max_conn=4 --ssid_hidden=0 --bw=1')
+
+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()
+
+ap_mac = commands.get_mac(softap)
+if (ap_mac == failure):
+ print("Failed to get is SoftAP mac address")
+ flag = failure
+else :
+ print("SoftAP MAC Address "+str(ap_mac))
+
+if (flag == success):
+ softap_config = commands.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 == failure):
+ print("setting softap config failed")
+ flag = failure
+ else:
+ print("setting softap config success")
+
+if (flag == failure):
+ print("failure in setting SoftAP 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 = 'sudo ifconfig ethap0 up'
+ os.system(command)
+ print(command)
+
+ time.sleep(1)
+
+ print("softAP config successfully set")
--- /dev/null
+# Copyright 2015-2020 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 commands
+import argparse
+import os
+
+# WiFi Mode
+# NULL 0
+# Station 1
+# SoftAP 2
+# Station + SoftAP 3
+
+none = 0
+station = 1
+softap = 2
+station_softap = 3
+failure = "failure"
+success = "success"
+stop = "Not set"
+flag = success
+
+parser = argparse.ArgumentParser(description='softap_stop.py script will stop ESP32 softap ex. python softap_close.py')
+
+wifi_mode = commands.get_wifi_mode()
+print("WiFi Mode: "+str(wifi_mode))
+
+if (wifi_mode == failure):
+ print("Failed to get wifi mode")
+ flag = failure
+elif (wifi_mode == softap):
+ wifi_mode = commands.set_wifi_mode(none)
+ if (wifi_mode == failure):
+ print("Failed to stop softap")
+ flag = failure
+ else :
+ print("SoftAP stopped")
+elif (wifi_mode == station_softap):
+ wifi_mode = commands.set_wifi_mode(station)
+ if (wifi_mode == failure):
+ print("failure in stopping softap")
+ flag = failure
+ else :
+ print("SoftAP stopped")
+
+if (flag == success):
+ command = 'sudo ifconfig ethap0 down'
+ os.system(command)
+ print(command)
+ print("SoftAP interface down")
--- /dev/null
+# Copyright 2015-2020 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 commands
+import argparse
+import time
+import os
+
+# WiFi Mode
+# NULL 0
+# Station 1
+# SoftAP 2
+# Station + SoftAP 3
+
+none = 0
+station = 1
+softap = 2
+station_softap = 3
+failure = "failure"
+success = "success"
+flag = success
+station_status = 'Nothing set'
+
+parser = argparse.ArgumentParser(description='station_connect.py is a python script which connect ESPstation to AP. ex. python 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()
+
+sta_mac = commands.get_mac(station)
+if (sta_mac == failure):
+ flag = failure
+ print("Failed to get station MAC address")
+else :
+ print("station MAC address "+str(sta_mac))
+
+if (flag == success):
+ station_status = commands.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 "+args.ssid)
+
+if (flag == failure):
+ print("Failed to connect with 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 = 'sudo ifconfig ethsta0 up'
+ os.system(command)
+ print(command)
+
+ time.sleep(1)
+
+ command = 'sudo dhclient ethsta0 -r'
+ os.system(command)
+ print(command)
+
+ command = 'sudo dhclient ethsta0 -v'
+ os.system(command)
+ print(command)
+
+ print("Success in setting AP config")
+
--- /dev/null
+# Copyright 2015-2020 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 commands
+import argparse
+import os
+
+# WiFi Mode
+# NULL 0
+# Station 1
+# SoftAP 2
+# Station + SoftAP 3
+
+none = 0
+station = 1
+softap = 2
+station_softap = 3
+failure = "failure"
+success = "success"
+flag = success
+disconnect = "Not set"
+
+parser = argparse.ArgumentParser(description='station_disconnect.py script will disconnect ESPStation from AP ex. python station_disconnect.py')
+
+wifi_mode = commands.get_wifi_mode()
+print("WiFi Mode: "+str(wifi_mode))
+
+if (wifi_mode == failure):
+ print("Failed to get WiFi Mode")
+ flag = failure
+elif (wifi_mode == station or wifi_mode == station_softap):
+ disconnect = commands.wifi_disconnect_ap()
+ if (disconnect == failure):
+ print("Failed to Disconnected from AP")
+ flag = failure
+ else :
+ print("Success in Disconnecting from AP")
+else :
+ print("Station is not enabled")
+ flag = failure
+
+if (flag == success):
+ command = 'sudo dhclient ethsta0 -r'
+ print('$ '+command)
+ os.system(command)
+
+ command = 'sudo ifconfig ethsta0 down'
+ print('$ '+command)
+ os.system(command)
+
--- /dev/null
+# Copyright 2015-2020 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 commands
+failure = 'failure'
+# get mac address
+
+# 1 : station
+# 2 : softAP
+'''
+x = commands.get_mac(2)
+print("sta mac "+str(x))
+
+# 0: null Mode, Wi-Fi mode not set
+# 1: station mode
+# 2: softAP mode
+# 3: softAP+station mode
+# or Failure
+
+x = commands.get_wifi_mode()
+print("wifi mode is "+str(x))
+
+x = commands.set_wifi_mode(2)
+print("connected mode is "+str(x))
+
+x = commands.wifi_set_ap_config('xyz','xyz123456','0')
+print(x)
+
+x = commands.wifi_get_ap_config()
+print(x)
+
+x = commands.wifi_disconnect_ap()
+print(x)
+
+x = commands.wifi_set_softap_config('ESP12','0',4,0,5,0,1)
+print(x)
+
+x = commands.wifi_get_softap_config()
+print(x)
+
+# output is list of Aplist class instances
+x = commands.wifi_ap_scan_list()
+print(x)
+if (x == failure):
+ print(failure)
+else:
+ for obj in x:
+ print(obj.ssid,obj.chnl,obj.rssi,obj.bssid,obj.ecn)
+
+
+# output is list of Stationlist class instances
+x = commands.wifi_connected_stations_list()
+print(x)
+if (x == failure):
+ print(failure)
+else :
+ for obj in x:
+ print(obj.mac)
+'''
--- /dev/null
+GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ {description}
+ Copyright (C) {year} {fullname}
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ {signature of Ty Coon}, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
+
--- /dev/null
+CONFIG_SUPPORT_ESP_SERIAL = y
+CONFIG_ENABLE_MONITOR_PROCESS = n
+
+ifeq ($(CONFIG_SUPPORT_ESP_SERIAL), y)
+ EXTRA_CFLAGS += -DCONFIG_SUPPORT_ESP_SERIAL
+endif
+
+ifeq ($(CONFIG_ENABLE_MONITOR_PROCESS), y)
+ EXTRA_CFLAGS += -DCONFIG_ENABLE_MONITOR_PROCESS
+endif
+
+EXTRA_CFLAGS += -I$(PWD)/../../../common/include
+
+CR_C := arm-linux-gnueabihf-
+PWD := $(shell pwd)
+obj-m := esp32.o
+
+esp32-y := esp_sdio.o esp_sdio_api.o esp_bt.o main.o
+ifeq ($(CONFIG_SUPPORT_ESP_SERIAL), y)
+esp32-y += esp_serial.o esp_rb.o
+endif
+
+all:
+ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+clean:
+ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
+
--- /dev/null
+/*
+ * Espressif Systems Wireless LAN device driver
+ *
+ * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
+ *
+ * This software file (the "File") is distributed by Espressif Systems (Shanghai)
+ * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
+ * (the "License"). You may use, redistribute and/or modify this File in
+ * accordance with the terms and conditions of the License, a copy of which
+ * is available by writing to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
+ * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
+ * this warranty disclaimer.
+ */
+
+#ifndef __esp__h_
+#define __esp__h_
+
+#include <linux/workqueue.h>
+#include <linux/interrupt.h>
+#include <linux/netdevice.h>
+#include <net/bluetooth/bluetooth.h>
+#include <net/bluetooth/hci_core.h>
+#include "adapter.h"
+
+#define ESP_IF_TYPE_SDIO 1
+
+/* Network link status */
+#define ESP_LINK_DOWN 0
+#define ESP_LINK_UP 1
+
+#define ESP_MAX_INTERFACE 2
+
+#define ESP_PAYLOAD_HEADER 8
+struct esp_private;
+struct esp_adapter;
+
+#define ACQUIRE_LOCK 1
+#define LOCK_ALREADY_ACQUIRED 0
+
+struct esp_adapter {
+ u8 if_type;
+ u32 capabilities;
+
+ /* Possible types:
+ * struct esp_sdio_context */
+ void *if_context;
+
+ struct esp_if_ops *if_ops;
+
+ /* Private for each interface */
+ struct esp_private *priv[ESP_MAX_INTERFACE];
+ struct hci_dev *hcidev;
+
+ struct workqueue_struct *if_rx_workqueue;
+ struct work_struct if_rx_work;
+
+ /* Process TX work */
+ struct workqueue_struct *tx_workqueue;
+ struct work_struct tx_work;
+
+ /* TX queue */
+ struct sk_buff_head tx_q;
+
+ /* RX Queue */
+ struct sk_buff_head rx_q;
+
+ /* Counters */
+ atomic_t tx_pending;
+ atomic_t rx_pending;
+};
+
+
+struct esp_private {
+ struct esp_adapter *adapter;
+ struct net_device *ndev;
+ struct net_device_stats stats;
+ u8 link_state;
+ u8 mac_address[6];
+ u8 if_type;
+ u8 if_num;
+};
+
+struct esp_skb_cb {
+ struct esp_private *priv;
+};
+#endif
--- /dev/null
+/*
+ * Espressif Systems Wireless LAN device driver
+ *
+ * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
+ *
+ * This software file (the "File") is distributed by Espressif Systems (Shanghai)
+ * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
+ * (the "License"). You may use, redistribute and/or modify this File in
+ * accordance with the terms and conditions of the License, a copy of which
+ * is available by writing to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
+ * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
+ * this warranty disclaimer.
+ */
+
+#ifndef _esp_api__h_
+#define _esp_api__h_
+
+#include "esp.h"
+
+int esp_add_card(struct esp_adapter *adapter);
+int esp_remove_card(struct esp_adapter *adapter);
+void esp_process_new_packet_intr(struct esp_adapter *adapter);
+struct esp_adapter * esp_get_adapter(void);
+struct sk_buff * esp_alloc_skb(u32 len);
+int esp_send_packet(struct esp_adapter *adapter, u8 *buf, u32 size);
+u8 esp_is_bt_supported_over_sdio(u32 cap);
+
+#endif
--- /dev/null
+/*
+ * Espressif Systems Wireless LAN device driver
+ *
+ * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
+ *
+ * This software file (the "File") is distributed by Espressif Systems (Shanghai)
+ * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
+ * (the "License"). You may use, redistribute and/or modify this File in
+ * accordance with the terms and conditions of the License, a copy of which
+ * is available by writing to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
+ * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
+ * this warranty disclaimer.
+ */
+#include "esp_bt_api.h"
+#include "esp_api.h"
+
+void esp_hci_update_tx_counter(struct hci_dev *hdev, u8 pkt_type, size_t len)
+{
+ if (hdev) {
+ if (pkt_type == HCI_COMMAND_PKT) {
+ hdev->stat.cmd_tx++;
+ } else if (pkt_type == HCI_ACLDATA_PKT) {
+ hdev->stat.acl_tx++;
+ } else if (pkt_type == HCI_SCODATA_PKT) {
+ hdev->stat.sco_tx++;
+ }
+
+ hdev->stat.byte_tx += len;
+ }
+}
+
+void esp_hci_update_rx_counter(struct hci_dev *hdev, u8 pkt_type, size_t len)
+{
+ if (hdev) {
+ if (pkt_type == HCI_EVENT_PKT) {
+ hdev->stat.evt_rx++;
+ } else if (pkt_type == HCI_ACLDATA_PKT) {
+ hdev->stat.acl_rx++;
+ } else if (pkt_type == HCI_SCODATA_PKT) {
+ hdev->stat.sco_rx++;
+ }
+
+ hdev->stat.byte_rx += len;
+ }
+}
+
+static int esp_bt_open(struct hci_dev *hdev)
+{
+ return 0;
+}
+
+static int esp_bt_close(struct hci_dev *hdev)
+{
+ return 0;
+}
+
+static int esp_bt_flush(struct hci_dev *hdev)
+{
+ return 0;
+}
+
+static int esp_bt_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
+{
+ struct esp_payload_header *hdr;
+ size_t total_len, len = skb->len;
+ int ret = 0;
+ struct esp_adapter *adapter = hci_get_drvdata(hdev);
+ struct sk_buff *new_skb;
+
+ if (!adapter) {
+ printk(KERN_ERR "%s: invalid args", __func__);
+ return -EINVAL;
+ }
+
+ total_len = len + sizeof(struct esp_payload_header);
+
+ if (skb_headroom(skb) < sizeof(struct esp_payload_header)) {
+ /* insufficent headroom to add payload header */
+ new_skb = skb_realloc_headroom(skb, sizeof(struct esp_payload_header));
+
+ if(!new_skb) {
+ printk(KERN_ERR "%s: Failed to allocate SKB", __func__);
+ dev_kfree_skb(skb);
+ hdev->stat.err_tx++;
+ return -ENOMEM;
+ }
+
+ dev_kfree_skb(skb);
+
+ skb = new_skb;
+ }
+
+ skb_push(skb, sizeof(struct esp_payload_header));
+
+ hdr = (struct esp_payload_header *) skb->data;
+
+ memset (hdr, 0, sizeof(struct esp_payload_header));
+
+ hdr->if_type = ESP_HCI_IF;
+ hdr->if_num = 0;
+ hdr->len = cpu_to_le16(len);
+ hdr->offset = cpu_to_le16(sizeof(struct esp_payload_header));
+ hdr->hci_pkt_type = hci_skb_pkt_type(skb);
+
+/* print_hex_dump_bytes("Tx:", DUMP_PREFIX_NONE, skb->data, skb->len);*/
+ ret = esp_send_packet(adapter, skb->data, skb->len);
+
+ if (ret) {
+ hdev->stat.err_tx++;
+ } else {
+ esp_hci_update_tx_counter(hdev, hdr->hci_pkt_type, skb->len);
+ }
+
+ dev_kfree_skb(skb);
+
+ return 0;
+}
+
+static int esp_bt_setup(struct hci_dev *hdev)
+{
+ return 0;
+}
+
+static int esp_bt_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
+{
+ return 0;
+}
+
+int esp_deinit_bt(struct esp_adapter *adapter)
+{
+ struct hci_dev *hdev = NULL;
+
+ hdev = adapter->hcidev;
+
+ hci_unregister_dev(hdev);
+ hci_free_dev(hdev);
+
+ adapter->hcidev = NULL;
+
+ return 0;
+}
+
+int esp_init_bt(struct esp_adapter *adapter)
+{
+ int ret = 0;
+ struct hci_dev *hdev = NULL;
+
+ if (!adapter) {
+ return -EINVAL;
+ }
+
+ if (adapter->hcidev) {
+ return -EEXIST;
+ }
+
+ hdev = hci_alloc_dev();
+
+ if (!hdev) {
+ BT_ERR("Can not allocate HCI device");
+ return -ENOMEM;
+ }
+
+ adapter->hcidev = hdev;
+ hci_set_drvdata(hdev, adapter);
+
+ hdev->bus = HCI_SDIO;
+ hdev->open = esp_bt_open;
+ hdev->close = esp_bt_close;
+ hdev->flush = esp_bt_flush;
+ hdev->send = esp_bt_send_frame;
+ hdev->setup = esp_bt_setup;
+ hdev->set_bdaddr = esp_bt_set_bdaddr;
+
+ hdev->dev_type = HCI_PRIMARY;
+
+ ret = hci_register_dev(hdev);
+ if (ret < 0) {
+ BT_ERR("Can not register HCI device");
+ hci_free_dev(hdev);
+ return -ENOMEM;
+ }
+
+ return 0;
+}
--- /dev/null
+/*
+ * Espressif Systems Wireless LAN device driver
+ *
+ * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
+ *
+ * This software file (the "File") is distributed by Espressif Systems (Shanghai)
+ * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
+ * (the "License"). You may use, redistribute and/or modify this File in
+ * accordance with the terms and conditions of the License, a copy of which
+ * is available by writing to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
+ * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
+ * this warranty disclaimer.
+ */
+
+#ifndef __esp_bt_api_h_
+#define __esp_bt_api_h_
+
+#include "esp.h"
+
+int esp_init_bt(struct esp_adapter *adapter);
+int esp_deinit_bt(struct esp_adapter *adapter);
+void esp_hci_update_tx_counter(struct hci_dev *hdev, u8 pkt_type, size_t len);
+void esp_hci_update_rx_counter(struct hci_dev *hdev, u8 pkt_type, size_t len);
+
+#endif
--- /dev/null
+/*
+ * Espressif Systems Wireless LAN device driver
+ *
+ * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
+ *
+ * This software file (the "File") is distributed by Espressif Systems (Shanghai)
+ * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
+ * (the "License"). You may use, redistribute and/or modify this File in
+ * accordance with the terms and conditions of the License, a copy of which
+ * is available by writing to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
+ * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
+ * this warranty disclaimer.
+ */
+
+#ifndef __ESP_IF__H_
+#define __ESP_IF__H_
+
+#include "esp.h"
+
+struct esp_if_ops {
+ int (*init)(struct esp_adapter *adapter);
+ struct sk_buff* (*read)(struct esp_adapter *adapter);
+ int (*write)(struct esp_adapter *adapter, u8 *buf, u32 size);
+ int (*deinit)(struct esp_adapter *adapter);
+};
+
+int esp_init_interface_layer(struct esp_adapter *adapter);
+void esp_deinit_interface_layer(void);
+
+#endif
--- /dev/null
+/*
+ * The citation should list that the code comes from the book "Linux Device
+ * Drivers" by Alessandro Rubini and Jonathan Corbet, published
+ * by O'Reilly & Associates.No warranty is attached;
+ *
+ * */
+
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/sched.h>
+#include <linux/types.h>
+#include <linux/slab.h>
+#include <linux/semaphore.h>
+#include <linux/uaccess.h>
+
+#include "esp_rb.h"
+
+int esp_rb_init(esp_rb_t *rb, size_t sz)
+{
+ init_waitqueue_head(&(rb->wq));
+
+ rb->buf = kmalloc(sz, GFP_KERNEL);
+ if (!rb->buf) {
+ printk(KERN_ERR "Failed to allocate memory for rb\n");
+ return -ENOMEM;
+ }
+
+ rb->end = rb->buf + sz;
+ rb->rp = rb->wp = rb->buf;
+ rb->size = sz;
+
+ sema_init(&(rb->sem), 1);
+ return 0;
+}
+
+ssize_t esp_rb_read_by_user(esp_rb_t *rb, const char __user *buf, size_t sz, int block)
+{
+ if (down_interruptible(&rb->sem)) {
+ return -ERESTARTSYS; /* Signal interruption */
+ }
+
+ while(rb->rp == rb->wp) {
+ up(&rb->sem);
+ if (block == 0) {
+ return -EAGAIN;
+ }
+ if (wait_event_interruptible(rb->wq, (rb->rp != rb->wp))) {
+ return -ERESTARTSYS; /* Signal interruption */
+ }
+ if (down_interruptible(&rb->sem)) {
+ return -ERESTARTSYS;
+ }
+ }
+
+ if (rb->wp > rb->rp) {
+ sz = min(sz, (size_t)(rb->wp - rb->rp));
+ } else {
+ sz = min(sz, (size_t)(rb->end - rb->rp));
+ }
+ if (copy_to_user((void *)buf, rb->rp, sz)) {
+ up(&rb->sem);
+ return -EFAULT;
+ }
+ rb->rp += sz;
+ if (rb->rp == rb->end) {
+ rb->rp = rb->buf;
+ }
+ up(&rb->sem);
+
+ return sz;
+}
+
+static size_t get_free_space(esp_rb_t *rb)
+{
+ if (rb->rp == rb->wp) {
+ return rb->size - 1;
+ } else {
+ return ((rb->rp + rb->size - rb->wp) % rb->size) - 1;
+ }
+}
+
+ssize_t esp_rb_write_by_kernel(esp_rb_t *rb, const char *buf, size_t sz)
+{
+ if (down_interruptible(&rb->sem)) {
+ return -ERESTARTSYS;
+ }
+
+ if (get_free_space(rb) == 0) {
+ up(&rb->sem);
+ printk(KERN_ERR "Ringbuffer full, no space to write\n");
+ return 0;
+ }
+
+ sz = min(sz, get_free_space(rb));
+ if (rb->wp >= rb->rp) {
+ sz = min(sz, (size_t)(rb->end - rb->wp));
+ } else {
+ sz = min(sz, (size_t)(rb->rp - rb->wp - 1));
+ }
+
+ memcpy(rb->wp, buf, sz);
+ rb->wp += sz;
+ if (rb->wp == rb->end) {
+ rb->wp = rb->buf;
+ }
+ up(&rb->sem);
+
+ wake_up_interruptible(&rb->wq);
+
+ return sz;
+}
+
+void esp_rb_cleanup(esp_rb_t *rb)
+{
+ kfree(rb->buf);
+ rb->buf = rb->end = rb->rp = rb->wp = NULL;
+ rb->size = 0;
+ return;
+}
--- /dev/null
+/*
+ * The citation should list that the code comes from the book "Linux Device
+ * Drivers" by Alessandro Rubini and Jonathan Corbet, published
+ * by O'Reilly & Associates.No warranty is attached;
+ *
+ * */
+
+#ifndef _ESP_RB_H_
+#define _ESP_RB_H_
+
+typedef struct esp_rb {
+ wait_queue_head_t wq; /* waitqueue to wait for data */
+ unsigned char *buf, *end; /* actual queue start and end */
+ size_t size;
+ unsigned char *rp, *wp; /* current read/write pointers */
+ struct semaphore sem; /* Mutex to protect rb */
+} esp_rb_t;
+
+int esp_rb_init(esp_rb_t *rb, size_t sz);
+void esp_rb_cleanup(esp_rb_t *rb);
+ssize_t esp_rb_read_by_user(esp_rb_t *rb, const char __user *buf, size_t sz, int block);
+ssize_t esp_rb_write_by_kernel(esp_rb_t *rb, const char *buf, size_t sz);
+
+#endif
--- /dev/null
+/*
+ * Espressif Systems Wireless LAN device driver
+ *
+ * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
+ *
+ * This software file (the "File") is distributed by Espressif Systems (Shanghai)
+ * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
+ * (the "License"). You may use, redistribute and/or modify this File in
+ * accordance with the terms and conditions of the License, a copy of which
+ * is available by writing to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
+ * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
+ * this warranty disclaimer.
+ */
+
+#include <linux/mutex.h>
+#include <linux/mmc/sdio.h>
+#include <linux/mmc/sdio_func.h>
+#include <linux/mmc/sdio_ids.h>
+#include <linux/mmc/card.h>
+#include <linux/mmc/host.h>
+#include "esp_if.h"
+#include "esp_sdio_api.h"
+#include "esp_api.h"
+#include "esp_bt_api.h"
+#ifdef CONFIG_SUPPORT_ESP_SERIAL
+#include "esp_serial.h"
+#endif
+#include <linux/kthread.h>
+
+#define CHECK_SDIO_RW_ERROR(ret) do { \
+ if (ret) \
+ printk(KERN_ERR "%s: CMD53 read/write error at %d\n", __func__, __LINE__); \
+} while (0);
+
+struct esp_sdio_context sdio_context;
+
+#ifdef CONFIG_ENABLE_MONITOR_PROCESS
+struct task_struct *monitor_thread;
+#endif
+
+static int init_context(struct esp_sdio_context *context);
+static struct sk_buff * read_packet(struct esp_adapter *adapter);
+static int write_packet(struct esp_adapter *adapter, u8 *buf, u32 size);
+/*int deinit_context(struct esp_adapter *adapter);*/
+
+static const struct sdio_device_id esp_devices[] = {
+ { SDIO_DEVICE(ESP_VENDOR_ID, ESP_DEVICE_ID_1) },
+ { SDIO_DEVICE(ESP_VENDOR_ID, ESP_DEVICE_ID_2) },
+ {}
+};
+
+static void print_capabilities(u32 cap)
+{
+ printk(KERN_INFO "Features supported are:\n");
+ if (cap & ESP_WLAN_SUPPORT)
+ printk(KERN_INFO "\t * WLAN\n");
+ if ((cap & ESP_BT_UART_SUPPORT) || (cap & ESP_BT_SDIO_SUPPORT)) {
+ printk(KERN_INFO "\t * BT/BLE\n");
+ if (cap & ESP_BT_UART_SUPPORT)
+ printk(KERN_INFO "\t - HCI over UART\n");
+ if (cap & ESP_BT_SDIO_SUPPORT)
+ printk(KERN_INFO "\t - HCI over SDIO\n");
+
+ if ((cap & ESP_BLE_ONLY_SUPPORT) && (cap & ESP_BR_EDR_ONLY_SUPPORT))
+ printk(KERN_INFO "\t - BT/BLE dual mode\n");
+ else if (cap & ESP_BLE_ONLY_SUPPORT)
+ printk(KERN_INFO "\t - BLE only\n");
+ else if (cap & ESP_BR_EDR_ONLY_SUPPORT)
+ printk(KERN_INFO "\t - BR EDR only\n");
+ }
+}
+
+static void esp_process_interrupt(struct esp_sdio_context *context, u32 int_status)
+{
+ if (!context) {
+ return;
+ }
+
+ if (int_status & ESP_SLAVE_RX_NEW_PACKET_INT) {
+ esp_process_new_packet_intr(context->adapter);
+ }
+}
+
+static void esp_handle_isr(struct sdio_func *func)
+{
+ struct esp_sdio_context *context = NULL;
+ u32 int_status = 0;
+ int ret;
+
+ if (!func) {
+ return;
+ }
+
+ context = sdio_get_drvdata(func);
+
+ if (!context) {
+ return;
+ }
+
+ /* Read interrupt status register */
+ ret = esp_read_reg(context, ESP_SLAVE_INT_ST_REG,
+ (u8 *) &int_status, sizeof(int_status), ACQUIRE_LOCK);
+ CHECK_SDIO_RW_ERROR(ret);
+
+ esp_process_interrupt(context, int_status);
+
+ /* Clear interrupt status */
+ ret = esp_write_reg(context, ESP_SLAVE_INT_CLR_REG,
+ (u8 *) &int_status, sizeof(int_status), ACQUIRE_LOCK);
+ CHECK_SDIO_RW_ERROR(ret);
+}
+
+int generate_slave_intr(struct esp_sdio_context *context, u8 data)
+{
+ if (!context)
+ return -EINVAL;
+
+ return esp_write_reg(context, ESP_SLAVE_SCRATCH_REG_7, &data,
+ sizeof(data), ACQUIRE_LOCK);
+}
+
+static void deinit_sdio_func(struct sdio_func *func)
+{
+ sdio_claim_host(func);
+ /* Release IRQ */
+ sdio_release_irq(func);
+ /* Disable sdio function */
+ sdio_disable_func(func);
+ sdio_release_host(func);
+ sdio_set_drvdata(func, NULL);
+}
+
+static int esp_slave_get_tx_buffer_num(struct esp_sdio_context *context, u32 *tx_num, u8 is_lock_needed)
+{
+ u32 len;
+ int ret = 0;
+
+ ret = esp_read_reg(context, ESP_SLAVE_TOKEN_RDATA, (uint8_t*)&len, 4, is_lock_needed);
+
+ if (ret)
+ return ret;
+
+ len = (len >> 16) & ESP_TX_BUFFER_MASK;
+ len = (len + ESP_TX_BUFFER_MAX - context->tx_buffer_count) % ESP_TX_BUFFER_MAX;
+
+ *tx_num = len;
+
+ return ret;
+}
+
+static int esp_get_len_from_slave(struct esp_sdio_context *context, u32 *rx_size, u8 is_lock_needed)
+{
+ u32 len, temp;
+ int ret = 0;
+
+ ret = esp_read_reg(context, ESP_SLAVE_PACKET_LEN_REG,
+ (u8 *) &len, sizeof(len), is_lock_needed);
+
+ if (ret)
+ return ret;
+
+ len &= ESP_SLAVE_LEN_MASK;
+
+ if (len >= context->rx_byte_count)
+ len = (len + ESP_RX_BYTE_MAX - context->rx_byte_count) % ESP_RX_BYTE_MAX;
+ else {
+ /* Handle a case of roll over */
+ temp = ESP_RX_BYTE_MAX - context->rx_byte_count;
+ len = temp + len;
+
+ if (len > ESP_RX_BUFFER_SIZE) {
+ printk(KERN_INFO "%s: Len from slave[%d] exceeds max [%d]\n",
+ __func__, len, ESP_RX_BUFFER_SIZE);
+ }
+ }
+ *rx_size = len;
+
+ return 0;
+}
+
+
+static void flush_sdio(struct esp_sdio_context *context)
+{
+ struct sk_buff *skb;
+
+ if (!context || !context->adapter)
+ return;
+
+ while (1) {
+ skb = read_packet(context->adapter);
+
+ if (!skb) {
+ break;
+ }
+
+ if (skb->len)
+ printk (KERN_INFO "%s: Flushed %d bytes\n", __func__, skb->len);
+ dev_kfree_skb(skb);
+ }
+}
+
+static void esp_remove(struct sdio_func *func)
+{
+ struct esp_sdio_context *context;
+ context = sdio_get_drvdata(func);
+
+ printk(KERN_INFO "%s -> Remove card", __func__);
+
+#ifdef CONFIG_SUPPORT_ESP_SERIAL
+ esp_serial_cleanup();
+#endif
+
+#ifdef CONFIG_ENABLE_MONITOR_PROCESS
+ if (monitor_thread)
+ kthread_stop(monitor_thread);
+#endif
+
+ if (context) {
+ generate_slave_intr(context, BIT(ESP_CLOSE_DATA_PATH));
+ msleep(100);
+
+ flush_sdio(context);
+
+ if (context->adapter) {
+ esp_remove_card(context->adapter);
+
+ if (context->adapter->hcidev) {
+ esp_deinit_bt(context->adapter);
+ }
+
+ }
+
+ memset(context, 0, sizeof(struct esp_sdio_context));
+ }
+
+ deinit_sdio_func(func);
+
+ printk (KERN_INFO "%s: Context deinit %d - %d\n", __func__, context->rx_byte_count,
+ context->tx_buffer_count);
+
+}
+
+static struct esp_if_ops if_ops = {
+ .read = read_packet,
+ .write = write_packet,
+};
+
+static int init_context(struct esp_sdio_context *context)
+{
+ int ret = 0;
+ u32 val = 0;
+
+ if (!context) {
+ return -EINVAL;
+ }
+
+ /* Initialize rx_byte_count */
+ ret = esp_read_reg(context, ESP_SLAVE_PACKET_LEN_REG,
+ (u8 *) &val, sizeof(val), ACQUIRE_LOCK);
+ if (ret)
+ return ret;
+
+/* printk(KERN_DEBUG "%s: LEN %d\n", __func__, (val & ESP_SLAVE_LEN_MASK));*/
+
+ context->rx_byte_count = val & ESP_SLAVE_LEN_MASK;
+
+ /* Initialize tx_buffer_count */
+ ret = esp_read_reg(context, ESP_SLAVE_TOKEN_RDATA, (u8 *) &val,
+ sizeof(val), ACQUIRE_LOCK);
+
+ if (ret)
+ return ret;
+
+ val = ((val >> 16) & ESP_TX_BUFFER_MASK);
+
+/* printk(KERN_DEBUG "%s: BUF_CNT %d\n", __func__, val);*/
+
+ if (val >= ESP_MAX_BUF_CNT)
+ context->tx_buffer_count = val - ESP_MAX_BUF_CNT;
+ else
+ context->tx_buffer_count = 0;
+
+/* printk(KERN_DEBUG "%s: Context init %d - %d\n", __func__, context->rx_byte_count,*/
+/* context->tx_buffer_count);*/
+
+ context->adapter = esp_get_adapter();
+
+ if (!context->adapter)
+ printk (KERN_ERR "%s: Failed to get adapter\n", __func__);
+
+ return ret;
+}
+
+static struct sk_buff * read_packet(struct esp_adapter *adapter)
+{
+ u32 len_from_slave, data_left, len_to_read, size, num_blocks;
+ int ret = 0;
+ struct sk_buff *skb;
+ u8 *pos;
+ struct esp_sdio_context *context;
+
+ if (!adapter || !adapter->if_context) {
+ printk (KERN_ERR "%s: INVALID args\n", __func__);
+ return NULL;
+ }
+
+ context = adapter->if_context;
+
+ sdio_claim_host(context->func);
+
+ data_left = len_to_read = len_from_slave = num_blocks = 0;
+
+ /* Read length */
+ ret = esp_get_len_from_slave(context, &len_from_slave, LOCK_ALREADY_ACQUIRED);
+
+/* printk (KERN_DEBUG "LEN FROM SLAVE: %d\n", len_from_slave);*/
+
+ if (ret || !len_from_slave) {
+ sdio_release_host(context->func);
+ return NULL;
+ }
+
+ size = ESP_BLOCK_SIZE * 4;
+
+ if (len_from_slave > size) {
+ printk(KERN_INFO "Rx large packet: %d\n", len_from_slave);
+ }
+
+ skb = esp_alloc_skb(len_from_slave);
+
+ if (!skb) {
+ printk (KERN_ERR "%s: SKB alloc failed\n", __func__);
+ sdio_release_host(context->func);
+ return NULL;
+ }
+
+ skb_put(skb, len_from_slave);
+ pos = skb->data;
+
+ data_left = len_from_slave;
+
+ do {
+ num_blocks = data_left/ESP_BLOCK_SIZE;
+
+#if 0
+ if (!context->rx_byte_count) {
+ start_time = ktime_get_ns();
+ }
+#endif
+
+ if (num_blocks) {
+ len_to_read = num_blocks * ESP_BLOCK_SIZE;
+ ret = esp_read_block(context,
+ ESP_SLAVE_CMD53_END_ADDR - len_to_read,
+ pos, len_to_read, LOCK_ALREADY_ACQUIRED);
+ } else {
+ len_to_read = data_left;
+ /* 4 byte aligned length */
+ ret = esp_read_block(context,
+ ESP_SLAVE_CMD53_END_ADDR - len_to_read,
+ pos, (len_to_read + 3) & (~3), LOCK_ALREADY_ACQUIRED);
+ }
+
+ if (ret) {
+ printk (KERN_ERR "%s: Failed to read data\n", __func__);
+ dev_kfree_skb(skb);
+ sdio_release_host(context->func);
+ return NULL;
+ }
+
+ data_left -= len_to_read;
+ pos += len_to_read;
+ context->rx_byte_count += len_to_read;
+ context->rx_byte_count = context->rx_byte_count % ESP_RX_BYTE_MAX;
+
+ } while (data_left > 0);
+
+ sdio_release_host(context->func);
+
+ return skb;
+}
+
+static int write_packet(struct esp_adapter *adapter, u8 *buf, u32 size)
+{
+ u32 block_cnt = 0, buf_needed = 0;
+ u32 buf_available = 0;
+ int ret = 0;
+ u8 *pos = NULL;
+ u32 data_left, len_to_send, pad;
+ struct esp_sdio_context *context;
+
+ if (!adapter || !adapter->if_context || !buf || !size) {
+ printk (KERN_ERR "%s: Invalid args\n", __func__);
+ return -EINVAL;
+ }
+
+ context = adapter->if_context;
+
+ sdio_claim_host(context->func);
+
+ buf_needed = (size + ESP_RX_BUFFER_SIZE - 1) / ESP_RX_BUFFER_SIZE;
+
+ ret = esp_slave_get_tx_buffer_num(context, &buf_available, LOCK_ALREADY_ACQUIRED);
+
+/* printk(KERN_ERR "%s: TX -> Available [%d], needed [%d]\n", __func__, buf_available, buf_needed);*/
+
+ if (buf_available < buf_needed) {
+ printk(KERN_DEBUG "%s: Not enough buffers available: availabale [%d], needed [%d]\n", __func__,
+ buf_available, buf_needed);
+ sdio_release_host(context->func);
+ return -ENOMEM;
+ }
+
+ pos = buf;
+ data_left = len_to_send = 0;
+
+ data_left = size;
+ pad = ESP_BLOCK_SIZE - (data_left % ESP_BLOCK_SIZE);
+ data_left += pad;
+
+
+ do {
+ block_cnt = data_left / ESP_BLOCK_SIZE;
+ len_to_send = data_left;
+ ret = esp_write_block(context, ESP_SLAVE_CMD53_END_ADDR - len_to_send,
+ pos, (len_to_send + 3) & (~3), LOCK_ALREADY_ACQUIRED);
+
+ if (ret) {
+ printk (KERN_ERR "%s: Failed to send data\n", __func__);
+ sdio_release_host(context->func);
+ return ret;
+ }
+/* printk (KERN_ERR "--> %d %d %d\n", block_cnt, data_left, len_to_send);*/
+
+ data_left -= len_to_send;
+ pos += len_to_send;
+ } while (data_left);
+
+ context->tx_buffer_count += buf_needed;
+ context->tx_buffer_count = context->tx_buffer_count % ESP_TX_BUFFER_MAX;
+
+ sdio_release_host(context->func);
+
+ return 0;
+}
+
+static struct esp_sdio_context * init_sdio_func(struct sdio_func *func)
+{
+ struct esp_sdio_context *context = NULL;
+ int ret = 0;
+
+ if (!func)
+ return NULL;
+
+ context = &sdio_context;
+
+ context->func = func;
+
+ sdio_claim_host(func);
+
+ /* Enable Function */
+ ret = sdio_enable_func(func);
+ if (ret) {
+ return NULL;
+ }
+
+ /* Register IRQ */
+ ret = sdio_claim_irq(func, esp_handle_isr);
+ if (ret) {
+ sdio_disable_func(func);
+ return NULL;
+ }
+
+ /* Set private data */
+ sdio_set_drvdata(func, context);
+
+ context->state = ESP_CONTEXT_INIT;
+
+ sdio_release_host(func);
+
+ return context;
+}
+
+#ifdef CONFIG_ENABLE_MONITOR_PROCESS
+static int monitor_process(void *data)
+{
+ u32 val, intr, len_reg, rdata, old_len = 0;
+ struct esp_sdio_context *context = (struct esp_sdio_context *) data;
+ struct sk_buff *skb;
+
+ while (!kthread_should_stop()) {
+ msleep(5000);
+
+ val = intr = len_reg = rdata = 0;
+
+ esp_read_reg(context, ESP_SLAVE_PACKET_LEN_REG,
+ (u8 *) &val, sizeof(val), ACQUIRE_LOCK);
+
+ len_reg = val & ESP_SLAVE_LEN_MASK;
+
+ val = 0;
+ esp_read_reg(context, ESP_SLAVE_TOKEN_RDATA, (u8 *) &val,
+ sizeof(val), ACQUIRE_LOCK);
+
+ rdata = ((val >> 16) & ESP_TX_BUFFER_MASK);
+
+ esp_read_reg(context, ESP_SLAVE_INT_ST_REG,
+ (u8 *) &intr, sizeof(intr), ACQUIRE_LOCK);
+
+
+ if (len_reg > context->rx_byte_count) {
+ if (old_len && (context->rx_byte_count == old_len)) {
+ printk (KERN_DEBUG "Monitor thread ----> [%d - %d] [%d - %d] %d\n",
+ len_reg, context->rx_byte_count,
+ rdata, context->tx_buffer_count, intr);
+
+ skb = read_packet(context->adapter);
+
+ if (!skb)
+ continue;
+
+ if (skb->len)
+ printk (KERN_DEBUG "%s: Flushed %d bytes\n", __func__, skb->len);
+
+ /* drop the packet */
+ dev_kfree_skb(skb);
+ }
+ }
+
+ old_len = context->rx_byte_count;
+ }
+
+ do_exit(0);
+ return 0;
+}
+#endif
+
+static int esp_probe(struct sdio_func *func,
+ const struct sdio_device_id *id)
+{
+ struct esp_sdio_context *context = NULL;
+ int ret = 0;
+ uint32_t cap = 0;
+
+ if (func->num != 1) {
+ return -EINVAL;
+ }
+
+ printk(KERN_INFO "%s: ESP network device detected\n", __func__);
+
+ context = init_sdio_func(func);
+
+ if (!context) {
+ return -ENOMEM;
+ }
+
+ generate_slave_intr(context, BIT(ESP_RESET));
+
+ msleep(200);
+
+ ret = init_context(context);
+ if (ret) {
+ deinit_sdio_func(func);
+ return ret;
+ }
+
+#ifdef CONFIG_SUPPORT_ESP_SERIAL
+ ret = esp_serial_init((void *) context->adapter);
+ if (ret != 0) {
+ esp_remove(func);
+ printk(KERN_ERR "Error initialising serial interface\n");
+ return ret;
+ }
+#endif
+
+ ret = esp_add_card(context->adapter);
+ if (ret) {
+ esp_remove(func);
+ printk (KERN_ERR "Failed to add card\n");
+ deinit_sdio_func(func);
+ return ret;
+ }
+
+ /* Read slave capabilities */
+ esp_read_reg(context, ESP_SLAVE_SCRATCH_REG_0,
+ (u8 *) &cap, sizeof(cap), ACQUIRE_LOCK);
+
+ context->adapter->capabilities = cap;
+
+ print_capabilities(cap);
+
+ if (esp_is_bt_supported_over_sdio(cap)) {
+ ret = esp_init_bt(context->adapter);
+ if (ret) {
+ esp_remove(func);
+ printk (KERN_ERR "Failed to init BT\n");
+ deinit_sdio_func(func);
+ return ret;
+ }
+ }
+
+ context->state = ESP_CONTEXT_READY;
+
+#ifdef CONFIG_ENABLE_MONITOR_PROCESS
+ monitor_thread = kthread_run(monitor_process, context, "Monitor process");
+
+ if (!monitor_thread)
+ printk (KERN_ERR "Failed to create monitor thread\n");
+#endif
+
+
+ msleep(200);
+ generate_slave_intr(context, BIT(ESP_OPEN_DATA_PATH));
+ return ret;
+}
+
+/* SDIO driver structure to be registered with kernel */
+static struct sdio_driver esp_sdio_driver = {
+ .name = "esp_sdio",
+ .id_table = esp_devices,
+ .probe = esp_probe,
+ .remove = esp_remove,
+};
+
+int esp_init_interface_layer(struct esp_adapter *adapter)
+{
+ if (!adapter)
+ return -EINVAL;
+
+ adapter->if_context = &sdio_context;
+ adapter->if_ops = &if_ops;
+ sdio_context.adapter = adapter;
+
+ return sdio_register_driver(&esp_sdio_driver);
+}
+
+void esp_deinit_interface_layer(void)
+{
+ sdio_unregister_driver(&esp_sdio_driver);
+}
--- /dev/null
+/*
+ * Espressif Systems Wireless LAN device driver
+ *
+ * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
+ *
+ * This software file (the "File") is distributed by Espressif Systems (Shanghai)
+ * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
+ * (the "License"). You may use, redistribute and/or modify this File in
+ * accordance with the terms and conditions of the License, a copy of which
+ * is available by writing to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
+ * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
+ * this warranty disclaimer.
+ */
+
+#include <linux/mmc/sdio.h>
+#include <linux/mmc/sdio_func.h>
+#include <linux/mmc/sdio_ids.h>
+#include <linux/mmc/card.h>
+#include <linux/mmc/host.h>
+#include "esp_sdio_api.h"
+
+static int esp_read_byte(struct esp_sdio_context *context, u32 reg, u8 *data, u8 is_lock_needed)
+{
+ struct sdio_func *func = NULL;
+ int ret;
+
+ if (!context || !context->func || !data) {
+ printk (KERN_ERR "%s: Invalid or incomplete arguments!\n", __func__);
+ return -1;
+ }
+
+ func = context->func;
+
+ if (is_lock_needed)
+ sdio_claim_host(func);
+
+ *data = sdio_readb(func, reg, &ret);
+
+ if (is_lock_needed)
+ sdio_release_host(func);
+
+ return ret;
+}
+
+static int esp_write_byte(struct esp_sdio_context *context, u32 reg, u8 data, u8 is_lock_needed)
+{
+ struct sdio_func *func = NULL;
+ int ret;
+
+ if (!context || !context->func) {
+ printk (KERN_ERR "%s: Invalid or incomplete arguments!\n", __func__);
+ return -1;
+ }
+
+ func = context->func;
+
+ if (is_lock_needed)
+ sdio_claim_host(func);
+
+ sdio_writeb(func, data, reg, &ret);
+
+ if (is_lock_needed)
+ sdio_release_host(func);
+
+ return ret;
+}
+
+static int esp_read_multi_byte(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed)
+{
+ struct sdio_func *func = NULL;
+ int ret;
+
+ if (!context || !context->func || !data) {
+ printk (KERN_ERR "%s: Invalid or incomplete arguments!\n", __func__);
+ return -1;
+ }
+
+ func = context->func;
+
+ if (is_lock_needed)
+ sdio_claim_host(func);
+
+ ret = sdio_memcpy_fromio(func, data, reg, size);
+
+ if (is_lock_needed)
+ sdio_release_host(func);
+
+ return ret;
+}
+
+static int esp_write_multi_byte(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed)
+{
+ struct sdio_func *func = NULL;
+ int ret;
+
+ if (!context || !context->func || !data) {
+ printk (KERN_ERR "%s: Invalid or incomplete arguments!\n", __func__);
+ return -1;
+ }
+
+ func = context->func;
+
+ if (is_lock_needed)
+ sdio_claim_host(func);
+
+ ret = sdio_memcpy_toio(func, reg, data, size);
+
+ if (is_lock_needed)
+ sdio_release_host(func);
+
+ return ret;
+}
+
+int esp_read_reg(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed)
+{
+ /* Need to apply address mask when reading/writing slave registers */
+ reg &= ESP_ADDRESS_MASK;
+
+ if (size <= 1) {
+ return esp_read_byte(context, reg, data, is_lock_needed);
+ } else {
+ return esp_read_multi_byte(context, reg, data, size, is_lock_needed);
+ }
+}
+
+int esp_read_block(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed)
+{
+ if (size <= 1) {
+ return esp_read_byte(context, reg, data, is_lock_needed);
+ } else {
+ return esp_read_multi_byte(context, reg, data, size, is_lock_needed);
+ }
+}
+
+int esp_write_reg(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed)
+{
+ /* Need to apply address mask when reading/writing slave registers */
+ reg &= ESP_ADDRESS_MASK;
+
+ if (size <= 1) {
+ return esp_write_byte(context, reg, *data, is_lock_needed);
+ } else {
+ return esp_write_multi_byte(context, reg, data, size, is_lock_needed);
+ }
+}
+
+int esp_write_block(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed)
+{
+ if (size <= 1) {
+ return esp_write_byte(context, reg, *data, is_lock_needed);
+ } else {
+ return esp_write_multi_byte(context, reg, data, size, is_lock_needed);
+ }
+}
+
--- /dev/null
+/*
+ * Espressif Systems Wireless LAN device driver
+ *
+ * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
+ *
+ * This software file (the "File") is distributed by Espressif Systems (Shanghai)
+ * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
+ * (the "License"). You may use, redistribute and/or modify this File in
+ * accordance with the terms and conditions of the License, a copy of which
+ * is available by writing to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
+ * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
+ * this warranty disclaimer.
+ */
+
+#ifndef _ESP_SDIO_API_H_
+#define _ESP_SDIO_API_H_
+#include "esp_sdio_decl.h"
+
+int esp_read_reg(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed);
+int esp_read_block(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed);
+int esp_write_reg(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed);
+int esp_write_block(struct esp_sdio_context *context, u32 reg, u8 *data, u16 size, u8 is_lock_needed);
+
+#endif
--- /dev/null
+/*
+ * Espressif Systems Wireless LAN device driver
+ *
+ * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
+ *
+ * This software file (the "File") is distributed by Espressif Systems (Shanghai)
+ * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
+ * (the "License"). You may use, redistribute and/or modify this File in
+ * accordance with the terms and conditions of the License, a copy of which
+ * is available by writing to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
+ * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
+ * this warranty disclaimer.
+ */
+
+#ifndef _ESP_DECL_H_
+#define _ESP_DECL_H_
+
+#include <linux/bits.h>
+#include "esp.h"
+
+/* Interrupt Status */
+#define ESP_SLAVE_BIT0_INT BIT(0)
+#define ESP_SLAVE_BIT1_INT BIT(1)
+#define ESP_SLAVE_BIT2_INT BIT(2)
+#define ESP_SLAVE_BIT3_INT BIT(3)
+#define ESP_SLAVE_BIT4_INT BIT(4)
+#define ESP_SLAVE_BIT5_INT BIT(5)
+#define ESP_SLAVE_BIT6_INT BIT(6)
+#define ESP_SLAVE_BIT7_INT BIT(7)
+#define ESP_SLAVE_RX_UNDERFLOW_INT BIT(16)
+#define ESP_SLAVE_TX_OVERFLOW_INT BIT(17)
+#define ESP_SLAVE_RX_NEW_PACKET_INT BIT(23)
+
+
+#define ESP_SLAVE_CMD53_END_ADDR 0x1F800
+#define ESP_SLAVE_LEN_MASK 0xFFFFF
+#define ESP_BLOCK_SIZE 512
+#define ESP_RX_BYTE_MAX 0x100000
+#define ESP_RX_BUFFER_SIZE 2048
+
+#define ESP_TX_BUFFER_MASK 0xFFF
+#define ESP_TX_BUFFER_MAX 0x1000
+#define ESP_MAX_BUF_CNT 10
+
+#define ESP_SLAVE_SLCHOST_BASE 0x3FF55000
+
+#define ESP_SLAVE_SCRATCH_REG_7 (ESP_SLAVE_SLCHOST_BASE + 0x8C)
+/* SLAVE registers */
+/* Interrupt Registers */
+#define ESP_SLAVE_INT_RAW_REG (ESP_SLAVE_SLCHOST_BASE + 0x50)
+#define ESP_SLAVE_INT_ST_REG (ESP_SLAVE_SLCHOST_BASE + 0x58)
+#define ESP_SLAVE_INT_CLR_REG (ESP_SLAVE_SLCHOST_BASE + 0xD4)
+
+/* Data path registers*/
+#define ESP_SLAVE_PACKET_LEN_REG (ESP_SLAVE_SLCHOST_BASE + 0x60)
+#define ESP_SLAVE_TOKEN_RDATA (ESP_SLAVE_SLCHOST_BASE + 0x44)
+
+/* Scratch registers*/
+#define ESP_SLAVE_SCRATCH_REG_0 (ESP_SLAVE_SLCHOST_BASE + 0x6C)
+#define ESP_SLAVE_SCRATCH_REG_1 (ESP_SLAVE_SLCHOST_BASE + 0x70)
+#define ESP_SLAVE_SCRATCH_REG_2 (ESP_SLAVE_SLCHOST_BASE + 0x74)
+#define ESP_SLAVE_SCRATCH_REG_3 (ESP_SLAVE_SLCHOST_BASE + 0x78)
+#define ESP_SLAVE_SCRATCH_REG_4 (ESP_SLAVE_SLCHOST_BASE + 0x7C)
+#define ESP_SLAVE_SCRATCH_REG_6 (ESP_SLAVE_SLCHOST_BASE + 0x88)
+#define ESP_SLAVE_SCRATCH_REG_8 (ESP_SLAVE_SLCHOST_BASE + 0x9C)
+#define ESP_SLAVE_SCRATCH_REG_9 (ESP_SLAVE_SLCHOST_BASE + 0xA0)
+#define ESP_SLAVE_SCRATCH_REG_10 (ESP_SLAVE_SLCHOST_BASE + 0xA4)
+#define ESP_SLAVE_SCRATCH_REG_11 (ESP_SLAVE_SLCHOST_BASE + 0xA8)
+#define ESP_SLAVE_SCRATCH_REG_12 (ESP_SLAVE_SLCHOST_BASE + 0xAC)
+#define ESP_SLAVE_SCRATCH_REG_13 (ESP_SLAVE_SLCHOST_BASE + 0xB0)
+#define ESP_SLAVE_SCRATCH_REG_14 (ESP_SLAVE_SLCHOST_BASE + 0xB4)
+#define ESP_SLAVE_SCRATCH_REG_15 (ESP_SLAVE_SLCHOST_BASE + 0xB8)
+
+#define ESP_ADDRESS_MASK 0x3FF
+
+#define ESP_VENDOR_ID 0x6666
+#define ESP_DEVICE_ID_1 0x2222
+#define ESP_DEVICE_ID_2 0x3333
+
+
+enum context_state {
+ ESP_CONTEXT_DISABLED = 0,
+ ESP_CONTEXT_INIT,
+ ESP_CONTEXT_READY
+};
+
+struct esp_sdio_context {
+ struct esp_adapter *adapter;
+ struct sdio_func *func;
+ enum context_state state;
+ u32 rx_byte_count;
+ u32 tx_buffer_count;
+};
+
+#endif
--- /dev/null
+/*
+ * Espressif Systems Wireless LAN device driver
+ *
+ * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
+ *
+ * This software file (the "File") is distributed by Espressif Systems (Shanghai)
+ * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
+ * (the "License"). You may use, redistribute and/or modify this File in
+ * accordance with the terms and conditions of the License, a copy of which
+ * is available by writing to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
+ * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
+ * this warranty disclaimer.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/cdev.h>
+#include <linux/fs.h>
+#include <linux/kthread.h>
+#include <linux/delay.h>
+#include <linux/slab.h>
+
+#include "esp.h"
+#include "esp_rb.h"
+#include "esp_api.h"
+
+#define ESP_SERIAL_MAJOR 221
+#define ESP_SERIAL_MINOR_MAX 2
+#define ESP_RX_RB_SIZE 4096
+
+//#define ESP_SERIAL_TEST
+
+
+static struct esp_serial_devs {
+ struct cdev cdev;
+ int dev_index;
+ esp_rb_t rb;
+ void *priv;
+} devs[ESP_SERIAL_MINOR_MAX];
+
+static int esp_serial_read(struct file *file, char __user *user_buffer, size_t size, loff_t *offset)
+{
+ struct esp_serial_devs *dev;
+ dev = (struct esp_serial_devs *) file->private_data;
+ size = esp_rb_read_by_user(&dev->rb, user_buffer, size, file->f_flags & O_NONBLOCK);
+/* print_hex_dump_bytes("Rx:", DUMP_PREFIX_NONE, user_buffer, size);*/
+ if (size == 0) {
+ return -EAGAIN;
+ }
+
+ return size;
+}
+
+static int esp_serial_write(struct file *file, const char __user *user_buffer, size_t size, loff_t * offset)
+{
+ struct esp_payload_header *hdr;
+ char *buf;
+ struct esp_serial_devs *dev;
+ int ret;
+ size_t total_len;
+
+ dev = (struct esp_serial_devs *) file->private_data;
+ total_len = size + sizeof(struct esp_payload_header);
+
+ buf = kmalloc(total_len, GFP_KERNEL);
+ if (!buf) {
+ printk(KERN_ERR "Error allocating buffer to send serial data\n");
+ return -ENOMEM;
+ }
+
+ hdr = (struct esp_payload_header *) buf;
+
+ hdr->if_type = ESP_SERIAL_IF;
+ hdr->if_num = dev->dev_index;
+ hdr->len = cpu_to_le16(size);
+ hdr->offset = cpu_to_le16(sizeof(struct esp_payload_header));
+
+ ret = copy_from_user(buf + hdr->offset, user_buffer, size);
+ if (ret != 0) {
+ kfree(buf);
+ printk(KERN_ERR "Error copying buffer to send serial data\n");
+ return -EFAULT;
+ }
+
+ print_hex_dump_bytes("Tx:", DUMP_PREFIX_NONE, buf, total_len);
+ ret = esp_send_packet(dev->priv, buf, total_len);
+ if (ret) {
+ printk (KERN_ERR "%s: Failed to transmit data\n", __func__);
+ }
+
+ kfree(buf);
+ return size;
+}
+
+static long esp_serial_ioctl (struct file *file, unsigned int cmd, unsigned long arg)
+{
+ printk(KERN_INFO "%s IOCTL %d\n", __func__, cmd);
+ return 0;
+}
+
+static int esp_serial_open(struct inode *inode, struct file *file)
+{
+ struct esp_serial_devs *devs;
+
+ devs = container_of(inode->i_cdev, struct esp_serial_devs, cdev);
+ file->private_data = devs;
+ printk(KERN_INFO "%s on device %d\n", __func__, devs->dev_index);
+
+ return 0;
+}
+
+const struct file_operations esp_serial_fops = {
+ .owner = THIS_MODULE,
+ .open = esp_serial_open,
+ .read = esp_serial_read,
+ .write = esp_serial_write,
+ .unlocked_ioctl = esp_serial_ioctl
+};
+
+int esp_serial_data_received(int dev_index, const char *data, size_t len)
+{
+ int ret;
+ size_t ret_len = 0;
+
+ while (ret_len != len) {
+ ret = esp_rb_write_by_kernel(&devs[dev_index].rb, data, len);
+ ret_len += ret;
+ if (ret == 0) {
+ break;
+ }
+ }
+ if (ret_len != len) {
+ printk(KERN_ERR "RB full, no space to receive. Dropping packet");
+ }
+
+ return ret_len;
+}
+
+#ifdef ESP_SERIAL_TEST
+static int thread_fn(void *unused)
+{
+ int i = 100;
+
+ while(i--) {
+ esp_rb_write_by_kernel(&devs[0].rb, "alphabetagamma", 14);
+ ssleep(1);
+ }
+ printk(KERN_INFO "Thread stopping\n");
+ do_exit(0);
+ return 0;
+}
+#endif
+
+int esp_serial_init(void *priv)
+{
+ int err;
+ int i;
+
+ err = register_chrdev_region(MKDEV(ESP_SERIAL_MAJOR, 0), ESP_SERIAL_MINOR_MAX, "esp_serial_driver");
+ if (err) {
+ printk(KERN_ERR "Error registering chrdev region %d\n", err);
+ return -1;
+ }
+
+ for (i = 0; i < ESP_SERIAL_MINOR_MAX; i++) {
+ cdev_init(&devs[i].cdev, &esp_serial_fops);
+ devs[i].dev_index = i;
+ cdev_add(&devs[i].cdev, MKDEV(ESP_SERIAL_MAJOR, i), 1);
+ esp_rb_init(&devs[i].rb, ESP_RX_RB_SIZE);
+ devs[i].priv = priv;
+ }
+
+#ifdef ESP_SERIAL_TEST
+ kthread_run(thread_fn, NULL, "esptest-thread");
+#endif
+ return 0;
+}
+
+void esp_serial_cleanup(void)
+{
+ int i;
+ for (i = 0; i < ESP_SERIAL_MINOR_MAX; i++) {
+ cdev_del(&devs[i].cdev);
+ esp_rb_cleanup(&devs[i].rb);
+ }
+ unregister_chrdev_region(MKDEV(ESP_SERIAL_MAJOR, 0), ESP_SERIAL_MINOR_MAX);
+ return;
+}
--- /dev/null
+/*
+ * Espressif Systems Wireless LAN device driver
+ *
+ * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
+ *
+ * This software file (the "File") is distributed by Espressif Systems (Shanghai)
+ * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
+ * (the "License"). You may use, redistribute and/or modify this File in
+ * accordance with the terms and conditions of the License, a copy of which
+ * is available by writing to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
+ * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
+ * this warranty disclaimer.
+ */
+
+#ifndef _ESP_SERIAL_H_
+#define _ESP_SERIAL_H_
+
+int esp_serial_init(void * priv);
+void esp_serial_cleanup(void);
+
+int esp_serial_data_received(int dev_index, const char *data, size_t len);
+#endif
--- /dev/null
+/*
+ * Espressif Systems Wireless LAN device driver
+ *
+ * Copyright (C) 2015-2020 Espressif Systems (Shanghai) PTE LTD
+ *
+ * This software file (the "File") is distributed by Espressif Systems (Shanghai)
+ * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
+ * (the "License"). You may use, redistribute and/or modify this File in
+ * accordance with the terms and conditions of the License, a copy of which
+ * is available by writing to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
+ * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
+ * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
+ * this warranty disclaimer.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/slab.h>
+#include <linux/timekeeping.h>
+#include <linux/etherdevice.h>
+#include <linux/netdevice.h>
+
+#include "esp.h"
+#include "esp_if.h"
+#ifdef CONFIG_SUPPORT_ESP_SERIAL
+#include "esp_serial.h"
+#endif
+#include "esp_bt_api.h"
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("WLAN device driver for ESP32 module");
+MODULE_VERSION("0.01");
+
+struct esp_adapter adapter;
+volatile u8 stop_data = 0;
+
+#define ACTION_DROP 1
+
+static int esp_open(struct net_device *ndev);
+static int esp_stop(struct net_device *ndev);
+static int esp_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev);
+static int esp_set_mac_address(struct net_device *ndev, void *addr);
+static void esp_tx_timeout(struct net_device *ndev);
+static struct net_device_stats* esp_get_stats(struct net_device *ndev);
+static void esp_set_rx_mode(struct net_device *ndev);
+int esp_send_packet(struct esp_adapter *adapter, u8 *buf, u32 size);
+
+static const struct net_device_ops esp_netdev_ops = {
+ .ndo_open = esp_open,
+ .ndo_stop = esp_stop,
+ .ndo_start_xmit = esp_hard_start_xmit,
+ .ndo_set_mac_address = esp_set_mac_address,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_tx_timeout = esp_tx_timeout,
+ .ndo_get_stats = esp_get_stats,
+ .ndo_set_rx_mode = esp_set_rx_mode,
+};
+
+#if 0
+u64 start_time, end_time;
+#endif
+
+struct esp_adapter * esp_get_adapter(void)
+{
+ return &adapter;
+}
+
+static int esp_open(struct net_device *ndev)
+{
+ netif_start_queue(ndev);
+ return 0;
+}
+
+static int esp_stop(struct net_device *ndev)
+{
+ netif_stop_queue(ndev);
+ return 0;
+}
+
+static struct net_device_stats* esp_get_stats(struct net_device *ndev)
+{
+ struct esp_private *priv = netdev_priv(ndev);
+ return &priv->stats;
+}
+
+static int esp_set_mac_address(struct net_device *ndev, void *data)
+{
+ struct esp_private *priv = netdev_priv(ndev);
+ struct sockaddr *mac_addr = data;
+
+ if (!priv)
+ return -EINVAL;
+
+ ether_addr_copy(priv->mac_address, mac_addr->sa_data);
+ ether_addr_copy(ndev->dev_addr, mac_addr->sa_data);
+ return 0;
+}
+
+static void esp_tx_timeout(struct net_device *ndev)
+{
+}
+
+static void esp_set_rx_mode(struct net_device *ndev)
+{
+}
+
+static int esp_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
+{
+ struct sk_buff *new_skb;
+ struct esp_private *priv = netdev_priv(ndev);
+ struct esp_skb_cb *cb;
+
+ if (!priv) {
+ dev_kfree_skb(skb);
+ return -EINVAL;
+ }
+
+ if (!skb->len || (skb->len > ETH_FRAME_LEN)) {
+ printk (KERN_ERR "%s: Bad len %d\n", __func__, skb->len);
+ priv->stats.tx_dropped++;
+ dev_kfree_skb(skb);
+ return -EINVAL;
+ }
+
+ if (skb_headroom(skb) < ESP_PAYLOAD_HEADER) {
+ /* Insufficient space. Realloc skb. */
+ new_skb = skb_realloc_headroom(skb, ESP_PAYLOAD_HEADER);
+
+ if (unlikely(!new_skb)) {
+ printk (KERN_ERR "%s: Failed to allocate SKB\n", __func__);
+ priv->stats.tx_dropped++;
+ dev_kfree_skb(skb);
+ return -ENOMEM;
+ }
+
+ /* Free old SKB */
+ dev_kfree_skb(skb);
+
+ skb = new_skb;
+ }
+
+ cb = (struct esp_skb_cb *) skb->cb;
+ cb->priv = priv;
+
+/* print_hex_dump_bytes("Tx:", DUMP_PREFIX_NONE, skb->data, 8);*/
+
+ skb_queue_tail(&adapter.tx_q, skb);
+ atomic_inc(&adapter.tx_pending);
+ queue_work(adapter.tx_workqueue, &adapter.tx_work);
+
+ return 0;
+}
+
+u8 esp_is_bt_supported_over_sdio(u32 cap)
+{
+ return (cap & ESP_BT_SDIO_SUPPORT);
+}
+
+static struct esp_private * get_priv_from_payload_header(struct esp_payload_header *header)
+{
+ struct esp_private *priv;
+ u8 i;
+
+ if (!header)
+ return NULL;
+
+ for (i = 0; i < ESP_MAX_INTERFACE; i++) {
+ priv = adapter.priv[i];
+
+ if (!priv)
+ continue;
+
+ if (priv->if_type == header->if_type &&
+ priv->if_num == header->if_num) {
+ return priv;
+ }
+ }
+
+ return NULL;
+}
+
+void esp_process_new_packet_intr(struct esp_adapter *adapter)
+{
+ if(adapter)
+ queue_work(adapter->if_rx_workqueue, &adapter->if_rx_work);
+}
+
+static void process_tx_packet (void)
+{
+ struct sk_buff *skb;
+ struct esp_private *priv;
+ struct esp_skb_cb *cb;
+ struct esp_payload_header *payload_header;
+ struct sk_buff *new_skb;
+ int ret = 0;
+ u8 pad_len = 0;
+ u16 len = 0;
+ static u32 c = 0;
+
+ while ((skb = skb_dequeue(&adapter.tx_q))) {
+ c++;
+ /* Get the priv */
+ cb = (struct esp_skb_cb *) skb->cb;
+ priv = cb->priv;
+
+ if (!priv) {
+ dev_kfree_skb_any(skb);
+ atomic_dec(&adapter.tx_pending);
+ continue;
+ }
+
+ len = skb->len;
+
+ /* Create space for payload header */
+ pad_len = sizeof(struct esp_payload_header);
+
+ if (skb_headroom(skb) < pad_len) {
+ /* insufficent headroom to add payload header */
+ new_skb = skb_realloc_headroom(skb, pad_len);
+
+ if(!new_skb) {
+ printk(KERN_ERR "%s: Failed to allocate SKB", __func__);
+ dev_kfree_skb(skb);
+ atomic_dec(&adapter.tx_pending);
+ continue;
+ }
+
+ dev_kfree_skb(skb);
+
+ skb = new_skb;
+ }
+
+ skb_push(skb, pad_len);
+
+ /* Set payload header */
+ payload_header = (struct esp_payload_header *) skb->data;
+ memset(payload_header, 0, pad_len);
+
+ payload_header->if_type = priv->if_type;
+ payload_header->if_num = priv->if_num;
+ payload_header->len = cpu_to_le16(skb->len - pad_len);
+ payload_header->offset = cpu_to_le16(pad_len);
+ payload_header->reserved1 = c % 255;
+
+/* printk (KERN_ERR "H -> S: %d %d %d %d", len, payload_header->offset,*/
+/* payload_header->len, payload_header->reserved1);*/
+
+ if (!stop_data) {
+ ret = esp_send_packet(priv->adapter, skb->data, skb->len);
+
+ if (ret) {
+ priv->stats.tx_errors++;
+ } else {
+ priv->stats.tx_packets++;
+ priv->stats.tx_bytes += skb->len;
+ }
+ } else {
+ priv->stats.tx_dropped++;
+ }
+
+ dev_kfree_skb_any(skb);
+ atomic_dec(&adapter.tx_pending);
+ }
+}
+
+static void process_rx_packet(struct sk_buff *skb)
+{
+ struct esp_private *priv;
+ struct esp_payload_header *payload_header;
+ u16 len, offset;
+ struct hci_dev *hdev = adapter.hcidev;
+ u8 *type;
+
+ if (!skb)
+ return;
+
+ /* get the paload header */
+ payload_header = (struct esp_payload_header *) skb->data;
+ /* print_hex_dump_bytes("Rx:", DUMP_PREFIX_NONE, (skb->data + 8), 32);*/
+
+ len = le16_to_cpu(payload_header->len);
+ offset = le16_to_cpu(payload_header->offset);
+
+ if (payload_header->if_type == ESP_SERIAL_IF) {
+ print_hex_dump_bytes("Rx:", DUMP_PREFIX_NONE, (skb->data + offset), len);
+#ifdef CONFIG_SUPPORT_ESP_SERIAL
+ esp_serial_data_received(payload_header->if_num, skb->data + offset, len);
+#else
+ printk(KERN_ERR "Dropping unsupported serial frame\n");
+#endif
+ dev_kfree_skb_any(skb);
+ } else if (payload_header->if_type == ESP_STA_IF || payload_header->if_type == ESP_AP_IF) {
+ /* chop off the header from skb */
+ skb_pull(skb, offset);
+
+ /* retrieve priv based on payload header contents */
+ priv = get_priv_from_payload_header(payload_header);
+
+ if (!priv) {
+ printk (KERN_ERR "%s: empty priv\n", __func__);
+ dev_kfree_skb_any(skb);
+/* atomic_dec(&adapter.rx_pending);*/
+ return;
+ }
+
+ skb->dev = priv->ndev;
+ skb->protocol = eth_type_trans(skb, priv->ndev);
+ skb->ip_summed = CHECKSUM_NONE;
+ /* print_hex_dump_bytes("Rx:", DUMP_PREFIX_NONE, skb->data, 8);*/
+
+ /* Forward skb to kernel */
+ netif_rx(skb);
+
+ priv->stats.rx_bytes += skb->len;
+ priv->stats.rx_packets++;
+ } else if (payload_header->if_type == ESP_HCI_IF) {
+ if (hdev) {
+ /* chop off the header from skb */
+ skb_pull(skb, offset);
+
+/* print_hex_dump_bytes("Rx:", DUMP_PREFIX_NONE, skb->data, skb->len);*/
+ type = skb->data;
+ hci_skb_pkt_type(skb) = *type;
+ skb_pull(skb, 1);
+
+ if (hci_recv_frame(hdev, skb)) {
+ hdev->stat.err_rx++;
+ } else {
+ esp_hci_update_rx_counter(hdev, *type, skb->len);
+ }
+ }
+ }
+}
+
+struct sk_buff * esp_alloc_skb(u32 len)
+{
+ struct sk_buff *skb;
+
+ skb = netdev_alloc_skb(NULL, len);
+ return skb;
+}
+
+
+static int esp_get_packets(struct esp_adapter *adapter)
+{
+ struct sk_buff *skb;
+
+ if (!adapter || !adapter->if_ops || !adapter->if_ops->read)
+ return -EINVAL;
+
+ skb = adapter->if_ops->read(adapter);
+
+ if (!skb)
+ return -EFAULT;
+
+ process_rx_packet(skb);
+
+ return 0;
+}
+
+int esp_send_packet(struct esp_adapter *adapter, u8 *buf, u32 size)
+{
+ if (!adapter || !adapter->if_ops || !adapter->if_ops->write)
+ return -EINVAL;
+
+ return adapter->if_ops->write(adapter, buf, size);
+}
+
+static int insert_priv_to_adapter(struct esp_private *priv)
+{
+ int i = 0;
+
+ for (i = 0; i < ESP_MAX_INTERFACE; i++) {
+ /* Check if priv can be added */
+ if (adapter.priv[i] == NULL) {
+ adapter.priv[i] = priv;
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+static int esp_init_priv(struct esp_private *priv, struct net_device *dev,
+ u8 if_type, u8 if_num)
+{
+ int ret = 0;
+
+ if (!priv || !dev)
+ return -EINVAL;
+
+ ret = insert_priv_to_adapter(priv);
+ if (ret)
+ return ret;
+
+ priv->ndev = dev;
+ priv->if_type = if_type;
+ priv->if_num = if_num;
+ priv->link_state = ESP_LINK_DOWN;
+ priv->adapter = &adapter;
+ memset(&priv->stats, 0, sizeof(priv->stats));
+
+ return 0;
+}
+
+static int esp_init_net_dev(struct net_device *ndev, struct esp_private *priv)
+{
+ int ret = 0;
+ /* Set netdev */
+/* SET_NETDEV_DEV(ndev, &adapter->context.func->dev);*/
+
+ /* set net dev ops */
+ ndev->netdev_ops = &esp_netdev_ops;
+
+ ether_addr_copy(ndev->dev_addr, priv->mac_address);
+ /* set ethtool ops */
+
+ /* update features supported */
+
+ /* min mtu */
+
+ /* register netdev */
+ ret = register_netdev(ndev);
+
+/* netif_start_queue(ndev);*/
+ /* ndev->needs_free_netdev = true; */
+
+ /* set watchdog timeout */
+
+ return ret;
+}
+
+static int esp_add_interface(struct esp_adapter *adapter, u8 if_type, u8 if_num, char *name)
+{
+ struct net_device *ndev = NULL;
+ struct esp_private *priv = NULL;
+ int ret = 0;
+
+ ndev = alloc_netdev_mqs(sizeof(struct esp_private), name,
+ NET_NAME_ENUM, ether_setup, 1, 1);
+
+ if (!ndev) {
+ printk(KERN_ERR "%s: alloc failed\n", __func__);
+ return -ENOMEM;
+ }
+
+ priv = netdev_priv(ndev);
+
+ /* Init priv */
+ ret = esp_init_priv(priv, ndev, if_type, if_num);
+ if (ret) {
+ printk(KERN_ERR "%s: Init priv failed\n", __func__);
+ goto error_exit;
+ }
+
+ ret = esp_init_net_dev(ndev, priv);
+ if (ret) {
+ printk(KERN_ERR "%s: Init netdev failed\n", __func__);
+ goto error_exit;
+ }
+
+ return ret;
+
+error_exit:
+ free_netdev(ndev);
+ return ret;
+}
+
+static void flush_ring_buffers(struct esp_adapter *adapter)
+{
+ struct sk_buff *skb;
+
+ printk (KERN_INFO "%s: Flush Pending SKBs: %d %d\n", __func__,
+ atomic_read(&adapter->tx_pending),
+ atomic_read(&adapter->rx_pending));
+
+ while ((skb = skb_dequeue(&adapter->tx_q))) {
+ dev_kfree_skb_any(skb);
+ atomic_dec(&adapter->tx_pending);
+ }
+
+ while ((skb = skb_dequeue(&adapter->rx_q))) {
+ dev_kfree_skb_any(skb);
+ atomic_dec(&adapter->rx_pending);
+ }
+}
+
+static void esp_remove_network_interfaces(struct esp_adapter *adapter)
+{
+ if (adapter->priv[0]->ndev) {
+ netif_stop_queue(adapter->priv[0]->ndev);
+ unregister_netdev(adapter->priv[0]->ndev);
+ free_netdev(adapter->priv[0]->ndev);
+ }
+
+ if (adapter->priv[1]->ndev) {
+ netif_stop_queue(adapter->priv[1]->ndev);
+ unregister_netdev(adapter->priv[1]->ndev);
+ free_netdev(adapter->priv[1]->ndev);
+ }
+}
+
+int esp_add_card(struct esp_adapter *adapter)
+{
+ int ret = 0;
+
+ if (!adapter) {
+ printk(KERN_ERR "%s: Invalid args\n", __func__);
+ return -EINVAL;
+ }
+
+ stop_data = 0;
+
+ /* Add interface STA and AP */
+ ret = esp_add_interface(adapter, ESP_STA_IF, 0, "ethsta%d");
+ if (ret) {
+ printk(KERN_ERR "%s: Failed to add STA\n", __func__);
+ return ret;
+ }
+
+ ret = esp_add_interface(adapter, ESP_AP_IF, 0, "ethap%d");
+ if (ret) {
+ printk(KERN_ERR "%s: Failed to add AP\n", __func__);
+ esp_remove_network_interfaces(adapter);
+ }
+
+ return ret;
+}
+
+int esp_remove_card(struct esp_adapter *adapter)
+{
+ stop_data = 1;
+
+ if (!adapter)
+ return 0;
+
+ /* Flush workqueues */
+ if (adapter->if_rx_workqueue)
+ flush_workqueue(adapter->if_rx_workqueue);
+
+ if (adapter->tx_workqueue)
+ flush_workqueue(adapter->tx_workqueue);
+
+ esp_remove_network_interfaces(adapter);
+
+ flush_ring_buffers(adapter);
+
+ adapter->priv[0] = NULL;
+ adapter->priv[1] = NULL;
+
+ atomic_set(&adapter->tx_pending, 0);
+ atomic_set(&adapter->rx_pending, 0);
+
+ return 0;
+}
+
+
+static void esp_tx_work (struct work_struct *work)
+{
+ process_tx_packet();
+}
+
+static void esp_if_rx_work (struct work_struct *work)
+{
+ /* read inbound packet and forward it to network/serial interface */
+ esp_get_packets(&adapter);
+}
+
+static void deinit_adapter(void)
+{
+ if (adapter.if_rx_workqueue)
+ destroy_workqueue(adapter.if_rx_workqueue);
+
+ if (adapter.tx_workqueue)
+ destroy_workqueue(adapter.tx_workqueue);
+}
+
+static struct esp_adapter * init_adapter(void)
+{
+ memset(&adapter, 0, sizeof(adapter));
+
+ /* Prepare interface RX work */
+ adapter.if_rx_workqueue = create_workqueue("ESP_IF_RX_WORK_QUEUE");
+
+ if (!adapter.if_rx_workqueue) {
+ deinit_adapter();
+ return NULL;
+ }
+
+ INIT_WORK(&adapter.if_rx_work, esp_if_rx_work);
+
+ /* Prepare TX work */
+ adapter.tx_workqueue = create_workqueue("ESP_TX_WORK_QUEUE");
+
+ if (!adapter.tx_workqueue) {
+ deinit_adapter();
+ return NULL;
+ }
+
+ INIT_WORK(&adapter.tx_work, esp_tx_work);
+
+ /* Prepare TX work */
+ skb_queue_head_init(&adapter.tx_q);
+ skb_queue_head_init(&adapter.rx_q);
+
+ atomic_set(&adapter.tx_pending, 0);
+ atomic_set(&adapter.rx_pending, 0);
+
+ return &adapter;
+}
+
+
+static int __init esp_init(void)
+{
+ int ret = 0;
+ struct esp_adapter *adapter;
+
+ /* Init adapter */
+ adapter = init_adapter();
+
+ if (!adapter)
+ return -EFAULT;
+
+ /* Init transport layer */
+ ret = esp_init_interface_layer(adapter);
+
+ if (ret != 0) {
+ deinit_adapter();
+ }
+
+ return ret;
+}
+
+static void __exit esp_exit(void)
+{
+ esp_deinit_interface_layer();
+ deinit_adapter();
+}
+
+module_init(esp_init);
+module_exit(esp_exit);