mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-07-29 16:29:17 +02:00
temp for oda and allow ascii from uecp
This commit is contained in:
+2
-1
@@ -314,8 +314,9 @@ function rds.ext.set_af_oda(afs) end
|
|||||||
---@param group_version boolean
|
---@param group_version boolean
|
||||||
---@param aid integer
|
---@param aid integer
|
||||||
---@param data integer
|
---@param data integer
|
||||||
|
---@param temp boolean
|
||||||
---@return integer oda_id
|
---@return integer oda_id
|
||||||
function ext.register_oda(group, group_version, aid, data) end
|
function ext.register_oda(group, group_version, aid, data, temp) end
|
||||||
|
|
||||||
---Unregisters an ODA, this stops the handler or AID being called/sent
|
---Unregisters an ODA, this stops the handler or AID being called/sent
|
||||||
---@param oda_id integer
|
---@param oda_id integer
|
||||||
|
|||||||
+10
-6
@@ -1,7 +1,7 @@
|
|||||||
local _ODA = { group = 0, group_version = false, aid = 0, data = 0, handler = false }
|
local _ODA = { group = 0, group_version = false, aid = 0, data = 0, handler = false, temp = false }
|
||||||
|
|
||||||
function _ODA.new(group, group_version, aid, data, handler)
|
function _ODA.new(group, group_version, aid, data, handler, temp)
|
||||||
local instance = { group = group or 0, group_version = group_version or false, aid = aid or 0, data = data or 0, handler = handler or false }
|
local instance = { group = group or 0, group_version = group_version or false, aid = aid or 0, data = data or 0, handler = handler or false, temp = temp or false }
|
||||||
setmetatable(instance, { __index = _ODA })
|
setmetatable(instance, { __index = _ODA })
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
@@ -16,11 +16,12 @@ local _RDS_ODA_pointer = 1
|
|||||||
---@param group_version boolean
|
---@param group_version boolean
|
||||||
---@param aid integer
|
---@param aid integer
|
||||||
---@param data integer
|
---@param data integer
|
||||||
|
---@param temp boolean
|
||||||
---@return integer oda_id
|
---@return integer oda_id
|
||||||
function ext.register_oda(group, group_version, aid, data)
|
function ext.register_oda(group, group_version, aid, data, temp)
|
||||||
if group == 14 or group == 15 or group == 2 or group == 0 then error("Group is incorrect", 2) end
|
if group == 14 or group == 15 or group == 2 or group == 0 then error("Group is incorrect", 2) end
|
||||||
if (group == 10 or group == 4 or group == 1) and group_version then error("Group is incorrect", 2) end
|
if (group == 10 or group == 4 or group == 1) and group_version then error("Group is incorrect", 2) end
|
||||||
local oda = _ODA.new(group, group_version, aid, data, false)
|
local oda = _ODA.new(group, group_version, aid, data, false, temp)
|
||||||
for i = 1, #_RDS_ODAs do
|
for i = 1, #_RDS_ODAs do
|
||||||
if _RDS_ODAs[i] == false then
|
if _RDS_ODAs[i] == false then
|
||||||
_RDS_ODAs[i] = oda
|
_RDS_ODAs[i] = oda
|
||||||
@@ -74,6 +75,9 @@ local function get_aid()
|
|||||||
local data, aid = oda.data, oda.aid
|
local data, aid = oda.data, oda.aid
|
||||||
|
|
||||||
_RDS_ODA_pointer = (_RDS_ODA_pointer % #_RDS_ODAs) + 1
|
_RDS_ODA_pointer = (_RDS_ODA_pointer % #_RDS_ODAs) + 1
|
||||||
|
|
||||||
|
if oda.temp then _RDS_ODAs[_RDS_ODA_pointer] = false end
|
||||||
|
|
||||||
return true, b, data, aid
|
return true, b, data, aid
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -91,7 +95,7 @@ local function get_data()
|
|||||||
while checked_count < #_RDS_ODAs do
|
while checked_count < #_RDS_ODAs do
|
||||||
local oda = _RDS_ODAs[_RDS_ODA_pointer]
|
local oda = _RDS_ODAs[_RDS_ODA_pointer]
|
||||||
|
|
||||||
if oda ~= false and type(oda.handler) == "function" then
|
if oda ~= false and type(oda.handler) == "function" and not oda.temp then
|
||||||
local ok, generated, b, c, d = pcall(oda.handler)
|
local ok, generated, b, c, d = pcall(oda.handler)
|
||||||
if ok and generated then
|
if ok and generated then
|
||||||
_RDS_ODA_pointer = (_RDS_ODA_pointer % #_RDS_ODAs) + 1
|
_RDS_ODA_pointer = (_RDS_ODA_pointer % #_RDS_ODAs) + 1
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ end
|
|||||||
|
|
||||||
local function init_af_oda()
|
local function init_af_oda()
|
||||||
if _Af_Oda_id == nil then
|
if _Af_Oda_id == nil then
|
||||||
_Af_Oda_id = ext.register_oda(7, false, 0x6365, 0)
|
_Af_Oda_id = ext.register_oda(7, false, 0x6365, 0, false)
|
||||||
ext.set_oda_handler(_Af_Oda_id, function()
|
ext.set_oda_handler(_Af_Oda_id, function()
|
||||||
local b, c, d = get_next_af_oda_group()
|
local b, c, d = get_next_af_oda_group()
|
||||||
return true, b, c, d
|
return true, b, c, d
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ local USERDATA_ERT_OFFSET = 0
|
|||||||
|
|
||||||
local function init_ert()
|
local function init_ert()
|
||||||
if _Ert_oda_id == nil then
|
if _Ert_oda_id == nil then
|
||||||
_Ert_oda_id = ext.register_oda(13, false, 0x6552, 1)
|
_Ert_oda_id = ext.register_oda(13, false, 0x6552, 1, false)
|
||||||
ext.set_oda_handler(_Ert_oda_id, function ()
|
ext.set_oda_handler(_Ert_oda_id, function ()
|
||||||
if string.byte(userdata.get_offset(USERDATA_ERT_OFFSET+258, 1)) == 1 then
|
if string.byte(userdata.get_offset(USERDATA_ERT_OFFSET+258, 1)) == 1 then
|
||||||
local new_data = userdata.get_offset(USERDATA_ERT_OFFSET, 128)
|
local new_data = userdata.get_offset(USERDATA_ERT_OFFSET, 128)
|
||||||
|
|||||||
+2
-2
@@ -8,7 +8,7 @@ local USERDATA_RTP_OFFSET = 259
|
|||||||
|
|
||||||
local function init_rtp()
|
local function init_rtp()
|
||||||
if _Rtp_oda_id == nil then
|
if _Rtp_oda_id == nil then
|
||||||
_Rtp_oda_id = ext.register_oda(11, false, 0x4BD7, 0)
|
_Rtp_oda_id = ext.register_oda(11, false, 0x4BD7, 0, false)
|
||||||
ext.set_oda_handler(_Rtp_oda_id, function ()
|
ext.set_oda_handler(_Rtp_oda_id, function ()
|
||||||
local b = (_Rtp_toggle and 1 or 0) << 4 | string.byte(userdata.get_offset(USERDATA_RTP_OFFSET, 1)) << 3
|
local b = (_Rtp_toggle and 1 or 0) << 4 | string.byte(userdata.get_offset(USERDATA_RTP_OFFSET, 1)) << 3
|
||||||
local data_0 = userdata.get_offset(USERDATA_RTP_OFFSET+1, 3)
|
local data_0 = userdata.get_offset(USERDATA_RTP_OFFSET+1, 3)
|
||||||
@@ -31,7 +31,7 @@ end
|
|||||||
|
|
||||||
local function init_ertp()
|
local function init_ertp()
|
||||||
if _Ertp_oda_id == nil then
|
if _Ertp_oda_id == nil then
|
||||||
_Ertp_oda_id = ext.register_oda(12, false, 0x4BD8, 0)
|
_Ertp_oda_id = ext.register_oda(12, false, 0x4BD8, 0, false)
|
||||||
ext.set_oda_handler(_Ertp_oda_id, function ()
|
ext.set_oda_handler(_Ertp_oda_id, function ()
|
||||||
local b = (_Ertp_toggle and 1 or 0) << 4 | string.byte(userdata.get_offset(USERDATA_RTP_OFFSET+7, 1)) << 3
|
local b = (_Ertp_toggle and 1 or 0) << 4 | string.byte(userdata.get_offset(USERDATA_RTP_OFFSET+7, 1)) << 3
|
||||||
local data_0 = userdata.get_offset(USERDATA_RTP_OFFSET+8, 3)
|
local data_0 = userdata.get_offset(USERDATA_RTP_OFFSET+8, 3)
|
||||||
|
|||||||
+23
-11
@@ -45,29 +45,29 @@ local function dsn_helper(dsn, write)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mec_handlers[1] = function (data)
|
mec_handlers[1] = function(data)
|
||||||
-- PI
|
-- PI
|
||||||
local dsn = string.byte(data, 2)
|
local dsn = string.byte(data, 2)
|
||||||
local psn = string.byte(data, 3)
|
local psn = string.byte(data, 3)
|
||||||
local pi_msb = string.byte(data, 4)
|
local pi_msb = string.byte(data, 4)
|
||||||
local pi_lsb = string.byte(data, 5)
|
local pi_lsb = string.byte(data, 5)
|
||||||
|
|
||||||
dsn_helper(dsn, function ()
|
dsn_helper(dsn, function()
|
||||||
rds.set_pi((pi_msb << 8) | pi_lsb)
|
rds.set_pi((pi_msb << 8) | pi_lsb)
|
||||||
end)
|
end)
|
||||||
return 5
|
return 5
|
||||||
end
|
end
|
||||||
mec_handlers[2] = function (data)
|
mec_handlers[2] = function(data)
|
||||||
-- PS
|
-- PS
|
||||||
local dsn = string.byte(data, 2)
|
local dsn = string.byte(data, 2)
|
||||||
local psn = string.byte(data, 3)
|
local psn = string.byte(data, 3)
|
||||||
local ps = string.sub(data, 4, 11) -- Static len
|
local ps = string.sub(data, 4, 11) -- Static len
|
||||||
dsn_helper(dsn, function ()
|
dsn_helper(dsn, function()
|
||||||
rds.set_ps(ps)
|
rds.set_ps(ps)
|
||||||
end)
|
end)
|
||||||
return 11
|
return 11
|
||||||
end
|
end
|
||||||
mec_handlers[0x21] = function (data)
|
mec_handlers[0x21] = function(data)
|
||||||
-- LPS
|
-- LPS
|
||||||
local dsn = string.byte(data, 2)
|
local dsn = string.byte(data, 2)
|
||||||
local psn = string.byte(data, 3)
|
local psn = string.byte(data, 3)
|
||||||
@@ -77,12 +77,12 @@ mec_handlers[0x21] = function (data)
|
|||||||
local cut = string.find(lps, "\r", 1, true)
|
local cut = string.find(lps, "\r", 1, true)
|
||||||
if cut then lps = string.sub(lps, 1, cut - 1) end
|
if cut then lps = string.sub(lps, 1, cut - 1) end
|
||||||
|
|
||||||
dsn_helper(dsn, function ()
|
dsn_helper(dsn, function()
|
||||||
rds.set_lps(lps)
|
rds.set_lps(lps)
|
||||||
end)
|
end)
|
||||||
return 4 + mel
|
return 4 + mel
|
||||||
end
|
end
|
||||||
mec_handlers[4] = function (data)
|
mec_handlers[4] = function(data)
|
||||||
-- PTYI
|
-- PTYI
|
||||||
local dsn = string.byte(data, 2)
|
local dsn = string.byte(data, 2)
|
||||||
local psn = string.byte(data, 3)
|
local psn = string.byte(data, 3)
|
||||||
@@ -92,7 +92,7 @@ mec_handlers[4] = function (data)
|
|||||||
end)
|
end)
|
||||||
return 4
|
return 4
|
||||||
end
|
end
|
||||||
mec_handlers[3] = function (data)
|
mec_handlers[3] = function(data)
|
||||||
-- TP/TA
|
-- TP/TA
|
||||||
local dsn = string.byte(data, 2)
|
local dsn = string.byte(data, 2)
|
||||||
local psn = string.byte(data, 3)
|
local psn = string.byte(data, 3)
|
||||||
@@ -103,7 +103,7 @@ mec_handlers[3] = function (data)
|
|||||||
end)
|
end)
|
||||||
return 4
|
return 4
|
||||||
end
|
end
|
||||||
mec_handlers[7] = function (data)
|
mec_handlers[7] = function(data)
|
||||||
-- PTY
|
-- PTY
|
||||||
local dsn = string.byte(data, 2)
|
local dsn = string.byte(data, 2)
|
||||||
local psn = string.byte(data, 3)
|
local psn = string.byte(data, 3)
|
||||||
@@ -113,7 +113,7 @@ mec_handlers[7] = function (data)
|
|||||||
end)
|
end)
|
||||||
return 4
|
return 4
|
||||||
end
|
end
|
||||||
mec_handlers[0x3E] = function (data)
|
mec_handlers[0x3E] = function(data)
|
||||||
-- PTYN
|
-- PTYN
|
||||||
local dsn = string.byte(data, 2)
|
local dsn = string.byte(data, 2)
|
||||||
local psn = string.byte(data, 3)
|
local psn = string.byte(data, 3)
|
||||||
@@ -123,7 +123,8 @@ mec_handlers[0x3E] = function (data)
|
|||||||
end)
|
end)
|
||||||
return 11
|
return 11
|
||||||
end
|
end
|
||||||
mec_handlers[0x0A] = function (data)
|
mec_handlers[0x0A] = function(data)
|
||||||
|
-- RT
|
||||||
local dsn = string.byte(data, 2)
|
local dsn = string.byte(data, 2)
|
||||||
local psn = string.byte(data, 3)
|
local psn = string.byte(data, 3)
|
||||||
local mel = string.byte(data, 4)
|
local mel = string.byte(data, 4)
|
||||||
@@ -215,6 +216,17 @@ mec_handlers[0x1C] = function (data)
|
|||||||
return 2
|
return 2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
mec_handlers[0x2D] = function (data)
|
||||||
|
-- Manufacturer
|
||||||
|
local mel = string.byte(data, 2)
|
||||||
|
local designation = string.sub(data, 3, 4)
|
||||||
|
if designation == "95" and mel > 2 then
|
||||||
|
local data = string.sub(data, 5, 4+mel)
|
||||||
|
pcall(data_handle, data)
|
||||||
|
end
|
||||||
|
return 2+mel
|
||||||
|
end
|
||||||
|
|
||||||
---@param data string
|
---@param data string
|
||||||
local function undo_byte_stuff(data)
|
local function undo_byte_stuff(data)
|
||||||
local output = {}
|
local output = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user