Log firmware and RSSI levels with powershell


function Get-TimeStamp {
    return "[{0:MM/dd/yy} {0:HH:mm:ss}]" -f (Get-Date)

$udpobject = new-Object system.Net.Sockets.Udpclient(50222)
$a = new-object system.text.asciiencoding

#IPEndPoint object will allow us to read datagrams sent from any source.
$remoteendpoint = New-Object system.net.ipendpoint([system.net.ipaddress]::Any,50222)

#Blocks until a message returns on this socket from a remote host.
$receivebytes = $udpobject.Receive([ref]$remoteendpoint)
If ($receivebytes) {
    [string]$returndata = $a.GetString($receivebytes)
    if ($returndata.Contains("hub_status")) {
    if ($returndata.Contains("device_status")) {
} Else {
    "No data received from {0} on port {1}" -f $Computername,$Port
} while (($Hub_Firmware -eq "") -or ($Tempest_Firmware -eq ""))

Write-Output "$(Get-TimeStamp) HUB $Hub_Firmware : Tempest $Tempest_Firmware : HUB-RSSI $hub_rssi : Tempest-RSSI $tempest_rssi" | Out-file "weatherflow.log" -append

#Convert returned data into string format
#[string]$returndata = $a.GetString($receivebytes)
#Uses the IPEndPoint object to show that the host responded.
#Write-Host "This is the message you received: $($returndata.ToString())"

1 Like

Other than the Microsoft usage, pretty cool.

(just kidding - very cool !!!)

My first go at UDP
Figured it might be useful to someone else running Windows :relaxed:

updated to log RSSI levels as well