-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathrtl_fm_python_web.py
executable file
·85 lines (71 loc) · 2.22 KB
/
rtl_fm_python_web.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/python
# rtl-sdr, turns your Realtek RTL2832 based DVB dongle into a SDR receiver
# Copyright (C) 2012 by Steve Markgraf <[email protected]>
# Copyright (C) 2012 by Hoernchen <[email protected]>
# Copyright (C) 2012 by Kyle Keen <[email protected]>
# Copyright (C) 2013 by Elias Oenal <[email protected]>
# Copyright (C) 2014 by Thomas Winningham <[email protected]>
#
# 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, see <http://www.gnu.org/licenses/>.
from flask import Flask, jsonify, url_for, redirect
from rtl_fm_python_thread import *
make_rtl_fm_thread(block=False)
app = Flask(__name__)
@app.route('/')
def web_root():
return redirect(url_for('static', filename='index.html'))
@app.route('/state')
def web_state():
return jsonify(
{
's_level' : get_s_level(),
'freq_s' : get_freq_human(),
'freq_i' : get_frequency(),
'mod' : get_demod(),
'gain' : get_gain(),
'autogain' : get_auto_gain()
})
@app.route('/frequency/<int:f>')
def web_set_frequency(f):
set_frequency(f)
return web_state()
@app.route('/frequency/human/<f>')
def web_set_human_frequency(f):
set_freq_human(str(f))
return web_state()
@app.route('/demod/<c>')
def web_set_demod(c):
set_demod(str(c))
return web_state()
@app.route('/gain/<g>')
def web_set_gain(g):
gain = int(str(g))
set_gain(gain)
return web_state()
@app.route('/gain/human/<g>')
def web_set_gain_human(g):
gain = int(str(g))
set_gain_human(gain)
return web_state()
@app.route('/gain/auto')
def web_set_auto_gain():
set_auto_gain()
return web_state()
@app.route('/gain/list')
def web_get_gain_list():
l=get_gains()
return jsonify({'gains':l})
if __name__ == '__main__':
app.run(host='0.0.0.0',port=10100)
stop_thread()