Skip to content

Commit fee8487

Browse files
committed
add wifi stub
1 parent fb0f02e commit fee8487

File tree

6 files changed

+121
-6
lines changed

6 files changed

+121
-6
lines changed

coderbot/audio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import pyaudio
2727
import alsaaudio
2828

29-
from six.moves import queue
29+
import queue
3030
# [END import_libraries]
3131

3232
# Audio recording parameters

docker/stub/requirements.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# API framework
2-
connexion==2.14.2
3-
Flask==2.2.5
4-
Flask-Cors==3.0.10
2+
connexion[uvicorn,flask,swagger-ui]==3.0.5
53
tinydb==4.8.0
6-
Werkzeug==2.2.3
74

85
# Misc utils
96
setuptools==69.2.0

docker/stub/start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
export PYTHONPATH=./stub:./test:./coderbot
44
cd /coderbot
5-
python3 coderbot/main.py
5+
python3 coderbot/main.py & python3 stub/wifi/main.py

stub/wifi/api.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import logging
2+
3+
def list_access_points():
4+
return {"ssids": [{"ssid": "my_wifi"}]}
5+
6+
def connection_status():
7+
return {"wifi": "true", "internet": "true"}
8+
9+
def connect():
10+
return "ok"
11+
12+
def forget():
13+
return "ok"
14+
15+
def sset_hotspot_ssid():
16+
return "ok"
17+
18+
def set_hotspot_password():
19+
return "ok"

stub/wifi/main.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/python
2+
3+
import os
4+
import logging
5+
import logging.handlers
6+
import connexion
7+
from connexion.middleware import MiddlewarePosition
8+
from starlette.middleware.cors import CORSMiddleware
9+
10+
# Logging configuration
11+
logger = logging.getLogger()
12+
logger.setLevel(os.environ.get("LOGLEVEL", "INFO"))
13+
14+
## (Connexion) Flask app configuration
15+
16+
# Serve a custom version of the swagger ui (Jinja2 templates) based on the default one
17+
# from the folder 'swagger-ui'. Clone the 'swagger-ui' repository inside the backend folder
18+
19+
app = connexion.App(__name__)
20+
app.add_middleware(
21+
CORSMiddleware,
22+
position=MiddlewarePosition.BEFORE_EXCEPTION,
23+
allow_origins=["*"],
24+
allow_credentials=True,
25+
allow_methods=["*"],
26+
allow_headers=["*"],
27+
)
28+
29+
## New API and web application
30+
31+
# API v1 is defined in v1.yml and its methods are in api.py
32+
app.add_api('v1.yml')
33+
34+
if __name__ == "__main__":
35+
app.run(host="0.0.0.0", port=9090)

stub/wifi/v1.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
openapi: "3.0.0"
2+
info:
3+
version: "1.0"
4+
title: OpenAPI 3.0 definition of WiFi API
5+
6+
servers:
7+
- url: http://coderbot.local/v1
8+
9+
# Paths supported by the server application
10+
paths:
11+
/list_access_points:
12+
get:
13+
operationId: "api.list_access_points"
14+
summary: "list Access Points"
15+
responses:
16+
200:
17+
description: "ok"
18+
tags:
19+
- Wifi
20+
/connection_status:
21+
get:
22+
operationId: "api.connection_status"
23+
summary: "connection Status"
24+
responses:
25+
200:
26+
description: "ok"
27+
tags:
28+
- Wifi
29+
/connect:
30+
post:
31+
operationId: "api.connect"
32+
summary: "connect"
33+
responses:
34+
200:
35+
description: "ok"
36+
tags:
37+
- Wifi
38+
/forget:
39+
post:
40+
operationId: "api.forget"
41+
summary: "forget"
42+
responses:
43+
200:
44+
description: "ok"
45+
tags:
46+
- Wifi
47+
/sset_hotspot_ssid:
48+
post:
49+
operationId: "api.sset_hotspot_ssid"
50+
summary: "sset_hotspot_ssid"
51+
responses:
52+
200:
53+
description: "ok"
54+
tags:
55+
- Wifi
56+
/set_hotspot_password:
57+
post:
58+
operationId: "api.set_hotspot_password"
59+
summary: "set_hotspot_password"
60+
responses:
61+
200:
62+
description: "ok"
63+
tags:
64+
- Wifi

0 commit comments

Comments
 (0)