Merge branch 'main' into unison

unison
probonopd 1 week ago committed by GitHub
commit 14989027b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      src/mididevice.cpp
  2. 3
      src/minidexed.cpp
  3. 11
      src/net/applemidi.cpp
  4. 4
      src/net/applemidi.h
  5. 8
      src/net/ftpdaemon.cpp
  6. 6
      src/net/ftpdaemon.h
  7. 25
      src/net/ftpworker.cpp
  8. 7
      src/net/ftpworker.h
  9. 39
      src/net/mdnspublisher.cpp
  10. 7
      src/net/mdnspublisher.h
  11. 16
      src/performanceconfig.cpp
  12. 2
      src/udpmididevice.cpp
  13. 2
      submod.sh

@ -715,6 +715,11 @@ void CMIDIDevice::HandleSystemExclusive(const uint8_t* pMessage, const size_t nL
//TODO: add code for storing a bank bulk upload
LOGNOTE("Currently code for storing a bulk bank upload is missing!");
break;
case 455:
// Parameter 155 + 300 added by Synth_Dexed = 455
LOGDBG("Operators enabled: %d%d%d%d%d%d", (pMessage[5] & 0x20) ? 1 : 0, (pMessage[5] & 0x10) ? 1 : 0, (pMessage[5] & 0x08) ? 1 : 0, (pMessage[5] & 0x04) ? 1 : 0, (pMessage[5] & 0x02) ? 1 : 0, (pMessage[5] & 0x01) ? 1 : 0);
m_pSynthesizer->setOPMask(pMessage[5], nTG);
break;
default:
if(sysex_return >= 300 && sysex_return < 500)
{

@ -1215,6 +1215,7 @@ void CMiniDexed::SetTGParameter (TTGParameter Parameter, int nValue, unsigned nT
case TGParameterUnisonSpread:
m_nUnisonSpread[nTG] = constrain(nValue, 0, 99);
break;
case TGParameterMIDIChannel:
SetMIDIChannel(nValue, nTG);
break;
@ -2450,7 +2451,7 @@ void CMiniDexed::UpdateNetwork()
}
if (m_pConfig->GetNetworkFTPEnabled()) {
m_pFTPDaemon = new CFTPDaemon(FTPUSERNAME, FTPPASSWORD);
m_pFTPDaemon = new CFTPDaemon(FTPUSERNAME, FTPPASSWORD, m_pmDNSPublisher, m_pConfig);
if (!m_pFTPDaemon->Initialize())
{

@ -457,7 +457,7 @@ bool ParseMIDIPacket(const u8* pBuffer, size_t nSize, TRTPMIDI* pOutPacket, CApp
return ParseMIDICommandSection(pMIDICommandSection, nRemaining, pHandler);
}
CAppleMIDIParticipant::CAppleMIDIParticipant(CBcmRandomNumberGenerator* pRandom, CAppleMIDIHandler* pHandler)
CAppleMIDIParticipant::CAppleMIDIParticipant(CBcmRandomNumberGenerator* pRandom, CAppleMIDIHandler* pHandler, const char* pSessionName)
: CTask(TASK_STACK_SIZE, true),
m_pRandom(pRandom),
@ -489,7 +489,9 @@ CAppleMIDIParticipant::CAppleMIDIParticipant(CBcmRandomNumberGenerator* pRandom,
m_nSequence(0),
m_nLastFeedbackSequence(0),
m_nLastFeedbackTime(0)
m_nLastFeedbackTime(0),
m_pSessionName(pSessionName)
{
}
@ -802,7 +804,10 @@ bool CAppleMIDIParticipant::SendAcceptInvitationPacket(CSocket* pSocket, CIPAddr
{'\0'}
};
// TODO: configurable name
// Use hostname as the session name
if (m_pSessionName && m_pSessionName[0])
strncpy(AcceptPacket.Name, m_pSessionName, sizeof(AcceptPacket.Name));
else
strncpy(AcceptPacket.Name, "MiniDexed", sizeof(AcceptPacket.Name));
#ifdef APPLEMIDI_DEBUG

@ -39,7 +39,7 @@ public:
class CAppleMIDIParticipant : protected CTask
{
public:
CAppleMIDIParticipant(CBcmRandomNumberGenerator* pRandom, CAppleMIDIHandler* pHandler);
CAppleMIDIParticipant(CBcmRandomNumberGenerator* pRandom, CAppleMIDIHandler* pHandler, const char* pSessionName);
virtual ~CAppleMIDIParticipant() override;
bool Initialize();
@ -106,6 +106,8 @@ private:
u16 m_nSequence = 0;
u16 m_nLastFeedbackSequence = 0;
u64 m_nLastFeedbackTime = 0;
const char* m_pSessionName;
};
#endif

@ -34,11 +34,13 @@ LOGMODULE("ftpd");
constexpr u16 ListenPort = 21;
constexpr u8 MaxConnections = 1;
CFTPDaemon::CFTPDaemon(const char* pUser, const char* pPassword)
CFTPDaemon::CFTPDaemon(const char* pUser, const char* pPassword, CmDNSPublisher* pMDNSPublisher, CConfig* pConfig)
: CTask(TASK_STACK_SIZE, true),
m_pListenSocket(nullptr),
m_pUser(pUser),
m_pPassword(pPassword)
m_pPassword(pPassword),
m_pmDNSPublisher(pMDNSPublisher),
m_pConfig(pConfig)
{
}
@ -106,6 +108,6 @@ void CFTPDaemon::Run()
}
// Spawn new worker
new CFTPWorker(pConnection, m_pUser, m_pPassword);
new CFTPWorker(pConnection, m_pUser, m_pPassword, m_pmDNSPublisher, m_pConfig);
}
}

@ -25,11 +25,13 @@
#include <circle/net/socket.h>
#include <circle/sched/task.h>
#include "mdnspublisher.h"
#include "../config.h"
class CFTPDaemon : protected CTask
{
public:
CFTPDaemon(const char* pUser, const char* pPassword);
CFTPDaemon(const char* pUser, const char* pPassword, CmDNSPublisher* pMDNSPublisher, CConfig* pConfig);
virtual ~CFTPDaemon() override;
bool Initialize();
@ -42,6 +44,8 @@ private:
const char* m_pUser;
const char* m_pPassword;
CmDNSPublisher* m_pmDNSPublisher;
CConfig* m_pConfig;
};
#endif

@ -126,7 +126,7 @@ inline bool DirectoryCaseInsensitiveAscending(const TDirectoryListEntry& EntryA,
}
CFTPWorker::CFTPWorker(CSocket* pControlSocket, const char* pExpectedUser, const char* pExpectedPassword)
CFTPWorker::CFTPWorker(CSocket* pControlSocket, const char* pExpectedUser, const char* pExpectedPassword, CmDNSPublisher* pMDNSPublisher, CConfig* pConfig)
: CTask(TASK_STACK_SIZE),
m_LogName(),
m_pExpectedUser(pExpectedUser),
@ -142,7 +142,9 @@ CFTPWorker::CFTPWorker(CSocket* pControlSocket, const char* pExpectedUser, const
m_DataType(TDataType::ASCII),
m_TransferMode(TTransferMode::Active),
m_CurrentPath(),
m_RenameFrom()
m_RenameFrom(),
m_pmDNSPublisher(pMDNSPublisher),
m_pConfig(pConfig)
{
++s_nInstanceCount;
m_LogName.Format("ftpd[%d]", s_nInstanceCount);
@ -562,7 +564,7 @@ bool CFTPWorker::Passive(const char* pArgs)
IPAddress[2],
IPAddress[3],
(m_nDataSocketPort >> 8) & 0xFF,
m_nDataSocketPort & 0xFF
(m_nDataSocketPort & 0xFF)
);
SendStatus(TFTPStatus::EnteringPassiveMode, Buffer);
@ -1059,8 +1061,23 @@ bool CFTPWorker::Bye(const char* pArgs)
delete m_pControlSocket;
m_pControlSocket = nullptr;
// Unpublish the mDNS services
if (m_pmDNSPublisher && m_pConfig)
{
m_pmDNSPublisher->UnpublishService(m_pConfig->GetNetworkHostname());
m_pmDNSPublisher->UnpublishService(m_pConfig->GetNetworkHostname(), CmDNSPublisher::ServiceTypeAppleMIDI, 5004);
m_pmDNSPublisher->UnpublishService(m_pConfig->GetNetworkHostname(), CmDNSPublisher::ServiceTypeFTP, 21);
}
// Non-blocking 2 second delay before reboot
CTimer* const pTimer = CTimer::Get();
unsigned int start = pTimer->GetTicks();
while ((pTimer->GetTicks() - start) < 2 * HZ) {
CScheduler::Get()->Yield();
}
// Reboot the system if the user disconnects in order to apply any changes made
reboot ();
reboot();
return true;
}

@ -27,6 +27,8 @@
#include <circle/net/socket.h>
#include <circle/sched/task.h>
#include <circle/string.h>
#include "../config.h"
#include "mdnspublisher.h"
// TODO: These may be incomplete/inaccurate
enum TFTPStatus
@ -79,7 +81,7 @@ struct TDirectoryListEntry;
class CFTPWorker : protected CTask
{
public:
CFTPWorker(CSocket* pControlSocket, const char* pExpectedUser, const char* pExpectedPassword);
CFTPWorker(CSocket* pControlSocket, const char* pExpectedUser, const char* pExpectedPassword, CmDNSPublisher* pMDNSPublisher, CConfig* pConfig);
virtual ~CFTPWorker() override;
virtual void Run() override;
@ -142,6 +144,9 @@ private:
CString m_CurrentPath;
CString m_RenameFrom;
CmDNSPublisher* m_pmDNSPublisher;
CConfig* m_pConfig;
static void FatFsPathToFTPPath(const char* pInBuffer, char* pOutBuffer, size_t nSize);
static void FTPPathToFatFsPath(const char* pInBuffer, char* pOutBuffer, size_t nSize);

@ -131,6 +131,45 @@ boolean CmDNSPublisher::UnpublishService (const char *pServiceName)
delete pService;
return TRUE;
}
boolean CmDNSPublisher::UnpublishService(const char *pServiceName, const char *pServiceType, u16 usServicePort)
{
if (!m_bRunning)
{
return FALSE;
}
assert(pServiceName);
assert(pServiceType);
m_Mutex.Acquire();
TService *pService = nullptr;
TPtrListElement *pElement = m_ServiceList.GetFirst();
while (pElement)
{
pService = static_cast<TService *>(CPtrList::GetPtr(pElement));
assert(pService);
if (pService->ServiceName.Compare(pServiceName) == 0 &&
pService->ServiceType.Compare(pServiceType) == 0 &&
pService->usServicePort == usServicePort)
{
m_ServiceList.Remove(pElement);
break;
}
pService = nullptr;
pElement = m_ServiceList.GetNext(pElement);
}
m_Mutex.Release();
if (!pService)
{
return FALSE;
}
LOGDBG("Unpublish service %s %s %u", (const char *)pService->ServiceName, (const char *)pService->ServiceType, pService->usServicePort);
SendResponse(pService, FALSE);
for (unsigned i = 0; i < pService->nTextRecords; i++)
{
delete pService->ppText[i];
}
delete pService;
return TRUE;
}
void CmDNSPublisher::Run (void)
{
assert (m_pNet);

@ -32,6 +32,7 @@ class CmDNSPublisher : public CTask /// mDNS / Bonjour client task
{
public:
static constexpr const char *ServiceTypeAppleMIDI = "_apple-midi._udp";
static constexpr const char *ServiceTypeFTP = "_ftp._tcp";
public:
/// \param pNet Pointer to the network subsystem object
CmDNSPublisher (CNetSubSystem *pNet);
@ -50,6 +51,12 @@ public:
/// \param pServiceName Name of the service to be unpublished (same as when published)
/// \return Operation successful?
boolean UnpublishService (const char *pServiceName);
/// \brief Stop publishing a service
/// \param pServiceName Name of the service to be unpublished
/// \param pServiceType Type of the service to be unpublished
/// \param usServicePort Port number of the service to be unpublished
/// \return Operation successful?
boolean UnpublishService (const char *pServiceName, const char *pServiceType, u16 usServicePort);
void Run (void) override;
private:
static const unsigned MaxTextRecords = 10;

@ -33,7 +33,6 @@ LOGMODULE ("Performance");
#define PERFORMANCE_DIR "performance"
#define DEFAULT_PERFORMANCE_FILENAME "performance.ini"
#define DEFAULT_PERFORMANCE_NAME "Default"
#define DEFAULT_PERFORMANCE_BANK_NAME "Default"
CPerformanceConfig::CPerformanceConfig (FATFS *pFileSystem)
: m_Properties (DEFAULT_PERFORMANCE_FILENAME, pFileSystem)
@ -1182,10 +1181,6 @@ bool CPerformanceConfig::ListPerformanceBanks()
}
unsigned nNumBanks = 0;
// Add in the default performance directory as the first bank
m_PerformanceBankName[0] = DEFAULT_PERFORMANCE_BANK_NAME;
nNumBanks = 1;
m_nLastPerformanceBank = 0;
// List directories with names in format 01_Perf Bank Name
@ -1291,10 +1286,7 @@ std::string CPerformanceConfig::GetPerformanceBankName(unsigned nBankID)
{
return m_PerformanceBankName[nBankID];
}
else
{
return DEFAULT_PERFORMANCE_BANK_NAME;
}
return "";
}
std::string CPerformanceConfig::AddPerformanceBankDirName(unsigned nBankID)
@ -1304,12 +1296,6 @@ std::string CPerformanceConfig::AddPerformanceBankDirName(unsigned nBankID)
{
// Performance Banks directories in format "001_Bank Name"
std::string Index;
if (nBankID == 0)
{
// Legacy: Bank 1 is the default performance directory
return "";
}
if (nBankID < 9)
{
Index = "00" + std::to_string(nBankID+1);

@ -46,7 +46,7 @@ CUDPMIDIDevice::~CUDPMIDIDevice (void)
boolean CUDPMIDIDevice::Initialize (void)
{
m_pAppleMIDIParticipant = new CAppleMIDIParticipant(&m_Random, this);
m_pAppleMIDIParticipant = new CAppleMIDIParticipant(&m_Random, this, m_pConfig->GetNetworkHostname());
if (!m_pAppleMIDIParticipant->Initialize())
{
LOGERR("Failed to init RTP listener");

@ -23,5 +23,5 @@ cd -
# Use fixed master branch of Synth_Dexed
cd Synth_Dexed/
git reset --hard
git checkout 65d8383ad5 -f
git checkout 2ad9e43095 -f
cd -

Loading…
Cancel
Save