User Tools

Site Tools


airwave

This is an old revision of the document!


Connecting AirWave remote arbitrary data telemetry module

The AirWave is a modification of the AirPoint wireless telemetry module which allows for sending arbitrary process data over the LoRa radio channels which are employed in AirPoint/AirGate modules.

When you have a remote standalone (or auxilary) system with WebHMI, that is not able to send data to another system or to a higher-level system like Level2 (due to the absence of the local network/mobile connection ), you can use this solution to nonetheless send necessary data.

The application structure is as follows:

To achieve this, you need the following steps:

  1. Connect AirWave to WebHMI with a micro USB - cable which will create a new serial port in the system
  2. Setup AirGate to match your MQTT client (WebHMI, Level2, and others) setting to be able to accept data
  3. Write a small Lua script, formatting your application data into JSON topic, compatible with AirGate data format and sending it to the USB port.
  4. Write a small custom protocol driver that will send the necessary data to this port

We will consider this more in detail in the following parts:

Connecting AirWave to WebHMI

That is the simplest part. Upon connection, there will be an extra serial port available in the connection option that you have to use in your custom protocol connection.

Check that the extra port is present in some serial connection (or create a new one) in the 'Device' field. Use the following screen for reference when creating a connection for the AirWave module.

AirGate setup

Please refer to the AirGate manual for reference.

Lua script preparing your data

The AirGate expects certain data format when accepting packets from AirPoint modules, which you should follow when writing a communication functoin. E.g. the hardware address of the AirPoint has a kind of self-check based on hash/checksum. To get the “valid” address for the AirWave you can use “Add custom IoT device” procedure on the Level and get the address:

Store the hw address of the custom device you got and use it in the script:

TARGET_DEV_ID = "CS631FCEC8C8"
regsToSend = {"payload", "error", "ts"}
 
function main (userId)
  local tabToSend = {}
  for _, regId in pairs(regsToSend)  do 
      tabToSend[reg] = R(regId)
  end 
 
  local jsonString = cjson.encode(tabToSend)  ; TRACE("json str = " .. jsonString)
  local jsonL2 = "$C," .. TARGET_DEV_ID .. "," .. jsonString  ; TRACE("jsonL2 = " .. jsonL2)
 
  W(5, jsonL2)
end

Custom Protocol for AirWave

The AirGate expects certain data format when accepting packets from AirPoint modules, which you should follow when writing a driver. E.g. the hardware address of the AirPoint has a kind of self-check based on hash/checksum. To get the “valid” address for the AirWave you can use “Add custom IoT device” procedure and get the address:

function createDevices ()
    addDevice({name = "W",  shift = 0, base = 10, xtraFields = {}})
end
 
function splitString(str)
    local s, retTab = tostring(str), {}
    for i = 1, #s do 
        table.insert(retTab, s.sub(i, i))
    end 
    return retTab
end 
 
function writeRegister (reg, device, unitId, newValue)
  local wrRequest = splitString(newValue)
  wrRequest[#wrRequest - 1] = ';'         ; DEBUG("Going to send this packet " .. table.concat(wrRequest) )
 
  TRACE("estimated resp len = " .. #wrRequest - 2)
  local resp = sendBytes(wrRequest)
  if (not resp) then 
      ERROR("Can't send request")
      return false 
  end 
 
  sleep(100)
 
  resp = readBytes(4)  
  if (not resp) then 
      ERROR("Can't receive reply") ; return false 
  end 
  if (#resp ~= 4) then 
      ERROR("Response length is wrong") ; return false 
  end 
 
  local respondedLength = resp[1]                   ; DEBUG("respondedLength: " .. respondedLength)
  if (respondedLength ~= #wrRequest - 1) then 
      ERROR("Wrong responded length: " .. respondedLength .. ", expected " .. #wrRequest - 1)
      return false 
  end 
  TRACE("Write done successfully!")  
  return true 
 
end
 
function readRegister (reg, device, unitId)
  return 1 
end
airwave.1651496037.txt.gz · Last modified: 2022/05/02 12:53 by emozolyak

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki