Skip to content

Commit

Permalink
handle display of no 5G connection, display carrier aggregation infor…
Browse files Browse the repository at this point in the history
…mation
  • Loading branch information
highvolt-dev committed Dec 30, 2021
1 parent 04f59ec commit e682dea
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ This project has not been prepared to handle proxying in a production-ready rele

### 4G LTE
- Connected band
- Carrier Aggregation (Download, Upload, Bands)
- Current/Best RSRP
- Current/Best SNR
- Current/Best RSRQ
Expand Down
1 change: 1 addition & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ dl {
margin-top: 0.25rem;
}
dl dt {
flex-basis: 50%;
width: 40%;
font-weight: bold;
}
Expand Down
25 changes: 18 additions & 7 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,17 @@ function App() {
const date = new Date();
const primary = {...json['cell_LTE_stats_cfg'][0]['stat']};
const secondary = {...json['cell_5G_stats_cfg'][0]['stat']};
setData(data => [...data.slice(-24), {date, time: `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}` , lte: primary, nr: secondary}]);
if (primary['RSRPStrengthIndexCurrent'] === 0) {
primary['SNRCurrent'] = null;
primary['RSRPCurrent'] = null;
primary['RSRQCurrent'] = null;
}
if (secondary['RSRPStrengthIndexCurrent'] === 0) {
secondary['SNRCurrent'] = null;
secondary['RSRPCurrent'] = null;
secondary['RSRQCurrent'] = null;
}
setData(data => [...data.slice(-24), {date, time: `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}` , lte: primary, nr: secondary, ca: { ...json['cell_CA_stats_cfg'][0] }}]);
}, 2000);

return (
Expand All @@ -96,19 +106,20 @@ function App() {
main={true}
band={data.length ? data.slice(-1)[0].lte.Band : 'N/A'}
RSRPCurrent={data.length ? data.slice(-1)[0].lte.RSRPCurrent : null}
RSRPBest={data.length ? data.map(plot => plot.lte.RSRPCurrent).reduce((best, val) => val > best ? val : best, -140) : null}
RSRPBest={data.length ? data.map(plot => plot.lte.RSRPCurrent).filter(val => val !== null).reduce((best, val) => val > best ? val : best, -140) : null}
SNRCurrent={data.length ? data.slice(-1)[0].lte.SNRCurrent : null}
SNRBest={data.length ? data.map(plot => plot.lte.SNRCurrent).reduce((best, val) => val > best ? val : best, -19.5) : null}
SNRBest={data.length ? data.map(plot => plot.lte.SNRCurrent).filter(val => val !== null).reduce((best, val) => val > best ? val : best, -19.5) : null}
CA={data.length ? data.slice(-1)[0].ca /* "ca":{ "X_ALU_COM_DLCarrierAggregationNumberOfEntries":1, "X_ALU_COM_ULCarrierAggregationNumberOfEntries":0 ,"1":{"PhysicalCellID":49, "ScellBand":"B2", "ScellChannel":675 }} }]} */ : null }
/>
<Card
signal="nr"
title="5G NR"
main={true}
band={data.length ? data.slice(-1)[0].nr.Band : 'N/A'}
RSRPCurrent={data.length ? data.slice(-1)[0].nr.RSRPCurrent : null}
RSRPBest={data.length ? data.map(plot => plot.nr.RSRPCurrent).reduce((best, val) => val > best ? val : best, -140) : null}
RSRPBest={data.length ? data.map(plot => plot.nr.RSRPCurrent).filter(val => val !== null).reduce((best, val) => val > best ? val : best, -140) : null}
SNRCurrent={data.length ? data.slice(-1)[0].nr.SNRCurrent : null}
SNRBest={data.length ? data.map(plot => plot.nr.SNRCurrent).reduce((best, val) => val > best ? val : best, -19.5) : null}
SNRBest={data.length ? data.map(plot => plot.nr.SNRCurrent).filter(val => val !== null).reduce((best, val) => val > best ? val : best, -19.5) : null}
/>
</div>
</header>
Expand All @@ -122,14 +133,14 @@ function App() {
title="4G LTE"
main={false}
RSRQCurrent={data.length ? data.slice(-1)[0].lte.RSRQCurrent : null}
RSRQBest={data.length ? data.map(plot => plot.lte.RSRQCurrent).reduce((best, val) => val > best ? val : best, -19.5) : null}
RSRQBest={data.length ? data.map(plot => plot.lte.RSRQCurrent).filter(val => val !== null).reduce((best, val) => val > best ? val : best, -19.5) : null}
/>
<Card
signal="nr"
title="5G NR"
main={false}
RSRQCurrent={data.length ? data.slice(-1)[0].nr.RSRQCurrent : null}
RSRQBest={data.length ? data.map(plot => plot.nr.RSRQCurrent).reduce((best, val) => val > best ? val : best, -19.5) : null}
RSRQBest={data.length ? data.map(plot => plot.nr.RSRQCurrent).filter(val => val !== null).reduce((best, val) => val > best ? val : best, -19.5) : null}
/>
</div>
</header>
Expand Down
29 changes: 22 additions & 7 deletions src/components/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,22 @@ function Card(props) {
<h2>{props.title}</h2>
{props.main ? (
<>
<h3>Band {props.band}</h3>
<h3>Band {props.band ? props.band : 'N/A'}</h3>
{props.signal === 'lte' && props.CA ? (
<>
<h3>Carrier Aggregation</h3>
<dl>
<dt>Download</dt>
<dd>{props.CA.ca.X_ALU_COM_DLCarrierAggregationNumberOfEntries ? `+{props.CA.ca.X_ALU_COM_DLCarrierAggregationNumberOfEntries}` : 'None'}</dd>
<dt>Upload</dt>
<dd>{props.CA.ca.X_ALU_COM_ULCarrierAggregationNumberOfEntries ? `+{props.CA.ca.X_ALU_COM_ULCarrierAggregationNumberOfEntries}` : 'None'}</dd>
{Object.keys(props.CA.ca).filter(key => props.CA.ca.hasOwnProperty(key) && !isNaN(key)).map(key => <>
<dt>CA Add({key})</dt>
<dd>Band {props.CA.ca[key]['ScellBand']}</dd>
</> )}
</dl>
</>
) : props.signal === 'lte' ? 'NO CA' : ''}
<h3>RSRP</h3>
<dl>
<dt>Current:</dt>
Expand All @@ -16,15 +31,15 @@ function Card(props) {
<>
{props.RSRPCurrent} <span className="unit">dBm</span>
</>
) : ''}
) : 'N/A'}
</dd>
<dt>Best:</dt>
<dd>
{props.RSRPBest ? (
<>
{props.RSRPBest} <span className="unit">dBm</span>
</>
) : ''}
) : 'N/A'}
</dd>
</dl>
<h3>SNR</h3>
Expand All @@ -35,15 +50,15 @@ function Card(props) {
<>
{props.SNRCurrent} <span className="unit">dB</span>
</>
) : ''}
) : 'N/A'}
</dd>
<dt>Best:</dt>
<dd>
{props.SNRBest ? (
<>
{props.SNRBest} <span className="unit">dB</span>
</>
) : ''}
) : 'N/A'}
</dd>
</dl>
</>
Expand All @@ -57,15 +72,15 @@ function Card(props) {
<>
{props.RSRQCurrent} <span className="unit">dB</span>
</>
) : ''}
) : 'N/A'}
</dd>
<dt>Best:</dt>
<dd>
{props.RSRQBest ? (
<>
{props.RSRQBest} <span className="unit">dB</span>
</>
) : ''}
) : 'N/A'}
</dd>
</dl>
</>
Expand Down

0 comments on commit e682dea

Please sign in to comment.