Skip to content

Commit 744e84e

Browse files
committed
added test for long sessionNames
1 parent 278f7ef commit 744e84e

File tree

2 files changed

+35
-61
lines changed

2 files changed

+35
-61
lines changed

src/AppleMIDI_Defs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ enum parserReturn: uint8_t
3434
UnexpectedData,
3535
UnexpectedMidiData,
3636
UnexpectedJournalData,
37+
SessionNameVeryLong,
3738
};
3839

3940
#if defined(__AVR__)

test/Ethernet.h

Lines changed: 34 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ class EthernetUDP
1515
EthernetUDP()
1616
{
1717
_port = 0;
18+
19+
20+
21+
1822
}
1923

2024
void begin(uint16_t port)
@@ -24,6 +28,21 @@ class EthernetUDP
2428
if (port == DEFAULT_CONTROL_PORT && true)
2529
{
2630
// AppleMIDI messages
31+
byte okSessionName[] = {
32+
0xff, 0xff, 0x49, 0x4e, 0x00, 0x00, 0x00, 0x02, 0x4e, 0x27, 0x95, 0x9e, 0x00, 0x00, 0xec, 0xf9,
33+
0x6c, 0x61, 0x70, 0x70, 0x69, 0x65, 0x6d, 0x63, 0x74, 0x6f, 0x70, 0x66, 0x61, 0x63, 0x65, 0x00
34+
};
35+
36+
byte notOKSessionName[] = {
37+
0xff, 0xff, 0x49, 0x4e, 0x00, 0x00, 0x00, 0x02, 0xcc, 0x0f, 0x6c, 0x49, 0x00, 0x00, 0xa4, 0x9b,
38+
0x6c, 0x61, 0x70, 0x70, 0x69, 0x65, 0x6d, 0x63, 0x74, 0x6f, 0x70, 0x66, 0x61, 0x63, 0x65, 0x2f,
39+
0x46, 0x4c, 0x55, 0x49, 0x44, 0x20, 0x53, 0x79, 0x6e, 0x74, 0x68, 0x20, 0x28, 0x36, 0x34, 0x37,
40+
0x38, 0x29, 0x2d, 0x53, 0x79, 0x6e, 0x74, 0x68, 0x20, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x70,
41+
0x6f, 0x72, 0x74, 0x20, 0x28, 0x36, 0x34, 0x37, 0x38, 0x3a, 0x30, 0x29, 0x00
42+
};
43+
44+
write(notOKSessionName, sizeof(notOKSessionName));
45+
2746
}
2847

2948
if (port == (DEFAULT_CONTROL_PORT + 1) && true)
@@ -309,7 +328,7 @@ class EthernetUDP
309328

310329
byte slecht[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
311330

312-
write(rr2, sizeof(rr2));
331+
// write(rr2, sizeof(rr2));
313332
}
314333

315334
if (port == 5005 && true)
@@ -339,6 +358,19 @@ class EthernetUDP
339358
return _buffer.size();
340359
};
341360

361+
int read()
362+
{
363+
int uu = _buffer.size();
364+
365+
if (_buffer.size() == 0)
366+
return -1;
367+
368+
byte value = _buffer.front();
369+
_buffer.pop_front();
370+
371+
return value;
372+
}
373+
342374
size_t read(byte* buffer, size_t size)
343375
{
344376
size = min(size, _buffer.size());
@@ -363,68 +395,9 @@ class EthernetUDP
363395
};
364396

365397
void endPacket() { };
398+
366399
void flush()
367400
{
368-
if (_port == 5004)
369-
{
370-
if (_buffer[0] == 0xff && _buffer[1] == 0xff && _buffer[2] == 'I' &&_buffer[3] == 'N')
371-
{
372-
_buffer.clear();
373-
374-
375-
byte u[] = {
376-
0xff, 0xff,
377-
0x4f, 0x4b,
378-
0x00, 0x00, 0x00, 0x02,
379-
0xb7, 0x06, 0x20, 0x30,
380-
0xda, 0x8d, 0xc5, 0x8a,
381-
0x4d, 0x61, 0x63, 0x62, 0x6f, 0x6f, 0x6b, 0x20, 0x50, 0x72, 0x6f, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x53, 0x61, 0x6e, 0x64, 0x72, 0x61, 0x20, 0x56, 0x65, 0x72, 0x62, 0x65, 0x6b, 0x65, 0x6e, 0x20, 0x28, 0x32, 0x29, 0x00 };
382-
383-
384-
385-
386-
387-
byte r[] = { 0xff, 0xff,
388-
0x4f, 0x4b,
389-
0x00, 0x0, 0x00, 0x02,
390-
0xb7, 0x06, 0x20, 0x30,
391-
0xda, 0x8d, 0xc5, 0x8a,
392-
0x53, 0x65, 0x73, 0x73, 0x69, 0x6, 0x6e, 0x31, 0x2d, 0x42, 0x00 };
393-
write(u, sizeof(u));
394-
}
395-
}
396-
if (_port == 5005)
397-
{
398-
if (_buffer[0] == 0xff && _buffer[1] == 0xff && _buffer[2] == 'I' &&_buffer[3] == 'N')
399-
{
400-
_buffer.clear();
401-
byte r[] = { 0xff, 0xff,
402-
0x4f, 0x4b,
403-
0x00, 0x0, 0x00, 0x02,
404-
0xb7, 0x06, 0x20, 0x30,
405-
0xda, 0x8d, 0xc5, 0x8a,
406-
0x53, 0x65, 0x73, 0x73, 0x69, 0x6, 0x6e, 0x31, 0x2d, 0x42, 0x00 };
407-
write(r, sizeof(r));
408-
}
409-
else if (_buffer[0] == 0xff && _buffer[1] == 0xff && _buffer[2] == 'C' &&_buffer[3] == 'K')
410-
{
411-
if (_buffer[8] == 0x00)
412-
{
413-
_buffer.clear();
414-
byte r[] = { 0xff, 0xff,
415-
0x43, 0x4b,
416-
0xda, 0x8d, 0xc5, 0x8a,
417-
0x01,
418-
0x65, 0x73, 0x73,
419-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x34,
420-
0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x6c, 0x83,
421-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
422-
write(r, sizeof(r));
423-
}
424-
else
425-
_buffer.clear();
426-
}
427-
}
428401
};
429402

430403
void stop() { _buffer.clear(); };

0 commit comments

Comments
 (0)