Skip to content

Commit

Permalink
Support for Windows and placed in a VS project to help with testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
judahr committed Aug 29, 2022
1 parent badb7f0 commit aa38713
Show file tree
Hide file tree
Showing 16 changed files with 120 additions and 5 deletions.
Binary file added .vs/NodejsApp1/v17/.suo
Binary file not shown.
6 changes: 6 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added .vs/homebridge-rtl/v17/.suo
Binary file not shown.
Binary file modified .vs/slnx.sqlite
Binary file not shown.
72 changes: 72 additions & 0 deletions NodejsApp1.njsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{3f688df9-1d58-4219-b712-10554b93e08c}</ProjectGuid>
<ProjectHome>.</ProjectHome>
<ProjectView>ShowAllFiles</ProjectView>
<StartupFile>
</StartupFile>
<WorkingDirectory>.</WorkingDirectory>
<OutputPath>.</OutputPath>
<ProjectTypeGuids>{3AF33F2E-1136-4D97-BBB7-1795711AC8B8};{349c5851-65df-11da-9384-00065b846f21};{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">17.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'" />
<PropertyGroup Condition="'$(Configuration)' == 'Release'" />
<ItemGroup>
<Content Include="package-lock.json" />
<Content Include="package.json" />
<Content Include="sample-config.json" />
<Content Include="MIGHTY-MULE-DRIVEWAY-ALARM-INSTRUCTIONS.md" />
<Content Include="README.md" />
<Content Include="sensor.js" />
<Content Include="lib\CustomCharacteristic.js" />
</ItemGroup>
<ItemGroup>
<Folder Include="lib" />
<Folder Include="NodejsApp1" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(VSToolsPath)\Node.js Tools\Microsoft.NodejsToolsV2.targets" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>False</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>0</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:48022/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>True</UseCustomServer>
<CustomServerUrl>http://localhost:1337</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}" User="">
<WebProjectProperties>
<StartPageUrl>
</StartPageUrl>
<StartAction>CurrentPage</StartAction>
<AspNetDebugging>True</AspNetDebugging>
<SilverlightDebugging>False</SilverlightDebugging>
<NativeDebugging>False</NativeDebugging>
<SQLDebugging>False</SQLDebugging>
<ExternalProgram>
</ExternalProgram>
<StartExternalURL>
</StartExternalURL>
<StartCmdLineArguments>
</StartCmdLineArguments>
<StartWorkingDirectory>
</StartWorkingDirectory>
<EnableENC>False</EnableENC>
<AlwaysStartWebServerOnDebug>False</AlwaysStartWebServerOnDebug>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>
6 changes: 6 additions & 0 deletions NodejsApp1.njsproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
</PropertyGroup>
</Project>
25 changes: 25 additions & 0 deletions NodejsApp1.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32819.101
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}") = "NodejsApp1", "NodejsApp1.njsproj", "{3F688DF9-1D58-4219-B712-10554B93E08C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3F688DF9-1D58-4219-B712-10554B93E08C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F688DF9-1D58-4219-B712-10554B93E08C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F688DF9-1D58-4219-B712-10554B93E08C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F688DF9-1D58-4219-B712-10554B93E08C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B3B0160A-F968-46A4-B416-349DC714FACE}
EndGlobalSection
EndGlobal
Binary file added bin/Microsoft.NodejsTools.WebRole.dll
Binary file not shown.
Binary file added obj/Debug/NodejsApp1.njsproj.AssemblyReference.cache
Binary file not shown.
1 change: 1 addition & 0 deletions obj/Debug/NodejsApp1.njsproj.CoreCompileInputs.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a006da68cee2e5948f791e89043c9fd33dcfa03a
3 changes: 3 additions & 0 deletions obj/Debug/NodejsApp1.njsproj.FileListAbsolute.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
C:\Users\judah\source\repos\homebridge-rtl\obj\Debug\NodejsApp1.njsproj.AssemblyReference.cache
C:\Users\judah\source\repos\homebridge-rtl\obj\Debug\NodejsApp1.njsproj.CoreCompileInputs.cache
C:\Users\judah\source\repos\homebridge-rtl\bin\Microsoft.NodejsTools.WebRole.dll
12 changes: 7 additions & 5 deletions sensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ module.exports = (homebridge) => {
CustomCharacteristic = require('./lib/CustomCharacteristic.js')(homebridge);
FakeGatoHistoryService = require('fakegato-history')(homebridge);

homebridge.registerPlatform('homebridge-rtl', 'rtl_433', rtl433Plugin);
homebridge.registerPlatform('homebridge-rtl-jdr', 'rtl_433', rtl433Plugin);
};

function rtl433Plugin(log, config, api) {
this.log = log;
this.refresh = config['refresh'] || 60; // Update every minute
this.options = config.options || {};
this.storage = config['storage'] || "fs";
this.storagePath = config['storagePath'] || "/tmp/rtl433.json";
//8/28/2022 JDR added this for Windows.
this.rtl433Path = config['rtl433Path'] || "/usr/local/bin/";
this.rtl433Bin = config['rtl433Bin'] || "rtl_433";
this.killCommand = config['killCommand'] || ("pkill " + this.rtl433Bin + ';');// for linux/mac windows: taskkill /im "rtl_433_64bit_static.exe"
Expand Down Expand Up @@ -57,16 +57,18 @@ function rtl433Server() {
var childProcess = require('child_process');
var readline = require('readline');
var previousMessage;
this.log("Spawning rtl_433");
this.log("Spawning rtl_433 " + this.killCommand + '; ' + this.rtl433Path + this.rtl433Bin);
// if you start rtl_433 outside homebride to get log: rtl_433 -v -F json -C si -M protocol > /tmp/rtl433.json
//var proc = childProcess.spawn('/usr/bin/truncate -s 0 /tmp/rtl433.json;/usr/bin/tail', ['-F','/tmp/rtl433.json'], {
var proc = childProcess.spawn(this.killCommand + ' ' + this.rtl433Path + this.rtl433Bin, [' - q', ' - F', 'json', ' - C', 'si'], {
////8/28/2022 JDR added this for Windows. fixed command line arguments. They weren't working for Windows, but should still work for others.
var proc = childProcess.spawn(this.killCommand + '; ' + this.rtl433Path + this.rtl433Bin, ['-d 0', '-F json', '-C si'], {
shell: true
});
readline.createInterface({
input: proc.stdout,
terminal: false
}).on('line', function(message) {
}).on('line', function (message) {
this.log("Message", message.toString());
debug("Message", message.toString());

if (message.toString().startsWith('{')) {
Expand Down

0 comments on commit aa38713

Please sign in to comment.