Skip to content

Commit

Permalink
Revert "Now -> UtcNow"
Browse files Browse the repository at this point in the history
This reverts commit f4cc720.
  • Loading branch information
adrianstevens committed Oct 27, 2023
1 parent 2810927 commit 411301c
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 72 deletions.
2 changes: 1 addition & 1 deletion source/Meadow.Core/Hardware/BiDirectionalInterruptPort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ private void OnInterrupt(IPin pin, bool state)
if (pin == this.Pin)
{
var capturedLastTime = LastEventTime; // note: doing this for latency reasons. kind of. sort of. bad time good time. all time.
this.LastEventTime = DateTime.UtcNow;
this.LastEventTime = DateTime.Now;
// BC 2021.05.21 b5.0: Changed this to the new result type.
// assuming that old state is just an inversion of the new state, yeah?
RaiseChangedAndNotify(new DigitalPortResult(new DigitalState(state, this.LastEventTime), new DigitalState(!state, capturedLastTime)));
Expand Down
2 changes: 1 addition & 1 deletion source/Meadow.Core/Hardware/DigitalInterruptPort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private void OnInterrupt(IPin pin, bool state)
{
// this is all to prevent new-ing up (and thereby preventing GC stuff)
_oldState.Time = LastEventTime; // note: doing this for latency reasons. kind of. sort of. bad time good time. all time.
_newState.Time = this.LastEventTime = DateTime.UtcNow;
_newState.Time = this.LastEventTime = DateTime.Now;
_oldState.State = !state;
_newState.State = state;
_interruptResult.Old = (LastEventTime == DateTime.MinValue) ? null : _oldState;
Expand Down
8 changes: 4 additions & 4 deletions source/Meadow.Core/Update/UpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class UpdateService : IUpdateService, ICommandService
/// Specifies the maximum number of download attempts before giving up.
/// </summary>
public const int MaxDownloadRetries = 10;

/// <summary>
/// Period the service will wait between download attempts in
/// case of failure.
Expand Down Expand Up @@ -209,14 +209,14 @@ private async Task<bool> AuthenticateWithServer()

return _jwt != null;
}

/// <summary>
/// Method to determine if the authentication is required based on whether the time since
/// the last authentication exceeds the token expiration period (in minutes).
/// </summary>
private bool ShouldAuthenticate()
{
return (DateTime.UtcNow - _lastAuthenticationTime).TotalMinutes >= TokenExpirationPeriod;
return (DateTime.Now - _lastAuthenticationTime).TotalMinutes >= TokenExpirationPeriod;
}

private async void UpdateStateMachine()
Expand Down Expand Up @@ -252,7 +252,7 @@ private async void UpdateStateMachine()
if (await AuthenticateWithServer())
{
// Update the last authentication time when successfully authenticated
_lastAuthenticationTime = DateTime.UtcNow;
_lastAuthenticationTime = DateTime.Now;
State = UpdateState.Connecting;
}
else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
using Meadow.Devices.Esp32.MessagePayloads;
using System;
using System;
using Meadow.Gateway.WiFi;
using Meadow.Devices.Esp32.MessagePayloads;
using Meadow.Gateways;
using Meadow.Gateways.Exceptions;
using System.Net;

namespace Meadow.Gateway.WiFi;

/// <summary>
/// Data relating to a WiFi connection.
/// </summary>
public class WiFiDisconnectEventArgs : EventArgs
namespace Meadow.Gateway.WiFi
{
/// <summary>
/// Status code of the connection request.
/// Data relating to a WiFi connection.
/// </summary>
public StatusCodes StatusCode { get; private set; }
public class WiFiDisconnectEventArgs : EventArgs
{
/// <summary>
/// Status code of the connection request.
/// </summary>
public StatusCodes StatusCode { get; private set; }

/// <summary>
/// Date and time the event was generated.
/// </summary>
public DateTime When { get; private set; }
/// <summary>
/// Date and time the event was generated.
/// </summary>
public DateTime When { get; private set; }

/// <summary>
/// Construct a WiFiConnectEventArgs request.
/// </summary>
/// <param name="statusCode">Status code of the network connection.</param>
public WiFiDisconnectEventArgs(StatusCodes statusCode)
{
StatusCode = statusCode;
When = DateTime.UtcNow;
/// <summary>
/// Construct a WiFiConnectEventArgs request.
/// </summary>
/// <param name="statusCode">Status code of the network connection.</param>
public WiFiDisconnectEventArgs(StatusCodes statusCode)
{
StatusCode = statusCode;
When = DateTime.Now;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
using Meadow.Devices.Esp32.MessagePayloads;
using System;
using System;
using Meadow.Gateway.WiFi;
using Meadow.Devices.Esp32.MessagePayloads;
using Meadow.Gateways;
using Meadow.Gateways.Exceptions;

namespace Meadow.Gateway.WiFi;

/// <summary>
/// Data related to a start WiFi interface request.
/// </summary>
public class WiFiInterfaceStartedEventArgs : EventArgs
namespace Meadow.Gateway.WiFi
{
/// <summary>
/// Status code of the start WiFi interface request.
/// Data related to a start WiFi interface request.
/// </summary>
public StatusCodes StatusCode { get; private set; }
public class WiFiInterfaceStartedEventArgs : EventArgs
{
/// <summary>
/// Status code of the start WiFi interface request.
/// </summary>
public StatusCodes StatusCode { get; private set; }

/// <summary>
/// Date and time the event was generated.
/// </summary>
public DateTime When { get; private set; }
/// <summary>
/// Date and time the event was generated.
/// </summary>
public DateTime When { get; private set; }

/// <summary>
/// Construct a WiFiInterfaceStartedEventArgs object.
/// </summary>
/// <param name="statusCode">Status of the WiFi start interface start request.</param>
public WiFiInterfaceStartedEventArgs(StatusCodes statusCode)
{
StatusCode = statusCode;
When = DateTime.UtcNow;
/// <summary>
/// Construct a WiFiInterfaceStartedEventArgs object.
/// </summary>
/// <param name="statusCode">Status of the WiFi start interface start request.</param>
public WiFiInterfaceStartedEventArgs(StatusCodes statusCode)
{
StatusCode = statusCode;
When = DateTime.Now;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
using Meadow.Devices.Esp32.MessagePayloads;
using System;
using System;
using Meadow.Devices.Esp32.MessagePayloads;

namespace Meadow.Gateway.WiFi;

/// <summary>
/// Data relating to a stop WiFi interface request.
/// </summary>
public class WiFiInterfaceStoppedEventArgs : EventArgs
namespace Meadow.Gateway.WiFi
{
/// <summary>
/// Status code of the stop WiFi interface request.
/// Data relating to a stop WiFi interface request.
/// </summary>
public StatusCodes StatusCode { get; private set; }
public class WiFiInterfaceStoppedEventArgs : EventArgs
{
/// <summary>
/// Status code of the stop WiFi interface request.
/// </summary>
public StatusCodes StatusCode { get; private set; }

/// <summary>
/// Date and time the event was generated.
/// </summary>
public DateTime When { get; private set; }
/// <summary>
/// Date and time the event was generated.
/// </summary>
public DateTime When { get; private set; }

/// <summary>
/// Construct a WiFiInterfaceStoppedEventArgs object.
/// </summary>
/// <param name="statusCode">Status code of the </param>
public WiFiInterfaceStoppedEventArgs(StatusCodes statusCode)
{
StatusCode = statusCode;
When = DateTime.UtcNow;
/// <summary>
/// Construct a WiFiInterfaceStoppedEventArgs object.
/// </summary>
/// <param name="statusCode">Status code of the </param>
public WiFiInterfaceStoppedEventArgs(StatusCodes statusCode)
{
StatusCode = statusCode;
When = DateTime.Now;
}
}
}

0 comments on commit 411301c

Please sign in to comment.