save device model details to global and parse out serial

This commit is contained in:
Charles Ewert 2023-09-03 19:42:21 -04:00
parent f8fc95418a
commit 4c303daedf

View File

@ -40,9 +40,13 @@ end sub
' Save information from roDeviceInfo to m.global.device ' Save information from roDeviceInfo to m.global.device
sub SaveDeviceToGlobal() sub SaveDeviceToGlobal()
deviceInfo = CreateObject("roDeviceInfo") deviceInfo = CreateObject("roDeviceInfo")
' remove special characters ' remove special characters
regex = CreateObject("roRegex", "[^a-zA-Z0-9\ \-\_]", "") regex = CreateObject("roRegex", "[^a-zA-Z0-9\ \-\_]", "")
filteredFriendly = regex.ReplaceAll(deviceInfo.getFriendlyName(), "") filteredFriendly = regex.ReplaceAll(deviceInfo.getFriendlyName(), "")
' parse out serial
displayName = deviceInfo.getModelDisplayName()
deviceSerial = Mid(filteredFriendly, len(displayName) + 4)
' determine max playback resolution ' determine max playback resolution
' https://developer.roku.com/en-ca/docs/references/brightscript/interfaces/ifdeviceinfo.md#getvideomode-as-string ' https://developer.roku.com/en-ca/docs/references/brightscript/interfaces/ifdeviceinfo.md#getvideomode-as-string
videoMode = deviceInfo.GetVideoMode() videoMode = deviceInfo.GetVideoMode()
@ -94,14 +98,17 @@ sub SaveDeviceToGlobal()
else if videoHeight = "4320" else if videoHeight = "4320"
bitDepth = 12 bitDepth = 12
end if end if
m.global.addFields({ m.global.addFields({
device: { device: {
id: deviceInfo.getChannelClientID(), id: deviceInfo.getChannelClientID(),
uuid: deviceInfo.GetRandomUUID(), uuid: deviceInfo.GetRandomUUID(),
name: deviceInfo.getModelDisplayName(), name: displayName,
friendlyName: filteredFriendly, friendlyName: filteredFriendly,
model: deviceInfo.GetModel(), model: deviceInfo.GetModel(),
modelType: deviceInfo.GetModelType(), modelType: deviceInfo.GetModelType(),
modelDetails: deviceInfo.GetModelDetails(),
serial: deviceSerial,
osVersion: deviceInfo.GetOSVersion(), osVersion: deviceInfo.GetOSVersion(),
locale: deviceInfo.GetCurrentLocale(), locale: deviceInfo.GetCurrentLocale(),
clockFormat: deviceInfo.GetClockFormat(), clockFormat: deviceInfo.GetClockFormat(),