33 changed files with 1569 additions and 629 deletions
File diff suppressed because it is too large
@ -0,0 +1,40 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mUplinkMsgHandler; |
|||
import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClient; |
|||
|
|||
public abstract class AbstractTbLwM2MRequestCallback<T> implements DownlinkRequestCallback<T> { |
|||
|
|||
protected final LwM2mUplinkMsgHandler handler; |
|||
protected final LwM2mClient client; |
|||
|
|||
protected AbstractTbLwM2MRequestCallback(LwM2mUplinkMsgHandler handler, LwM2mClient client) { |
|||
this.handler = handler; |
|||
this.client = client; |
|||
} |
|||
|
|||
@Override |
|||
public void onValidationError(String msg) { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void onError(Exception e) { |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import lombok.Getter; |
|||
|
|||
public abstract class AbstractTbLwM2MTargetedDownlinkRequest<T> implements TbLwM2MDownlinkRequest<T>, HasVersionedId { |
|||
|
|||
@Getter |
|||
private final String versionedId; |
|||
@Getter |
|||
private final long timeout; |
|||
|
|||
public AbstractTbLwM2MTargetedDownlinkRequest(String versionedId, long timeout) { |
|||
this.versionedId = versionedId; |
|||
this.timeout = timeout; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import org.eclipse.leshan.core.request.ContentFormat; |
|||
|
|||
public interface HasContentFormat { |
|||
|
|||
ContentFormat getContentFormat(); |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil; |
|||
|
|||
public interface HasVersionedId { |
|||
|
|||
String getVersionedId(); |
|||
|
|||
default String getObjectId(){ |
|||
return LwM2mTransportUtil.fromVersionedIdToObjectId(getVersionedId()); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mUplinkMsgHandler; |
|||
import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClient; |
|||
|
|||
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LOG_LW2M_INFO; |
|||
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.OBSERVE_CANCEL; |
|||
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.OBSERVE_CANCEL_ALL; |
|||
|
|||
public class TbLwM2MCancelAllObserveRequestCallback extends AbstractTbLwM2MRequestCallback<Integer> { |
|||
|
|||
public TbLwM2MCancelAllObserveRequestCallback(LwM2mUplinkMsgHandler handler, LwM2mClient client) { |
|||
super(handler, client); |
|||
} |
|||
|
|||
@Override |
|||
public void onSuccess(Integer canceledSubscriptionsCount) { |
|||
String observeCancelMsg = String.format("%s: type operation %s paths: count: %d", LOG_LW2M_INFO, OBSERVE_CANCEL_ALL.name(), canceledSubscriptionsCount); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import lombok.Builder; |
|||
import lombok.Getter; |
|||
import org.eclipse.leshan.core.response.CancelObservationResponse; |
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil; |
|||
|
|||
public class TbLwM2MCancelAllRequest implements TbLwM2MDownlinkRequest<Integer> { |
|||
|
|||
@Getter |
|||
private final long timeout; |
|||
|
|||
@Builder |
|||
private TbLwM2MCancelAllRequest(long timeout) { |
|||
this.timeout = timeout; |
|||
} |
|||
|
|||
@Override |
|||
public LwM2mTransportUtil.LwM2mTypeOper getType() { |
|||
return LwM2mTransportUtil.LwM2mTypeOper.OBSERVE_CANCEL_ALL; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import lombok.Builder; |
|||
import org.eclipse.leshan.core.response.CancelObservationResponse; |
|||
import org.eclipse.leshan.core.response.ReadResponse; |
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil; |
|||
|
|||
public class TbLwM2MCancelObserveRequest extends AbstractTbLwM2MTargetedDownlinkRequest<Integer> { |
|||
|
|||
@Builder |
|||
private TbLwM2MCancelObserveRequest(String versionedId, long timeout) { |
|||
super(versionedId, timeout); |
|||
} |
|||
|
|||
@Override |
|||
public LwM2mTransportUtil.LwM2mTypeOper getType() { |
|||
return LwM2mTransportUtil.LwM2mTypeOper.OBSERVE_CANCEL; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mUplinkMsgHandler; |
|||
import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClient; |
|||
|
|||
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LOG_LW2M_INFO; |
|||
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.OBSERVE_CANCEL; |
|||
|
|||
public class TbLwM2MCancelObserveRequestCallback extends AbstractTbLwM2MRequestCallback<Integer> { |
|||
|
|||
private final String versionedId; |
|||
|
|||
public TbLwM2MCancelObserveRequestCallback(LwM2mUplinkMsgHandler handler, LwM2mClient client, String versionedId) { |
|||
super(handler, client); |
|||
this.versionedId = versionedId; |
|||
} |
|||
|
|||
@Override |
|||
public void onSuccess(Integer canceledSubscriptionsCount) { |
|||
String observeCancelMsg = String.format("%s: type operation %s paths: %s count: %d", LOG_LW2M_INFO, OBSERVE_CANCEL.name(), versionedId, canceledSubscriptionsCount); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import lombok.Builder; |
|||
import lombok.Getter; |
|||
import org.eclipse.leshan.core.response.ReadResponse; |
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil; |
|||
|
|||
public class TbLwM2MDeleteRequest extends AbstractTbLwM2MTargetedDownlinkRequest<ReadResponse> { |
|||
|
|||
@Builder |
|||
private TbLwM2MDeleteRequest(String versionedId, long timeout) { |
|||
super(versionedId, timeout); |
|||
} |
|||
|
|||
@Override |
|||
public LwM2mTransportUtil.LwM2mTypeOper getType() { |
|||
return LwM2mTransportUtil.LwM2mTypeOper.DELETE; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import org.eclipse.leshan.core.response.DeleteResponse; |
|||
import org.eclipse.leshan.core.response.ExecuteResponse; |
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mUplinkMsgHandler; |
|||
import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClient; |
|||
|
|||
public class TbLwM2MDeleteRequestCallback extends AbstractTbLwM2MRequestCallback<DeleteResponse> { |
|||
|
|||
private final String targetId; |
|||
|
|||
public TbLwM2MDeleteRequestCallback(LwM2mUplinkMsgHandler handler, LwM2mClient client, String targetId) { |
|||
super(handler, client); |
|||
this.targetId = targetId; |
|||
} |
|||
|
|||
@Override |
|||
public void onSuccess(DeleteResponse response) { |
|||
//TODO: separate callback wrapper for the RPC calls.
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import lombok.Builder; |
|||
import lombok.Getter; |
|||
import org.eclipse.leshan.core.response.DiscoverResponse; |
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil; |
|||
|
|||
public class TbLwM2MDiscoverAllRequest implements TbLwM2MDownlinkRequest<String> { |
|||
|
|||
@Getter |
|||
private final long timeout; |
|||
|
|||
@Builder |
|||
private TbLwM2MDiscoverAllRequest(long timeout) { |
|||
this.timeout = timeout; |
|||
} |
|||
|
|||
@Override |
|||
public LwM2mTransportUtil.LwM2mTypeOper getType() { |
|||
return LwM2mTransportUtil.LwM2mTypeOper.DISCOVER_ALL; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import org.eclipse.leshan.core.response.DeleteResponse; |
|||
import org.eclipse.leshan.core.response.DiscoverResponse; |
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mUplinkMsgHandler; |
|||
import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClient; |
|||
|
|||
public class TbLwM2MDiscoverCallback extends AbstractTbLwM2MRequestCallback<DiscoverResponse> { |
|||
|
|||
private final String targetId; |
|||
|
|||
public TbLwM2MDiscoverCallback(LwM2mUplinkMsgHandler handler, LwM2mClient client, String targetId) { |
|||
super(handler, client); |
|||
this.targetId = targetId; |
|||
} |
|||
|
|||
@Override |
|||
public void onSuccess(DiscoverResponse response) { |
|||
//TODO: separate callback wrapper for the RPC calls.
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import lombok.Builder; |
|||
import org.eclipse.leshan.core.response.DiscoverResponse; |
|||
import org.eclipse.leshan.core.response.ReadResponse; |
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil; |
|||
|
|||
public class TbLwM2MDiscoverRequest extends AbstractTbLwM2MTargetedDownlinkRequest<DiscoverResponse> { |
|||
|
|||
@Builder |
|||
private TbLwM2MDiscoverRequest(String versionedId, long timeout) { |
|||
super(versionedId, timeout); |
|||
} |
|||
|
|||
@Override |
|||
public LwM2mTransportUtil.LwM2mTypeOper getType() { |
|||
return LwM2mTransportUtil.LwM2mTypeOper.DISCOVER; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil; |
|||
|
|||
public interface TbLwM2MDownlinkRequest<T> { |
|||
|
|||
LwM2mTransportUtil.LwM2mTypeOper getType(); |
|||
|
|||
long getTimeout(); |
|||
|
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import lombok.Builder; |
|||
import lombok.Getter; |
|||
import org.eclipse.leshan.core.response.ReadResponse; |
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil; |
|||
|
|||
public class TbLwM2MExecuteRequest extends AbstractTbLwM2MTargetedDownlinkRequest<ReadResponse> { |
|||
|
|||
@Getter |
|||
private final Object params; |
|||
|
|||
@Builder |
|||
private TbLwM2MExecuteRequest(String versionedId, long timeout, Object params) { |
|||
super(versionedId, timeout); |
|||
this.params = params; |
|||
} |
|||
|
|||
@Override |
|||
public LwM2mTransportUtil.LwM2mTypeOper getType() { |
|||
return LwM2mTransportUtil.LwM2mTypeOper.EXECUTE; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import org.eclipse.leshan.core.response.ExecuteResponse; |
|||
import org.eclipse.leshan.core.response.ReadResponse; |
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mUplinkMsgHandler; |
|||
import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClient; |
|||
|
|||
public class TbLwM2MExecuteRequestCallback extends AbstractTbLwM2MRequestCallback<ExecuteResponse> { |
|||
|
|||
private final String targetId; |
|||
|
|||
public TbLwM2MExecuteRequestCallback(LwM2mUplinkMsgHandler handler, LwM2mClient client, String targetId) { |
|||
super(handler, client); |
|||
this.targetId = targetId; |
|||
} |
|||
|
|||
@Override |
|||
public void onSuccess(ExecuteResponse response) { |
|||
//TODO: separate callback wrapper for the RPC calls.
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import lombok.Builder; |
|||
import lombok.Getter; |
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil; |
|||
|
|||
import java.util.Set; |
|||
|
|||
public class TbLwM2MObserveAllRequest implements TbLwM2MDownlinkRequest<Set<String>> { |
|||
|
|||
@Getter |
|||
private final long timeout; |
|||
|
|||
@Builder |
|||
private TbLwM2MObserveAllRequest(long timeout) { |
|||
this.timeout = timeout; |
|||
} |
|||
|
|||
@Override |
|||
public LwM2mTransportUtil.LwM2mTypeOper getType() { |
|||
return LwM2mTransportUtil.LwM2mTypeOper.OBSERVE_READ_ALL; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import lombok.Builder; |
|||
import lombok.Getter; |
|||
import org.eclipse.leshan.core.request.ContentFormat; |
|||
import org.eclipse.leshan.core.response.ObserveResponse; |
|||
import org.eclipse.leshan.core.response.ReadResponse; |
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil; |
|||
|
|||
public class TbLwM2MObserveRequest extends AbstractTbLwM2MTargetedDownlinkRequest<ObserveResponse> implements HasContentFormat { |
|||
|
|||
@Getter |
|||
private final ContentFormat contentFormat; |
|||
|
|||
@Builder |
|||
private TbLwM2MObserveRequest(String versionedId, long timeout, ContentFormat contentFormat) { |
|||
super(versionedId, timeout); |
|||
this.contentFormat = contentFormat; |
|||
} |
|||
|
|||
@Override |
|||
public LwM2mTransportUtil.LwM2mTypeOper getType() { |
|||
return LwM2mTransportUtil.LwM2mTypeOper.OBSERVE; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import org.eclipse.leshan.core.response.ObserveResponse; |
|||
import org.eclipse.leshan.core.response.ReadResponse; |
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mUplinkMsgHandler; |
|||
import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClient; |
|||
|
|||
public class TbLwM2MObserveRequestCallback extends AbstractTbLwM2MRequestCallback<ObserveResponse> { |
|||
|
|||
private final String targetId; |
|||
|
|||
public TbLwM2MObserveRequestCallback(LwM2mUplinkMsgHandler handler, LwM2mClient client, String targetId) { |
|||
super(handler, client); |
|||
this.targetId = targetId; |
|||
} |
|||
|
|||
@Override |
|||
public void onSuccess(ObserveResponse response) { |
|||
//TODO: handle the response (at least log to telemetry)
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import lombok.Builder; |
|||
import lombok.Getter; |
|||
import org.eclipse.leshan.core.request.ContentFormat; |
|||
import org.eclipse.leshan.core.response.ReadResponse; |
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil; |
|||
|
|||
public class TbLwM2MReadRequest extends AbstractTbLwM2MTargetedDownlinkRequest<ReadResponse> implements HasContentFormat { |
|||
|
|||
@Getter |
|||
private final ContentFormat contentFormat; |
|||
|
|||
@Builder |
|||
private TbLwM2MReadRequest(String versionedId, long timeout, ContentFormat contentFormat) { |
|||
super(versionedId, timeout); |
|||
this.contentFormat = contentFormat; |
|||
} |
|||
|
|||
@Override |
|||
public LwM2mTransportUtil.LwM2mTypeOper getType() { |
|||
return LwM2mTransportUtil.LwM2mTypeOper.READ; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import org.eclipse.leshan.core.response.ReadResponse; |
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mUplinkMsgHandler; |
|||
import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClient; |
|||
|
|||
public class TbLwM2MReadRequestCallback extends AbstractTbLwM2MRequestCallback<ReadResponse> { |
|||
|
|||
private final String targetId; |
|||
|
|||
public TbLwM2MReadRequestCallback(LwM2mUplinkMsgHandler handler, LwM2mClient client, String targetId) { |
|||
super(handler, client); |
|||
this.targetId = targetId; |
|||
} |
|||
|
|||
@Override |
|||
public void onSuccess(ReadResponse response) { |
|||
//TODO: separate callback wrapper for the RPC calls.
|
|||
handler.onUpdateValueAfterReadResponse(client.getRegistration(), targetId, response, null); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import org.eclipse.leshan.core.response.ReadResponse; |
|||
import org.eclipse.leshan.core.response.WriteAttributesResponse; |
|||
import org.eclipse.leshan.core.response.WriteResponse; |
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mUplinkMsgHandler; |
|||
import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClient; |
|||
|
|||
public class TbLwM2MWriteAttributesCallback extends AbstractTbLwM2MRequestCallback<WriteAttributesResponse> { |
|||
|
|||
private final String targetId; |
|||
|
|||
public TbLwM2MWriteAttributesCallback(LwM2mUplinkMsgHandler handler, LwM2mClient client, String targetId) { |
|||
super(handler, client); |
|||
this.targetId = targetId; |
|||
} |
|||
|
|||
@Override |
|||
public void onSuccess(WriteAttributesResponse response) { |
|||
//TODO: separate callback wrapper for the RPC calls.
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import lombok.Builder; |
|||
import lombok.Getter; |
|||
import org.eclipse.leshan.core.request.ContentFormat; |
|||
import org.eclipse.leshan.core.response.ObserveResponse; |
|||
import org.eclipse.leshan.core.response.WriteAttributesResponse; |
|||
import org.thingsboard.server.common.data.device.data.lwm2m.ObjectAttributes; |
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil; |
|||
|
|||
public class TbLwM2MWriteAttributesRequest extends AbstractTbLwM2MTargetedDownlinkRequest<WriteAttributesResponse> { |
|||
|
|||
@Getter |
|||
private final ObjectAttributes attributes; |
|||
|
|||
@Builder |
|||
private TbLwM2MWriteAttributesRequest(String versionedId, long timeout, ObjectAttributes attributes) { |
|||
super(versionedId, timeout); |
|||
this.attributes = attributes; |
|||
} |
|||
|
|||
@Override |
|||
public LwM2mTransportUtil.LwM2mTypeOper getType() { |
|||
return LwM2mTransportUtil.LwM2mTypeOper.WRITE_ATTRIBUTES; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import org.eclipse.leshan.core.response.WriteAttributesResponse; |
|||
import org.eclipse.leshan.core.response.WriteResponse; |
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mUplinkMsgHandler; |
|||
import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClient; |
|||
|
|||
public class TbLwM2MWriteReplaceCallback extends AbstractTbLwM2MRequestCallback<WriteResponse> { |
|||
|
|||
private final String targetId; |
|||
|
|||
public TbLwM2MWriteReplaceCallback(LwM2mUplinkMsgHandler handler, LwM2mClient client, String targetId) { |
|||
super(handler, client); |
|||
this.targetId = targetId; |
|||
} |
|||
|
|||
@Override |
|||
public void onSuccess(WriteResponse response) { |
|||
//TODO: separate callback wrapper for the RPC calls.
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import lombok.Builder; |
|||
import lombok.Getter; |
|||
import org.eclipse.leshan.core.response.WriteAttributesResponse; |
|||
import org.eclipse.leshan.core.response.WriteResponse; |
|||
import org.thingsboard.server.common.data.device.data.lwm2m.ObjectAttributes; |
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil; |
|||
|
|||
public class TbLwM2MWriteReplaceRequest extends AbstractTbLwM2MTargetedDownlinkRequest<WriteResponse> { |
|||
|
|||
@Getter |
|||
private final Object value; |
|||
|
|||
@Builder |
|||
private TbLwM2MWriteReplaceRequest(String versionedId, long timeout, Object value) { |
|||
super(versionedId, timeout); |
|||
this.value = value; |
|||
} |
|||
|
|||
@Override |
|||
public LwM2mTransportUtil.LwM2mTypeOper getType() { |
|||
return LwM2mTransportUtil.LwM2mTypeOper.WRITE_REPLACE; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.transport.lwm2m.server.downlink; |
|||
|
|||
import lombok.Builder; |
|||
import lombok.Getter; |
|||
import org.eclipse.leshan.core.request.ContentFormat; |
|||
import org.eclipse.leshan.core.response.WriteResponse; |
|||
import org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil; |
|||
|
|||
public class TbLwM2MWriteUpdateRequest extends AbstractTbLwM2MTargetedDownlinkRequest<WriteResponse> { |
|||
|
|||
@Getter |
|||
private final Object value; |
|||
@Getter |
|||
private final ContentFormat objectContentFormat; |
|||
|
|||
@Builder |
|||
private TbLwM2MWriteUpdateRequest(String versionedId, long timeout, Object value, ContentFormat objectContentFormat) { |
|||
super(versionedId, timeout); |
|||
this.value = value; |
|||
this.objectContentFormat = objectContentFormat; |
|||
} |
|||
|
|||
@Override |
|||
public LwM2mTransportUtil.LwM2mTypeOper getType() { |
|||
return LwM2mTransportUtil.LwM2mTypeOper.WRITE_UPDATE; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
Loading…
Reference in new issue