Skip to content

Commit 5952002

Browse files
Luminaireのリーダーデバイスを指定した時にflashingが実行されない件の修正。
1 parent a0bb9be commit 5952002

1 file changed

Lines changed: 74 additions & 10 deletions

File tree

dConnectDevicePlugin/dConnectDeviceAllJoyn/dConnectDeviceAllJoyn/Sources/Profiles/DPAllJoynLightProfile.mm

Lines changed: 74 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -813,12 +813,44 @@ - (void) didReceivePostLightRequestForLampControllerWithResponse:(DConnectRespon
813813
MsgArg newStateArg("a{sv}", count, newStates);
814814
AJNMessageArgument *newState =
815815
[[AJNMessageArgument alloc] initWithHandle:&newStateArg];
816-
[proxy transitionLampStateWithLampID:_lightId
817-
lampState:newState
818-
transitionPeriod:@10
819-
responseCode:&responseCode
820-
lampID:&ignored];
821816

817+
if (flashing && flashing.count > 0) {
818+
MsgArg offStates[1];
819+
MsgArg offTmp1;
820+
MsgArg offTmp2("b", NO);
821+
offTmp1.Set("{sv}", "OnOff", &offTmp2);
822+
offStates[0] = offTmp1;
823+
MsgArg offStateArg("a{sv}", 1, offStates);
824+
AJNMessageArgument *offState =
825+
[[AJNMessageArgument alloc] initWithHandle:&offStateArg];
826+
827+
for (int i = 0; i < flashing.count; i++) {
828+
int delay = [flashing[i] intValue];
829+
if (i % 2 == 0) {
830+
[proxy transitionLampStateWithLampID:_lightId
831+
lampState:newState
832+
transitionPeriod:@10
833+
responseCode:&responseCode
834+
lampID:&ignored];
835+
sleep(delay / 1000);
836+
} else {
837+
[proxy transitionLampStateWithLampID:_lightId
838+
lampState:offState
839+
transitionPeriod:@10
840+
responseCode:&responseCode
841+
lampID:&ignored];
842+
sleep(delay / 1000);
843+
}
844+
}
845+
} else {
846+
[proxy transitionLampStateWithLampID:_lightId
847+
lampState:newState
848+
transitionPeriod:@10
849+
responseCode:&responseCode
850+
lampID:&ignored];
851+
852+
}
853+
822854
if (!responseCode) {
823855
[response setErrorToUnknownWithMessage:@"Failed to change status."];
824856
}
@@ -1076,11 +1108,43 @@ - (void) didReceivePutLightRequestForLampControllerWithResponse:(DConnectRespons
10761108
MsgArg newStateArg("a{sv}", count, newStates);
10771109
AJNMessageArgument *newState =
10781110
[[AJNMessageArgument alloc] initWithHandle:&newStateArg];
1079-
[proxy transitionLampStateWithLampID:_lightId
1080-
lampState:newState
1081-
transitionPeriod:@10
1082-
responseCode:&responseCode
1083-
lampID:&ignored];
1111+
if (flashing && flashing.count > 0) {
1112+
MsgArg offStates[1];
1113+
MsgArg offTmp1;
1114+
MsgArg offTmp2("b", NO);
1115+
offTmp1.Set("{sv}", "OnOff", &offTmp2);
1116+
offStates[0] = offTmp1;
1117+
MsgArg offStateArg("a{sv}", 1, offStates);
1118+
AJNMessageArgument *offState =
1119+
[[AJNMessageArgument alloc] initWithHandle:&offStateArg];
1120+
1121+
for (int i = 0; i < flashing.count; i++) {
1122+
int delay = [flashing[i] intValue];
1123+
if (i % 2 == 0) {
1124+
[proxy transitionLampStateWithLampID:_lightId
1125+
lampState:newState
1126+
transitionPeriod:@10
1127+
responseCode:&responseCode
1128+
lampID:&ignored];
1129+
sleep(delay / 1000);
1130+
} else {
1131+
[proxy transitionLampStateWithLampID:_lightId
1132+
lampState:offState
1133+
transitionPeriod:@10
1134+
responseCode:&responseCode
1135+
lampID:&ignored];
1136+
sleep(delay / 1000);
1137+
}
1138+
}
1139+
} else {
1140+
[proxy transitionLampStateWithLampID:_lightId
1141+
lampState:newState
1142+
transitionPeriod:@10
1143+
responseCode:&responseCode
1144+
lampID:&ignored];
1145+
1146+
}
1147+
10841148

10851149
if (name) {
10861150
NSString *ignored;

0 commit comments

Comments
 (0)