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
18extern struct userapp_info userapp_vector;
19
20// our main mculib handle to be used for every mculib call
21int MCULIBHANDLE;
22static long ctr;
23static int userctr = 0;
24static struct sc_firmware_api *api;
31int start(int mculib_handle, struct sc_firmware_api *uapi) {
32 api = uapi;
33 api->printf("Hello World (userapp)\r\n");
34 return 0;
35}
36/*
37 * \brief called when user code is stopped
38 */
39void stop() {
40}
41
53int on_command_received(struct command *com) {
54 return 0;
55}
56
61void on_new_node(struct hostroute *host) {
62}
67void user_loop() {
68 if (api->mculib_has_time_passed(2, &ctr)) {
69 api->printf("user_loop (%i) (app: %p)\r\n", userctr, &userapp_vector);
70 userctr++;
71 }
72}
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:61
int start(int mculib_handle, struct sc_firmware_api *uapi)
this is called when the board powers up
Definition: userhooks.c:31
int on_command_received(struct command *com)
this is called for each command we receive
Definition: userhooks.c:53
void user_loop()
this is called frequently, but with no timing guarantees. essentially, it's called in the "idle-loop"...
Definition: userhooks.c:67
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:34
definitions of routing table structures
these are the callbacks available. the firmware "api". provided to the app on startup
Definition: user_app_info.h:29
this must be implemented by the userapp, stored in flash at the beginning of the file (offset 0)
user application interface