diff --git a/build.sh b/build.sh index 25d9dfc4..c2122be2 100755 --- a/build.sh +++ b/build.sh @@ -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 diff --git a/src/circle_stdlib_app.h b/src/circle_stdlib_app.h index 8a69c828..bf4534af 100644 --- a/src/circle_stdlib_app.h +++ b/src/circle_stdlib_app.h @@ -223,6 +223,7 @@ class CStdlibAppStdio: public CStdlibAppScreen CEMMCDevice mEMMC; FATFS mFileSystem; CConsole mConsole; + CScheduler mScheduler; }; /** diff --git a/src/config.cpp b/src/config.cpp index ac6a2e49..ca958eff 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -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; } \ No newline at end of file diff --git a/src/config.h b/src/config.h index 30ee5ed9..794b9cec 100644 --- a/src/config.h +++ b/src/config.h @@ -23,6 +23,7 @@ #ifndef _config_h #define _config_h +#include #include #include #include @@ -171,6 +172,12 @@ class CConfig // Configuration for MiniDexed // 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 @@ class CConfig // Configuration for MiniDexed // 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 diff --git a/src/kernel.cpp b/src/kernel.cpp index 5c7a7a93..8874cf70 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -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; } diff --git a/src/kernel.h b/src/kernel.h index 000985ba..f5e080ea 100644 --- a/src/kernel.h +++ b/src/kernel.h @@ -25,6 +25,7 @@ #include #include #include +#include #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 @@ class CKernel : public CStdlibAppNetwork CCPUThrottle m_CPUThrottle; CGPIOManager m_GPIOManager; CI2CMaster m_I2CMaster; + //CScheduler m_Scheduler; CMiniDexed *m_pDexed; CUSBController *m_pUSB; diff --git a/src/mididevice.cpp b/src/mididevice.cpp index 917f674e..cc5a79ca 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -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) diff --git a/src/minidexed.cpp b/src/minidexed.cpp index 7e0c9302..1c0c89fa 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -27,15 +27,14 @@ #include #include #include -#include +//#include //#include //#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(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; -} -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/src/minidexed.h b/src/minidexed.h index 45c3797c..d566e828 100644 --- a/src/minidexed.h +++ b/src/minidexed.h @@ -39,8 +39,9 @@ #include #include #include -////#include -//#include +#include +#include +#include #include #include "common.h" #include "effect_mixer.hpp" @@ -218,7 +219,7 @@ class CMiniDexed bool DoSavePerformance (void); void setMasterVolume (float32_t vol); - //bool InitNetwork(); + bool InitNetwork(); void UpdateNetwork(); private: @@ -319,7 +320,6 @@ class CMiniDexed unsigned m_nDeletePerformanceID; bool m_bLoadPerformanceBusy; bool m_bSaveAsDeault; - bool m_bNetworkReady; //CNetSubSystem* m_pNet; //CWPASupplicant m_WPASupplicant; // Networking @@ -332,8 +332,15 @@ class CMiniDexed 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 diff --git a/src/net/applemidi.cpp b/src/net/applemidi.cpp index b484a077..3c96629f 100644 --- a/src/net/applemidi.cpp +++ b/src/net/applemidi.cpp @@ -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"); diff --git a/src/net/ftpworker.cpp b/src/net/ftpworker.cpp index e3fd1f3d..f61b07b4 100644 --- a/src/net/ftpworker.cpp +++ b/src/net/ftpworker.cpp @@ -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 { diff --git a/src/udpmididevice.cpp b/src/udpmididevice.cpp index 97355b7b..f24d5804 100644 --- a/src/udpmididevice.cpp +++ b/src/udpmididevice.cpp @@ -26,7 +26,7 @@ #include "udpmididevice.h" #include -//#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); } \ No newline at end of file