Skip to content

Commit

Permalink
Merge pull request #23 from martinroger/20-duplicate-requests-during-…
Browse files Browse the repository at this point in the history
…handshake

Double flag handshake implementation
  • Loading branch information
martinroger authored Jan 7, 2025
2 parents 05efd77 + 5b81e8c commit 61c9ced
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
6 changes: 6 additions & 0 deletions include/esPod.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,17 @@ class esPod
const char* _serialNumber = "AB345F7HIJK";

//MINI metadata
bool _accessoryNameReceived = false;
bool _accessoryNameRequested = false;
bool _accessoryCapabilitiesReceived = false;
bool _accessoryCapabilitiesRequested = false;
bool _accessoryFirmwareReceived = false;
bool _accessoryFirmwareRequested = false;
bool _accessoryManufReceived = false;
bool _accessoryManufRequested = false;
bool _accessoryModelReceived = false;
bool _accessoryModelRequested = false;
bool _accessoryHardwareReceived = false;
bool _accessoryHardwareRequested = false;

//Handler functions
Expand Down
11 changes: 4 additions & 7 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ build_flags =
-D BUILD_BRANCH="\"main"\"
-D PIOENV="\"$PIOENV"\"
-D REFRESH_INTERVAL=10

[env:audioKit]
board = esp32dev
lib_deps =
lib_deps =
https://github.com/pschatzmann/ESP32-A2DP.git@^1.8.4
https://github.com/pschatzmann/arduino-audio-tools.git@^1.0.1
https://github.com/pschatzmann/arduino-audio-driver.git@^0.1.0

[env:audioKit]
board = esp32dev
build_flags =
${env.build_flags}
-D BOARD_HAS_PSRAM
Expand Down Expand Up @@ -111,9 +111,6 @@ build_flags =


[env:nodeMCUESP32S_externalDAC]
lib_deps =
https://github.com/pschatzmann/ESP32-A2DP.git
https://github.com/pschatzmann/arduino-audio-tools.git
monitor_speed = 115200
build_flags =
${env.build_flags}
Expand Down
36 changes: 24 additions & 12 deletions src/esPod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,17 @@ void esPod::resetState(){
_rxInProgress = false;

//Mini metadata
_accessoryCapabilitiesReceived = false;
_accessoryCapabilitiesRequested = false;
_accessoryFirmwareReceived = false;
_accessoryFirmwareRequested = false;
_accessoryHardwareReceived = false;
_accessoryHardwareRequested = false;
_accessoryManufReceived = false;
_accessoryManufRequested = false;
_accessoryModelReceived = false;
_accessoryModelRequested = false;
_accessoryNameReceived = false;
_accessoryNameRequested = false;
}

Expand Down Expand Up @@ -616,9 +622,10 @@ void esPod::processLingo0x00(const byte *byteArray, uint32_t len)
{
ESP_LOGI(IPOD_TAG,"CMD: 0x%02x IdentifyDeviceLingoes",cmdID);
L0x00_0x02_iPodAck(iPodAck_OK,cmdID);//Acknowledge, start capabilities pingpong
if(!_accessoryCapabilitiesRequested)
if(!_accessoryCapabilitiesReceived && !_accessoryCapabilitiesRequested)
{
L0x00_0x27_GetAccessoryInfo(0x00); //Immediately request general capabilities
_accessoryCapabilitiesRequested = true;
}

}
Expand All @@ -630,47 +637,52 @@ void esPod::processLingo0x00(const byte *byteArray, uint32_t len)
switch (byteArray[1]) //Ping-pong the next request based on the current response
{
case 0x00:
_accessoryCapabilitiesRequested = true;
if (!_accessoryNameRequested)
_accessoryCapabilitiesReceived = true;
if (!_accessoryNameReceived && !_accessoryNameRequested)
{
L0x00_0x27_GetAccessoryInfo(0x01); //Request the name
_accessoryNameRequested = true;
}
break;

case 0x01:
_accessoryNameRequested = true;
if (!_accessoryFirmwareRequested)
_accessoryNameReceived = true;
if (!_accessoryFirmwareReceived && !_accessoryFirmwareRequested)
{
L0x00_0x27_GetAccessoryInfo(0x04); //Request the firmware version
_accessoryFirmwareRequested = true;
}
break;

case 0x04:
_accessoryFirmwareRequested = true;
if (!_accessoryHardwareRequested)
_accessoryFirmwareReceived = true;
if (!_accessoryHardwareReceived && !_accessoryHardwareRequested)
{
L0x00_0x27_GetAccessoryInfo(0x05); //Request the hardware number
_accessoryHardwareRequested = true;
}
break;

case 0x05:
_accessoryHardwareRequested = true;
if (!_accessoryManufRequested)
_accessoryHardwareReceived = true;
if (!_accessoryManufReceived && !_accessoryManufRequested)
{
L0x00_0x27_GetAccessoryInfo(0x06); //Request the manufacturer name
_accessoryManufRequested = true;
}
break;

case 0x06:
_accessoryManufRequested = true;
if (!_accessoryModelRequested)
_accessoryManufReceived = true;
if (!_accessoryModelReceived && !_accessoryModelRequested)
{
L0x00_0x27_GetAccessoryInfo(0x07); //Request the model number
_accessoryModelRequested = true;
}
break;

case 0x07:
_accessoryModelRequested = true; //End of the reactionchain
_accessoryModelReceived = true; //End of the reactionchain
ESP_LOGI(IPOD_TAG,"Handshake complete.");
break;
}
Expand Down

0 comments on commit 61c9ced

Please sign in to comment.