Step47 Network Support without mDNS (#757)

* add initial mdns responder for rtp-midi aka applemidi

* do not reinitialized network

* continue publishing mdns after network connection reestablishes

* remote mdnsresponder and revert to step48

* disable mdns TTL patching for now
pull/761/head
Ömer Şiar Baysal 7 days ago committed by GitHub
parent a95d6e0c65
commit 024d23a69d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      .github/workflows/build.yml
  2. 55
      src/minidexed.cpp
  3. 5
      src/minidexed.h
  4. 2
      src/net/applemidi.cpp
  5. 7
      src/net/ftpworker.cpp
  6. 74
      src/rtpmididevice.cpp
  7. 49
      src/rtpmididevice.h
  8. 7
      src/udpmididevice.cpp
  9. 5
      src/udpmididevice.h
  10. 4
      submod.sh

@ -24,7 +24,7 @@ jobs:
# Put git hash in startup message # Put git hash in startup message
sed -i "s/Loading.../$(date +%Y%m%d)-$(git rev-parse --short HEAD)/g" src/userinterface.cpp sed -i "s/Loading.../$(date +%Y%m%d)-$(git rev-parse --short HEAD)/g" src/userinterface.cpp
# https://github.com/rsta2/circle/discussions/427#discussioncomment-11198505 # https://github.com/rsta2/circle/discussions/427#discussioncomment-11198505
sed -i -e 's|TTLShort = 120|TTLShort = 15|g' circle-stdlib/libs/circle/include/circle/net/mdnspublisher.h # sed -i -e 's|TTLShort = 120|TTLShort = 15|g' circle-stdlib/libs/circle/include/circle/net/mdnspublisher.h
- name: Install toolchains - name: Install toolchains
run: | run: |
set -ex set -ex

@ -62,8 +62,9 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt,
m_WLAN(WLANFirmwarePath), m_WLAN(WLANFirmwarePath),
m_WPASupplicant(WLANConfigFile), m_WPASupplicant(WLANConfigFile),
m_bNetworkReady(false), m_bNetworkReady(false),
m_bNetworkInit(false),
m_UDPMIDI (this, pConfig, &m_UI), m_UDPMIDI (this, pConfig, &m_UI),
m_pmDNSPublisher (), //m_pmDNSPublisher (nullptr),
m_bSavePerformance (false), m_bSavePerformance (false),
m_bSavePerformanceNewFile (false), m_bSavePerformanceNewFile (false),
m_bSetNewPerformance (false), m_bSetNewPerformance (false),
@ -367,12 +368,14 @@ void CMiniDexed::Process (bool bPlugAndPlayUpdated)
CScheduler* const pScheduler = CScheduler::Get(); CScheduler* const pScheduler = CScheduler::Get();
#ifndef ARM_ALLOW_MULTI_CORE #ifndef ARM_ALLOW_MULTI_CORE
ProcessSound (); ProcessSound ();
pScheduler->Yield();
#endif #endif
for (unsigned i = 0; i < CConfig::MaxUSBMIDIDevices; i++) for (unsigned i = 0; i < CConfig::MaxUSBMIDIDevices; i++)
{ {
assert (m_pMIDIKeyboard[i]); assert (m_pMIDIKeyboard[i]);
m_pMIDIKeyboard[i]->Process (bPlugAndPlayUpdated); m_pMIDIKeyboard[i]->Process (bPlugAndPlayUpdated);
pScheduler->Yield();
} }
m_PCKeyboard.Process (bPlugAndPlayUpdated); m_PCKeyboard.Process (bPlugAndPlayUpdated);
@ -380,6 +383,7 @@ void CMiniDexed::Process (bool bPlugAndPlayUpdated)
if (m_bUseSerial) if (m_bUseSerial)
{ {
m_SerialMIDI.Process (); m_SerialMIDI.Process ();
pScheduler->Yield();
} }
m_UI.Process (); m_UI.Process ();
@ -389,12 +393,14 @@ void CMiniDexed::Process (bool bPlugAndPlayUpdated)
DoSavePerformance (); DoSavePerformance ();
m_bSavePerformance = false; m_bSavePerformance = false;
pScheduler->Yield();
} }
if (m_bSavePerformanceNewFile) if (m_bSavePerformanceNewFile)
{ {
DoSavePerformanceNewFile (); DoSavePerformanceNewFile ();
m_bSavePerformanceNewFile = false; m_bSavePerformanceNewFile = false;
pScheduler->Yield();
} }
if (m_bSetNewPerformanceBank && !m_bLoadPerformanceBusy && !m_bLoadPerformanceBankBusy) if (m_bSetNewPerformanceBank && !m_bLoadPerformanceBusy && !m_bLoadPerformanceBankBusy)
@ -412,6 +418,7 @@ void CMiniDexed::Process (bool bPlugAndPlayUpdated)
{ {
DoSetFirstPerformance(); DoSetFirstPerformance();
} }
pScheduler->Yield();
} }
if (m_bSetNewPerformance && !m_bSetNewPerformanceBank && !m_bLoadPerformanceBusy && !m_bLoadPerformanceBankBusy) if (m_bSetNewPerformance && !m_bSetNewPerformanceBank && !m_bLoadPerformanceBusy && !m_bLoadPerformanceBankBusy)
@ -421,17 +428,20 @@ void CMiniDexed::Process (bool bPlugAndPlayUpdated)
{ {
m_bSetNewPerformance = false; m_bSetNewPerformance = false;
} }
pScheduler->Yield();
} }
if(m_bDeletePerformance) if(m_bDeletePerformance)
{ {
DoDeletePerformance (); DoDeletePerformance ();
m_bDeletePerformance = false; m_bDeletePerformance = false;
pScheduler->Yield();
} }
if (m_bProfileEnabled) if (m_bProfileEnabled)
{ {
m_GetChunkTimer.Dump (); m_GetChunkTimer.Dump ();
pScheduler->Yield();
} }
UpdateNetwork(); UpdateNetwork();
// Allow other tasks to run // Allow other tasks to run
@ -2190,16 +2200,17 @@ void CMiniDexed::UpdateNetwork()
if (!m_pNet) if (!m_pNet)
return; return;
//add wired network check as well
//add wired network check as well //add wired network check as well
bool bNetIsRunning = m_pNet->IsRunning(); bool bNetIsRunning = m_pNet->IsRunning();
if ((strcmp(m_pConfig->GetNetworkType(), "ethernet") == 0)) if (m_pNetDevice->GetType() == NetDeviceTypeEthernet)
bNetIsRunning &= m_pNetDevice->IsLinkUp(); bNetIsRunning &= m_pNetDevice->IsLinkUp();
else if ((strcmp(m_pConfig->GetNetworkType(), "wifi") == 0)) else if (m_pNetDevice->GetType() == NetDeviceTypeWLAN)
bNetIsRunning &= m_WPASupplicant.IsConnected(); bNetIsRunning &= m_WPASupplicant.IsConnected();
if (!m_bNetworkReady && (m_pNet->IsRunning())) if (!m_bNetworkInit)
{ {
m_bNetworkReady = true; m_bNetworkInit = true;
CString IPString; CString IPString;
m_pNet->GetConfig()->GetIPAddress()->Format(&IPString); m_pNet->GetConfig()->GetIPAddress()->Format(&IPString);
@ -2219,39 +2230,37 @@ void CMiniDexed::UpdateNetwork()
{ {
LOGNOTE("FTP daemon initialized"); LOGNOTE("FTP daemon initialized");
} }
m_UI.DisplayWrite ("IP", "Network", IPString, 0, 1); m_UI.DisplayWrite ("IP", "Network", IPString, 0, 1);
CmDNSPublisher *pmDNSPublisher = new CmDNSPublisher (m_pNet); /*m_pmDNSPublisher = new CmDNSPublisher (m_pNet);
assert (pmDNSPublisher); assert (m_pmDNSPublisher);
static const char ServiceName[] = "MiniDexed";
static const char *ppText[] = {"RTP-MIDI Receiver", nullptr}; // TXT record strings //static const char *ppText[] = {"RTP-MIDI Receiver", nullptr}; // dont bother adding additional data
if (!pmDNSPublisher->PublishService (ServiceName, CmDNSPublisher::ServiceTypeAppleMIDI, if (!m_pmDNSPublisher->PublishService (MDNSSERVICENAME, CmDNSPublisher::ServiceTypeAppleMIDI,
5004, ppText)) 5004))
{
LOGPANIC ("Cannot publish mdns service");
}
static const char *ppText2[] = {"FTP Server", nullptr}; // TXT record strings
static constexpr const char *ServiceTypeFTP = "_ftp._tcp";
if (!pmDNSPublisher->PublishService (ServiceName, ServiceTypeFTP,
21, ppText2))
{ {
LOGPANIC ("Cannot publish mdns service"); LOGPANIC ("Cannot publish mdns service");
} }
*/
m_bNetworkReady = true;
} }
else if (m_bNetworkReady && !bNetIsRunning)
if (m_bNetworkReady && !bNetIsRunning)
{ {
//m_bNetworkReady = false; m_bNetworkReady = false;
m_pmDNSPublisher->UnpublishService (MDNSSERVICENAME); //m_pmDNSPublisher->UnpublishService (MDNSSERVICENAME);
LOGNOTE("Network disconnected."); LOGNOTE("Network disconnected.");
} }
else if (m_bNetworkReady && bNetIsRunning) else if (!m_bNetworkReady && bNetIsRunning)
{ {
m_bNetworkReady = true;
/*
if (!m_pmDNSPublisher->PublishService (MDNSSERVICENAME, CmDNSPublisher::ServiceTypeAppleMIDI, if (!m_pmDNSPublisher->PublishService (MDNSSERVICENAME, CmDNSPublisher::ServiceTypeAppleMIDI,
5004)) 5004))
{ {
LOGPANIC ("Cannot publish mdns service"); LOGPANIC ("Cannot publish mdns service");
} }
*/
LOGNOTE("Network connection reestablished."); LOGNOTE("Network connection reestablished.");
} }

@ -43,7 +43,7 @@
#include <circle/net/netsubsystem.h> #include <circle/net/netsubsystem.h>
#include <wlan/bcm4343.h> #include <wlan/bcm4343.h>
#include <wlan/hostap/wpa_supplicant/wpasupplicant.h> #include <wlan/hostap/wpa_supplicant/wpasupplicant.h>
#include <circle/net/mdnspublisher.h> //#include <circle/net/mdnspublisher.h>
#include <circle/spinlock.h> #include <circle/spinlock.h>
#include "common.h" #include "common.h"
#include "effect_mixer.hpp" #include "effect_mixer.hpp"
@ -338,9 +338,10 @@ private:
CBcm4343Device m_WLAN; CBcm4343Device m_WLAN;
CWPASupplicant m_WPASupplicant; CWPASupplicant m_WPASupplicant;
bool m_bNetworkReady; bool m_bNetworkReady;
bool m_bNetworkInit;
CUDPMIDIDevice m_UDPMIDI; CUDPMIDIDevice m_UDPMIDI;
CFTPDaemon* m_pFTPDaemon; CFTPDaemon* m_pFTPDaemon;
CmDNSPublisher *m_pmDNSPublisher; //CmDNSPublisher *m_pmDNSPublisher;
bool m_bSavePerformance; bool m_bSavePerformance;
bool m_bSavePerformanceNewFile; bool m_bSavePerformanceNewFile;

@ -803,7 +803,7 @@ bool CAppleMIDIParticipant::SendAcceptInvitationPacket(CSocket* pSocket, CIPAddr
}; };
// TODO: configurable name // TODO: configurable name
strncpy(AcceptPacket.Name, "minidexed", sizeof(AcceptPacket.Name)); strncpy(AcceptPacket.Name, "MiniDexed", sizeof(AcceptPacket.Name));
#ifdef APPLEMIDI_DEBUG #ifdef APPLEMIDI_DEBUG
LOGNOTE("--> Accept invitation"); LOGNOTE("--> Accept invitation");

@ -61,6 +61,7 @@ struct TDirectoryListEntry
u32 nSize; u32 nSize;
u16 nLastModifedDate; u16 nLastModifedDate;
u16 nLastModifedTime; u16 nLastModifedTime;
//bool bHid;
}; };
using TCommandHandler = bool (CFTPWorker::*)(const char* pArgs); using TCommandHandler = bool (CFTPWorker::*)(const char* pArgs);
@ -422,6 +423,7 @@ const TDirectoryListEntry* CFTPWorker::BuildDirectoryList(size_t& nOutEntries) c
{ {
Entry.Type = TDirectoryListEntryType::File; Entry.Type = TDirectoryListEntryType::File;
Entry.nSize = FileInfo.fsize; Entry.nSize = FileInfo.fsize;
//Entry.bHid = (FileInfo.fattrib & AM_HID) ? true : false;
} }
Entry.nLastModifedDate = FileInfo.fdate; Entry.nLastModifedDate = FileInfo.fdate;
@ -984,7 +986,10 @@ bool CFTPWorker::ListFileNames(const char* pArgs)
const TDirectoryListEntry& Entry = pDirEntries[i]; const TDirectoryListEntry& Entry = pDirEntries[i];
if (Entry.Type == TDirectoryListEntryType::Directory) if (Entry.Type == TDirectoryListEntryType::Directory)
continue; continue;
/*if (Entry.Name == "wpa_supplicant.conf")
{
continue;
}*/
const int nLength = snprintf(Buffer, sizeof(Buffer), "%s\r\n", Entry.Name); const int nLength = snprintf(Buffer, sizeof(Buffer), "%s\r\n", Entry.Name);
if (pDataSocket->Send(Buffer, nLength, 0) < 0) if (pDataSocket->Send(Buffer, nLength, 0) < 0)
{ {

@ -1,74 +0,0 @@
//
// serialmididevice.cpp
//
// MiniDexed - Dexed FM synthesizer for bare metal Raspberry Pi
// Copyright (C) 2022 The MiniDexed Team
//
// Original author of this class:
// R. Stange <rsta2@o2online.de>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#include <circle/logger.h>
#include <cstring>
#include "rtpmididevice.h"
#include <assert.h>
#define VIRTUALCABLE 24
LOGMODULE("rtpmididevice");
CRTPMIDIDevice::CRTPMIDIDevice (CMiniDexed *pSynthesizer,
CConfig *pConfig, CUserInterface *pUI)
: CMIDIDevice (pSynthesizer, pConfig, pUI),
m_pConfig (pConfig)
{
AddDevice ("rtpdummy");
}
CRTPMIDIDevice::~CRTPMIDIDevice (void)
{
}
boolean CRTPMIDIDevice::Initialize (void)
{
m_pAppleMIDIParticipant = new CAppleMIDIParticipant(&m_Random, this);
if (!m_pAppleMIDIParticipant->Initialize())
{
LOGERR("Failed to init RTP listener");
return false; //continue without rtp midi
}
else
LOGNOTE("RTP Listener initialized");
return true;
}
// Methods to handle MIDI events
void CRTPMIDIDevice::OnAppleMIDIDataReceived(const u8* pData, size_t nSize)
{
MIDIMessageHandler(pData, nSize, VIRTUALCABLE);
}
void CRTPMIDIDevice::OnAppleMIDIConnect(const CIPAddress* pIPAddress, const char* pName)
{
LOGNOTE("RTP Device connected");
}
void CRTPMIDIDevice::OnAppleMIDIDisconnect(const CIPAddress* pIPAddress, const char* pName)
{
// RemoveRTPDevice
}

@ -1,49 +0,0 @@
//
// .h
//
// MiniDexed - Dexed FM synthesizer for bare metal Raspberry Pi
// Copyright (C) 2022 The MiniDexed Team
//
// Original author of this class:
// R. Stange <rsta2@o2online.de>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef _rtpmididevice_h
#define _rtpmididevice_h
#include "mididevice.h"
#include "config.h"
#include "net/applemidi.h"
class CMiniDexed;
class CRTPMIDIDevice : CAppleMIDIHandler, CMIDIDevice
{
public:
CRTPMIDIDevice (CMiniDexed *pSynthesizer, CConfig *pConfig, CUserInterface *pUI);
~CRTPMIDIDevice (void);
boolean Initialize (void);
virtual void OnAppleMIDIDataReceived(const u8* pData, size_t nSize) override;
virtual void OnAppleMIDIConnect(const CIPAddress* pIPAddress, const char* pName) override;
virtual void OnAppleMIDIDisconnect(const CIPAddress* pIPAddress, const char* pName) override;
private:
CConfig *m_pConfig;
CBcmRandomNumberGenerator m_Random;
CAppleMIDIParticipant* m_pAppleMIDIParticipant;
};
#endif

@ -28,7 +28,7 @@
#define VIRTUALCABLE 24 #define VIRTUALCABLE 24
LOGMODULE("rtpmididevice"); LOGMODULE("udpmididevice");
CUDPMIDIDevice::CUDPMIDIDevice (CMiniDexed *pSynthesizer, CUDPMIDIDevice::CUDPMIDIDevice (CMiniDexed *pSynthesizer,
CConfig *pConfig, CUserInterface *pUI) CConfig *pConfig, CUserInterface *pUI)
@ -50,11 +50,11 @@ boolean CUDPMIDIDevice::Initialize (void)
if (!m_pAppleMIDIParticipant->Initialize()) if (!m_pAppleMIDIParticipant->Initialize())
{ {
LOGERR("Failed to init RTP listener"); LOGERR("Failed to init RTP listener");
return false; //continue without rtp midi delete m_pAppleMIDIParticipant;
m_pAppleMIDIParticipant = nullptr;
} }
else else
LOGNOTE("RTP Listener initialized"); LOGNOTE("RTP Listener initialized");
return true;
m_pUDPMIDIReceiver = new CUDPMIDIReceiver(this); m_pUDPMIDIReceiver = new CUDPMIDIReceiver(this);
if (!m_pUDPMIDIReceiver->Initialize()) if (!m_pUDPMIDIReceiver->Initialize())
{ {
@ -64,6 +64,7 @@ boolean CUDPMIDIDevice::Initialize (void)
} }
else else
LOGNOTE("UDP MIDI receiver initialized"); LOGNOTE("UDP MIDI receiver initialized");
return true;
} }
// Methods to handle MIDI events // Methods to handle MIDI events

@ -22,8 +22,8 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
#ifndef _rtpmididevice_h #ifndef _udpmididevice_h
#define _rtpmididevice_h #define _udpmididevice_h
#include "mididevice.h" #include "mididevice.h"
#include "config.h" #include "config.h"
@ -50,7 +50,6 @@ private:
CBcmRandomNumberGenerator m_Random; CBcmRandomNumberGenerator m_Random;
CAppleMIDIParticipant* m_pAppleMIDIParticipant; // AppleMIDI participant instance CAppleMIDIParticipant* m_pAppleMIDIParticipant; // AppleMIDI participant instance
CUDPMIDIReceiver* m_pUDPMIDIReceiver; CUDPMIDIReceiver* m_pUDPMIDIReceiver;
}; };
#endif #endif

@ -6,13 +6,13 @@ git submodule update --init --recursive
# #
# Use fixed master branch of circle-stdlib then re-update # Use fixed master branch of circle-stdlib then re-update
cd circle-stdlib/ cd circle-stdlib/
git checkout 3bd135d git checkout tags/v16.5
git submodule update --init --recursive git submodule update --init --recursive
cd - cd -
# #
# Optional update submodules explicitly # Optional update submodules explicitly
cd circle-stdlib/libs/circle cd circle-stdlib/libs/circle
git checkout c243194 git checkout tags/Step47
cd - cd -
cd circle-stdlib/libs/circle-newlib cd circle-stdlib/libs/circle-newlib
#git checkout develop #git checkout develop

Loading…
Cancel
Save