Skip to content

Commit 10cbd4f

Browse files
Merge pull request #148 from TakayukiHoshi1984/modify_alljoyn_change_name_and_flashing
Luminaireを操作するときのAllJoynデバイスプラグインの挙動修正
2 parents 4bf47c1 + aa76031 commit 10cbd4f

2 files changed

Lines changed: 79 additions & 14 deletions

File tree

dConnectDevicePlugin/dConnectDeviceAllJoyn/dConnectDeviceAllJoyn/Sources/DPAllJoynHandler.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ - (void) updateManageServices: (BOOL) onlineForSet {
436436
for (DPAllJoynServiceEntity *serviceEntity in [self.discoveredAllJoynServices allValues]) {
437437
DConnectService *service = [_serviceProvider service: serviceEntity.appId];
438438
if (service) {
439+
[service setName:serviceEntity.serviceName];
439440
[service setOnline: YES];
440441
} else {
441442
service = [[DPAllJoynService alloc] initWithServiceId:serviceEntity.appId

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

Lines changed: 78 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -672,10 +672,10 @@ - (void) didReceivePostLightRequestForSingleLampWithResponse:(DConnectResponseMe
672672
int delay = [flashing[i] intValue];
673673
if (i % 2 == 0) {
674674
proxy.OnOff = YES;
675-
sleep(delay / 1000);
675+
usleep(delay * 1000);
676676
} else {
677677
proxy.OnOff = NO;
678-
sleep(delay / 1000);
678+
usleep(delay * 1000);
679679
}
680680
}
681681
}
@@ -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+
usleep(delay * 1000);
836+
} else {
837+
[proxy transitionLampStateWithLampID:_lightId
838+
lampState:offState
839+
transitionPeriod:@10
840+
responseCode:&responseCode
841+
lampID:&ignored];
842+
usleep(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
}
@@ -937,10 +969,10 @@ - (void) didReceivePutLightRequestForSingleLampWithResponse:(DConnectResponseMes
937969
int delay = [flashing[i] intValue];
938970
if (i % 2 == 0) {
939971
proxy.OnOff = YES;
940-
sleep(delay / 1000);
972+
usleep(delay * 1000);
941973
} else {
942974
proxy.OnOff = NO;
943-
sleep(delay / 1000);
975+
usleep(delay * 1000);
944976
}
945977
}
946978
}
@@ -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+
usleep(delay * 1000);
1130+
} else {
1131+
[proxy transitionLampStateWithLampID:_lightId
1132+
lampState:offState
1133+
transitionPeriod:@10
1134+
responseCode:&responseCode
1135+
lampID:&ignored];
1136+
usleep(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)