Skip to content

Commit

Permalink
GroundSdk release 7.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins.onyxia authored and Thibaut-Martin committed Oct 7, 2022
1 parent d2cf3af commit bc98abd
Show file tree
Hide file tree
Showing 76 changed files with 2,316 additions and 873 deletions.
6 changes: 3 additions & 3 deletions GroundSdk.podspec
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@

Pod::Spec.new do |s|
s.name = "GroundSdk"
s.version = "7.3.0"
s.version = "7.4.0"
s.summary = "Parrot Drone SDK"
s.homepage = "https://developer.parrot.com"
s.license = "{ :type => 'BSD 3-Clause License', :file => 'LICENSE' }"
s.author = 'Parrot Drone SAS'
s.source = { :git => 'https://github.com/Parrot-Developers/pod_groundsdk.git', :tag => "7.3.0" }
s.source = { :git => 'https://github.com/Parrot-Developers/pod_groundsdk.git', :tag => "7.4.0" }
s.platform = :ios
s.ios.deployment_target = '12.0'
s.source_files = 'GroundSdk/**/*.{swift,h,m}'
s.resources = 'GroundSdk/**/*.{vsh,fsh,txt,png}'
s.dependency 'SdkCore', '7.3.0'
s.dependency 'SdkCore', '7.4.0'
s.public_header_files = ["GroundSdk/GroundSdk.h"]
s.swift_version = '5'
s.pod_target_xcconfig = {'SWIFT_VERSION' => '5'}
Expand Down
3 changes: 2 additions & 1 deletion GroundSdk/Device/DeviceModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ public enum DeviceModel: CustomStringConvertible {
}

/// List of devices that can be connectable through usb.
private static var usbDevices: Set<DeviceModel> = [.rc(.skyCtrl3), .rc(.skyCtrl4), .rc(.skyCtrlUA)]
private static var usbDevices: Set<DeviceModel> = [.rc(.skyCtrl3), .rc(.skyCtrl4), .rc(.skyCtrl4Black),
.rc(.skyCtrlUA)]

/// List of devices that can be connectable through wifi.
private static var wifiDevices: Set<DeviceModel> = [.drone(.anafi4k), .drone(.anafiThermal), .drone(.anafi2),
Expand Down
2 changes: 1 addition & 1 deletion GroundSdk/Device/DeviceState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public class DeviceState: NSObject {

/// Debug description.
override public var description: String {
return "[\(connectionState)[\(connectionStateCause)]) \(connectors.debugDescription)]"
return "[\(connectionState)[\(connectionStateCause)] \(connectors.debugDescription)]"
}
}

Expand Down
21 changes: 19 additions & 2 deletions GroundSdk/Device/Instrument/Alarms.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public class Alarm: NSObject {
/// Battery authentication has failed.
case batteryAuthenticationFailure

/// Battery poor connection.
case batteryPoorConnection

/// Hovering is difficult due to a lack of GPS positioning and not enough light to use its vertical camera.
case hoveringDifficultiesNoGpsTooDark

Expand Down Expand Up @@ -193,6 +196,15 @@ public class Alarm: NSObject {
/// Stereo camera is decalibrated.
case stereoCameraDecalibrated

/// Propeller are critically iced, so forced landing auto trigger is planned.
case automaticLandingPropellerIcingIssue

/// Battery is too hot, so forced landing auto trigger is planned.
case automaticLandingBatteryTooHot

/// Battery is too cold, so forced landing auto trigger is planned.
case automaticLandingBatteryTooCold

/// Debug description.
public var description: String {
switch self {
Expand All @@ -204,6 +216,7 @@ public class Alarm: NSObject {
case .batteryTooCold: return "batteryTooCold"
case .batteryGaugeUpdateRequired: return "batteryGaugeUpdateRequired"
case .batteryAuthenticationFailure: return "batteryAuthenticationFailure"
case .batteryPoorConnection: return "batteryPoorConnection"
case .hoveringDifficultiesNoGpsTooDark: return "hoveringDifficultiesNoGpsTooDark"
case .hoveringDifficultiesNoGpsTooHigh: return "hoveringDifficultiesNoGpsTooHigh"
case .automaticLandingBatteryIssue: return "automaticLandingBatteryIssue"
Expand Down Expand Up @@ -234,13 +247,16 @@ public class Alarm: NSObject {
case .obstacleAvoidanceFreeze: return "obstacleAvoidanceFreeze"
case .freeFallDetected: return "freeFallDetected"
case .stereoCameraDecalibrated: return "stereoCameraDecalibrated"
case .automaticLandingPropellerIcingIssue: return "automaticLandingPropellerIcingIssue"
case .automaticLandingBatteryTooHot: return "automaticLandingBatteryTooHot"
case .automaticLandingBatteryTooCold: return "automaticLandingBatteryTooCold"
}
}

/// Set containing all possible kinds of alarm.
public static let allCases: Set<Kind> = [
.power, .motorCutOut, .userEmergency, .motorError, .batteryTooHot, .batteryTooCold,
.batteryGaugeUpdateRequired, .batteryAuthenticationFailure,
.batteryGaugeUpdateRequired, .batteryAuthenticationFailure, .batteryPoorConnection,
.hoveringDifficultiesNoGpsTooDark, .hoveringDifficultiesNoGpsTooHigh,
.automaticLandingBatteryIssue, .wind, .verticalCamera, .strongVibrations,
.magnetometerPertubation, .magnetometerLowEarthField, .unreliableControllerLocation,
Expand All @@ -252,7 +268,8 @@ public class Alarm: NSObject {
.obstacleAvoidancePoorGps, .obstacleAvoidanceComputationalError,
.obstacleAvoidanceBlindMotionDirection, .inclinationTooHigh, .horizontalGeofenceReached,
.verticalGeofenceReached, .obstacleAvoidanceFreeze, .freeFallDetected,
.stereoCameraDecalibrated]
.stereoCameraDecalibrated, .automaticLandingPropellerIcingIssue, .automaticLandingBatteryTooHot,
.automaticLandingBatteryTooCold]
}

/// Alarm level.
Expand Down
31 changes: 31 additions & 0 deletions GroundSdk/Device/Instrument/BatteryInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ public protocol BatteryInfo: Instrument {
/// - note: The size of this array if not empty is expected to be equal to
/// `batteryDescription.cellCount`.
var cellVoltages: [UInt?] { get }

/// Battery components' versions.
/// `nil` if not available. This can happen if the drone does not know or provide this information.
var version: BatteryVersion? { get }
}

/// The battery description.
Expand Down Expand Up @@ -138,6 +142,33 @@ public struct BatteryCapacity: Equatable {
}
}

/// The battery components' versions.
public struct BatteryVersion: Equatable {
/// The battery hardware revision.
public let hardwareRevision: UInt
/// The battery firmware version.
public let firmwareVersion: String
/// The battery gauge version.
public let gaugeVersion: String
/// The battery USB version.
public let usbVersion: String

/// Constructor
///
/// - Parameters:
/// - hardwareRevision: the battery hardware revision
/// - firmwareVersion: the battery firmware version
/// - gaugeVersion: the battery gauge version
/// - usbVersion: the battery USB version
public init(hardwareRevision: UInt, firmwareVersion: String, gaugeVersion: String,
usbVersion: String) {
self.hardwareRevision = hardwareRevision
self.firmwareVersion = firmwareVersion
self.gaugeVersion = gaugeVersion
self.usbVersion = usbVersion
}
}

// MARK: Objective-C API

/// Instrument that informs a device's battery.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import Foundation

/// Cellular link status.
public enum CellularLinkStatusStatus: CustomStringConvertible, Equatable {
public enum CellularLinkStatus: CustomStringConvertible, Equatable {
/// Interface is down.
case down
/// Interface is up with IP connectivity.
Expand Down Expand Up @@ -79,23 +79,23 @@ public enum CellularLinkStatusError: String, CustomStringConvertible, CaseIterab
public var description: String { rawValue }
}

/// CellularLinkStatus instrument.
/// CellularLink instrument.
///
/// This instrument provides status of cellular link.
///
/// This instrument can be retrieved by:
/// ```
/// device.getInstrument(Instruments.cellularLinkStatus)
/// device.getInstrument(Instruments.cellularLink)
/// ```
public protocol CellularLinkStatus: Instrument {
public protocol CellularLink: Instrument {
/// Celullar link status, or `nil` if not available.
var status: CellularLinkStatusStatus? { get }
var status: CellularLinkStatus? { get }
}

/// :nodoc:
/// Instrument descriptor.
public class CellularLinkStatusDesc: NSObject, InstrumentClassDesc {
public typealias ApiProtocol = CellularLinkStatus
public let uid = InstrumentUid.cellularLinkStatus.rawValue
public class CellularLinkDesc: NSObject, InstrumentClassDesc {
public typealias ApiProtocol = CellularLink
public let uid = InstrumentUid.cellularLink.rawValue
public let parent: ComponentDescriptor? = nil
}
207 changes: 207 additions & 0 deletions GroundSdk/Device/Instrument/CellularSession.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
// Copyright (C) 2022 Parrot Drones SAS
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in
// the documentation and/or other materials provided with the
// distribution.
// * Neither the name of the Parrot Company nor the names
// of its contributors may be used to endorse or promote products
// derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// PARROT COMPANY BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.

import Foundation

/// Cellular session status.
public enum CellularSessionStatus: Hashable, Equatable, CaseIterable, CustomStringConvertible {
/* Modem status. */
public enum Modem: Hashable, Equatable, CaseIterable {
case off
case offline
case updating
case online
case error
}

/* SIM status. */
public enum Sim: Hashable, Equatable, CaseIterable {
case locked
case ready
case absent
case error
}

/* Network registration status. */
public enum Network: Hashable, Equatable, CaseIterable {
case searching
case home
case roaming
case registrationDenied
case activationDenied
}

/* Parrot server connection status. */
public enum Server: Hashable, Equatable, CaseIterable {
case waitApcToken
case connecting
case connected
case unreachableDns
case unreachableConnect
case unreachableAuth
}

/* Drone/controller connection status. */
public enum Connection: Hashable, Equatable, CaseIterable {
case offline
case connecting
case established
case error
case errorCommLink
case errorTimeout
case errorMismatch
}

case unknown
case modem(Modem)
case sim(Sim)
case network(Network)
case server(Server)
case connection(Connection)

public static var allCases: [CellularSessionStatus] {
[CellularSessionStatus.unknown]
+ Modem.allCases.map { CellularSessionStatus.modem($0) }
+ Sim.allCases.map { CellularSessionStatus.sim($0) }
+ Network.allCases.map { CellularSessionStatus.network($0) }
+ Server.allCases.map { CellularSessionStatus.server($0) }
+ Connection.allCases.map { CellularSessionStatus.connection($0) }
}

/// Debug description
public var description: String {
switch self {
case .modem(let sub):
switch sub {
case .off: return "modemOff"
case .offline: return "modemOffline"
case .updating: return "modemUpdating"
case .online: return "modemOnline"
case .error: return "modemError"
}
case .sim(let sub):
switch sub {
case .locked: return "simLocked"
case .ready: return "simReady"
case .absent: return "simAbsent"
case .error: return "simError"
}
case .network(let sub):
switch sub {
case .searching: return "networkSearching"
case .home: return "networkHome"
case .roaming: return "networkRoaming"
case .registrationDenied: return "networkRegistrationDenied"
case .activationDenied: return "networkActivationDenied"
}
case .server(let sub):
switch sub {
case .waitApcToken: return "serverWaitApcToken"
case .connecting: return "serverConnecting"
case .connected: return "serverConnected"
case .unreachableDns: return "serverUnreachableDns"
case .unreachableConnect: return "serverUnreachableConnect"
case .unreachableAuth: return "serverUnreachableAuth"
}
case .connection(let sub):
switch sub {
case .offline: return "connectionOffline"
case .connecting: return "connectionConnecting"
case .established: return "connectionEstablished"
case .error: return "connectionError"
case .errorCommLink: return "connectionErrorCommLink"
case .errorTimeout: return "connectionErrorTimeout"
case .errorMismatch: return "connectionErrorMismatch"
}
case .unknown:
return "unknown"
}
}

/// States indicating a functioning cellular session.
public static var nominalStates: Set<CellularSessionStatus> {
[.modem(.online), .sim(.ready), .network(.home), .network(.roaming),
.server(.connected), .connection(.established)]
}

/// States indicating a transition of the cellular session from a nominal state towards a new
/// nominal state or an new error state.
public static var transitoryStates: Set<CellularSessionStatus> {
[.modem(.off), .modem(.offline), .modem(.updating),
.sim(.locked), .sim(.absent),
.network(.searching),
.server(.waitApcToken), .server(.connecting),
.connection(.offline), .connection(.connecting)]
}

/// States indicating an error on the cellular session.
public static var errorStates: Set<CellularSessionStatus> {
[.modem(.error), .sim(.error),
.network(.registrationDenied), .network(.activationDenied),
.server(.unreachableDns), .server(.unreachableConnect), .server(.unreachableAuth),
.connection(.error), .connection(.errorCommLink), .connection(.errorTimeout),
.connection(.errorMismatch)]
}

/// Whether the receiver is a nominal state.
public var isNominal: Bool {
CellularSessionStatus.nominalStates.contains(self)
}

/// Whether the receiver is an error state.
public var isError: Bool {
CellularSessionStatus.errorStates.contains(self)
}

/// Whether the receiver is a transitory state.
public var isTransitory: Bool {
CellularSessionStatus.transitoryStates.contains(self)
}
}

/// CellularSession instrument.
///
/// This instrument provides status of cellular session.
///
/// This instrument can be retrieved by:
/// ```
/// device.getInstrument(Instruments.cellularSession)
/// ```
public protocol CellularSession: Instrument {
/// Celullar link status, or `nil` if not available.
var status: CellularSessionStatus? { get }
}

/// :nodoc:
/// Instrument descriptor.
public class CellularSessionDesc: NSObject, InstrumentClassDesc {
public typealias ApiProtocol = CellularSession
public let uid = InstrumentUid.cellularSession.rawValue
public let parent: ComponentDescriptor? = nil
}
Loading

0 comments on commit bc98abd

Please sign in to comment.