hotspot-app
hotspot-app copied to clipboard
[#976] Scan to assert antenna gain and elevation
Feature request: https://github.com/helium/hotspot-app/issues/976
Summary
This PR adds the ability to scan a QR code (structure defined below) to reassert the gain/elevation of a hotspot's antenna within a single screen. The code can be scanned by tapping the QR symbol within the Wallet View, and will render a pre-filled version of the "Update Antenna" screen from Settings.
QR Code JSON Payload
{
"hotspot_address": "11vAu1u...",
"gain": 1.3,
"elevation": 3
}
Screenshot | Invalid Address | Demo* |
---|---|---|
![]() |
![]() |
![]() |
* To facilitate the demo on local simulator, I hooked up the "X" icon from the Scan View into handleBarCodeScanned
with a hardcoded JSON payload.
Implementation
This PR adds a new, lightweight HotspotAntennaUpdateScreen
component nested within HotspotsStack
stack navigator (alongside HotspotsScreen
). The hotspot address, elevation, and gain parsed from the QR code are passed to this screen via navigation props. It then renders an updated version of UpdateHotspotConfig
which accepts three new props:
antennaGain?: number
antennaElevation?: number
initState?: State
This allows UpdateHotspotConfig
to be render with pre-filled gain/elevation values. It also pre-fills the antenna maker as "Custom" if a gain is provided so that the gain field can be edited without selecting a specific antenna maker.
It also updates the relationship between UpdateHotspotConfig
and HotspotConfigurationPicker
so that the gain and elevation inputs act more as controlled inputs. Now UpdateHotspotConfig
is responsible for persisting the gain
and elevation
numbers, then passes those down to HotspotConfigurationPicker
, who then passes the values to TextInput
. However, I maintained the existing behavior where formatting only happens after the user has finished editing (rather than formatting the input upon each character).
Testing
So far the extent of testing done is basically what's shown in the demo above. The submitTxn
call has been stubbed out,
relying on the assumption that submitTxn
within the usual "Settings > Update Antenna" flow works as expected.
Have also tested that providing either an invalid address in the QR code payload or a hotspot address that doesn't belong to the currently authenticated user will result in the "error" dialog shown above.
Hi @MichaelBrew . I rebased your PR with the latest changes and pushed it here https://github.com/helium/hotspot-app/tree/scan_antenna_rebased
I tested with the QR scanner and JSON format you provided, but it doesn't appear to be working. Could you provide a working QR code?