summaryrefslogtreecommitdiff
path: root/apps/iap.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/iap.c')
-rw-r--r--apps/iap.c153
1 files changed, 82 insertions, 71 deletions
diff --git a/apps/iap.c b/apps/iap.c
index 48344cd4cc..ecf70b2e69 100644
--- a/apps/iap.c
+++ b/apps/iap.c
@@ -220,7 +220,7 @@ static void iap_set_remote_volume(void)
220 220
221static void cmd_ok_mode0(unsigned char cmd) 221static void cmd_ok_mode0(unsigned char cmd)
222{ 222{
223 unsigned char data[] = {0x00, 0x02, 0x00, 0x13}; 223 unsigned char data[] = {0x00, 0x02, 0x00, 0x00};
224 data[3] = cmd; /* respond with cmd */ 224 data[3] = cmd; /* respond with cmd */
225 iap_send_pkt(data, sizeof(data)); 225 iap_send_pkt(data, sizeof(data));
226} 226}
@@ -229,42 +229,71 @@ static void iap_handlepkt_mode0(void)
229{ 229{
230 unsigned int cmd = serbuf[2]; 230 unsigned int cmd = serbuf[2];
231 switch (cmd) { 231 switch (cmd) {
232 /* Identify */
233 case 0x01:
234 {
235 /* FM transmitter sends this: */
236 /* FF 55 06 00 01 05 00 02 01 F1 (mode switch) */
237 if(serbuf[3] == 0x05)
238 {
239 sleep(HZ/3);
240 /* RF Transmitter: Begin transmission */
241 unsigned char data[] = {0x05, 0x02};
242 iap_send_pkt(data, sizeof(data));
243 }
244 /* FM remote sends this: */
245 /* FF 55 03 00 01 02 FA (1st thing sent) */
246 else if(serbuf[3] == 0x02)
247 {
248 /* useful only for apple firmware */
249 }
250 break;
251 }
232 252
233 case 0x24: 253 /* EnterRemoteUIMode, FM transmitter sends FF 55 02 00 05 F9 */
254 case 0x05:
234 { 255 {
235 /* ipod video send this */ 256 /* ACK Pending (3000 ms) */
236 unsigned char data[] = {0x00, 0x25, 0x00, 0x00, 0x00, 257 unsigned char data[] = {0x00, 0x02, 0x06,
237 0x00, 0x00, 0x00, 0x00, 0x01}; 258 0x05, 0x00, 0x00, 0x0B, 0xB8};
238 iap_send_pkt(data, sizeof(data)); 259 iap_send_pkt(data, sizeof(data));
260 cmd_ok_mode0(cmd);
239 break; 261 break;
240 } 262 }
241 263
242 case 0x18: 264 /* RequestiPodSoftwareVersion, Ipod FM remote sends FF 55 02 00 09 F5 */
265 case 0x09:
243 { 266 {
244 /* ciphered authentication command */ 267 /* ReturniPodSoftwareVersion, ipod5G firmware version */
245 /* Isn't used since we don't send the 0x00 0x17 command */ 268 unsigned char data[] = {0x00, 0x0A, 0x01, 0x02, 0x01};
269 iap_send_pkt(data, sizeof(data));
270 break;
271 }
272
273 /* RequestiPodModelNum */
274 case 0x0D:
275 {
276 /* ipod is supposed to work only with 5G and nano 2G */
277 /*{0x00, 0x0E, 0x00, 0x0B, 0x00, 0x05, 0x50, 0x41, 0x31, 0x34,
278 0x37, 0x4C, 0x4C, 0x00}; PA147LL (IPOD 5G 60 GO) */
279 /* ReturniPodModelNum */
280 unsigned char data[] = {0x00, 0x0E, 0x00, 0x0B, 0x00, 0x10,
281 'R', 'O', 'C', 'K', 'B', 'O', 'X', 0x00};
282 iap_send_pkt(data, sizeof(data));
246 break; 283 break;
247 } 284 }
248 285
249 case 0x15: 286 /* RequestLingoProtocolVersion */
287 case 0x0F:
250 { 288 {
251 unsigned char data0[] = {0x00, 0x16, 0x00}; 289 /* ReturnLingoProtocolVersion */
252 iap_send_pkt(data0, sizeof(data0)); 290 unsigned char data[] = {0x00, 0x10, 0x00, 0x01, 0x05};
253 unsigned char data1[] = {0x00, 0x27, 0x00}; 291 data[2] = serbuf[3];
254 iap_send_pkt(data1, sizeof(data1)); 292 iap_send_pkt(data, sizeof(data));
255 /* authentication ack, mandatory to enable some hardware */
256 unsigned char data2[] = {0x00, 0x19, 0x00};
257 iap_send_pkt(data2, sizeof(data2));
258 if (radio_present == 1)
259 {
260 /* get tuner capacities */
261 unsigned char data3[] = {0x07, 0x01};
262 iap_send_pkt(data3, sizeof(data3));
263 }
264 iap_set_remote_volume();
265 break; 293 break;
266 } 294 }
267 295
296 /* IdentifyDeviceLingoes */
268 case 0x13: 297 case 0x13:
269 { 298 {
270 cmd_ok_mode0(cmd); 299 cmd_ok_mode0(cmd);
@@ -273,8 +302,10 @@ static void iap_handlepkt_mode0(void)
273 /* FM transmitter sends this: */ 302 /* FM transmitter sends this: */
274 /* FF 55 0E 00 13 00 00 00 35 00 00 00 04 00 00 00 00 A6 (??)*/ 303 /* FF 55 0E 00 13 00 00 00 35 00 00 00 04 00 00 00 00 A6 (??)*/
275 { 304 {
305 /* GetAccessoryInfo */
276 unsigned char data2[] = {0x00, 0x27, 0x00}; 306 unsigned char data2[] = {0x00, 0x27, 0x00};
277 iap_send_pkt(data2, sizeof(data2)); 307 iap_send_pkt(data2, sizeof(data2));
308 /* RF Transmitter: Begin transmission */
278 unsigned char data3[] = {0x05, 0x02}; 309 unsigned char data3[] = {0x05, 0x02};
279 iap_send_pkt(data3, sizeof(data3)); 310 iap_send_pkt(data3, sizeof(data3));
280 } 311 }
@@ -285,72 +316,52 @@ static void iap_handlepkt_mode0(void)
285 /* FF 55 0E 00 13 00 00 00 8D 00 00 00 0E 00 00 00 03 41 */ 316 /* FF 55 0E 00 13 00 00 00 8D 00 00 00 0E 00 00 00 03 41 */
286 if (serbuf[6] |= 0x80) 317 if (serbuf[6] |= 0x80)
287 radio_present = 1; 318 radio_present = 1;
319 /* GetDevAuthenticationInfo */
288 unsigned char data4[] = {0x00, 0x14}; 320 unsigned char data4[] = {0x00, 0x14};
289 iap_send_pkt(data4, sizeof(data4)); 321 iap_send_pkt(data4, sizeof(data4));
290 } 322 }
291 break; 323 break;
292 } 324 }
293 325
294 /* Init */ 326 /* RetDevAuthenticationInfo */
295 case 0x0F: 327 case 0x15:
296 { 328 {
297 unsigned char data[] = {0x00, 0x10, 0x00, 0x01, 0x05}; 329 /* AckDevAuthenticationInfo */
298 data[2] = serbuf[3]; 330 unsigned char data0[] = {0x00, 0x16, 0x00};
299 iap_send_pkt(data, sizeof(data)); 331 iap_send_pkt(data0, sizeof(data0));
332 /* GetAccessoryInfo */
333 unsigned char data1[] = {0x00, 0x27, 0x00};
334 iap_send_pkt(data1, sizeof(data1));
335 /* AckDevAuthenticationStatus, mandatory to enable some hardware */
336 unsigned char data2[] = {0x00, 0x19, 0x00};
337 iap_send_pkt(data2, sizeof(data2));
338 if (radio_present == 1)
339 {
340 /* GetTunerCaps */
341 unsigned char data3[] = {0x07, 0x01};
342 iap_send_pkt(data3, sizeof(data3));
343 }
344 iap_set_remote_volume();
300 break; 345 break;
301 } 346 }
302 347
303 /* get model info */ 348 /* RetDevAuthenticationSignature */
304 case 0x0D: 349 case 0x18:
305 { 350 {
306 /* ipod is supposed to work only with 5G and nano 2G */ 351 /* Isn't used since we don't send the 0x00 0x17 command */
307 /*{0x00, 0x0E, 0x00, 0x0B, 0x00, 0x05, 0x50, 0x41, 0x31, 0x34,
308 0x37, 0x4C, 0x4C, 0x00}; PA147LL (IPOD 5G 60 GO) */
309 unsigned char data[] = {0x00, 0x0E, 0x00, 0x0B, 0x00, 0x10,
310 'R', 'O', 'C', 'K', 'B', 'O', 'X', 0x00};
311 iap_send_pkt(data, sizeof(data));
312 break; 352 break;
313 } 353 }
314 354
315 /* Ipod FM remote sends this: FF 55 02 00 09 F5 */ 355 /* GetIpodOptions */
316 case 0x09: 356 case 0x24:
317 {
318 /* ipod5G firmware version */
319 unsigned char data[] = {0x00, 0x0A, 0x01, 0x02, 0x01 };
320 iap_send_pkt(data, sizeof(data));
321 break;
322 }
323
324 /* FM transmitter sends this: */
325 /* FF 55 02 00 05 F9 (mode switch: AiR mode) */
326 case 0x05:
327 { 357 {
328 unsigned char data[] = {0x00, 0x02, 0x06, 358 /* RetIpodOptions (ipod video send this) */
329 0x05, 0x00, 0x00, 0x0B, 0xB8, 0x28}; 359 unsigned char data[] = {0x00, 0x25, 0x00, 0x00, 0x00,
360 0x00, 0x00, 0x00, 0x00, 0x01};
330 iap_send_pkt(data, sizeof(data)); 361 iap_send_pkt(data, sizeof(data));
331 cmd_ok_mode0(cmd);
332 break;
333 }
334
335 case 0x01:
336 {
337 /* FM transmitter sends this: */
338 /* FF 55 06 00 01 05 00 02 01 F1 (mode switch) */
339 if(serbuf[3] == 0x05)
340 {
341 sleep(HZ/3);
342 unsigned char data[] = {0x05, 0x02};
343 iap_send_pkt(data, sizeof(data));
344 }
345 /* FM remote sends this: */
346 /* FF 55 03 00 01 02 FA (1st thing sent) */
347 else if(serbuf[3] == 0x02)
348 {
349 /* useful only for apple firmware */
350 }
351 break; 362 break;
352 } 363 }
353 364
354 /* default response is with cmd ok packet */ 365 /* default response is with cmd ok packet */
355 default: 366 default:
356 { 367 {