init network after minidexed starts

pull/744/head
Ömer Şiar Baysal 2 months ago
parent 893b9f60f1
commit 2046d81d58
  1. 9
      build.sh
  2. 1
      src/circle_stdlib_app.h
  3. 38
      src/config.cpp
  4. 13
      src/config.h
  5. 9
      src/kernel.cpp
  6. 4
      src/kernel.h
  7. 12
      src/mididevice.cpp
  8. 87
      src/minidexed.cpp
  9. 15
      src/minidexed.h
  10. 2
      src/net/applemidi.cpp
  11. 4
      src/net/ftpworker.cpp
  12. 14
      src/udpmididevice.cpp

@ -14,12 +14,19 @@ else
export TOOLCHAIN_PREFIX="arm-none-eabi-"
fi
SDHOST=$([ "${RPI}" == 3 ] && echo "" || echo "")
# Define system options
OPTIONS="-o USE_PWM_AUDIO_ON_ZERO -o SAVE_VFP_REGS_ON_IRQ -o REALTIME -o USE_SDHOST -o SCREEN_DMA_BURST_LENGTH=1"
OPTIONS="-o USE_PWM_AUDIO_ON_ZERO -o SAVE_VFP_REGS_ON_IRQ -o REALTIME -o SCREEN_DMA_BURST_LENGTH=1"
if [ "${RPI}" -gt "1" ]; then
OPTIONS="${OPTIONS} -o ARM_ALLOW_MULTI_CORE"
fi
# For wireless access
if [ "${RPI}" == "3" ]; then
OPTIONS="${OPTIONS} -o USE_SDHOST"
fi
# USB Vendor and Device ID for use with USB Gadget Mode
source USBID.sh
if [ "${USB_VID}" ] ; then

@ -223,6 +223,7 @@ protected:
CEMMCDevice mEMMC;
FATFS mFileSystem;
CConsole mConsole;
CScheduler mScheduler;
};
/**

@ -155,7 +155,13 @@ void CConfig::Load (void)
// Network
m_bNetworkEnabled = m_Properties.GetNumber ("NetworkEnabled", 0) != 0;
m_NetworkType = m_Properties.GetString ("NetworkType", "");
m_bNetworkDHCP = m_Properties.GetNumber ("NetworkDHCP", 0) != 0;
m_NetworkType = m_Properties.GetString ("NetworkType", "wifi");
m_NetworkHostname = m_Properties.GetString ("NetworkHostname", "minidexed");
m_INetworkIPAddress = m_Properties.GetIPAddress("NetworkIPAddress") != 0;
m_INetworkSubnetMask = m_Properties.GetIPAddress("NetworkSubnetMask") != 0;
m_INetworkDefaultGateway = m_Properties.GetIPAddress("NetworkDefaultGateway") != 0;
m_INetworkDNSServer = m_Properties.GetIPAddress("NetworkDNSServer") != 0;
}
bool CConfig::GetUSBGadgetMode (void) const
@ -514,7 +520,37 @@ bool CConfig::GetNetworkEnabled (void) const
return m_bNetworkEnabled;
}
bool CConfig::GetNetworkDHCP (void) const
{
return m_bNetworkDHCP;
}
const char *CConfig::GetNetworkType (void) const
{
return m_NetworkType.c_str();
}
const char *CConfig::GetNetworkHostname (void) const
{
return m_NetworkHostname.c_str();
}
CIPAddress CConfig::GetNetworkIPAddress (void) const
{
return m_INetworkIPAddress;
}
CIPAddress CConfig::GetNetworkSubnetMask (void) const
{
return m_INetworkSubnetMask;
}
CIPAddress CConfig::GetNetworkDefaultGateway (void) const
{
return m_INetworkDefaultGateway;
}
CIPAddress CConfig::GetNetworkDNSServer (void) const
{
return m_INetworkDNSServer;
}

@ -23,6 +23,7 @@
#ifndef _config_h
#define _config_h
#include <circle/net/ipaddress.h>
#include <fatfs/ff.h>
#include <Properties/propertiesfatfsfile.h>
#include <circle/sysconfig.h>
@ -171,6 +172,12 @@ public:
// Network
bool GetNetworkEnabled (void) const;
const char *GetNetworkType (void) const;
bool GetNetworkDHCP (void) const;
const char *GetNetworkHostname (void) const;
CIPAddress GetNetworkIPAddress (void) const;
CIPAddress GetNetworkSubnetMask (void) const;
CIPAddress GetNetworkDefaultGateway (void) const;
CIPAddress GetNetworkDNSServer (void) const;
private:
CPropertiesFatFsFile m_Properties;
@ -259,7 +266,13 @@ private:
// Network
bool m_bNetworkEnabled;
bool m_bNetworkDHCP;
std::string m_NetworkType;
std::string m_NetworkHostname;
CIPAddress m_INetworkIPAddress;
CIPAddress m_INetworkSubnetMask;
CIPAddress m_INetworkDefaultGateway;
CIPAddress m_INetworkDNSServer;
};
#endif

@ -32,12 +32,13 @@ CKernel *CKernel::s_pThis = 0;
CKernel::CKernel (void)
:
//CStdlibAppStdio ("minidexed"),
CStdlibAppNetwork ("minidexed", CSTDLIBAPP_DEFAULT_PARTITION,
0, 0, 0, 0, NET_DEVICE_TYPE),
CStdlibAppStdio ("minidexed"),
//CStdlibAppNetwork ("minidexed", CSTDLIBAPP_DEFAULT_PARTITION,
// 0, 0, 0, 0, NET_DEVICE_TYPE),
m_Config (&mFileSystem),
m_GPIOManager (&mInterrupt),
m_I2CMaster (CMachineInfo::Get ()->GetDevice (DeviceI2CMaster), TRUE),
//m_Scheduler(),
m_pDexed (0)
{
s_pThis = this;
@ -52,7 +53,7 @@ CKernel::~CKernel(void)
bool CKernel::Initialize (void)
{
if (!CStdlibAppNetwork::Initialize ())
if (!CStdlibAppStdio::Initialize ())
{
return FALSE;
}

@ -25,6 +25,7 @@
#include <circle/gpiomanager.h>
#include <circle/i2cmaster.h>
#include <circle/usb/usbcontroller.h>
#include <circle/sched/scheduler.h>
#include "config.h"
#include "minidexed.h"
@ -35,7 +36,7 @@ enum TShutdownMode
ShutdownReboot
};
class CKernel : public CStdlibAppNetwork
class CKernel : public CStdlibAppStdio
{
public:
CKernel (void);
@ -54,6 +55,7 @@ private:
CCPUThrottle m_CPUThrottle;
CGPIOManager m_GPIOManager;
CI2CMaster m_I2CMaster;
//CScheduler m_Scheduler;
CMiniDexed *m_pDexed;
CUSBController *m_pUSB;

@ -169,7 +169,6 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
}
m_MIDISpinLock.Acquire ();
printf ("MIDI-DEBUG: SPINLOCK ACQUIRED\n");
u8 ucStatus = pMessage[0];
u8 ucChannel = ucStatus & 0x0F;
@ -205,7 +204,6 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
{
if ((ucChannel == nPerfCh) || (nPerfCh == OmniMode))
{
//printf("Performance Select Channel %d\n", nPerfCh);
m_pSynthesizer->ProgramChangePerformance (pMessage[1]);
}
}
@ -214,10 +212,8 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
}
// Process MIDI for each Tone Generator
printf ("MIDI-DEBUG: EACH TONEGENERATOR LOOP\n");
for (unsigned nTG = 0; nTG < CConfig::ToneGenerators; nTG++)
{
printf ("%u TONE GENERATOR", nTG);
if (ucStatus == MIDI_SYSTEM_EXCLUSIVE_BEGIN)
{
// MIDI SYSEX per MIDI channel
@ -230,15 +226,12 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
}
else
{
printf ("NOT AN SYSEX");
if ( m_ChannelMap[nTG] == ucChannel
|| m_ChannelMap[nTG] == OmniMode)
{
switch (ucType)
{
case MIDI_NOTE_ON:
printf ("MIDI-DEBUG: CASE MIDI NOTE ON\n");
if (nLength < 3)
{
break;
@ -248,15 +241,12 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
{
if (pMessage[2] <= 127)
{
printf ("MIDI-DEBUG: KEYDOWN EVENT\n");
m_pSynthesizer->keydown (pMessage[1],
pMessage[2], nTG);
}
}
else
{
printf ("MIDI-DEBUG: KEYUP EVENT\n");
//printf ("MIDI-RTP: %02X\n", m_pSynthesizer);
m_pSynthesizer->keyup (pMessage[1], nTG);
}
break;
@ -266,7 +256,6 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
{
break;
}
printf ("MIDI-DEBUG: MIDI NOTE OFF\n");
m_pSynthesizer->keyup (pMessage[1], nTG);
break;
@ -388,7 +377,6 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign
}
}
m_MIDISpinLock.Release ();
printf ("MIDI-DEBUG: SPINLOCK RELEASED\n");
}
void CMIDIDevice::AddDevice (const char *pDeviceName)

@ -27,15 +27,14 @@
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <circle/net/netsubsystem.h>
//#include <circle/net/netsubsystem.h>
//#include <circle/sched/scheduler.h>
//#include "circle_stdlib_app.h"
//#include "mididevice.h"
#define DRIVE "SD:"
#define FIRMWARE_PATH DRIVE "/firmware/" // firmware files must be provided here
#define CONFIG_FILE DRIVE "/wpa_supplicant.conf"
const char WLANFirmwarePath[] = "SD:firmware/";
const char WLANConfigFile[] = "SD:wpa_supplicant.conf";
#define FTPUSERNAME "admin"
#define FTPPASSWORD "admin"
/*
@ -78,6 +77,10 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt,
m_bNetworkReady(false),
*/
//CNetSubSystem* const pNet = CNetSubSystem::Get();
m_pNet(nullptr),
m_pNetDevice(nullptr),
m_WLAN(WLANFirmwarePath),
m_WPASupplicant(WLANConfigFile),
m_bNetworkReady(false),
m_UDPMIDI (this, pConfig, &m_UI)
{
@ -292,19 +295,10 @@ bool CMiniDexed::Initialize (void)
return false;
}
#endif
//InitNetwork();
InitNetwork();
//CMIDIDevice->InitializeRTP();
m_pFTPDaemon = new CFTPDaemon(FTPUSERNAME, FTPPASSWORD);
if (!m_pFTPDaemon->Initialize())
{
LOGERR("Failed to init FTP daemon");
delete m_pFTPDaemon;
m_pFTPDaemon = nullptr;
}
else
LOGNOTE("FTP daemon initialized");
return true;
}
@ -1861,18 +1855,18 @@ void CMiniDexed::UpdateNetwork()
}*/
{
CNetSubSystem* const pNet = CNetSubSystem::Get();
if (!pNet)
//CNetSubSystem* const pNet = CNetSubSystem::Get();
if (!m_pNet)
return;
bool bNetIsRunning = pNet->IsRunning();
//bNetIsRunning &= m_WPASupplicant.IsConnected();
bool bNetIsRunning = m_pNet->IsRunning();
bNetIsRunning &= m_WPASupplicant.IsConnected();
if (!m_bNetworkReady)
if (!m_bNetworkReady && bNetIsRunning)
{
m_bNetworkReady = true;
CString IPString;
pNet->GetConfig()->GetIPAddress()->Format(&IPString);
m_pNet->GetConfig()->GetIPAddress()->Format(&IPString);
LOGNOTE("Network up and running at: %s", static_cast<const char *>(IPString));
@ -1880,6 +1874,15 @@ void CMiniDexed::UpdateNetwork()
{
LOGNOTE ("RTP MIDI interface enabled");
}
m_pFTPDaemon = new CFTPDaemon(FTPUSERNAME, FTPPASSWORD);
if (!m_pFTPDaemon->Initialize())
{
LOGERR("Failed to init FTP daemon");
delete m_pFTPDaemon;
m_pFTPDaemon = nullptr;
}
else
LOGNOTE("FTP daemon initialized");
}
else if (m_bNetworkReady && !bNetIsRunning)
{
@ -1914,13 +1917,13 @@ void CMiniDexed::UpdateNetwork()
m_bNetworkReady = false;
LOGNOTE("Network disconnected.");
}
}
}*/
bool CMiniDexed::InitNetwork()
{
assert(m_pNet == nullptr);
TNetDeviceType NetDeviceType = NetDeviceTypeWLAN;
TNetDeviceType NetDeviceType = NetDeviceTypeUnknown;
if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "wifi") == 0))
{
@ -1929,7 +1932,7 @@ bool CMiniDexed::InitNetwork()
if (m_WLAN.Initialize() && m_WPASupplicant.Initialize())
{
LOGNOTE("wlan and wpasupplicant initialized");
//NetDeviceType = NetDeviceTypeWLAN;
NetDeviceType = NetDeviceTypeWLAN;
}
else
@ -1938,21 +1941,31 @@ bool CMiniDexed::InitNetwork()
else if (m_pConfig->GetNetworkEnabled () && (strcmp(m_pConfig->GetNetworkType(), "ethernet") == 0))
{
LOGNOTE("Initializing Ethernet");
//NetDeviceType = NetDeviceTypeEthernet;
NetDeviceType = NetDeviceTypeEthernet;
}
if (NetDeviceType != NetDeviceTypeUnknown)
{
if (m_pConfig->GetNetworkDHCP())
m_pNet = new CNetSubSystem(0, 0, 0, 0, m_pConfig->GetNetworkHostname(), NetDeviceType);
else
m_pNet = new CNetSubSystem(
m_pConfig->GetNetworkIPAddress().Get(),
m_pConfig->GetNetworkSubnetMask().Get(),
m_pConfig->GetNetworkDefaultGateway().Get(),
m_pConfig->GetNetworkDNSServer().Get(),
m_pConfig->GetNetworkHostname(),
NetDeviceType
);
if (!m_pNet->Initialize())
{
LOGERR("Failed to initialize network subsystem");
delete m_pNet;
m_pNet = nullptr;
}
LOGNOTE("creating network with wifi and dhcp");
m_pNet = new CNetSubSystem(0, 0, 0, 0, "minidexed", NetDeviceType);
if (!m_pNet->Initialize(true))
{
LOGERR("Failed to initialize network subsystem");
delete m_pNet;
m_pNet = nullptr;
}
m_pNetDevice = CNetDevice::GetNetDevice(NetDeviceType);
m_pNetDevice = CNetDevice::GetNetDevice(NetDeviceType);
}
return m_pNet != nullptr;
}
*/
}

@ -39,8 +39,9 @@
#include <circle/multicore.h>
#include <circle/sound/soundbasedevice.h>
#include <circle/sched/scheduler.h>
////#include <circle/net/netsubsystem.h>
//#include <wlan/hostap/wpa_supplicant/wpasupplicant.h>
#include <circle/net/netsubsystem.h>
#include <wlan/bcm4343.h>
#include <wlan/hostap/wpa_supplicant/wpasupplicant.h>
#include <circle/spinlock.h>
#include "common.h"
#include "effect_mixer.hpp"
@ -218,7 +219,7 @@ public:
bool DoSavePerformance (void);
void setMasterVolume (float32_t vol);
//bool InitNetwork();
bool InitNetwork();
void UpdateNetwork();
private:
@ -319,7 +320,6 @@ private:
unsigned m_nDeletePerformanceID;
bool m_bLoadPerformanceBusy;
bool m_bSaveAsDeault;
bool m_bNetworkReady;
//CNetSubSystem* m_pNet;
//CWPASupplicant m_WPASupplicant;
// Networking
@ -332,8 +332,15 @@ private:
bool m_bNetworkReady;
CBcmRandomNumberGenerator m_Random;
*/
// Networking
CNetSubSystem* m_pNet;
CNetDevice* m_pNetDevice;
CBcm4343Device m_WLAN;
CWPASupplicant m_WPASupplicant;
bool m_bNetworkReady;
CUDPMIDIDevice m_UDPMIDI;
CFTPDaemon* m_pFTPDaemon;
};
#endif

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

@ -43,10 +43,10 @@ constexpr unsigned int SocketTimeout = 20;
constexpr unsigned int NumRetries = 3;
#ifndef MT32_PI_VERSION
#define MT32_PI_VERSION "(version unknown)"
#define MT32_PI_VERSION "alpha version"
#endif
const char MOTDBanner[] = "Welcome to the mt32-pi " MT32_PI_VERSION " embedded FTP server!";
const char MOTDBanner[] = "Welcome to the minidexed " MT32_PI_VERSION " embedded FTP server!";
enum class TDirectoryListEntryType
{

@ -26,7 +26,7 @@
#include "udpmididevice.h"
#include <assert.h>
//#define VIRTUALCABLE 24
#define VIRTUALCABLE 24
LOGMODULE("rtpmididevice");
@ -51,7 +51,7 @@ CUDPMIDIDevice::CUDPMIDIDevice (CMiniDexed *pSynthesizer,
CUDPMIDIDevice::~CUDPMIDIDevice (void)
{
m_pSynthesizer = 0;
//m_pSynthesizer = 0;
}
boolean CUDPMIDIDevice::Initialize (void)
@ -80,10 +80,7 @@ boolean CUDPMIDIDevice::Initialize (void)
void CUDPMIDIDevice::OnAppleMIDIDataReceived(const u8* pData, size_t nSize)
{
LOGNOTE("Recieved RTPUDP MIDI Data");
printf ("MIDI-RTP: %02X %02X\n",
(unsigned) pData[0], (unsigned) pData[1]);
MIDIMessageHandler(pData, nSize);
MIDIMessageHandler(pData, nSize, VIRTUALCABLE);
}
void CUDPMIDIDevice::OnAppleMIDIConnect(const CIPAddress* pIPAddress, const char* pName)
@ -99,8 +96,5 @@ void CUDPMIDIDevice::OnAppleMIDIDisconnect(const CIPAddress* pIPAddress, const c
void CUDPMIDIDevice::OnUDPMIDIDataReceived(const u8* pData, size_t nSize)
{
LOGNOTE("Recieved UDP MIDI Data");
printf ("MIDI-UDP: %02X %02X\n",
(unsigned) pData[0], (unsigned) pData[1]);
MIDIMessageHandler(pData, nSize);
MIDIMessageHandler(pData, nSize, VIRTUALCABLE);
}
Loading…
Cancel
Save