Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2136 - 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
//# HISTORY  bluetooth.h
36
//#
37
//# 25.06.2014 OG
38
//# - chg: bt_discover() Parameter
39
//#
40
//# 16.06.2014 OG
41
//# - add: BTM222_Initalize()
42
//# - del: bt_init()
43
//#
44
//# 08.06.2014 OG
45
//# - del: BT_New_Baudrate
46
//#
47
//# 24.06.2013 OG
48
//# - add: bt_fixname()
49
//############################################################################
50
 
51
 
52
#ifndef _BLUETOOTH_H_
53
#define _BLUETOOTH_H_
54
 
55
#include <avr/io.h>
56
//#include <common.h>
57
#include "fifo.h"
58
 
59
 
60
#define SQUIRREL
61
#define NUTS_LIST           16
62
#define EXTENSIONS_LIST     16
63
#define RXD_BUFFER_SIZE     150
64
//void InitBT(void);
65
 
66
extern char bt_rx_buffer[RXD_BUFFER_SIZE];
67
extern volatile uint8_t bt_rx_len;
68
extern volatile uint8_t bt_rx_ready;
69
 
70
 
71
//extern char data_decode[RXD_BUFFER_SIZE];
72
 
73
extern uint8_t bt_rxerror;
74
extern uint8_t bt_frameerror;
75
extern uint8_t bt_overrun;
76
extern uint8_t bt_bufferoverflow;
77
 
78
extern fifo_t in_fifo;
79
 
80
 
81
typedef struct _device_info device_info;
82
 
83
// device info struct, holds mac , class and extensions + values of a device
84
struct _device_info
85
{
86
    char DevName[20];
87
    char mac[14];
88
 
89
//    uint8_t class;
90
//    uint8_t extension_types[EXTENSIONS_LIST];
91
//    uint16_t values_cache[EXTENSIONS_LIST];
92
};
93
extern uint8_t bt_devicecount;
94
extern device_info device_list[NUTS_LIST];
95
extern char localID[15];
96
#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))
97
 
98
 
99
extern void bt_start(void); // EchoAnswervariable setzen
100
void bt_set_EchoAnswer (uint8_t onoff);
101
 
102
extern uint8_t bt_getID (void);
103
 
104
//extern static communication_mode_t update_comm_mode(uint16_t timeout_ms);
105
 
106
// Bluetooth mode ENUM
107
typedef enum
108
{
109
    BLUETOOTH_MASTER, // < Master Mode (to create outgoinng connections).
110
    BLUETOOTH_SLAVE   // < Slave Mode (to wait for incoming connections).
111
} bt_mode_t;
112
 
113
// set baudrate bluetooth
114
// @return true = ok
115
//         false = error
116
//extern uint16_t bt_setbaud (uint8_t baudrate);
117
uint16_t bt_setbaud(uint8_t baudrate);
118
 
119
// init bluetooth driver
120
// @return always true
121
//
122
//extern uint16_t bt_init (void (*upate_percentage) (uint16_t));
123
//extern uint16_t bt_init (void);
124
 
125
// Set the Bluetooth mode
126
// @param mode bt_mode_t Bluetooth Mode ENUM (BLUETOOTH_MASTER or BLUETOOTH_SLAVE)
127
// @return true if mode change was succesful, false if not
128
//
129
extern uint8_t bt_set_mode (const bt_mode_t mode);
130
 
131
// recieve data over bluetooth
132
// @param data pointer to memory for data storage
133
// @param length value of length after call holds the actual recived data length
134
// @param timeout_ms timeout in ms after the recive function aborts and returns with false
135
// @return false if recived length > length parameter or it timeouted, true otherwise
136
//
137
extern uint16_t bt_receive (void * data, uint8_t length, uint16_t timeout_ms);
138
 
139
// send data over bluetooth
140
// @param data pointer to the data to send
141
// @param length length of the data to be send
142
// @return true if sendingn was successful, false otherwise
143
//
144
extern uint16_t bt_send (void * data, const uint8_t length);
145
 
146
// squirrelt only functions
147
#ifdef SQUIRREL
148
 
149
// open bluetoot connection (only one at a time possible)
150
// @param address connection is opened to this device mac address
151
// @return true if connection was established, false otherwise
152
//
153
extern uint16_t bt_connect (const char *address);
154
 
155
// closes bluetooth connection
156
// @return false if failed, true otherwise
157
//
158
extern uint16_t bt_disconnect (void);
159
 
160
// discover bluetooth devices
161
// @param result in a 2 dimensional array first index are devicecs (max 8) second is mac address string
162
// @param update_callback to inform of progress (in % from 0 to 100)
163
// @return true if successful, false if error occured
164
//
165
//extern uint16_t bt_discover(void);
166
//extern uint16_t bt_discover (char result[8][12], void (*update_callback)(const uint16_t progress));
167
 
168
extern void bt_downlink_init(void);        // Auf Master stellen für Devicesuche und GPS Empfang
169
 
170
extern void bt_searchDevice(void);              //Bluetoothgeräte suchen
171
 
172
#endif  // SQUIRREL
173
 
174
 
175
void uart_receive(void);
176
void bt_fixname(void);
177
void BTM222_Initalize( void );
178
uint8_t bt_showsettings( void );
179
 
180
 
181
#endif
182