Statistics
| Revision:

root / logic / trunk / src / startup / main.c @ 31

History | View | Annotate | Download (1.35 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
    /* initialisation */
26
    setDeviceList();
27
    setNewScenarioList();
28

    
29
    /* regular work */
30
    //*
31
        pthread_t hciConnectionThread;
32
        pthread_t decisionMakingThread;
33

    
34
        pthread_create(&hciConnectionThread,NULL,hciConnectionThread_routine,NULL);
35
        pthread_create(&decisionMakingThread,NULL,decisionMakingThread_routine,NULL);
36

    
37
        pthread_join(hciConnectionThread,NULL);
38
        pthread_join(decisionMakingThread,NULL);
39
    /**/
40
        exit(0);
41
}
42

    
43
// Decision-making thread routine
44
// Should just call a function that implements decision making module of the logic
45
void *decisionMakingThread_routine(void *dummy) {
46

    
47
        // TODO: Implemet decision making
48

    
49
        pthread_exit(0);
50

    
51
}
52

    
53
// HCI connection thread routine
54
// Start listening to some port
55
void *hciConnectionThread_routine(void *dummy) {
56

    
57
        int hciErrorCode = listenTo(1100);
58

    
59
        pthread_exit(0);
60

    
61
}