Skip to content

Commit

Permalink
Ghost MSP support
Browse files Browse the repository at this point in the history
  • Loading branch information
daleckystepan committed Jan 7, 2022
1 parent 4a181bf commit f43955f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/SCRIPTS/BF/MSP/ghost.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-- GHOST Frame Types
local GHST_FRAMETYPE_MSP_REQ = 0x21
local GHST_FRAMETYPE_MSP_WRITE = 0x22
local GHST_FRAMETYPE_MSP_RESP = 0x28

ghstMspType = 0

protocol.mspSend = function(payload)
return protocol.push(ghstMspType, payload)
end

protocol.mspRead = function(cmd)
ghstMspType = GHST_FRAMETYPE_MSP_REQ
return mspSendRequest(cmd, {})
end

protocol.mspWrite = function(cmd, payload)
ghstMspType = GHST_FRAMETYPE_MSP_WRITE
return mspSendRequest(cmd, payload)
end

protocol.mspPoll = function()
local type, data = ghostTelemetryPop()
if type == GHST_FRAMETYPE_MSP_RESP then
return mspReceivedReply(data)
end
return nil
end
12 changes: 12 additions & 0 deletions src/SCRIPTS/BF/protocols.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ local supportedProtocols =
saveMaxRetries = 2,
saveTimeout = 150,
cms = {},
},
ghost =
{
mspTransport = "MSP/ghost.lua",
push = ghostTelemetryPush,
maxTxBufferSize = 10, -- Tx -> Rx (Push)
maxRxBufferSize = 6, -- Rx -> Tx (Pop)
saveMaxRetries = 2,
saveTimeout = 250,
cms = {},
}
}

Expand All @@ -28,6 +38,8 @@ local function getProtocol()
return supportedProtocols.smartPort
elseif supportedProtocols.crsf.push() ~= nil then
return supportedProtocols.crsf
elseif supportedProtocols.ghost.push() ~= nil then
return supportedProtocols.ghost
end
end

Expand Down

0 comments on commit f43955f

Please sign in to comment.