Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1515 - 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
 
46
//void InitBT(void);
47
 
48
typedef struct _device_info device_info;
49
 
50
// device info struct, holds mac , class and extensions + values of a device
51
struct _device_info
52
{
53
    char mac[12];
54
 
55
    uint8_t class;
56
    uint8_t extension_types[EXTENSIONS_LIST];
57
    uint16_t values_cache[EXTENSIONS_LIST];
58
};
59
 
60
extern device_info device_list[NUTS_LIST];
61
 
62
#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))
63
 
64
 
65
 
66
// Bluetooth mode ENUM
67
typedef enum
68
{
69
    BLUETOOTH_MASTER, // < Master Mode (to create outgoinng connections).
70
    BLUETOOTH_SLAVE   // < Slave Mode (to wait for incoming connections).
71
} bt_mode_t;
72
 
73
 
74
// init bluetooth driver
75
// @return always true
76
//
77
//extern uint16_t bt_init (void (*upate_percentage) (uint16_t));
78
extern uint16_t bt_init (void);
79
 
80
// Set the Bluetooth mode
81
// @param mode bt_mode_t Bluetooth Mode ENUM (BLUETOOTH_MASTER or BLUETOOTH_SLAVE)
82
// @return true if mode change was succesful, false if not
83
//
84
extern uint16_t bt_set_mode (const bt_mode_t mode);
85
 
86
// recieve data over bluetooth
87
// @param data pointer to memory for data storage
88
// @param length value of length after call holds the actual recived data length
89
// @param timeout_ms timeout in ms after the recive function aborts and returns with false
90
// @return false if recived length > length parameter or it timeouted, true otherwise
91
//
92
extern uint16_t bt_receive (void * data, uint8_t length, uint16_t timeout_ms);
93
 
94
// send data over bluetooth
95
// @param data pointer to the data to send
96
// @param length length of the data to be send
97
// @return true if sendingn was successful, false otherwise
98
//
99
extern uint16_t bt_send (void * data, const uint8_t length);
100
 
101
// squirrelt only functions
102
#ifdef SQUIRREL
103
 
104
// open bluetoot connection (only one at a time possible)
105
// @param address connection is opened to this device mac address
106
// @return true if connection was established, false otherwise
107
//
108
extern uint16_t bt_connect (const char *address);
109
 
110
// closes bluetooth connection
111
// @return false if failed, true otherwise
112
//
113
extern uint16_t bt_disconnect (void);
114
 
115
// discover bluetooth devices
116
// @param result in a 2 dimensional array first index are devicecs (max 8) second is mac address string
117
// @param update_callback to inform of progress (in % from 0 to 100)
118
// @return true if successful, false if error occured
119
//
120
extern uint16_t bt_discover (char result[8][12]);
121
//extern uint16_t bt_discover (char result[8][12], void (*update_callback)(const uint16_t progress));
122
 
123
#endif  // SQUIRREL
124
 
125
 
126
#endif
127