package api import ( "context" "fmt" "github.com/pkg/errors" ) // GET http:///info // { // "device": { // "cloud": { // "supported": true, // "usage_analysis_accepted": false // }, // "country_code": "FR", // "critical_self_tests_passed": true, // "is_first_time_setup": false, // "local_address": "Reach.local", // "manufacturing_timestamp": "1693633066", // "name": "Reach", // "privacy_policy_accepted": true, // "public_key": "378A5081F445771316A0563CFCC168C813261C6EE9C5C50DF70CC4503C6D8839BED7AA40146A9D8D72BFC4DB85382EEE51B90D03B6CC6DF34E860E15EFEA7D38", // "self_tests": { // "antenna_board_detected": true, // "audio": true, // "bluetooth_detected": true, // "crypto-chip": true, // "image_and_device": true, // "lora": true, // "modem": true, // "mpu": true, // "stm32": true, // "u-blox": true, // "wifi_detected": true // }, // "serial_number": "8243276564AEA32D", // "statistics": { // "first_usage_timestamp": 4294967295 // }, // "time_sync_passed": true, // "type": "ReachRS2+", // "uptime": "2:50:57" // }, // "firmware": { // "api_version": "10.2", // "app_mode": "default", // "onboarding_shown": false, // "version": "32.0", // "version_full": "32.0-r0" // }, // "gnss_receiver": { // "firmware_version": "HPG_1.13" // }, // "lora": { // "firmware_version": "F-0LR-1F-1912161" // }, // "modem": { // "firmware_version": "MPSS.JO.2.0.2.c1.1-00098-9607_GENNS_PACK-1.402457.1 1 [May 18 2021 19:00:00]", // "imei": "350588283544948", // "modem_model": "\r\n^SYSSTART\r\n" // }, // "pmu": { // "balancer_version": "190602", // "git_hash": "0a241756", // "version": "3.35" // }, // "reachview": { // "api_version": "10.2", // "app_mode": "default", // "onboarding_shown": false, // "version": "32.0", // "version_full": "32.0-r0" // }, // "storage": { // "free": 11682, // "total": 12374 // } // } type Info struct { Device Device `json:"device,omitempty"` Firmware Firmware `json:"firmware,omitempty"` GnssReceiver GnssReceiver `json:"gnss_receiver,omitempty"` Lora Lora `json:"lora,omitempty"` Modem Modem `json:"modem,omitempty"` Pmu Pmu `json:"pmu,omitempty"` Reachview Reachview `json:"reachview,omitempty"` Storage Storage `json:"storage,omitempty"` } type Cloud struct { Supported bool `json:"supported,omitempty"` UsageAnalysisAccepted bool `json:"usage_analysis_accepted,omitempty"` } type SelfTests struct { AntennaBoardDetected bool `json:"antenna_board_detected,omitempty"` Audio bool `json:"audio,omitempty"` BluetoothDetected bool `json:"bluetooth_detected,omitempty"` CryptoChip bool `json:"crypto-chip,omitempty"` ImageAndDevice bool `json:"image_and_device,omitempty"` Lora bool `json:"lora,omitempty"` Modem bool `json:"modem,omitempty"` Mpu bool `json:"mpu,omitempty"` Stm32 bool `json:"stm32,omitempty"` UBlox bool `json:"u-blox,omitempty"` WifiDetected bool `json:"wifi_detected,omitempty"` } type Statistics struct { FirstUsageTimestamp int64 `json:"first_usage_timestamp,omitempty"` } type Device struct { Cloud Cloud `json:"cloud,omitempty"` CountryCode string `json:"country_code,omitempty"` CriticalSelfTestsPassed bool `json:"critical_self_tests_passed,omitempty"` IsFirstTimeSetup bool `json:"is_first_time_setup,omitempty"` LocalAddress string `json:"local_address,omitempty"` ManufacturingTimestamp string `json:"manufacturing_timestamp,omitempty"` Name string `json:"name,omitempty"` PrivacyPolicyAccepted bool `json:"privacy_policy_accepted,omitempty"` PublicKey string `json:"public_key,omitempty"` SelfTests SelfTests `json:"self_tests,omitempty"` SerialNumber string `json:"serial_number,omitempty"` Statistics Statistics `json:"statistics,omitempty"` TimeSyncPassed bool `json:"time_sync_passed,omitempty"` Type string `json:"type,omitempty"` Uptime string `json:"uptime,omitempty"` } type Firmware struct { APIVersion string `json:"api_version,omitempty"` AppMode string `json:"app_mode,omitempty"` OnboardingShown bool `json:"onboarding_shown,omitempty"` Version string `json:"version,omitempty"` VersionFull string `json:"version_full,omitempty"` } type GnssReceiver struct { FirmwareVersion string `json:"firmware_version,omitempty"` } type Lora struct { FirmwareVersion string `json:"firmware_version,omitempty"` } type Modem struct { FirmwareVersion string `json:"firmware_version,omitempty"` Imei string `json:"imei,omitempty"` ModemModel string `json:"modem_model,omitempty"` } type Pmu struct { BalancerVersion string `json:"balancer_version,omitempty"` GitHash string `json:"git_hash,omitempty"` Version string `json:"version,omitempty"` } type Reachview struct { APIVersion string `json:"api_version,omitempty"` AppMode string `json:"app_mode,omitempty"` OnboardingShown bool `json:"onboarding_shown,omitempty"` Version string `json:"version,omitempty"` VersionFull string `json:"version_full,omitempty"` } type Storage struct { Free int `json:"free,omitempty"` Total int `json:"total,omitempty"` } func GetInfo(ctx context.Context, addr string) (*Info, error) { url := fmt.Sprintf("http://%s/info", addr) info := &Info{} if err := GetJSON(url, info); err != nil { return nil, errors.WithStack(err) } return info, nil }