Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
soletta.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Soletta (TM) Project
3  *
4  * Copyright (C) 2016 Intel Corporation. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #pragma once
20 
21 #include <sol-log.h>
22 #include <sol-mainloop.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
65 #ifdef SOL_PLATFORM_CONTIKI
66 #include "sol-mainloop-contiki.h"
67 
68 #define SOL_MAIN_DEFAULT(STARTUP, SHUTDOWN) \
69  PROCESS(soletta_app_process, "soletta app process"); \
70  AUTOSTART_PROCESSES(&soletta_app_process); \
71  PROCESS_THREAD(soletta_app_process, ev, data) \
72  { \
73  SOL_LOG_LEVEL_INIT(); \
74  SOL_LOG_LEVELS_INIT(); \
75  sol_mainloop_contiki_event_set(ev, data); \
76  PROCESS_BEGIN(); \
77  if (sol_init() < 0) \
78  return EXIT_FAILURE; \
79  STARTUP(); \
80  sol_run(); \
81  while (sol_mainloop_contiki_iter()) \
82  PROCESS_WAIT_EVENT(); \
83  SHUTDOWN(); \
84  sol_shutdown(); \
85  PROCESS_END(); \
86  }
87 #else
88 #ifdef SOL_PLATFORM_RIOT
89 #define SOL_MAIN(CALLBACKS) \
90  int main(void) { \
91  SOL_LOG_LEVEL_INIT(); \
92  SOL_LOG_LEVELS_INIT(); \
93  return sol_mainloop_default_main(&(CALLBACKS), 0, NULL); \
94  }
95 #elif defined SOL_PLATFORM_ZEPHYR
96 #include <zephyr.h>
97 
98 #define SOL_MAIN(CALLBACKS) \
99  void main(void) { \
100  SOL_LOG_LEVEL_INIT(); \
101  SOL_LOG_LEVELS_INIT(); \
102  sol_mainloop_default_main(&(CALLBACKS), 0, NULL); \
103  }
104 #else
105 #define SOL_MAIN(CALLBACKS) \
106  int main(int argc, char *argv[]) { \
107  SOL_LOG_LEVEL_INIT(); \
108  SOL_LOG_LEVELS_INIT(); \
109  return sol_mainloop_default_main(&(CALLBACKS), argc, argv); \
110  }
111 #endif /* SOL_PLATFORM_RIOT */
112 
113 #ifdef __cplusplus
114 #define SOL_MAIN_DEFAULT(STARTUP, SHUTDOWN) \
115  static const struct sol_main_callbacks sol_main_callbacks_instance { \
116  SOL_SET_API_VERSION(.api_version = SOL_MAIN_CALLBACKS_API_VERSION, ) \
117  .flags = 0, \
118  .startup = (STARTUP), \
119  .shutdown = (SHUTDOWN) \
120  }; \
121  SOL_MAIN(sol_main_callbacks_instance)
122 #else
123 #define SOL_MAIN_DEFAULT(STARTUP, SHUTDOWN) \
124  static const struct sol_main_callbacks sol_main_callbacks_instance = { \
125  SOL_SET_API_VERSION(.api_version = SOL_MAIN_CALLBACKS_API_VERSION, ) \
126  .startup = (STARTUP), \
127  .shutdown = (SHUTDOWN) \
128  }; \
129  SOL_MAIN(sol_main_callbacks_instance)
130 #endif /* __cplusplus */
131 #endif /* SOL_PLATFORM_CONTIKI */
132 
137 #ifdef __cplusplus
138 }
139 #endif
These routines are used for Soletta logging.
These routines are used for Soletta's mainloop manipulation.