Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github Optional Shadow Topic Subscription #2039 fix. #3875

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions AWSIoT/AWSIoTDataManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,8 @@ enableVersioning: BOOL, set to NO to disable versioning (default YES)
enableForeignStateUpdateNotifications: BOOL, set to YES to enable foreign state updates (default NO)
enableStaleDiscards: BOOL, set to NO to disable discarding stale updates (default YES)
enableIgnoreDeltas: BOOL, set to YES to disable delta updates (default NO)
enableIgnoreDeletes: BOOL, set to YES to disable delete updates (default NO)
enableIgnoreRejecteds: BOOL, set to YES to disable all/rejected updates (default NO)
QoS: AWSIoTMQTTQoS (default AWSIoTMQTTQoSMessageDeliveryAttemptedAtMostOnce)
shadowOperationTimeoutSeconds: double, device shadow operation timeout (default 10.0)

Expand Down
29 changes: 25 additions & 4 deletions AWSIoT/AWSIoTDataManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ @interface AWSIoTDataShadow:NSObject
@property(atomic, assign) BOOL enableStaleDiscards;
@property(atomic, assign) BOOL enableIgnoreDeltas;
@property(atomic, assign) BOOL enableIgnoreDocuments;
@property(atomic, assign) BOOL enableIgnoreDeletes;
@property(atomic, assign) BOOL enableIgnoreRejecteds;
@property(atomic, assign) UInt32 version;
@property(nonatomic, strong) NSString *clientToken;
@property(atomic, assign) AWSIoTMQTTQoS qos;
Expand All @@ -73,6 +75,8 @@ - (instancetype)initWithName:(NSString *)name
discardStaleUpdates:(BOOL)enableStaleDiscards
discardDeltas:(BOOL)enableIgnoreDeltas
discardDocuments:(BOOL)enableIgnoreDocuments
discardDeletes:(BOOL)enableIgnoreDeletes
discardRejecteds:(BOOL)enableIgnoreRejecteds
updateOnForeignChanges:(BOOL)enableForeignStateUpdateNotifications
operationTimeout:(NSTimeInterval)operationTimeoutSeconds
QoS:(AWSIoTMQTTQoS)qos
Expand All @@ -85,6 +89,8 @@ - (instancetype)initWithName:(NSString *)name
_enableStaleDiscards = enableStaleDiscards;
_enableIgnoreDeltas = enableIgnoreDeltas;
_enableIgnoreDocuments = enableIgnoreDocuments;
_enableIgnoreDeletes = enableIgnoreDeletes;
_enableIgnoreRejecteds = enableIgnoreRejecteds;
_enableForeignStateUpdateNotifications = enableForeignStateUpdateNotifications;
_callback = callback;
_operationTimeout = operationTimeoutSeconds;
Expand Down Expand Up @@ -1218,6 +1224,8 @@ - (BOOL) registerWithShadow:(NSString *)name
discardStaleUpdates:YES
discardDeltas:NO
discardDocuments:NO
discardDeletes:NO
discardRejecteds:NO
updateOnForeignChanges:NO
operationTimeout:10.0
QoS:AWSIoTMQTTQoSMessageDeliveryAttemptedAtMostOnce
Expand Down Expand Up @@ -1257,6 +1265,14 @@ - (BOOL) registerWithShadow:(NSString *)name
if (numberOptionValue != nil) {
shadow.enableIgnoreDocuments = [numberOptionValue integerValue];
}
numberOptionValue = [options valueForKey:@"enableIgnoreDeletes"];
if (numberOptionValue != nil) {
shadow.enableIgnoreDeletes = [numberOptionValue integerValue];
}
numberOptionValue = [options valueForKey:@"enableIgnoreRejecteds"];
if (numberOptionValue != nil) {
shadow.enableIgnoreRejecteds = [numberOptionValue integerValue];
}
numberOptionValue = [options valueForKey:@"QoS"];
if (numberOptionValue != nil) {
shadow.qos = [numberOptionValue integerValue];
Expand All @@ -1276,12 +1292,17 @@ - (BOOL) registerWithShadow:(NSString *)name
operations:@[[NSNumber numberWithInteger:AWSIoTShadowOperationTypeUpdate]]
statii:@[[NSNumber numberWithInteger:AWSIoTShadowOperationStatusTypeDocuments]] ];
}
if (shadow.enableIgnoreDeletes == NO) {
NSArray * statii = shadow.enableIgnoreRejecteds ? @[[NSNumber numberWithInteger:AWSIoTShadowOperationStatusTypeAccepted]] : @[[NSNumber numberWithInteger:AWSIoTShadowOperationStatusTypeAccepted], [NSNumber numberWithInteger:AWSIoTShadowOperationStatusTypeRejected]];
[self createSubscriptionsForShadow:shadow
operations:@[[NSNumber numberWithInteger:AWSIoTShadowOperationTypeDelete]]
statii:statii];
}
NSArray * statii = shadow.enableIgnoreRejecteds ? @[[NSNumber numberWithInteger:AWSIoTShadowOperationStatusTypeAccepted]] : @[[NSNumber numberWithInteger:AWSIoTShadowOperationStatusTypeAccepted], [NSNumber numberWithInteger:AWSIoTShadowOperationStatusTypeRejected]];
[self createSubscriptionsForShadow:shadow
operations:@[[NSNumber numberWithInteger:AWSIoTShadowOperationTypeUpdate],
[NSNumber numberWithInteger:AWSIoTShadowOperationTypeGet],
[NSNumber numberWithInteger:AWSIoTShadowOperationTypeDelete]]
statii:@[[NSNumber numberWithInteger:AWSIoTShadowOperationStatusTypeAccepted],
[NSNumber numberWithInteger:AWSIoTShadowOperationStatusTypeRejected]]];
[NSNumber numberWithInteger:AWSIoTShadowOperationTypeGet]]
statii:statii];
//
// Persistently subscribe to the special topics for this shadow.
//
Expand Down