SingingCat  0
application
userhooks.c
Go to the documentation of this file.
1 #include "user_app_info.h"
2 #include "routing.h"
3 #include "command.h"
4 
18 extern struct userapp_info userapp_vector;
19 
20 // our main mculib handle to be used for every mculib call
21 int MCULIBHANDLE;
22 static long ctr;
23 static int userctr = 0;
24 static struct sc_firmware_api *api;
30 void start(int mculib_handle, struct sc_firmware_api *uapi) {
31  api = uapi;
32  api->printf("Hello World (userapp)\r\n");
33 }
34 /*
35  * \brief called when user code is stopped
36  */
37 void stop() {
38 }
39 
51 int on_command_received(struct command *com) {
52  return 0;
53 }
54 
59 void on_new_node(struct hostroute *host) {
60 }
65 void user_loop() {
66  if (api->mculib_has_time_passed(2, &ctr)) {
67  api->printf("user_loop (%i) (app: %p)\r\n", userctr, &userapp_vector);
68  userctr++;
69  }
70 }
void on_new_node(struct hostroute *host)
called when and if a new node is detected. this may be used, to, for example to activate when a route...
Definition: userhooks.c:59
int on_command_received(struct command *com)
this is called for each command we receive
Definition: userhooks.c:51
void(* printf)(const char *format,...)
print a message on console and possibly forward to server into logfile as well (uses radio - expensiv...
Definition: user_app_info.h:32
void start(int mculib_handle, struct sc_firmware_api *uapi)
this is called when the board powers up
Definition: userhooks.c:30
void user_loop()
this is called frequently, but with no timing guarantees. essentially, it's called in the "idle-loop"...
Definition: userhooks.c:65
definitions of routing table structures
these are the callbacks available. the firmware "api". provided to the app on startup
Definition: user_app_info.h:27
this must be implemented by the userapp, stored in flash at the beginning of the file (offset 0)
user application interface