root / logic / trunk / src / startup / main.c @ 9
History | View | Annotate | Download (1.2 KB)
1 | 9 | alexbesir | /*
|
---|---|---|---|
2 | * main.c
|
||
3 | *
|
||
4 | * 2011, Aleksander Besir (alex.besir@gmail.com)
|
||
5 | *
|
||
6 | */
|
||
7 | |||
8 | 8 | alexbesir | #include "../hci_comm/hci_comm.h" |
9 | 9 | alexbesir | #include <stdio.h> |
10 | #include <pthread.h> |
||
11 | 7 | alexbesir | |
12 | 9 | alexbesir | // Inter-thread shared variables
|
13 | // TODO: These variables could be configuration variables
|
||
14 | // (eg: static boolean loggingEnabled)
|
||
15 | |||
16 | // Crtitical section mutual exclusion security
|
||
17 | static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
|
||
18 | |||
19 | // Application entry point
|
||
20 | 7 | alexbesir | int main(int argc, char *argv[]) { |
21 | |||
22 | 9 | alexbesir | pthread_t hciConnectionThread; |
23 | pthread_t decisionMakingThread; |
||
24 | |||
25 | pthread_create(&hciConnectionThread,NULL,hciConnectionThread_routine,NULL); |
||
26 | pthread_create(&decisionMakingThread,NULL,decisionMakingThread_routine,NULL); |
||
27 | |||
28 | pthread_join(hciConnectionThread,NULL);
|
||
29 | pthread_join(decisionMakingThread,NULL);
|
||
30 | |||
31 | exit(0);
|
||
32 | 7 | alexbesir | |
33 | 8 | alexbesir | } |
34 | 9 | alexbesir | |
35 | // Decision-making thread routine
|
||
36 | // Should just call a function that implements decision making module of the logic
|
||
37 | void *decisionMakingThread_routine(void *dummy) { |
||
38 | |||
39 | // TODO: Implemet decision making
|
||
40 | |||
41 | pthread_exit(0);
|
||
42 | |||
43 | } |
||
44 | |||
45 | // HCI connection thread routine
|
||
46 | // Start listening to some port
|
||
47 | void *hciConnectionThread_routine(void *dummy) { |
||
48 | |||
49 | int hciErrorCode = listenTo(1100); |
||
50 | |||
51 | pthread_exit(0);
|
||
52 | |||
53 | } |