Commit 8ed62d14 authored by Joanne Hugé's avatar Joanne Hugé

software/ors-amarisoft: publish ors hardware infos

parent e8569a1b
......@@ -16,7 +16,7 @@
[template]
filename = instance.cfg
md5sum = 22aff707c77b0fd6b790c740aa09211d
md5sum = da084e9f8937c8797514dd73f093c96c
[amarisoft-stats.jinja2.py]
_update_hash_filename_ = amarisoft-stats.jinja2.py
......@@ -36,11 +36,11 @@ md5sum = b34fe47a73890097fbc6ea6374aeb38d
[template-enb]
_update_hash_filename_ = instance-enb.jinja2.cfg
md5sum = 9ebfd48ee126572d009f2d306cc134a3
md5sum = 2f3801e918435d595d2274f4125f6ec1
[template-gnb]
_update_hash_filename_ = instance-gnb.jinja2.cfg
md5sum = 0d909050573d635237f804461db6cbe9
md5sum = f62afdaa0033371db70465f61d83a9b2
[template-core-network]
_update_hash_filename_ = instance-core-network.jinja2.cfg
......
......@@ -314,6 +314,9 @@ extra-context =
recipe = slapos.cookbook:publish.serialised
enb-ipv6 = ${slap-configuration:ipv6-random}
enb-ipv4 = {{ lan_ipv4 }}
ors-version = {{ ors_version['ors-version'] }}
frequency-range-rating = {{ ors_version['range'] }}
current-tx-power-estimate = {{ ors_version['power_estimate'] }}
monitor-gadget-url = ${:monitor-base-url}/gadget/software.cfg.html
[monitor-instance-parameter]
......
......@@ -213,8 +213,12 @@ context =
key slapparameter_dict slap-configuration:configuration
key gtp_addr_v6 slap-configuration:ipv6-random
raw gtp_addr_v4 {{ lan_ipv4 }}
raw rf_mode {{ rf_mode }}
raw one_watt {{ ors_version['one-watt'] }}
raw tx_gain {{ ors_version['current-tx-gain'] }}
raw rx_gain {{ ors_version['current-rx-gain'] }}
raw nr_arfcn {{ ors_version['current-nr-arfcn'] }}
raw nr_band {{ ors_version['current-nr-band'] }}
raw rf_mode {{ rf_mode }}
import netaddr netaddr
[gnb-config]
......@@ -231,6 +235,9 @@ output = ${directory:etc}/gnb.cfg
recipe = slapos.cookbook:publish.serialised
gnb-ipv6 = ${slap-configuration:ipv6-random}
gnb-ipv4 = {{ lan_ipv4 }}
ors-version = {{ ors_version['ors-version'] }}
frequency-range-rating = {{ ors_version['range'] }}
current-tx-power-estimate = {{ ors_version['power_estimate'] }}
monitor-gadget-url = ${:monitor-base-url}/gadget/software.cfg.html
[monitor-instance-parameter]
......
......@@ -53,12 +53,78 @@ init =
[ors-version]
recipe = slapos.recipe.build
configuration = $${slap-configuration:configuration}
default-tx-gain = ${default-params:default-lte-tx-gain}
init =
import subprocess
v = subprocess.check_output(["sudo", "-n", "/opt/amarisoft/get-sdr-info", "-v"])
v = float(v.decode())
options['version'] = v
options['one-watt'] = bool(v >= 4)
tx_gain = options['configuration'].get('tx_gain', options['default-tx-gain'])
options['tx_gain'] = tx_gain
range_map = {
"B38": "2570MHz - 2620MHz",
"B39": "1880MHz - 1920MHz",
"B42": "3400MHz - 3600MHz",
"B43": "3600MHz - 3800MHz",
"Unknown": "Information not available for this band",
}
power_map = {
"B38": (
lambda x: (-0.008712931375092506) * x**2 + (2.1973585140044642) * x + (-94.29420762479742),
lambda x: (-0.004472751640641793) * x**2 + (1.6308290630103919) * x + (-81.84549245154561),
),
"B39": (
lambda x: (-0.008712931375092506) * x**2 + (2.1973585140044642) * x + (-94.29420762479742),
lambda x: (-0.0022523817802900985) * x**2 + (1.2674016231310092) * x + (-66.57165215468584),
),
"B42": (
lambda x: (-0.014198126839751619) * x**2 + (2.980758813262773) * x + (-125.25800492285738),
lambda x: (0.003977721774394756) * x**2 + (0.527208191717173) * x + (-42.761142655285376),
),
"B43": (
lambda x: (-0.014198126839751619) * x**2 + (2.980758813262773) * x + (-125.25800492285738),
lambda x: (-0.0036530114002551943) * x**2 + (1.510856844601873) * x + (-74.58790185136355),
),
"Unknown": (
lambda x: "UNKNOWN",
lambda x: "UNKNOWN",
),
}
def get_sdr_info(cmd):
if options['configuration'].get('testing', False):
return {'t': 'TDD', 'b': 'B39', 'v': '4.2', 's': 'B53'}[cmd].encode()
return subprocess.check_output(
["sudo", "-n", "/opt/amarisoft/get-sdr-info", "-" + cmd]
)
options['version'] = float(get_sdr_info('v').decode())
options['band'] = get_sdr_info('b').decode()
options['tdd'] = get_sdr_info('t').decode()
options['one-watt'] = bool(options['version'] >= 4)
options['ors-version'] = "{} {} {}".format(
options['tdd'],
options['band'],
"2x1W" if options['one-watt'] else "2x0.5W",
)
default_tx_gain = default_tx_gain_map [options['band']][int(options['one-watt'])]
default_rx_gain = default_rx_gain_map [options['band']][int(options['one-watt'])]
default_earfcn = default_earfcn_map [options['band']]
default_nr_arfcn = default_nr_arfcn_map[options['band']]
default_nr_band = default_nr_band_map [options['band']]
options['range'] = range_map [options['band']]
options['current-tx-gain'] = options['configuration'].get('tx_gain' , default_tx_gain )
options['current-rx-gain'] = options['configuration'].get('rx_gain' , default_rx_gain )
options['current-earfcn'] = options['configuration'].get('dl_earfcn' , default_earfcn )
options['current-nr-arfcn'] = options['configuration'].get('dl_nr_arfcn', default_nr_arfcn)
options['current-nr-band'] = options['configuration'].get('nr_band' , default_nr_band )
power_estimate_dbm = power_map[options['band']][int(options['one-watt'])](float(options['current-tx-gain']))
if power_estimate_dbm == "UNKNOWN":
power_estimate = "Information not available for this band"
else:
power_estimate_mw = 10 ** ( power_estimate_dbm / 10 )
if power_estimate_mw < 0.01:
power_estimate_s = "{:0.2f} µW".format(power_estimate_mw * 1000)
else:
power_estimate_s = "{:0.2f} mW".format(power_estimate_mw)
power_estimate = "{:0.2f} dBm ({})".format(power_estimate_dbm, power_estimate_s)
options['power-estimate'] = power_estimate
[lan-ip]
recipe = slapos.recipe.build
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment