Skip to content

Commit

Permalink
use config.json
Browse files Browse the repository at this point in the history
  • Loading branch information
jmservera committed Jan 5, 2016
1 parent f1264aa commit 26b79bc
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!--
IIS configuration sections.
Expand Down Expand Up @@ -137,8 +137,8 @@
<add name="Clr2IntegratedAppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />
<add name="Clr2ClassicAppPool" managedRuntimeVersion="v2.0" managedPipelineMode="Classic" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />
<add name="UnmanagedClassicAppPool" managedRuntimeVersion="" managedPipelineMode="Classic" autoStart="true" />
<applicationPoolDefaults managedRuntimeLoader="v4.0">
<processModel />
<applicationPoolDefaults managedRuntimeLoader="v4.0" >
<processModel/>
</applicationPoolDefaults>
</applicationPools>

Expand All @@ -161,14 +161,6 @@
<binding protocol="http" bindingInformation=":8080:localhost" />
</bindings>
</site>
<site name="ConnectTheDotsWebSite" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\source\demos\iot\WebSite\ConnectTheDotsWebSite" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:51716:localhost" />
</bindings>
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
<traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
Expand Down
22 changes: 22 additions & 0 deletions SensorTag/SensorTag.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SensorTag", "SensorTag\SensorTag.csproj", "{11392ED8-EEC7-425D-BB33-D510B252672D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "..\Common\Common.csproj", "{5DD7BF85-B31E-40A1-969E-8756319B4D2E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{11392ED8-EEC7-425D-BB33-D510B252672D}.Debug|Any CPU.ActiveCfg = Debug|x86
{11392ED8-EEC7-425D-BB33-D510B252672D}.Debug|ARM.ActiveCfg = Debug|ARM
{11392ED8-EEC7-425D-BB33-D510B252672D}.Debug|ARM.Build.0 = Debug|ARM
{11392ED8-EEC7-425D-BB33-D510B252672D}.Debug|ARM.Deploy.0 = Debug|ARM
Expand All @@ -24,6 +29,7 @@ Global
{11392ED8-EEC7-425D-BB33-D510B252672D}.Debug|x86.ActiveCfg = Debug|x86
{11392ED8-EEC7-425D-BB33-D510B252672D}.Debug|x86.Build.0 = Debug|x86
{11392ED8-EEC7-425D-BB33-D510B252672D}.Debug|x86.Deploy.0 = Debug|x86
{11392ED8-EEC7-425D-BB33-D510B252672D}.Release|Any CPU.ActiveCfg = Release|x86
{11392ED8-EEC7-425D-BB33-D510B252672D}.Release|ARM.ActiveCfg = Release|ARM
{11392ED8-EEC7-425D-BB33-D510B252672D}.Release|ARM.Build.0 = Release|ARM
{11392ED8-EEC7-425D-BB33-D510B252672D}.Release|ARM.Deploy.0 = Release|ARM
Expand All @@ -33,6 +39,22 @@ Global
{11392ED8-EEC7-425D-BB33-D510B252672D}.Release|x86.ActiveCfg = Release|x86
{11392ED8-EEC7-425D-BB33-D510B252672D}.Release|x86.Build.0 = Release|x86
{11392ED8-EEC7-425D-BB33-D510B252672D}.Release|x86.Deploy.0 = Release|x86
{5DD7BF85-B31E-40A1-969E-8756319B4D2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5DD7BF85-B31E-40A1-969E-8756319B4D2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5DD7BF85-B31E-40A1-969E-8756319B4D2E}.Debug|ARM.ActiveCfg = Debug|ARM
{5DD7BF85-B31E-40A1-969E-8756319B4D2E}.Debug|ARM.Build.0 = Debug|ARM
{5DD7BF85-B31E-40A1-969E-8756319B4D2E}.Debug|x64.ActiveCfg = Debug|x64
{5DD7BF85-B31E-40A1-969E-8756319B4D2E}.Debug|x64.Build.0 = Debug|x64
{5DD7BF85-B31E-40A1-969E-8756319B4D2E}.Debug|x86.ActiveCfg = Debug|x86
{5DD7BF85-B31E-40A1-969E-8756319B4D2E}.Debug|x86.Build.0 = Debug|x86
{5DD7BF85-B31E-40A1-969E-8756319B4D2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5DD7BF85-B31E-40A1-969E-8756319B4D2E}.Release|Any CPU.Build.0 = Release|Any CPU
{5DD7BF85-B31E-40A1-969E-8756319B4D2E}.Release|ARM.ActiveCfg = Release|ARM
{5DD7BF85-B31E-40A1-969E-8756319B4D2E}.Release|ARM.Build.0 = Release|ARM
{5DD7BF85-B31E-40A1-969E-8756319B4D2E}.Release|x64.ActiveCfg = Release|x64
{5DD7BF85-B31E-40A1-969E-8756319B4D2E}.Release|x64.Build.0 = Release|x64
{5DD7BF85-B31E-40A1-969E-8756319B4D2E}.Release|x86.ActiveCfg = Release|x86
{5DD7BF85-B31E-40A1-969E-8756319B4D2E}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
30 changes: 19 additions & 11 deletions SensorTag/SensorTag/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Microsoft.Azure.Devices.Client;
using Common;
using Microsoft.Azure.Devices.Client;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -26,9 +28,6 @@ namespace SensorTag
/// </summary>
public sealed partial class MainPage : Page
{
const string iotHubUri = "jmservera.azure-devices.net";
const string deviceName = "SensorTag";
const string deviceKey = "wSn3ojC9nKFIVuXFcJwKgCC3ixLhMV9LhDthZBniln4=";
const string GUID = "ECD59A6D-1D0E-4CE2-A839-31167815A22D"; //todo create a unique guid per device
const string GUIDir = "ECD59A6D-1D0E-4CE2-A839-31167815A22E"; //todo create a unique guid per device
const string GUIDAMB = "ECD59A6D-1D0E-4CE2-A839-31167815A2F"; //todo create a unique guid per device
Expand All @@ -40,15 +39,14 @@ public sealed partial class MainPage : Page
const string HUMIDMEASURE = "Humidity";
const string TEMPUNITS = "C";
const string HUMIDUNITS = "%";
const string jsonFormat = "{{\"guid\":\"{0}\", \"organization\":\"{1}\", \"displayname\": \"{2}\", \"location\": \"{3}\", \"measurename\": \"{4}\", \"unitofmeasure\": \"{5}\", \"value\":{6}, \"timecreated\":\"{7}\" }}";

DeviceClient deviceClient;

public MainPage()
{
this.InitializeComponent();
var key = AuthenticationMethodFactory.CreateAuthenticationWithRegistrySymmetricKey(deviceName, deviceKey);
deviceClient = DeviceClient.Create(iotHubUri, key, TransportType.Http1);
var key = AuthenticationMethodFactory.CreateAuthenticationWithRegistrySymmetricKey(Config.Default.DeviceName, Config.Default.DeviceKey);
deviceClient = DeviceClient.Create(Config.Default.IotHubUri, key, TransportType.Http1);
init();
}

Expand Down Expand Up @@ -94,10 +92,20 @@ private async Task sendValue(DoubleEventArgs e, string guid, string org, string
{
try
{
var timeCreated = $"{DateTime.UtcNow:u}".Replace(' ', 'T');
log($"{display} {measure}:{e.Value} Time:{timeCreated}");
var dataBuffer = string.Format(jsonFormat,
guid, org, display, location, measure, units, e.Value, timeCreated);
log($"{display} {measure}:{e.Value} Time:{DateTime.Now}");

var info = new SensorInfo
{
Guid = guid,
Organization = org,
DisplayName = display,
Location = location,
MeasureName = measure,
UnitOfMeasure = units,
Value = e.Value,
TimeCreated = DateTime.UtcNow
};
string dataBuffer = JsonConvert.SerializeObject(info);
var eventMessage = new Message(Encoding.UTF8.GetBytes(dataBuffer));
await deviceClient.SendEventAsync(eventMessage);
}
Expand Down
9 changes: 9 additions & 0 deletions SensorTag/SensorTag/SensorTag.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
<Content Include="ApplicationInsights.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="config.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -130,6 +133,12 @@
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Common\Common.csproj">
<Project>{5dd7bf85-b31e-40a1-969e-8756319b4d2e}</Project>
<Name>Common</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
Expand Down
3 changes: 2 additions & 1 deletion SensorTag/SensorTag/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"Microsoft.ApplicationInsights.PersistenceChannel": "1.0.0",
"Microsoft.ApplicationInsights.WindowsApps": "1.0.0",
"Microsoft.Azure.Devices.Client": "1.0.0-preview-007",
"Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"
"Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0",
"Newtonsoft.Json": "8.0.1"
},
"frameworks": {
"uap10.0": {}
Expand Down

0 comments on commit 26b79bc

Please sign in to comment.