Skip to content

Commit 9992b5d

Browse files
authored
Merge pull request #419 from daleckystepan/ghost-msp
Ghost MSP support
2 parents b42e495 + 9523c75 commit 9992b5d

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

src/SCRIPTS/BF/MSP/ghst.lua

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-- GHST Frame Types
2+
local GHST_FRAMETYPE_MSP_REQ = 0x21
3+
local GHST_FRAMETYPE_MSP_WRITE = 0x22
4+
local GHST_FRAMETYPE_MSP_RESP = 0x28
5+
6+
local ghstMspType = 0
7+
8+
protocol.mspSend = function(payload)
9+
return protocol.push(ghstMspType, payload)
10+
end
11+
12+
protocol.mspRead = function(cmd)
13+
ghstMspType = GHST_FRAMETYPE_MSP_REQ
14+
return mspSendRequest(cmd, {})
15+
end
16+
17+
protocol.mspWrite = function(cmd, payload)
18+
ghstMspType = GHST_FRAMETYPE_MSP_WRITE
19+
return mspSendRequest(cmd, payload)
20+
end
21+
22+
protocol.mspPoll = function()
23+
local type, data = ghostTelemetryPop()
24+
if type == GHST_FRAMETYPE_MSP_RESP then
25+
return mspReceivedReply(data)
26+
end
27+
return nil
28+
end

src/SCRIPTS/BF/protocols.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ local supportedProtocols =
2020
saveMaxRetries = 2,
2121
saveTimeout = 150,
2222
cms = {},
23+
},
24+
ghst =
25+
{
26+
mspTransport = "MSP/ghst.lua",
27+
push = ghostTelemetryPush,
28+
maxTxBufferSize = 10, -- Tx -> Rx (Push)
29+
maxRxBufferSize = 6, -- Rx -> Tx (Pop)
30+
saveMaxRetries = 2,
31+
saveTimeout = 250,
32+
cms = {},
2333
}
2434
}
2535

@@ -28,6 +38,8 @@ local function getProtocol()
2838
return supportedProtocols.smartPort
2939
elseif supportedProtocols.crsf.push() ~= nil then
3040
return supportedProtocols.crsf
41+
elseif supportedProtocols.ghst.push() ~= nil then
42+
return supportedProtocols.ghst
3143
end
3244
end
3345

0 commit comments

Comments
 (0)