Minor changes I forgot to commit previously
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
namespace NightScout.Alerters
|
||||||
|
{
|
||||||
|
public class EmptyClass
|
||||||
|
{
|
||||||
|
public EmptyClass()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -46,6 +46,11 @@ namespace NightScout
|
|||||||
this.ButtonSource.ButtonStateChange += ButtonSource_ButtonStateChange;
|
this.ButtonSource.ButtonStateChange += ButtonSource_ButtonStateChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetALSAAudioDevice(Int32 index)
|
||||||
|
{
|
||||||
|
this.PlayerCommandLine = String.Format("\"mpg123 -o alsa:hw:{0},0 ", index) + "-q {0}\"";
|
||||||
|
}
|
||||||
|
|
||||||
private void ButtonSource_ButtonStateChange(bool obj)
|
private void ButtonSource_ButtonStateChange(bool obj)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Button state change: {0}", obj);
|
Console.WriteLine("Button state change: {0}", obj);
|
||||||
|
|||||||
@@ -21,7 +21,11 @@ namespace NightScout
|
|||||||
|
|
||||||
private void SetupEvents()
|
private void SetupEvents()
|
||||||
{
|
{
|
||||||
DataSource.Connected += () => DataSource.Authorize();
|
DataSource.Connected += () =>
|
||||||
|
{
|
||||||
|
DataSource.Authorize();
|
||||||
|
|
||||||
|
}
|
||||||
DataSource.Alarm += (alarm) => Alerter.StartAlert();
|
DataSource.Alarm += (alarm) => Alerter.StartAlert();
|
||||||
DataSource.UrgentAlarm += (alarm) => Alerter.StartUrgentAlert();
|
DataSource.UrgentAlarm += (alarm) => Alerter.StartUrgentAlert();
|
||||||
DataSource.ClearAlarm += (alarm) => Alerter.StopAlerts();
|
DataSource.ClearAlarm += (alarm) => Alerter.StopAlerts();
|
||||||
|
|||||||
+19
-8
@@ -16,7 +16,7 @@ namespace NightScoutAlert
|
|||||||
if (args.Any(arg => arg.Equals("--test-audio")))
|
if (args.Any(arg => arg.Equals("--test-audio")))
|
||||||
{
|
{
|
||||||
Console.WriteLine("Starting audio test...");
|
Console.WriteLine("Starting audio test...");
|
||||||
RaspberryPiAudioAlert alerter = new RaspberryPiAudioAlert();
|
RaspberryPiAudioAlert alerter = SetupAudioAlert();
|
||||||
alerter.StartAlert();
|
alerter.StartAlert();
|
||||||
Thread.Sleep(3000);
|
Thread.Sleep(3000);
|
||||||
alerter.StopAlerts();
|
alerter.StopAlerts();
|
||||||
@@ -48,20 +48,15 @@ namespace NightScoutAlert
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
NightscoutDataSource dataSource =null;
|
NightscoutDataSource dataSource =null;
|
||||||
RaspberryPiAudioAlert audioAlerter = null;
|
RaspberryPiAudioAlert audioAlerter = SetupAudioAlert(buttonSource);
|
||||||
|
|
||||||
if (buttonSource != null)
|
if (buttonSource != null)
|
||||||
{
|
|
||||||
dataSource = new NightscoutDataSource(configuration,
|
dataSource = new NightscoutDataSource(configuration,
|
||||||
log4net.LogManager.GetLogger("NightscoutAlert"), buttonSource);
|
log4net.LogManager.GetLogger("NightscoutAlert"), buttonSource);
|
||||||
audioAlerter = new RaspberryPiAudioAlert(buttonSource);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
dataSource = new NightscoutDataSource(configuration,
|
dataSource = new NightscoutDataSource(configuration,
|
||||||
log4net.LogManager.GetLogger("NightscoutAlert"));
|
log4net.LogManager.GetLogger("NightscoutAlert"));
|
||||||
audioAlerter = new RaspberryPiAudioAlert();
|
|
||||||
}
|
|
||||||
ILog log = log4net.LogManager.GetLogger("NightscoutAlertMain");
|
ILog log = log4net.LogManager.GetLogger("NightscoutAlertMain");
|
||||||
log.Debug("Log started");
|
log.Debug("Log started");
|
||||||
ConsoleAlerter consoleAlerter = new ConsoleAlerter();
|
ConsoleAlerter consoleAlerter = new ConsoleAlerter();
|
||||||
@@ -123,5 +118,21 @@ namespace NightScoutAlert
|
|||||||
Console.WriteLine("Started");
|
Console.WriteLine("Started");
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
}
|
}
|
||||||
|
private static RaspberryPiAudioAlert SetupAudioAlert(RaspberryPIButtonSource buttonSource = null)
|
||||||
|
{
|
||||||
|
RaspberryPiAudioAlert alerter;
|
||||||
|
if (buttonSource != null)
|
||||||
|
alerter = new RaspberryPiAudioAlert(buttonSource);
|
||||||
|
else
|
||||||
|
alerter = new RaspberryPiAudioAlert();
|
||||||
|
|
||||||
|
String ALSADeviceNumber = ConfigurationManager.AppSettings["ALSADeviceNumber"];
|
||||||
|
Int32 devNumber = 0;
|
||||||
|
if(!String.IsNullOrEmpty(ALSADeviceNumber) && Int32.TryParse(ALSADeviceNumber, out devNumber))
|
||||||
|
{ //Set device
|
||||||
|
alerter.SetALSAAudioDevice(devNumber);
|
||||||
|
}
|
||||||
|
return alerter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,11 @@ namespace NightScout
|
|||||||
|
|
||||||
public virtual void Authorize()
|
public virtual void Authorize()
|
||||||
{
|
{
|
||||||
JObject authRequest = new JObject {{"client", "web"}};
|
JObject authRequest;
|
||||||
|
if (!String.IsNullOrEmpty(NightscoutAlertConfiguration.APISecretKey))
|
||||||
|
authRequest = new JObject { { "client", "web" }, { "secret", NightscoutAlertConfiguration.APISecretKey } };
|
||||||
|
else
|
||||||
|
authRequest = new JObject { { "client", "web" } };
|
||||||
|
|
||||||
Socket.Emit("authorize", authRequest);
|
Socket.Emit("authorize", authRequest);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user