root / logic / trunk / src / startup / main.c @ 24
History | View | Annotate | Download (1.31 KB)
1 |
/*
|
---|---|
2 |
* main.c
|
3 |
*
|
4 |
* 2011, Aleksander Besir (alex.besir@gmail.com)
|
5 |
*
|
6 |
*/
|
7 |
|
8 |
#include "../hci_comm/hci_comm.h" |
9 |
#include <stdio.h> |
10 |
#include <pthread.h> |
11 |
|
12 |
// 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 |
void *decisionMakingThread_routine(void *dummy); |
20 |
void *hciConnectionThread_routine(void *dummy); |
21 |
|
22 |
// Application entry point
|
23 |
int main(int argc, char *argv[]) { |
24 |
|
25 |
printf("Hello world!\n");
|
26 |
//*
|
27 |
setDeviceList(); |
28 |
/*
|
29 |
pthread_t hciConnectionThread;
|
30 |
pthread_t decisionMakingThread;
|
31 |
|
32 |
pthread_create(&hciConnectionThread,NULL,hciConnectionThread_routine,NULL);
|
33 |
pthread_create(&decisionMakingThread,NULL,decisionMakingThread_routine,NULL);
|
34 |
|
35 |
pthread_join(hciConnectionThread,NULL);
|
36 |
pthread_join(decisionMakingThread,NULL);
|
37 |
/**/
|
38 |
exit(0);
|
39 |
|
40 |
} |
41 |
|
42 |
// Decision-making thread routine
|
43 |
// Should just call a function that implements decision making module of the logic
|
44 |
void *decisionMakingThread_routine(void *dummy) { |
45 |
|
46 |
// TODO: Implemet decision making
|
47 |
|
48 |
pthread_exit(0);
|
49 |
|
50 |
} |
51 |
|
52 |
// HCI connection thread routine
|
53 |
// Start listening to some port
|
54 |
void *hciConnectionThread_routine(void *dummy) { |
55 |
|
56 |
int hciErrorCode = listenTo(1100); |
57 |
|
58 |
pthread_exit(0);
|
59 |
|
60 |
} |