File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 13
13
from coderbot import CoderBot
14
14
from program import ProgramEngine , Program
15
15
from config import Config
16
+ import pigpio
17
+
18
+ BUTTON_PIN = 16
16
19
17
20
bot_config = Config .get ()
18
21
bot = CoderBot .get_instance (
@@ -118,12 +121,20 @@ def exec(data):
118
121
119
122
def status ():
120
123
sts = get_status ()
124
+ # getting reset log file
125
+ try :
126
+ with open ('/home/pi/coderbot/logs/reset_trigger_service.log' , 'r' ) as log_file :
127
+ data = [x for x in log_file .read ().split ('\n ' ) if x ]
128
+ except Exception :
129
+ data = [] # if file doesn't exist, no restore as ever been performed. return empty data
130
+
121
131
122
132
return {
123
133
"status" : "ok" ,
124
134
"internetConnectivity" : sts ["internet_status" ],
125
135
"temp" : sts ["temp" ],
126
136
"uptime" : sts ["uptime" ],
137
+ "log" : data
127
138
}
128
139
129
140
def info ():
@@ -206,3 +217,16 @@ def resetDefaultPrograms():
206
217
with open ("data/defaults/programs/" + filename ) as p :
207
218
q = p .read ()
208
219
programs .insert (json .loads (q ))
220
+
221
+ ## Reset
222
+ def reset ():
223
+ pi = pigpio .pi ('localhost' )
224
+ #simulating FALLING EDGE
225
+ # it triggers the reset by using the service altready running on the system that detects a button press (3 sec).
226
+ pi .write (BUTTON_PIN , 1 )
227
+ pi .write (BUTTON_PIN , 0 )
228
+
229
+ return {
230
+ "status" : "ok"
231
+ }
232
+
Original file line number Diff line number Diff line change @@ -164,12 +164,21 @@ paths:
164
164
/status :
165
165
get :
166
166
operationId : " api.status"
167
- summary : " Bot general informations and execution status"
167
+ summary : " Bot general informations, execution status and reset log file "
168
168
tags :
169
169
- Status informations
170
170
responses :
171
171
200 :
172
172
description : " Bot status"
173
+ /reset :
174
+ post :
175
+ operationId : " api.reset"
176
+ summary : " Reset coderbot by restoring boot partition"
177
+ tags :
178
+ - Coderbot reset
179
+ responses :
180
+ 200 :
181
+ description : " resets coderbot entirely"
173
182
/info :
174
183
get :
175
184
operationId : " api.info"
You can’t perform that action at this time.
0 commit comments