Skip to content

Commit

Permalink
Merge pull request #269 from NebraLtd/shawaj/nebrafleets
Browse files Browse the repository at this point in the history
feat: add check for nebra fleets
  • Loading branch information
robputt authored Jun 26, 2023
2 parents af8818f + 7a48f78 commit de696c2
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 6 deletions.
83 changes: 78 additions & 5 deletions hm_pyhelper/sbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class DeviceVendorID(Enum):
}

COMMERCIAL_FLEETS = [
156, # Bobcat
156, # Bobcat PX30
56, # Controllino
106, # COTX,
106, # COTX
53, # Finestra
31, # Nebra Indoor 868MHz
40, # Nebra Indoor RockPi 868MHz
Expand All @@ -69,9 +69,9 @@ class DeviceVendorID(Enum):
90, # Syncrobit
126, # Syncrobit RKCM3
98, # Nebra Indoor Testing
158, # Bobcat Testing
158, # Bobcat PX30 Testing
127, # Controllino Testing
87, # COTX Testing,
87, # COTX Testing
76, # Finestra Testing
132, # Linxdot Testing
84, # Linxdot RKCM3 Testing
Expand All @@ -90,6 +90,67 @@ class DeviceVendorID(Enum):
2061340, # Rob Testing
]

NON_COMMERCIAL_FLEETS = [
67, # dev-1
54, # dev-2
74, # dev-3
25, # devnet-01
26, # devnet-02
150, # devnet-03
153, # dev-sensorhub
121, # Bobcat PX30
105, # Controllino
136, # COTX
99, # Disputed
118, # Finestra
109, # Indoor 470
39, # Indoor 868
134, # Indoor 868 RockPi
91, # Indoor 915
122, # Indoor 915 RockPi
46, # Linxdot
68, # Linxdot RKCM3
138, # Midas
3, # Indoor1
27, # Indoor2
28, # Outdoor1
29, # Outdoor2
104, # OG
79, # Outdoor 470
63, # Outdoor 868
133, # Outdoor 915
94, # Outdoor 915 RockPi
32, # Panther X1
71, # Pisces
83, # Pycom
78, # RAK
85, # RisingHF
101, # Sensecap
130, # Syncrobit
69, # Syncrobit RKCM3
123, # Testnet
157, # Bobcat PX30 Testnet
102, # Controllino Testnet
86, # COTX Testnet
77, # Finestra Testnet
117, # Linxdot Testnet
110, # Linxdot RKCM3 Testnet
139, # Midas Testnet
70, # OG Testnet
129, # Panther X1 Testnet
125, # Pisces Testnet
131, # Pycom Testnet
36, # RAK Testnet
55, # Rising HF Testnet
95, # RockPi Testnet
75, # Sensecap Testnet
97, # Syncrobit Testnet
37, # Syncrobit RKCM3 Testnet
22, # Indoor2 Testnet
]

NEBRA_API_URL = "https://api.cloud.nebra.com"

def device_model():
with open('/proc/device-tree/model', 'r') as f:
return f.readline().strip()
Expand Down Expand Up @@ -136,5 +197,17 @@ def is_commercial_fleet() -> bool:
if not fleet_name.endswith('-c') or fleet_id not in COMMERCIAL_FLEETS:
return False

return True


def is_nebra_fleet() -> bool:
'''
Return true if the device is in a Nebra Cloud fleet. Otherwise return false.
'''
api_url = os.environ.get('BALENA_API_URL')
fleet_id = int(os.environ.get('BALENA_APP_ID'))

if api_url is not NEBRA_API_URL or fleet_id not in COMMERCIAL_FLEETS or fleet_id not in NON_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.16"
version = "0.14.17"
description = "Helium Python Helper"
authors = ["Nebra Ltd <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit de696c2

Please sign in to comment.