Skip to content

Commit

Permalink
feat: move commercial fleet check to hm-pyhelper from diag
Browse files Browse the repository at this point in the history
- move commercial fleet check to hm-pyhelper from diag
- add bobcat px30 commercial fleet

Ref NebraLtd/hm-diag#602 and NebraLtd/hm-diag#606
  • Loading branch information
shawaj committed Jun 10, 2023
1 parent 99392c4 commit 026129c
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
60 changes: 60 additions & 0 deletions hm_pyhelper/sbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,52 @@ class DeviceVendorID(Enum):
DeviceVendorID.RASPBERRY_PI: BALENA_ENV_RASPBERRY_PI_MODELS
}

COMMERCIAL_FLEETS = [
156, # Bobcat
56, # Controllino
106, # COTX,
53, # Finestra
31, # Nebra Indoor 868MHz
40, # Nebra Indoor RockPi 868MHz
119, # Nebra Indoor 915MHz
58, # Nebra Indoor RockPi 915MHz
62, # Linxdot
42, # Linxdot RKCM3
143, # Midas
145, # Nebra indoor1
147, # Nebra indoor2
148, # Nebra outdoor1
149, # Nebra outdoor2
52, # Helium OG
80, # Nebra Outdoor 868MHz
107, # Nebra Outdoor 915MHz
47, # PantherX
66, # Pisces
73, # Pycom
88, # RAK
114, # RisingHF
124, # Sensecap
90, # Syncrobit
126, # Syncrobit RKCM3
98, # Nebra Indoor Testing
127, # Controllino Testing
87, # COTX Testing,
76, # Finestra Testing
132, # Linxdot Testing
84, # Linxdot RKCM3 Testing
144, # Midas Testing
128, # Helium OG Testing
41, # PantherX Testing
43, # Pisces Testing
116, # Pycom Testing
113, # RAK Testing
103, # RisingHF Testing
60, # Nebra RockPi Testing
137, # Sensecap Testing
57, # Syncrobit Testing
111, # Syncrobit RKCM3 Testing
2006816, # Rob Testing
]

def device_model():
with open('/proc/device-tree/model', 'r') as f:
Expand Down Expand Up @@ -76,3 +122,17 @@ def is_sbc_type(device_id: DeviceVendorID) -> bool:

# honor env override
return device_type in BALENA_MODELS.get(device_id, [])


def is_commercial_fleet() -> bool:
'''
Return true if the device is in a commercial fleet. Otherwise return false.
'''
fleet_name = os.environ.get('BALENA_APP_NAME')
fleet_id = int(os.environ.get('BALENA_APP_ID'))

if not fleet_name.endswith('-c') or fleet_id not in COMMERCIAL_FLEETS:
return False

return True

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "hm_pyhelper"
version = "0.14.14"
version = "0.14.15"
description = "Helium Python Helper"
authors = ["Nebra Ltd <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 026129c

Please sign in to comment.