Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions DemoWeb/DemoWeb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<Compile Include="DataModelBinderController.cs" />
<Compile Include="DefaultController.cs" />
<Compile Include="ExceptionController.cs" />
<Compile Include="FilesController.cs" />
<Compile Include="Forbidden.cs" />
<Compile Include="FormPostController.cs" />
<Compile Include="FormCollectionController.cs" />
Expand All @@ -49,6 +50,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Program.cs" />
<Compile Include="RequestFilter.cs" />
<Compile Include="SDCardManager.cs" />
<Compile Include="WebServer.cs" />
</ItemGroup>
<ItemGroup>
Expand All @@ -60,8 +62,14 @@
<Reference Include="SecretLabs.NETMF.Hardware" />
<Reference Include="SecretLabs.NETMF.Hardware.Netduino" />
<Reference Include="System" />
<Reference Include="System.IO" />
<Reference Include="System.Text.RegularExpressions" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NetduinoSDCard\NetduinoSDCard.csproj">
<Project>{66F7DA1E-2931-4E24-81F7-471B08488B96}</Project>
<Name>NetduinoSDCard</Name>
</ProjectReference>
<ProjectReference Include="..\Rinsen.WebServer\Rinsen.WebServer.csproj">
<Project>{6BFC7545-24EF-4C5B-9EDE-3EC99CDB86E4}</Project>
<Name>Rinsen.WebServer</Name>
Expand Down
42 changes: 42 additions & 0 deletions DemoWeb/FilesController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using Microsoft.SPOT;

using Rinsen.WebServer.FileAndDirectoryServer;
using Rinsen.WebServer;

namespace DemoWeb
{
public class FilesController : FileController
{
public void Index()
{
this.SDCardManager = new SDCardManager(Program.WORKINGDIRECTORY);
string strHTML = string.Empty;


try
{
strHTML = SDCardManager.ReadTextFile(SDCardManager.GetWorkingDirectoryPath() + "filemanager.html");
strHTML = strHTML.Substring(1, strHTML.Length - 2); //If I don't remove the first character then the page doesn't get rendered as html...
}
catch (Exception objEx)
{
Debug.Print("Exception caught in FilesController:\r\n" + objEx.Message);
}

SetHtmlResult(strHTML);
}

public void Upload()
{
this.SDCardManager = new SDCardManager(Program.WORKINGDIRECTORY);

if (HttpContext.Request.Method == HTTPMethod.Post)
{
var doFileUpload = RecieveFiles();

SetJsonResult(new Result { Success = true, Message = "Files Recieved!" });
}
}
}
}
10 changes: 8 additions & 2 deletions DemoWeb/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@ namespace DemoWeb
{
public class Program
{
public const string WORKINGDIRECTORY = @"\WWW";

public static void Main()
{
// write your code here
var webServer = new WebServer();
webServer.AddRequestFilter(new RequestFilter());
var fileAndDirectoryService = new FileAndDirectoryService();
fileAndDirectoryService.SetSDCardManager(new SDCardManager(WORKINGDIRECTORY));
webServer.SetFileAndDirectoryService(new FileAndDirectoryService());
webServer.RouteTable.DefaultControllerName = "Default";
webServer.StartServer();
/*By not setting a default Controller, the root web directory (set with WORKINGDIRECTORY) will have it's contents listed
* with the FileAndDirectoryServer library */
//webServer.RouteTable.DefaultControllerName = "Default";
webServer.StartServer(80);
}
}
}
13 changes: 13 additions & 0 deletions DemoWeb/SDCardManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using Microsoft.SPOT;

using Rinsen.WebServer.FileAndDirectoryServer;

namespace DemoWeb
{
public class SDCardManager : NetduinoSDCard.SDCard, ISDCardManager
{
public SDCardManager(string WorkingDirectory)
: base(WorkingDirectory) {}
}
}
36 changes: 36 additions & 0 deletions NetduinoSDCard/ConsoleWrite.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using Microsoft.SPOT;

namespace NetduinoSDCard
{
public class ConsoleWrite // todo this should be moved to a general library.
{
public static Object _PrintLock = new Object();
public static Object _GCLock = new Object();

public static void Print(string message)
{
lock (_PrintLock)
{
Debug.Print(message);
}
}

public static uint MemoryCollect(bool force)
{
uint freeMemory = 0;
lock (_GCLock)
{
freeMemory = Microsoft.SPOT.Debug.GC(force);
}
return freeMemory;
}

public static void CollectMemoryAndPrint(bool force, int id)
{
uint freeMemory = MemoryCollect(force);
Print("Memory: " + freeMemory.ToString() + ", release workerid: " + id.ToString());

}
}
}
47 changes: 47 additions & 0 deletions NetduinoSDCard/NetduinoSDCard.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<AssemblyName>NetduinoSDCard</AssemblyName>
<OutputType>Exe</OutputType>
<RootNamespace>NetduinoSDCard</RootNamespace>
<ProjectTypeGuids>{b69e3092-b931-443c-abe7-7e7b65f2a37f};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{66F7DA1E-2931-4E24-81F7-471B08488B96}</ProjectGuid>
<TargetFrameworkVersion>v4.3</TargetFrameworkVersion>
<NetMfTargetsBaseDir Condition="'$(NetMfTargetsBaseDir)'==''">$(MSBuildExtensionsPath32)\Microsoft\.NET Micro Framework\</NetMfTargetsBaseDir>
<DeployDevice>Netduino</DeployDevice>
<DeployTransport>USB</DeployTransport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<Import Project="$(NetMfTargetsBaseDir)$(TargetFrameworkVersion)\CSharp.Targets" />
<ItemGroup>
<Compile Include="ConsoleWrite.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Program.cs" />
<Compile Include="SDCard.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.SPOT.Native" />
<Reference Include="Microsoft.SPOT.Net" />
<Reference Include="SecretLabs.NETMF.Hardware.Netduino" />
<Reference Include="System" />
<Reference Include="System.IO" />
</ItemGroup>
</Project>
22 changes: 22 additions & 0 deletions NetduinoSDCard/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace NetduinoSDCard
{
public class Program
{
public static void Main()
{
// write your code here


}

}
}
25 changes: 25 additions & 0 deletions NetduinoSDCard/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("NetduinoSDCard")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NetduinoSDCard")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading