Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1734 - 1
/*****************************************************************************
2
 *   Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de                  *
3
 *   Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net                  *
4
 *   Copyright (C) 2011 Christian "Cebra" Brandtner, brandtner@brandtner.net *
5
 *   Copyright (C) 2011 Harald Bongartz                                      *
6
 *                                                                           *
7
 *   This program is free software; you can redistribute it and/or modify    *
8
 *   it under the terms of the GNU General Public License as published by    *
9
 *   the Free Software Foundation; either version 2 of the License.          *
10
 *                                                                           *
11
 *   This program is distributed in the hope that it will be useful,         *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
14
 *   GNU General Public License for more details.                            *
15
 *                                                                           *
16
 *   You should have received a copy of the GNU General Public License       *
17
 *   along with this program; if not, write to the                           *
18
 *   Free Software Foundation, Inc.,                                         *
19
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.               *
20
 *                                                                           *
21
 *                                                                           *
22
 *   Credits to:                                                             *
23
 *   Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN  *
24
 *                          http://www.mikrokopter.de                        *
25
 *   Gregor "killagreg" Stobrawa for his version of the MK code              *
26
 *   Thomas Kaiser "thkais" for the original project. See                    *
27
 *                          http://www.ft-fanpage.de/mikrokopter/            *
28
 *                          http://forum.mikrokopter.de/topic-4061-1.html    *
29
 *   Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code *
30
 *                          http://www.mylifesucks.de/oss/c-osd/             *
31
 *   Harald Bongartz "HaraldB" for providing his Ideas and Code for usibility*
32
 *****************************************************************************/
33
 
34
 
35
#ifndef _BLUETOOTH_H_
36
#define _BLUETOOTH_H_
37
 
38
#include <avr/io.h>
39
//#include <common.h>
40
 
41
 
42
#define SQUIRREL
43
#define NUTS_LIST 16
44
#define EXTENSIONS_LIST 16
45
#define RXD_BUFFER_SIZE         150
46
//void InitBT(void);
47
 
48
extern char rx_buffer[RXD_BUFFER_SIZE];
49
extern volatile uint8_t rx_len;
50
extern volatile uint8_t rx_ready;
51
extern uint8_t rx_GPS;
52
//extern static char start = '$';
53
//extern static char end = '\n';
54
extern char data_decode[RXD_BUFFER_SIZE];
55
extern volatile uint16_t rx_timeout;
56
extern uint8_t bt_rxerror;
57
 
58
typedef struct _device_info device_info;
59
 
60
// device info struct, holds mac , class and extensions + values of a device
61
struct _device_info
62
{
63
    char DevName[20];
64
    char mac[14];
65
 
66
//    uint8_t class;
67
//    uint8_t extension_types[EXTENSIONS_LIST];
68
//    uint16_t values_cache[EXTENSIONS_LIST];
69
};
70
extern uint8_t bt_devicecount;
71
extern device_info device_list[NUTS_LIST];
72
 
73
#define valid(num) (num < NUTS_LIST && (device_list[num].mac[0] != 0 || device_list[num].mac[1] != 0 || device_list[num].mac[2] != 0 || device_list[num].mac[3] != 0 || device_list[num].mac[4] != 0 || device_list[num].mac[5] != 0 || device_list[num].mac[6] != 0 || device_list[num].mac[7] != 0 || device_list[num].mac[8] != 0 || device_list[num].mac[9] != 0 || device_list[num].mac[10] != 0 || device_list[num].mac[11] != 0))
74
 
75
extern uint16_t bt_receiveNMEA(void);
76
 
77
//extern static communication_mode_t update_comm_mode(uint16_t timeout_ms);
78
 
79
// Bluetooth mode ENUM
80
typedef enum
81
{
82
    BLUETOOTH_MASTER, // < Master Mode (to create outgoinng connections).
83
    BLUETOOTH_SLAVE   // < Slave Mode (to wait for incoming connections).
84
} bt_mode_t;
85
 
86
 
87
// init bluetooth driver
88
// @return always true
89
//
90
//extern uint16_t bt_init (void (*upate_percentage) (uint16_t));
91
extern uint16_t bt_init (void);
92
 
93
// Set the Bluetooth mode
94
// @param mode bt_mode_t Bluetooth Mode ENUM (BLUETOOTH_MASTER or BLUETOOTH_SLAVE)
95
// @return true if mode change was succesful, false if not
96
//
97
extern uint16_t bt_set_mode (const bt_mode_t mode);
98
 
99
// recieve data over bluetooth
100
// @param data pointer to memory for data storage
101
// @param length value of length after call holds the actual recived data length
102
// @param timeout_ms timeout in ms after the recive function aborts and returns with false
103
// @return false if recived length > length parameter or it timeouted, true otherwise
104
//
105
extern uint16_t bt_receive (void * data, uint8_t length, uint16_t timeout_ms);
106
 
107
// send data over bluetooth
108
// @param data pointer to the data to send
109
// @param length length of the data to be send
110
// @return true if sendingn was successful, false otherwise
111
//
112
extern uint16_t bt_send (void * data, const uint8_t length);
113
 
114
// squirrelt only functions
115
#ifdef SQUIRREL
116
 
117
// open bluetoot connection (only one at a time possible)
118
// @param address connection is opened to this device mac address
119
// @return true if connection was established, false otherwise
120
//
121
extern uint16_t bt_connect (const char *address);
122
 
123
// closes bluetooth connection
124
// @return false if failed, true otherwise
125
//
126
extern uint16_t bt_disconnect (void);
127
 
128
// discover bluetooth devices
129
// @param result in a 2 dimensional array first index are devicecs (max 8) second is mac address string
130
// @param update_callback to inform of progress (in % from 0 to 100)
131
// @return true if successful, false if error occured
132
//
133
extern uint16_t bt_discover (char result[8][12]);
134
//extern uint16_t bt_discover (char result[8][12], void (*update_callback)(const uint16_t progress));
135
 
136
extern void bt_downlink_init(void);        // Auf Master stellen für Devicesuche und GPS Empfang
137
 
138
extern void bt_searchDevice(void);              //Bluetoothgeräte suchen
139
 
140
#endif  // SQUIRREL
141
 
142
 
143
#endif
144