Rev 221 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 221 | Rev 231 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /********************************************************************************************************************************* |
1 | /********************************************************************************************** |
2 | * * |
- | |
- | 2 | * |
|
3 | * Abstaction Layer to Communicate via J2ME and Bluetooth with the FlightCtrl of the MikroKopter Project (www.mikrokopter.de ) * |
3 | * Abstaction Layer to Communicate via J2ME and Bluetooth with the FlightCtrl of the MikroKopter Project (www.mikrokopter.de ) |
4 | * * |
- | |
- | 4 | * |
|
5 | * Author: Marcus -LiGi- Bueschleb * |
5 | * Author: Marcus -LiGi- Bueschleb |
6 | * Project-Start: 9/2007 * |
6 | * Project-Start: 9/2007 |
7 | * Version: 0.07 * |
7 | * Version: 0.07 |
8 | * Mailto: ligi@smart4mobile.de * |
8 | * Mailto: ligi@smart4mobile.de |
9 | * Licence: Creative Commons / Non Commercial * |
9 | * Licence: Creative Commons / Non Commercial |
10 | * Big Up: Holger&Ingo * |
10 | * Big Up: Holger&Ingo |
11 | * ChangeLog: * |
- | |
12 | * 0.01 - initial Version ( initialize connection / main Thread with reading data from MK) * |
- | |
13 | * 0.02 - reconnect after connection loss ( e.g. switching on/off ) * |
- | |
14 | * 0.03 - added send_command ( with CRC ) * |
- | |
15 | * 0.04 - added decode64 to decode 'pseudo' BASE64 * |
- | |
16 | * 0.05 - added get_version * |
- | |
17 | * 0.06 - added parsing of DebugData * |
- | |
18 | * 0.07 - Code-(Doc&&Cleanup) && initial svn commit * |
- | |
19 | * * |
- | |
- | 11 | * |
|
20 | *********************************************************************************************************************************/ |
12 | ************************************************************************************************/ |
Line 21... | Line 13... | ||
21 | 13 | ||
22 | import javax.microedition.io.*; |
14 | import javax.microedition.io.*; |
Line 23... | Line 15... | ||
23 | import java.io.*; |
15 | import java.io.*; |
Line 132... | Line 124... | ||
132 | { |
124 | { |
133 | send_command(0,'v',new int[0]); |
125 | send_command(0,'v',new int[0]); |
134 | } |
126 | } |
Line -... | Line 127... | ||
- | 127 | ||
- | 128 | ||
- | 129 | public void motor_test(int[] params) |
|
- | 130 | { |
|
- | 131 | send_command(0,'t',params); |
|
- | 132 | } |
|
135 | 133 | ||
136 | 134 | ||
137 | // send command to FC ( add crc and pack into pseudo Base64 |
135 | // send command to FC ( add crc and pack into pseudo Base64 |
138 | public void send_command(int modul,char cmd,int[] params) |
136 | public void send_command(int modul,char cmd,int[] params) |
139 | { |
137 | { |
140 | char[] send_buff=new char[5 + (params.length/3 + (params.length%3==0?0:1) )*4]; // 5=1*start_char+1*addr+1*cmd+2*crc |
138 | char[] send_buff=new char[5 + (params.length/3 + (params.length%3==0?0:1) )*4]; // 5=1*start_char+1*addr+1*cmd+2*crc |
141 | send_buff[0]='#'; |
139 | send_buff[0]='#'; |
Line 142... | Line 140... | ||
142 | send_buff[1]=(char)modul; |
140 | send_buff[1]=(char)modul; |
143 | send_buff[2]=cmd; |
141 | send_buff[2]=cmd; |
144 | 142 | ||
145 | for(int param_pos=0;param_pos<(params.length/3 + (params.length%3==0?0:1)) ;param_pos++) |
143 | for(int param_pos=0;param_pos<(params.length/3 + (params.length%3==0?0:1)) ;param_pos++) |
146 | { |
144 | { |
Line 147... | Line 145... | ||
147 | int a = (param_pos<params.length)?params[param_pos]:0; |
145 | int a = (param_pos*3<params.length)?params[param_pos*3]:0; |
148 | int b = ((param_pos+1)<params.length)?params[param_pos+1]:0; |
146 | int b = ((param_pos*3+1)<params.length)?params[param_pos*3+1]:0; |
149 | int c = ((param_pos+2)<params.length)?params[param_pos+2]:0; |
147 | int c = ((param_pos*3+2)<params.length)?params[param_pos*3+2]:0; |
150 | 148 |