greenhouse
main.cpp
Go to the documentation of this file.
1 #include "Callback.h"
2 #include "database.h"
3 #include "jukebox_task.h"
4 #include "mbed.h"
5 #include "mbed_wait_api.h"
6 #include "storage_task.h"
7 #include "ui/ui.h"
8 #include "webserver.h"
9 #include <cstdint>
10 #include <cstdlib>
11 #include "tasks.h"
12 
13 Thread thread_main;
16 Thread thread_stats;
17 Thread thread_sd;
18 
20 
21 void webserver_task(WebServer *webServer) {
22  while (true) {
23  webServer->tick();
24  }
25 }
26 
28 
29 void stats_task() {
31  task_stats->start();
32 }
33 
34 void jukebox_task() {
35  Tasks::Jukebox *jukebox;
36  jukebox->start();
37 }
38 
39 int main(void) {
40  display->init();
41 
42  thread_stats.start(stats_task);
44 
45  Database db;
46  WebServer webServer = WebServer(&db);
47 
48  display->log((uint8_t *)"[webserver]: starting");
49 
50  int status = webServer.start();
51  if (status == 0) {
52  display->log((uint8_t *)"[webserver]: error - No network interface found");
53  return 1;
54  }
55 
56  display->log((uint8_t *)"[webserver]: IP: 192.168.1.100");
57 
58  display->log((uint8_t *)"[host]: spawning webserver_thread");
59  thread_web_server.start(callback(webserver_task, &webServer));
60 
61  Tasks::Storage *storage;
62  storage->example(display);
63 
64  return 0;
65 }
void setDisplay(UI::Display *display)
Definition: stats_task.cpp:17
void start()
Definition: stats_task.cpp:27
void example(UI::Display *display)
Definition: ui.h:8
void log(uint8_t *text)
Definition: ui.cpp:53
void init()
Definition: ui.cpp:33
int start()
Definition: webserver.cpp:28
void tick()
Definition: webserver.cpp:92
void jukebox_task()
Definition: main.cpp:34
Thread thread_main
Definition: main.cpp:13
int main(void)
Definition: main.cpp:39
Tasks::Stats * task_stats
Definition: main.cpp:27
Thread thread_sd
Definition: main.cpp:17
Thread thread_stats
Definition: main.cpp:16
Thread thread_web_server
Definition: main.cpp:14
void stats_task()
Definition: main.cpp:29
UI::Display * display
Definition: main.cpp:19
void webserver_task(WebServer *webServer)
Definition: main.cpp:21
Thread thread_jukebox
Definition: main.cpp:15
Database * db
Definition: webserver.cpp:14