/*\r
- * //******************************************************************\r
- * //\r
- * // Copyright 2015 Intel Corporation.\r
- * //\r
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
- * //\r
- * // Licensed under the Apache License, Version 2.0 (the "License");\r
- * // you may not use this file except in compliance with the License.\r
- * // You may obtain a copy of the License at\r
- * //\r
- * // http://www.apache.org/licenses/LICENSE-2.0\r
- * //\r
- * // Unless required by applicable law or agreed to in writing, software\r
- * // distributed under the License is distributed on an "AS IS" BASIS,\r
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * // See the License for the specific language governing permissions and\r
- * // limitations under the License.\r
- * //\r
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ *******************************************************************\r
+ *\r
+ * Copyright 2015 Intel Corporation.\r
+ *\r
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
*/\r
\r
apply plugin: 'com.android.library'\r
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
}
}
}
-}
\ No newline at end of file
+}
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
return CT_DEFAULT;
}
}
-}
\ No newline at end of file
+}
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
* After creating instances of OcHeaderOptions, use setHeaderOptions API
* (in OcResource) to set header Options.
* NOTE: optionId is an integer value which MUST be within
- * range of 2048 to 3000 inclusive of lower and upper bound.
+ * range of 2048 to 3000 inclusive of lower and upper bound
+ * except for a few options including If-Match with empty(num : 1),
+ * If-None-Match(num : 5), Location-Path(num : 8),
+ * Location-Query(num : 20) CoAP option.
* HeaderOption instance creation fails if above condition is not satisfied.
*/
public class OcHeaderOption {
public static final int MIN_HEADER_OPTION_ID = 2048;
public static final int MAX_HEADER_OPTION_ID = 3000;
+ public static final int IF_MATCH_OPTION_ID = 1;
+ public static final int IF_NONE_MATCH_OPTION_ID = 5;
+ public static final int LOCATION_PATH_OPTION_ID = 8;
+ public static final int LOCATION_QUERY_OPTION_ID = 20;
private int mOptionId;
private String mOptionData;
public OcHeaderOption(int optionId, String optionData) {
- if (!(optionId >= MIN_HEADER_OPTION_ID && optionId <= MAX_HEADER_OPTION_ID)) {
+ if (!(optionId >= MIN_HEADER_OPTION_ID && optionId <= MAX_HEADER_OPTION_ID)
+ && optionId != IF_MATCH_OPTION_ID
+ && optionId != IF_NONE_MATCH_OPTION_ID
+ && optionId != LOCATION_PATH_OPTION_ID
+ && optionId != LOCATION_QUERY_OPTION_ID) {
throw new InvalidParameterException("Option ID range is invalid");
}
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
private long mNativeHandle;
private boolean mNativeNeedsDelete;
-}
\ No newline at end of file
+}
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.util.Log;
public class CaEdrInterface {
private static Context mContext;
IntentFilter filter = new IntentFilter();
filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
+ filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
mContext.registerReceiver(mReceiver, filter);
return filter;
}
private native static void caEdrBondStateChangedCallback(String addr);
+ private native static void caEdrConnectionStateChangedCallback(String addr, int isConnected);
+
private static final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
}
}
}
+
+ if (action != null && action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED)) {
+ BluetoothDevice device
+ = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+ if (BluetoothDevice.DEVICE_TYPE_CLASSIC == device.getType())
+ {
+ caEdrConnectionStateChangedCallback(device.getAddress(), 0);
+ }
+ }
}
};
}
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.ca;
private static native void caBtPairingStartScan();
private static native void caBtPairingStopScan();
private static native void caBtPairingCreateBond(BluetoothDevice device);
-}
\ No newline at end of file
+}
private static BroadcastReceiver mReceiver = new BroadcastReceiver() {\r
@Override\r
public void onReceive(Context context, Intent intent) {\r
- if (intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,\r
- WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_DISABLED) {\r
- caIpStateDisabled();\r
- } else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {\r
+ if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {\r
ConnectivityManager manager = (ConnectivityManager)\r
mContext.getSystemService(Context.CONNECTIVITY_SERVICE);\r
- NetworkInfo nwInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);\r
+ NetworkInfo wifiInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);\r
+ NetworkInfo mobileInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);\r
\r
- if(nwInfo.isConnected()) {\r
+ if (mobileInfo != null && mobileInfo.isConnected() || wifiInfo.isConnected()) {\r
caIpStateEnabled();\r
+ } else {\r
+ caIpStateDisabled();\r
}\r
}\r
\r
private native static void caLeGattServicesDiscoveredCallback(BluetoothGatt gatt, int status);
+ private native static void caLeGattNWServicesDiscoveredCallback(BluetoothGatt gatt,
+ int status);
+
+ private native static void caLeGattNWDescriptorWriteCallback(BluetoothGatt gatt, int status);
+
private native static void caLeGattCharacteristicWriteCallback(
BluetoothGatt gatt, byte[] data, int status);
caLeGattServicesDiscoveredCallback(gatt, status);
caManagerLeServicesDiscoveredCallback(gatt, status);
+ caLeGattNWServicesDiscoveredCallback(gatt, status);
}
@Override
super.onDescriptorWrite(gatt, descriptor, status);
caLeGattDescriptorWriteCallback(gatt, status);
+ caLeGattNWDescriptorWriteCallback(gatt, status);
}
@Override
/*\r
- * //******************************************************************\r
- * //\r
- * // Copyright 2014 Intel Corporation.\r
- * //\r
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
- * //\r
- * // Licensed under the Apache License, Version 2.0 (the "License");\r
- * // you may not use this file except in compliance with the License.\r
- * // You may obtain a copy of the License at\r
- * //\r
- * // http://www.apache.org/licenses/LICENSE-2.0\r
- * //\r
- * // Unless required by applicable law or agreed to in writing, software\r
- * // distributed under the License is distributed on an "AS IS" BASIS,\r
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * // See the License for the specific language governing permissions and\r
- * // limitations under the License.\r
- * //\r
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ *******************************************************************\r
+ *\r
+ * Copyright 2014 Intel Corporation.\r
+ *\r
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
*/\r
\r
// Top-level build file where you can add configuration options common to all sub-projects/modules.\r
/*\r
- * //******************************************************************\r
- * //\r
- * // Copyright 2015 Intel Corporation.\r
- * //\r
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
- * //\r
- * // Licensed under the Apache License, Version 2.0 (the "License");\r
- * // you may not use this file except in compliance with the License.\r
- * // You may obtain a copy of the License at\r
- * //\r
- * // http://www.apache.org/licenses/LICENSE-2.0\r
- * //\r
- * // Unless required by applicable law or agreed to in writing, software\r
- * // distributed under the License is distributed on an "AS IS" BASIS,\r
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * // See the License for the specific language governing permissions and\r
- * // limitations under the License.\r
- * //\r
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ *******************************************************************\r
+ *\r
+ * Copyright 2015 Intel Corporation.\r
+ *\r
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
*/\r
\r
include ':base'\r
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
private static String TAG = "FridgeClient: ";
private TextView mConsoleTextView;
-}
\ No newline at end of file
+}
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
});
Log.i(TAG, text);
}
-}
\ No newline at end of file
+}
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
intent.putExtra(Resource.MESSAGE, msg);
mContext.sendBroadcast(intent);
}
-}
\ No newline at end of file
+}
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
mRightDoor.bindTo(mFridge.getHandle());
mRandomDoor.bindTo(mFridge.getHandle());
}
-}
\ No newline at end of file
+}
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
public static final int SUCCESS = 200;
public static final String INTENT = "org.iotivity.base.examples.fridgegroupserver";
public static final String MESSAGE = "message";
-}
\ No newline at end of file
+}
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples.fridgeserver;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples.fridgeserver;
intent.putExtra(FridgeServer.MESSAGE, msg);
mContext.sendBroadcast(intent);
}
-}
\ No newline at end of file
+}
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples.fridgeserver;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples.fridgeserver;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples.fridgeserver;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples.fridgeserver;
}
public static final int SUCCESS = 200;
-}
\ No newline at end of file
+}
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
}
});
}
-}
\ No newline at end of file
+}
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
}
});
}
-}
\ No newline at end of file
+}
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
}
});
}
-}
\ No newline at end of file
+}
--- /dev/null
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 21
+ buildToolsVersion "20.0.0"
+
+ defaultConfig {
+ applicationId "org.iotivity.base.examples.simplebase"
+ minSdkVersion 21
+ targetSdkVersion 21
+ versionCode 1
+ versionName "1.0"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+ lintOptions {
+ abortOnError false
+ }
+}
+repositories {
+ flatDir {
+ dirs "../../android_api/base/build/outputs/aar/"
+ }
+}
+
+try {
+ dependencies {
+ compile files('libs/android-support-v4.jar')
+ compile ":iotivity-base-${TARGET_ARCH}-${RELEASE}@aar"
+ }
+} catch (all) {
+ print "${ERROR_MSG}"
+ assert all
+}
--- /dev/null
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /home/iotivity/sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<module external.linked.project.id=":simplebase" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="examples" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
+ <component name="FacetManager">
+ <facet type="android-gradle" name="Android-Gradle">
+ <configuration>
+ <option name="GRADLE_PROJECT_PATH" value=":simplebase" />
+ </configuration>
+ </facet>
+ <facet type="android" name="Android">
+ <configuration>
+ <option name="SELECTED_BUILD_VARIANT" value="debug" />
+ <option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
+ <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
+ <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
+ <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
+ <option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
+ <afterSyncTasks>
+ <task>generateDebugAndroidTestSources</task>
+ <task>generateDebugSources</task>
+ </afterSyncTasks>
+ <option name="ALLOW_USER_CONFIGURATION" value="false" />
+ <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
+ <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
+ <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
+ <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
+ </configuration>
+ </facet>
+ </component>
+ <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
+ <output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
+ <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
+ <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
+ <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
+ <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
+ <sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
+ <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
+ <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
+ <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
+ <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
+ <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
+ <sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
+ <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
+ <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
+ <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
+ <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
+ <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
+ <sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
+ <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
+ <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
+ <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
+ <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
+ <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
+ <excludeFolder url="file://$MODULE_DIR$/build/reports" />
+ <excludeFolder url="file://$MODULE_DIR$/build/test-results" />
+ <excludeFolder url="file://$MODULE_DIR$/build/tmp" />
+ </content>
+ <orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" exported="" name="iotivity-base-armeabi-release-" level="project" />
+ <orderEntry type="library" exported="" name="android-android-21" level="project" />
+ </component>
+</module>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.iotivity.base.examples" >
+ <uses-feature android:name="android.hardware.nfc" />
+ <uses-feature
+ android:name="android.hardware.bluetooth_le"
+ android:required="true" />
+
+ <uses-permission android:name="android.permission.BLUETOOTH" />
+ <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+ <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
+ <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+ <uses-permission android:name="android.permission.NFC" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@mipmap/iotivityicon"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:screenOrientation="portrait"
+ android:name=".SimpleBase"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
--- /dev/null
+/*
+ * ******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
+
+import android.app.Activity;
+import android.app.Fragment;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothGatt;
+import android.bluetooth.BluetoothManager;
+import android.bluetooth.le.BluetoothLeScanner;
+import android.bluetooth.le.ScanCallback;
+import android.bluetooth.le.ScanFilter;
+import android.bluetooth.le.ScanResult;
+import android.bluetooth.le.ScanSettings;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.ParcelUuid;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.ListView;
+
+import org.iotivity.base.ModeType;
+import org.iotivity.base.OcConnectivityType;
+import org.iotivity.base.OcException;
+import org.iotivity.base.OcPlatform;
+import org.iotivity.base.OcResource;
+import org.iotivity.base.PlatformConfig;
+import org.iotivity.base.QualityOfService;
+import org.iotivity.base.ServiceType;
+import org.iotivity.ca.CaBtPairingInterface;
+import org.iotivity.ca.CaInterface;
+
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+
+/**
+ * This class is for testing of Bluetooth util.
+ */
+public class BluetoothFragment extends Fragment implements
+ CaInterface.OnBtDeviceFoundListener,
+ CaInterface.OnConnectionManagerStateListener {
+
+ private static final String TAG = "OCF_SIMPLE_BLUETOOTH";
+ private static final String CA_GATT_SERVICE_UUID = "ADE3D529-C784-4F63-A987-EB69F70EE816";
+
+ private Activity mActivity;
+ private Context mContext;
+ private BluetoothAdapter mBluetoothAdapter;
+ private static final int REQUEST_ENABLE_BT = 1;
+ private static final long SCAN_PERIOD = 10000;
+ private BluetoothLeScanner mLEScanner;
+ private ScanSettings mScanSettings;
+ private List<ScanFilter> mScanFilters;
+ private BluetoothGatt mGatt;
+ private ArrayList<String> mItems;
+ private ArrayList<BluetoothDevice> mBluetoothDevices;
+ private ArrayAdapter<String> mAdapters;
+
+ private boolean mIsScanning;
+ private boolean mIsBTSelected;
+
+ private Button mBtButton;
+ private Button mLeButton;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.fragment_bluetooth, container, false);
+ mBtButton = (Button) rootView.findViewById(R.id.btn_bt);
+ mBtButton.setOnClickListener(scanButtonListener(true));
+
+ mLeButton = (Button) rootView.findViewById(R.id.btn_le);
+ mLeButton.setOnClickListener(scanButtonListener(false));
+
+ ListView listView = (ListView) rootView.findViewById(R.id.list_view);
+ mItems = new ArrayList<String>();
+ mAdapters = new ArrayAdapter<String>(mActivity, android.R.layout.simple_list_item_1, mItems);
+ listView.setAdapter(mAdapters);
+ listView.setOnItemClickListener(itemClickListener);
+ listView.setOnItemLongClickListener(itemLongClickListener);
+
+ return rootView;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mActivity = getActivity();
+ mContext = mActivity.getBaseContext();
+
+ mBluetoothDevices = new ArrayList<BluetoothDevice>();
+
+ if (!mActivity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
+ Common.showToast(mContext, "BLE Not Supported");
+ }
+ final BluetoothManager bluetoothManager = (BluetoothManager) mActivity
+ .getSystemService(Context.BLUETOOTH_SERVICE);
+ mBluetoothAdapter = bluetoothManager.getAdapter();
+
+ PlatformConfig cfg = new PlatformConfig(mActivity, mContext,
+ ServiceType.IN_PROC,
+ ModeType.CLIENT,
+ Common.IP_ADDRESS,
+ Common.IP_PORT,
+ QualityOfService.LOW);
+
+ OcPlatform.Configure(cfg);
+ CaInterface.startBtPairingService(mContext, this);
+ CaInterface.startManagerService(mContext, this);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
+ Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
+ startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
+ } else {
+ if (Build.VERSION.SDK_INT >= 21) {
+ mLEScanner = mBluetoothAdapter.getBluetoothLeScanner();
+ if (mScanSettings == null) {
+ mScanSettings = new ScanSettings.Builder()
+ .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
+ .build();
+ }
+
+ if (mScanFilters == null) {
+ mScanFilters = new ArrayList<ScanFilter>();
+ ScanFilter scanFilter = new ScanFilter.Builder()
+ .setServiceUuid(ParcelUuid.fromString(CA_GATT_SERVICE_UUID)).build();
+ mScanFilters.add(scanFilter);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ if (mBluetoothAdapter != null && mBluetoothAdapter.isEnabled()) {
+ scanLeDevice(false);
+ }
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ CaInterface.stopBtPairingService();
+ CaInterface.stopManagerService();
+ CaBtPairingInterface.destroyEdrInterface();
+ if (mGatt != null) {
+ mGatt.close();
+ mGatt = null;
+ }
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == REQUEST_ENABLE_BT) {
+ if (resultCode == Activity.RESULT_CANCELED) {
+ mActivity.finish();
+ return;
+ }
+ }
+ super.onActivityResult(requestCode, resultCode, data);
+ }
+
+ View.OnClickListener scanButtonListener(final boolean isBT) {
+ return new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (!mIsScanning) {
+ mItems.clear();
+ mBluetoothDevices.clear();
+ mAdapters.notifyDataSetChanged();
+ mIsBTSelected = isBT;
+ }
+
+ if (isBT) {
+ if (mIsScanning) {
+ // BT Stop
+ try {
+ CaInterface.stopScan();
+ } catch (OcException e) {
+ e.printStackTrace();
+ }
+ mBtButton.setText(R.string.bt_scan);
+ mLeButton.setVisibility(View.VISIBLE);
+ } else {
+ // BT Scan
+ try {
+ CaInterface.startScan();
+ } catch (OcException e) {
+ e.printStackTrace();
+ }
+ mBtButton.setText(R.string.stop_scan);
+ mLeButton.setVisibility(View.GONE);
+ }
+ } else {
+ if (mIsScanning) {
+ // LE Stop
+ mLeButton.setText(R.string.le_scan);
+ mBtButton.setVisibility(View.VISIBLE);
+ } else {
+ // LE Scan
+ mLeButton.setText(R.string.stop_scan);
+ mBtButton.setVisibility(View.GONE);
+ }
+ scanLeDevice(!mIsScanning);
+ }
+ mIsScanning = !mIsScanning;
+ }
+ };
+ }
+
+ @Override
+ public synchronized void onBtDeviceFound(BluetoothDevice device) throws OcException {
+ Log.i(TAG, "onBtDeviceFound address : " + device.getAddress());
+
+ addItemToList(device);
+ }
+
+ private AdapterView.OnItemClickListener itemClickListener = new AdapterView
+ .OnItemClickListener() {
+ public void onItemClick(AdapterView<?> adapterView, View clickedView, int pos, long id) {
+ StringBuilder sb = new StringBuilder();
+
+ if (mIsBTSelected) {
+ sb.append("Pairing with : ");
+ try {
+ CaInterface.createBond(mBluetoothDevices.get(pos));
+ } catch (OcException e) {
+ e.printStackTrace();
+ }
+ } else {
+ sb.append("Set Connect with : ");
+ try {
+ final String address = mBluetoothDevices.get(pos).getAddress();
+ CaInterface.setAutoConnectionDevice(address);
+ OcPlatform.OnResourceFoundListener resourceFoundListener =
+ new OcPlatform.OnResourceFoundListener() {
+ @Override
+ public void onResourceFound(OcResource ocResource) {
+ Log.i(TAG, "onResourceFound : " + ocResource.getUri());
+ }
+ };
+ OcPlatform.findResource("", address + OcPlatform.WELL_KNOWN_QUERY,
+ EnumSet.of(OcConnectivityType.CT_ADAPTER_GATT_BTLE),
+ resourceFoundListener, QualityOfService.LOW);
+ } catch (OcException e) {
+ e.printStackTrace();
+ }
+ }
+ Common.showToast(mContext, sb.append(mItems.get(pos)).toString());
+ }
+ };
+
+ private AdapterView.OnItemLongClickListener itemLongClickListener = new AdapterView
+ .OnItemLongClickListener() {
+ @Override
+ public boolean onItemLongClick(AdapterView<?> adapterView, View view, int pos, long id) {
+ StringBuilder sb = new StringBuilder();
+
+ if (!mIsBTSelected) {
+ sb.append("Unset Connect with : ");
+ try {
+ CaInterface.unsetAutoConnectionDevice(mBluetoothDevices.get(pos).getAddress());
+ } catch (OcException e) {
+ e.printStackTrace();
+ }
+ }
+ Common.showToast(mContext, sb.append(mItems.get(pos)).toString());
+
+ return true;
+ }
+ };
+
+ private void scanLeDevice(final boolean enable) {
+ if (enable) {
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ mLEScanner.stopScan(mScanCallback);
+ }
+ }, SCAN_PERIOD);
+
+ mLEScanner.startScan(mScanFilters, mScanSettings, mScanCallback);
+ } else {
+ mLEScanner.stopScan(mScanCallback);
+ }
+ }
+
+ private ScanCallback mScanCallback = new ScanCallback() {
+ @Override
+ public void onScanResult(int callbackType, ScanResult result) {
+ Log.i(TAG, "onScanResult : " + result.toString());
+
+ addItemToList(result.getDevice());
+ }
+
+ @Override
+ public void onScanFailed(int errorCode) {
+ Log.e(TAG, "Scan Failed, Error Code : " + errorCode);
+ }
+ };
+
+ private void addItemToList(BluetoothDevice btDevice) {
+ StringBuilder sb = new StringBuilder(btDevice.toString());
+ sb.append(" (");
+ if (btDevice.getName() != null) {
+ sb.append(btDevice.getName().toString());
+ } else {
+ sb.append("NULL");
+ }
+ sb.append(")");
+
+ if (mItems.contains(sb.toString())) {
+ // Duplicate
+ } else {
+ // add item
+ mItems.add(sb.toString());
+ mBluetoothDevices.add(btDevice);
+ mAdapters.notifyDataSetChanged();
+ }
+ }
+
+ @Override
+ public void onAdapterStateChanged(OcConnectivityType type, boolean enabled) {
+ final String msg = getString(R.string.action_onadapterstatechanged) + enabled;
+ Log.i(TAG, msg);
+ mActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ Common.showToast(mContext, msg);
+ }
+ });
+ }
+
+ @Override
+ public void onConnectionStateChanged(OcConnectivityType type,
+ String address, boolean connected) {
+ Log.i(TAG, "onConnectionStateChanged address: " + address);
+ final String msg = getString(R.string.action_onconnectionstatechanged) + connected;
+ Log.i(TAG, msg);
+ mActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ Common.showToast(mContext, msg);
+ }
+ });
+ }
+}
--- /dev/null
+/*
+ * ******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
+
+import android.content.Context;
+import android.widget.Toast;
+
+import org.iotivity.base.OcPlatform;
+import org.iotivity.base.ResourceProperty;
+
+import java.text.DateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.EnumSet;
+import java.util.Locale;
+
+/**
+ * This class charge of common part.
+ */
+public class Common {
+
+ public static final int DATA_SIZE = 3000;
+ public static final String COAP_TCP = "coap+tcp://";
+ public static String TCP_ADDRESS = "192.168.0.1";
+ public static final String TCP_PORT = ":8000";
+ public static final String IP_ADDRESS = "0.0.0.0";
+ public static final int IP_PORT = 0;
+ public static final String GET_COMMAND = "get_command";
+ public static final String STATE_KEY = "state_key";
+ public static final String STATE_GET = "state_get";
+ public static final String LARGE_KEY = "large_key";
+ public static final String LARGE_GET = "large_get";
+ public static final String RESOURCE_URI = "/a/light";
+ public static final String RESOURCE_TYPE = "core.light";
+ public static final String RESOURCE_INTERFACE = OcPlatform.DEFAULT_INTERFACE;
+ public static final EnumSet<ResourceProperty> RESOURCE_PROPERTIES =
+ EnumSet.of(ResourceProperty.DISCOVERABLE, ResourceProperty.OBSERVABLE);
+
+ public static String getDateCurrentTimeZone() {
+ StringBuilder sb = new StringBuilder();
+ try {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeInMillis(System.currentTimeMillis());
+ DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT,
+ DateFormat.DEFAULT,
+ Locale.getDefault());
+ Date currentTimeZone = calendar.getTime();
+ sb.append(dateFormat.format(currentTimeZone));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return sb.toString();
+ }
+
+ public static void showToast(Context context, String msg) {
+ Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
+ }
+}
--- /dev/null
+/*
+ * ******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
+
+import android.app.ActionBar;
+import android.app.Activity;
+import android.app.Fragment;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.support.v4.app.ActionBarDrawerToggle;
+import android.support.v4.view.GravityCompat;
+import android.support.v4.widget.DrawerLayout;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+
+/**
+ * Through a drawer able to move to another menu.
+ */
+public class DrawerFragment extends Fragment {
+
+ private static final String STATE_SELECTED_POSITION = "selected_navigation_drawer_position";
+ private DrawerCallbacks mCallbacks;
+
+ private ActionBarDrawerToggle mDrawerToggle;
+
+ private DrawerLayout mDrawerLayout;
+ private ListView mDrawerListView;
+ private View mFragmentContainerView;
+
+ private int mCurrentSelectedPosition = 0;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ if (savedInstanceState != null) {
+ mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION);
+ }
+
+ selectItem(mCurrentSelectedPosition);
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ mDrawerListView = (ListView) inflater.inflate(R.layout.fragment_drawer,
+ container, false);
+ mDrawerListView
+ .setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view,
+ int position, long id) {
+ selectItem(position);
+ }
+ });
+ mDrawerListView.setAdapter(new ArrayAdapter<String>(getActionBar()
+ .getThemedContext(),
+ android.R.layout.simple_list_item_activated_1,
+ android.R.id.text1, new String[] {
+ getString(R.string.title_message),
+ getString(R.string.title_bluetooth),
+ getString(R.string.title_template), }));
+ mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
+
+ return mDrawerListView;
+ }
+
+ public void setUp(int fragmentId, DrawerLayout drawerLayout) {
+ mFragmentContainerView = getActivity().findViewById(fragmentId);
+ mDrawerLayout = drawerLayout;
+
+ mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow,
+ GravityCompat.START);
+
+ ActionBar actionBar = getActionBar();
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setHomeButtonEnabled(true);
+ mDrawerToggle = new ActionBarDrawerToggle(getActivity(),
+ mDrawerLayout,
+ R.drawable.ic_drawer,
+ R.string.navigation_drawer_open,
+ R.string.navigation_drawer_close) {
+ @Override
+ public void onDrawerClosed(View drawerView) {
+ super.onDrawerClosed(drawerView);
+ if (!isAdded()) {
+ return;
+ }
+
+ getActivity().invalidateOptionsMenu();
+ }
+
+ @Override
+ public void onDrawerOpened(View drawerView) {
+ super.onDrawerOpened(drawerView);
+ if (!isAdded()) {
+ return;
+ }
+
+ getActivity().invalidateOptionsMenu();
+ }
+ };
+
+ mDrawerLayout.post(new Runnable() {
+ @Override
+ public void run() {
+ mDrawerToggle.syncState();
+ }
+ });
+
+ mDrawerLayout.setDrawerListener(mDrawerToggle);
+ }
+
+ private void selectItem(int position) {
+ mCurrentSelectedPosition = position;
+ if (mDrawerListView != null) {
+ mDrawerListView.setItemChecked(position, true);
+ }
+ if (mDrawerLayout != null) {
+ mDrawerLayout.closeDrawer(mFragmentContainerView);
+ }
+ if (mCallbacks != null) {
+ mCallbacks.onDrawerItemSelected(position);
+ }
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+ try {
+ mCallbacks = (DrawerCallbacks) activity;
+ } catch (ClassCastException e) {
+ throw new ClassCastException("Activity must implement DrawerCallbacks.");
+ }
+ }
+
+ @Override
+ public void onDetach() {
+ super.onDetach();
+ mCallbacks = null;
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putInt(STATE_SELECTED_POSITION, mCurrentSelectedPosition);
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ mDrawerToggle.onConfigurationChanged(newConfig);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (mDrawerToggle.onOptionsItemSelected(item)) {
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+
+ private ActionBar getActionBar() {
+ return getActivity().getActionBar();
+ }
+
+ public static interface DrawerCallbacks {
+ void onDrawerItemSelected(int position);
+ }
+}
--- /dev/null
+/*
+ * ******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Fragment;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.nfc.NfcAdapter;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.CompoundButton;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import android.widget.Toast;
+import android.widget.ToggleButton;
+
+import org.iotivity.base.EntityHandlerResult;
+import org.iotivity.base.ModeType;
+import org.iotivity.base.OcConnectivityType;
+import org.iotivity.base.OcException;
+import org.iotivity.base.OcHeaderOption;
+import org.iotivity.base.OcPlatform;
+import org.iotivity.base.OcRepresentation;
+import org.iotivity.base.OcResource;
+import org.iotivity.base.OcResourceHandle;
+import org.iotivity.base.OcResourceRequest;
+import org.iotivity.base.OcResourceResponse;
+import org.iotivity.base.PlatformConfig;
+import org.iotivity.base.QualityOfService;
+import org.iotivity.base.ServiceType;
+import org.iotivity.ca.CaEdrInterface;
+import org.iotivity.ca.CaIpInterface;
+import org.iotivity.ca.CaLeClientInterface;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * This class is for messaging between the server and the client.
+ * It can handle message manually.
+ */
+public class MessageFragment extends Fragment implements OcResource.OnGetListener,
+ OcResource.OnPutListener {
+
+ private static final String TAG = "OIC_SIMPLE_MESSAGE";
+ private final String EOL = System.getProperties().getProperty("line.separator");
+ private final double MILLI_PER_SEC = 1000.0;
+
+ private Activity mActivity;
+ private Context mContext;
+
+ OcPlatform.EntityHandler mEntityHandler;
+ private OcResourceHandle mResourceHandle;
+ private OcResource mFoundResource;
+
+ private QualityOfService mQos = QualityOfService.LOW;
+
+ private LinearLayout mServerLayout;
+ private LinearLayout mClientLayout;
+ private TextView mResourceText;
+ private TextView mActionLog;
+ private TextView mResultLog;
+ private ToggleButton mQosToggle;
+ private Button mRegisterButton;
+ private Button mGetButton;
+ private Button mPutButton;
+ private Button mLargeButton;
+ private Button mDiscoverIPButton;
+ private Button mDiscoverBTButton;
+ private Button mDiscoverLEButton;
+ private Button mDiscoverTCPButton;
+ private Button mDiscoverNFCButton;
+
+ private String mLargeData;
+ private boolean mState;
+ private long mStartTime;
+ private long mEndTime;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mActivity = getActivity();
+ mContext = mActivity.getBaseContext();
+ }
+
+ View.OnClickListener getButtonListener() {
+ return new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (mFoundResource != null) {
+ mStartTime = System.currentTimeMillis();
+ sendGetToFoundResource(Common.STATE_GET);
+ } else {
+ Common.showToast(mContext, "Please discovery first");
+ Log.e(TAG, "get() : resource is null");
+ }
+ }
+ };
+ }
+
+ View.OnClickListener putButtonListener() {
+ return new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (mFoundResource != null) {
+ mStartTime = System.currentTimeMillis();
+ sendPutToFoundResource();
+ } else {
+ Common.showToast(mContext, "Please discovery first");
+ Log.e(TAG, "put() : resource is null");
+ }
+ }
+ };
+ }
+
+ View.OnClickListener getLargeListener() {
+ return new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (mFoundResource != null) {
+ mStartTime = System.currentTimeMillis();
+ sendGetToFoundResource(Common.LARGE_GET);
+ } else {
+ Common.showToast(mContext, "Please discovery first");
+ Log.e(TAG, "large() : resource is null");
+ }
+ }
+ };
+ }
+
+ View.OnClickListener discoverButtonListener(
+ final OcConnectivityType connectivityType) {
+ return new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ initOcPlatform(ModeType.CLIENT);
+ mFoundResource = null;
+
+ if (OcConnectivityType.CT_ADAPTER_TCP == connectivityType) {
+ showTCPInput();
+ } else {
+ try {
+ Log.i(TAG, "discoverButtonListener");
+ OcPlatform.findResource("",
+ OcPlatform.WELL_KNOWN_QUERY,
+ EnumSet.of(connectivityType),
+ resourceFoundListener, mQos);
+
+ mActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ mActionLog.setText("[Action Log]" + EOL);
+ mActionLog.append("Find resource()" + EOL);
+ mActionLog.append("Connectivity : " + connectivityType + EOL);
+
+ mResultLog.setText("[Result Log]" + EOL);
+ mResultLog.append("Start Time : ");
+ mResultLog.append(Common.getDateCurrentTimeZone() + EOL);
+ mStartTime = System.currentTimeMillis();
+ }
+ });
+ } catch (OcException e) {
+ e.printStackTrace();
+ }
+ }
+ mServerLayout.setVisibility(View.GONE);
+ }
+ };
+ }
+
+ void makeTCPResource(String address) {
+
+ List<String> resourceTypeList = new ArrayList<String>();
+ List<String> resourceInterfaceList = new ArrayList<String>();
+ resourceInterfaceList.add(Common.RESOURCE_INTERFACE);
+ resourceTypeList.add(Common.RESOURCE_TYPE);
+ try {
+ mFoundResource = OcPlatform.constructResourceObject(address,
+ Common.RESOURCE_URI,
+ EnumSet.of(OcConnectivityType.CT_ADAPTER_TCP), false,
+ resourceTypeList, resourceInterfaceList);
+
+ mActionLog.setText("[Action Log]" + EOL);
+ mActionLog.append("Found resource()" + EOL);
+ mActionLog.append("Connectivity : " + OcConnectivityType.CT_ADAPTER_TCP + EOL);
+ mActionLog.append(mFoundResource.getHost() + Common.RESOURCE_URI);
+
+ mResultLog.setText("[Result Log]" + EOL);
+
+ } catch (OcException e) {
+ e.printStackTrace();
+ }
+ }
+
+ void sendGetToFoundResource(String command) {
+ try {
+ Log.i(TAG, "sendGetToFoundResource");
+
+ Map<String, String> queryParameters = new HashMap<String, String>();
+ queryParameters.put(Common.GET_COMMAND, command);
+
+ mFoundResource.get(queryParameters, this, mQos);
+
+ mActionLog.setText("[Action Log]" + EOL + "Send get()"+ EOL + "To : ");
+ mActionLog.append(mFoundResource.getHost() + mFoundResource.getUri() + EOL);
+ } catch (OcException e) {
+ e.printStackTrace();
+ }
+ }
+
+ void sendPutToFoundResource() {
+ try {
+ Log.i(TAG, "sendPutToFoundResource");
+
+ OcRepresentation rep = new OcRepresentation();
+ rep.setValue(Common.STATE_KEY, !mState);
+
+ Map<String, String> queryParams = new HashMap<>();
+
+ mFoundResource.put(rep, queryParams, this);
+ mActionLog.setText("[Action Log]" + EOL);
+ mActionLog.append("Send put()" + EOL + "To : ");
+ mActionLog.append(mFoundResource.getHost() + mFoundResource.getUri() + EOL);
+ } catch (OcException e) {
+ e.printStackTrace();
+ }
+ }
+
+ OcPlatform.OnResourceFoundListener resourceFoundListener =
+ new OcPlatform.OnResourceFoundListener() {
+ @Override
+ public void onResourceFound(OcResource ocResource) {
+ synchronized (mActivity) {
+ final String resourceUri = ocResource.getUri();
+ Log.i(TAG, "onResourceFound : " + ocResource.getUri());
+
+ if (resourceUri.contains(Common.RESOURCE_URI)) {
+ mFoundResource = ocResource;
+ mActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ mEndTime = System.currentTimeMillis();
+ double flightTime = (double) (mEndTime - mStartTime) / MILLI_PER_SEC;
+ mResultLog.append("Discovery Time : ");
+ mResultLog.append(String.format("%.3f", flightTime) + "sec" + EOL);
+ mActionLog.append(mFoundResource.getHost() + resourceUri + EOL);
+ }
+ });
+ }
+ }
+ }
+ };
+
+ @Override
+ public void onGetCompleted(List<OcHeaderOption> list, OcRepresentation ocRepresentation) {
+ String repUri = ocRepresentation.getUri();
+ Log.i(TAG, "onGetCompleted : " + repUri);
+
+ try {
+ final String command = ocRepresentation.getValue(Common.GET_COMMAND);
+
+ if (command == null || command.isEmpty()) {
+ Log.e(TAG, "Get command is null");
+ return;
+ } else if (command.equals(Common.STATE_GET)) {
+ mState = ocRepresentation.getValue(Common.STATE_KEY);
+ mLargeData = "";
+ } else if (command.equals(Common.LARGE_GET)) {
+ mLargeData = ocRepresentation.getValue(Common.LARGE_KEY);
+ }
+ } catch (OcException e) {
+ e.printStackTrace();
+ }
+
+ mActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ mEndTime = System.currentTimeMillis();
+ double flightTime = (double) (mEndTime - mStartTime) / MILLI_PER_SEC;
+
+ if (mLargeData == null || mLargeData.isEmpty()) {
+ mResultLog.append(EOL + "Get Light State : " + mState + EOL);
+ } else {
+ mResultLog.append(EOL + "Payload Size : " + mLargeData.length() + EOL);
+ }
+
+ mResultLog.append("Get Time : " + String.format("%.3f", flightTime) + "sec" + EOL);
+ }
+ });
+ }
+
+ @Override
+ public void onGetFailed(Throwable throwable) {
+ Log.e(TAG, "Get failed");
+ }
+
+ @Override
+ public void onPutCompleted(List<OcHeaderOption> list, OcRepresentation ocRepresentation) {
+ String repUri = ocRepresentation.getUri();
+ Log.i(TAG, "onPutCompleted : " + repUri);
+
+ try {
+ mState = ocRepresentation.getValue(Common.STATE_KEY);
+ } catch (OcException e) {
+ e.printStackTrace();
+ }
+
+ mActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ mEndTime = System.currentTimeMillis();
+ double flightTime = (double) (mEndTime - mStartTime) / MILLI_PER_SEC;
+ mResultLog.append(EOL + "Set Light State : " + !mState + EOL + "Put Time : ");
+ mResultLog.append(String.format("%.3f", flightTime) + "sec" + EOL);
+ }
+ });
+ }
+
+ @Override
+ public void onPutFailed(Throwable throwable) {
+ Log.e(TAG, "Put failed");
+ }
+
+ // ******************************************************************************
+ // End of the OCF Client specific code
+ // ******************************************************************************
+
+ private void createResource() {
+ mEntityHandler = new OcPlatform.EntityHandler() {
+ @Override
+ public EntityHandlerResult handleEntity(
+ OcResourceRequest ocResourceRequest) {
+ return mEntityHandler(ocResourceRequest);
+ }
+ };
+
+ try {
+ mResourceHandle = OcPlatform.registerResource(Common.RESOURCE_URI,
+ Common.RESOURCE_TYPE, Common.RESOURCE_INTERFACE,
+ mEntityHandler, Common.RESOURCE_PROPERTIES);
+
+ } catch (OcException e) {
+ String errString = "Error : " + e.getErrorCode().toString();
+ Log.e(TAG, errString);
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+ String exceptionAsString = sw.toString();
+ Log.e(TAG, exceptionAsString);
+ mResourceText.setText(errString);
+ }
+
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < Common.DATA_SIZE; i++) {
+ sb.append('j');
+ }
+ mLargeData = sb.toString();
+
+ sb.setLength(0);
+ sb.append("URI : " + Common.RESOURCE_URI + EOL);
+ sb.append("Type : " + Common.RESOURCE_TYPE + EOL);
+ sb.append("Interface : " + Common.RESOURCE_INTERFACE + EOL);
+ sb.append("Properties : " + Common.RESOURCE_PROPERTIES.toString() + EOL);
+ mResourceText.setText(sb.toString());
+ mActionLog.setText("");
+ mResultLog.setText("Created resource" + EOL);
+ }
+
+ protected EntityHandlerResult mEntityHandler(OcResourceRequest ocResourceRequest) {
+ EntityHandlerResult result = EntityHandlerResult.ERROR;
+ final StringBuilder sb = new StringBuilder();
+ switch (ocResourceRequest.getRequestType()) {
+ case GET:
+ sb.append("Type : GET");
+ if (sendGetResponse(ocResourceRequest)) {
+ result = EntityHandlerResult.OK;
+ }
+ break;
+ case PUT:
+ sb.append("Type : PUT");
+ if (sendPutResponse(ocResourceRequest)) {
+ result = EntityHandlerResult.OK;
+ }
+ break;
+ case DELETE:
+ sb.append("Type : DELETE");
+ break;
+ case POST:
+ sb.append("Type : POST");
+ break;
+ default:
+ break;
+ }
+ sb.append(EOL + "Light State : " + mState);
+ sb.append(EOL + "Time : " + Common.getDateCurrentTimeZone());
+ if (result == EntityHandlerResult.ERROR) {
+ sb.append(EOL + "!! Error occurred during sending the response !!");
+ }
+
+ mActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ mResultLog.setText(sb.toString());
+ }
+ });
+
+ return result;
+ }
+
+ private boolean sendGetResponse(OcResourceRequest ocResourceRequest) {
+ mActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ Common.showToast(mContext, "received get command, send response");
+ }
+ });
+
+ Map<String, String> queryParameters = ocResourceRequest.getQueryParameters();
+ final String command = queryParameters.get(Common.GET_COMMAND);
+
+ if (command == null
+ || (!command.equals(Common.STATE_GET) && !command.equals(Common.LARGE_GET))) {
+ return false;
+ }
+
+ OcRepresentation rep = new OcRepresentation();
+ try {
+ rep.setValue(Common.GET_COMMAND, command);
+ if (command.equals(Common.STATE_GET)) {
+ rep.setValue(Common.STATE_KEY, mState);
+ } else if (command.equals(Common.LARGE_GET)) {
+ rep.setValue(Common.LARGE_KEY, mLargeData);
+ }
+ } catch (OcException e) {
+ e.printStackTrace();
+ }
+
+ OcResourceResponse response = new OcResourceResponse();
+
+ response.setRequestHandle(ocResourceRequest.getRequestHandle());
+ response.setResourceHandle(ocResourceRequest.getResourceHandle());
+ response.setResourceRepresentation(rep);
+ try {
+ OcPlatform.sendResponse(response);
+ return true;
+ } catch (OcException e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ private boolean sendPutResponse(OcResourceRequest ocResourceRequest) {
+ mActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ Common.showToast(mContext, "received put command, send response");
+ }
+ });
+
+ try {
+ OcRepresentation rep = ocResourceRequest.getResourceRepresentation();
+ if (rep.hasAttribute(Common.STATE_KEY)) {
+ mState = rep.getValue(Common.STATE_KEY);
+ }
+ } catch (OcException e) {
+ e.printStackTrace();
+ }
+
+ OcResourceResponse response = new OcResourceResponse();
+ OcRepresentation rep = new OcRepresentation();
+
+ response.setRequestHandle(ocResourceRequest.getRequestHandle());
+ response.setResourceHandle(ocResourceRequest.getResourceHandle());
+ response.setResourceRepresentation(rep);
+ try {
+ OcPlatform.sendResponse(response);
+ return true;
+ } catch (OcException e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ // ******************************************************************************
+ // End of the OCF Server specific code
+ // ******************************************************************************
+
+ private void initOcPlatform(ModeType type) {
+ PlatformConfig cfg = new PlatformConfig(mActivity, mContext,
+ ServiceType.IN_PROC,
+ type,
+ Common.IP_ADDRESS,
+ Common.IP_PORT,
+ mQos);
+ OcPlatform.Configure(cfg);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.fragment_message, container, false);
+
+ mServerLayout = (LinearLayout) rootView.findViewById(R.id.server_layout);
+ mClientLayout = (LinearLayout) rootView.findViewById(R.id.client_layout);
+
+ mResourceText = (TextView) rootView.findViewById(R.id.resource_view);
+ mActionLog = (TextView) rootView.findViewById(R.id.action_log_view);
+ mResultLog = (TextView) rootView.findViewById(R.id.result_log_view);
+
+ mDiscoverIPButton = (Button) rootView.findViewById(R.id.ip_button);
+ mDiscoverBTButton = (Button) rootView.findViewById(R.id.bt_button);
+ mDiscoverLEButton = (Button) rootView.findViewById(R.id.le_button);
+ mDiscoverTCPButton = (Button) rootView.findViewById(R.id.tcp_button);
+ mDiscoverNFCButton = (Button) rootView.findViewById(R.id.nfc_button);
+
+ mRegisterButton = (Button) rootView.findViewById(R.id.register_button);
+ mGetButton = (Button) rootView.findViewById(R.id.get_button);
+ mPutButton = (Button) rootView.findViewById(R.id.put_button);
+ mLargeButton = (Button) rootView.findViewById(R.id.large_button);
+
+ mQosToggle = (ToggleButton) rootView.findViewById(R.id.qos_toggle_button);
+
+ mDiscoverIPButton.setOnClickListener(
+ discoverButtonListener(OcConnectivityType.CT_ADAPTER_IP));
+ mDiscoverBTButton.setOnClickListener(
+ discoverButtonListener(OcConnectivityType.CT_ADAPTER_RFCOMM_BTEDR));
+ mDiscoverLEButton.setOnClickListener(
+ discoverButtonListener(OcConnectivityType.CT_ADAPTER_GATT_BTLE));
+ mDiscoverTCPButton.setOnClickListener(
+ discoverButtonListener(OcConnectivityType.CT_ADAPTER_TCP));
+ mDiscoverNFCButton.setOnClickListener(
+ discoverButtonListener(OcConnectivityType.CT_ADAPTER_NFC));
+
+ mRegisterButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (mResourceHandle == null) {
+ initOcPlatform(ModeType.SERVER);
+ createResource();
+ mClientLayout.setVisibility(View.GONE);
+ } else {
+ Common.showToast(mContext, "Already created resource");
+ }
+ }
+ });
+ mGetButton.setOnClickListener(getButtonListener());
+ mPutButton.setOnClickListener(putButtonListener());
+ mLargeButton.setOnClickListener(getLargeListener());
+
+ mQosToggle
+ .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
+ if (b) {
+ mQos = QualityOfService.HIGH;
+ } else {
+ mQos = QualityOfService.LOW;
+ }
+ }
+ });
+
+ return rootView;
+ }
+
+ private void showTCPInput() {
+
+ LayoutInflater layoutInflater = LayoutInflater.from(mContext);
+ View inputView = layoutInflater.inflate(R.layout.tcp_input, null);
+ AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mActivity);
+ alertDialogBuilder.setView(inputView);
+
+ final EditText editText = (EditText) inputView.getRootView().findViewById(R.id.ipText);
+ editText.setText(Common.TCP_ADDRESS);
+ alertDialogBuilder
+ .setCancelable(false)
+ .setPositiveButton("OK", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ if (editText.getText().length() != 0) {
+ Common.TCP_ADDRESS = editText.getText().toString();
+
+ StringBuilder sb = new StringBuilder();
+ sb.append(Common.COAP_TCP);
+ sb.append(Common.TCP_ADDRESS);
+ sb.append(Common.TCP_PORT);
+ makeTCPResource(sb.toString());
+ }
+ }
+ })
+ .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ dialog.cancel();
+ }
+ });
+
+ AlertDialog alert = alertDialogBuilder.create();
+ alert.show();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ }
+}
--- /dev/null
+/*
+ * ******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
+
+import android.app.Activity;
+import android.app.Fragment;
+import android.content.Intent;
+import android.nfc.NfcAdapter;
+import android.os.Bundle;
+import android.support.v4.widget.DrawerLayout;
+import android.util.Log;
+
+/**
+ * SimpleBase is a sample OCF Base layer application.
+ * It can handle message and bluetooth manually.
+ */
+public class SimpleBase extends Activity implements DrawerFragment.DrawerCallbacks {
+
+ private static final String TAG = "OIC_SIMPLE_BASE";
+ private DrawerFragment mDrawerFragment;
+
+ private CharSequence mTitle;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_simplebase);
+
+ mDrawerFragment = (DrawerFragment) getFragmentManager()
+ .findFragmentById(R.id.navigation_drawer);
+ mTitle = getTitle();
+
+ mDrawerFragment.setUp(R.id.navigation_drawer,
+ (DrawerLayout) findViewById(R.id.drawer_layout));
+ }
+
+ @Override
+ public void onDrawerItemSelected(int position) {
+ Fragment fragment;
+ switch (position) {
+ case 0:
+ mTitle = getString(R.string.title_message);
+ fragment = new MessageFragment();
+ break;
+ case 1:
+ mTitle = getString(R.string.title_bluetooth);
+ fragment = new BluetoothFragment();
+ break;
+ case 2:
+ mTitle = getString(R.string.title_template);
+ fragment = new TemplateFragment();
+ break;
+ default:
+ mTitle = getString(R.string.title_message);
+ fragment = new MessageFragment();
+ break;
+ }
+ getFragmentManager().beginTransaction()
+ .replace(R.id.container, fragment)
+ .commit();
+
+ getActionBar().setTitle(mTitle);
+ }
+
+ @Override
+ public void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
+ Log.d(TAG, "onNewIntent with changes sending broadcast IN ");
+
+ Intent i = new Intent();
+ i.setAction(intent.getAction());
+ i.putExtra(NfcAdapter.EXTRA_NDEF_MESSAGES,
+ intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES));
+ sendBroadcast(i);
+ Log.d(TAG, "Initialize Context again resetting");
+ }
+}
--- /dev/null
+/*
+ * ******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
+
+import android.app.Activity;
+import android.app.Fragment;
+import android.content.Context;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+
+/**
+ * This class the template for the test.
+ */
+public class TemplateFragment extends Fragment implements View.OnClickListener {
+
+ private Activity mActivity;
+ private Context mContext;
+
+ Button buttonA;
+ Button buttonB;
+ Button buttonC;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.fragment_template, container, false);
+
+ buttonA = (Button) rootView.findViewById(R.id.btn_A);
+ buttonB = (Button) rootView.findViewById(R.id.btn_B);
+ buttonC = (Button) rootView.findViewById(R.id.btn_C);
+
+ buttonA.setOnClickListener(this);
+ buttonB.setOnClickListener(this);
+ buttonC.setOnClickListener(this);
+
+ return rootView;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mActivity = getActivity();
+ mContext = mActivity.getBaseContext();
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ }
+
+ @Override
+ public void onClick(View view) {
+ StringBuilder sb = new StringBuilder(getString(R.string.action_onclick));
+ switch (view.getId()) {
+ case R.id.btn_A:
+ sb.append(getString(R.string.button_A));
+ break;
+ case R.id.btn_B:
+ sb.append(getString(R.string.button_B));
+ break;
+ case R.id.btn_C:
+ sb.append(getString(R.string.button_C));
+ break;
+ }
+ Common.showToast(mContext, sb.toString());
+ }
+}
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/drawer_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".SimpleBase" >
+
+ <FrameLayout
+ android:id="@+id/container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ <fragment
+ android:id="@+id/navigation_drawer"
+ android:name="org.iotivity.base.examples.DrawerFragment"
+ android:layout_width="@dimen/navigation_drawer_width"
+ android:layout_height="match_parent"
+ android:layout_gravity="start"
+ tools:layout="@layout/fragment_drawer" />
+
+</android.support.v4.widget.DrawerLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ tools:context=".BluetoothFragment" >
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:gravity="center_horizontal"
+ android:orientation="horizontal" >
+
+ <Button
+ android:id="@+id/btn_bt"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginTop="10dp"
+ android:layout_weight="1"
+ android:text="@string/bt_scan" />
+
+ <Button
+ android:id="@+id/btn_le"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginTop="10dp"
+ android:layout_weight="1"
+ android:text="@string/le_scan" />
+ </LinearLayout>
+
+ <ListView
+ android:id="@+id/list_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:choiceMode="singleChoice"
+ android:divider="#cfcfcf"
+ android:dividerHeight="1.5dp" />
+ </LinearLayout>
+
+</RelativeLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<ListView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#cccc"
+ android:choiceMode="singleChoice"
+ android:divider="@android:color/transparent"
+ android:dividerHeight="0dp"
+ tools:context=".DrawerFragment" />
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:paddingLeft="0dp"
+ android:paddingRight="0dp"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ tools:context=".MessageFragment" >
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:id="@+id/server_layout"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:focusable="true"
+ android:focusableInTouchMode="true"
+ android:gravity="center_horizontal"
+ android:orientation="vertical" >
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="#AAAAAA"
+ android:gravity="center_vertical"
+ android:paddingLeft="10dp"
+ android:text="Resource Server Information"
+ android:textColor="#FFFFFF"
+ android:textSize="14sp" />
+
+ <TextView
+ android:id="@+id/resource_view"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingBottom="20dp"
+ android:paddingLeft="20dp"
+ android:paddingTop="5dp"
+ android:text="@string/resource_view" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="#AAAAAA"
+ android:gravity="center_vertical"
+ android:paddingLeft="10dp"
+ android:text="Server Buttons"
+ android:textColor="#FFFFFF"
+ android:textSize="14sp" />
+
+ <Button
+ android:id="@+id/register_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginLeft="6dp"
+ android:layout_marginTop="10dp"
+ android:text="Register Resource" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/client_layout"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:focusable="true"
+ android:focusableInTouchMode="true"
+ android:gravity="center_horizontal"
+ android:orientation="vertical" >
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="#AAAAAA"
+ android:gravity="center_vertical"
+ android:paddingLeft="10dp"
+ android:text="Client Buttons"
+ android:textColor="#FFFFFF"
+ android:textSize="14sp" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginTop="10dp"
+ android:gravity="center_horizontal"
+ android:orientation="horizontal" >
+
+ <Button
+ android:id="@+id/ip_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_weight="1"
+ android:text="IP" />
+
+ <Button
+ android:id="@+id/bt_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_weight="1"
+ android:text="BT" />
+
+ <Button
+ android:id="@+id/le_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_weight="1"
+ android:text="LE" />
+
+ <Button
+ android:id="@+id/tcp_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_weight="1"
+ android:text="TCP/IP" />
+
+ <Button
+ android:id="@+id/nfc_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_weight="1"
+ android:text="NFC" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginBottom="10dp"
+ android:gravity="center_horizontal"
+ android:orientation="horizontal" >
+
+ <Button
+ android:id="@+id/get_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="Get()" />
+
+ <Button
+ android:id="@+id/put_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="Put()" />
+
+ <Button
+ android:id="@+id/large_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="Large()" />
+
+ <TextView
+ android:id="@+id/textView"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:layout_marginLeft="10dp"
+ android:text="QoS:"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+ <ToggleButton
+ android:id="@+id/qos_toggle_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:checked="false"
+ android:text="QoS Toggle Button"
+ android:textOff="NON"
+ android:textOn="CON"
+ android:textSize="12sp" />
+ </LinearLayout>
+ </LinearLayout>
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="#AAAAAA"
+ android:gravity="center_vertical"
+ android:paddingLeft="10dp"
+ android:text="Log"
+ android:textColor="#FFFFFF"
+ android:textSize="14sp" />
+
+ <TextView
+ android:id="@+id/action_log_view"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingBottom="5dp"
+ android:paddingLeft="20dp"
+ android:paddingTop="5dp"
+ android:text="@string/action_log_view" />
+
+ <ScrollView
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent" >
+
+ <TextView
+ android:id="@+id/result_log_view"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingLeft="20dp"
+ android:paddingTop="5dp"
+ android:text="@string/result_log_view" />
+ </ScrollView>
+ </LinearLayout>
+
+</RelativeLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ tools:context=".TemplateFragment" >
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <Button
+ android:id="@+id/btn_A"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginTop="10dp"
+ android:text="@string/button_A" />
+
+ <Button
+ android:id="@+id/btn_B"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginTop="10dp"
+ android:text="@string/button_B" />
+
+ <Button
+ android:id="@+id/btn_C"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginTop="10dp"
+ android:text="@string/button_C" />
+ </LinearLayout>
+
+</RelativeLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:padding="@dimen/activity_vertical_margin" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Input Server IP"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <EditText
+ android:id="@+id/ipText"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="@dimen/activity_vertical_margin" />
+
+</LinearLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <style name="AppTheme" parent="android:Theme.Material.Light">
+ </style>
+</resources>
--- /dev/null
+<resources>
+ <!-- Example customization of dimensions originally defined in res/values/dimens.xml
+ (such as screen margins) for screens with more than 820dp of available width. This
+ would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
+ <dimen name="activity_horizontal_margin">64dp</dimen>
+</resources>
--- /dev/null
+<resources>
+ <!-- Default screen margins, per the Android Design guidelines. -->
+ <dimen name="activity_horizontal_margin">16dp</dimen>
+ <dimen name="activity_vertical_margin">16dp</dimen>
+
+ <dimen name="navigation_drawer_width">240dp</dimen>
+</resources>
--- /dev/null
+<resources>
+ <string name="app_name">Simple Base</string>
+
+ <string name="title_message">Message</string>
+ <string name="title_bluetooth">Bluetooth</string>
+ <string name="title_template">Template</string>
+
+ <string name="resource_view">[Resource View]</string>
+ <string name="action_log_view">[Action Log View]</string>
+ <string name="result_log_view">[Result Log View]</string>
+
+ <string name="bt_scan">BT SCAN</string>
+ <string name="le_scan">LE SCAN</string>
+ <string name="stop_scan">STOP SCAN</string>
+
+ <string name="action_onadapterstatechanged">onAdapterStateChanged : </string>
+ <string name="action_onconnectionstatechanged">onConnectionStateChanged : </string>
+ <string name="action_onclick">onClick : </string>
+
+ <string name="button_A">Button A</string>
+ <string name="button_B">Button B</string>
+ <string name="button_C">Button C</string>
+
+ <string name="navigation_drawer_open">Open navigation drawer</string>
+ <string name="navigation_drawer_close">Close navigation drawer</string>
+</resources>
--- /dev/null
+<resources>
+
+ <!-- Base application theme. -->
+ <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+ <!-- Customize your theme here. -->
+ </style>
+
+</resources>
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
private boolean mIsListOfObservers = false;
private Thread mObserverNotifier;
private Context mContext;
-}
\ No newline at end of file
+}
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.base.examples;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.accountserver;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.accountserver;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.accountserver;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.accountserver.db;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.accountserver.db;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.accountserver.db;
public String getDeviceId() {
return this.deviceId;
}
-}
\ No newline at end of file
+}
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.accountserver.db;
public String getSessionCode() {
return this.sessionCode;
}
-}
\ No newline at end of file
+}
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.accountserver.oauth;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.accountserver.oauth;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.accountserver.resources;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.accountserver.resources;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.accountserver.resources;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.accountserver.util;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.ciserver;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.ciserver;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.ciserver.protocols;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.ciserver.resources;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.rdserver;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.rdserver;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.rdserver;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.rdserver.resources;
public void setMt(ArrayList<String> mt) {
this.mt = mt;
}
-}
\ No newline at end of file
+}
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.rdserver.resources;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.rdserver.resources;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.testrdserver;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.base;
/*
- * //****************************************************************** // //
- * Copyright 2016 Samsung Electronics All Rights Reserved. //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // //
- * 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. //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.base;
//
/*
- * //****************************************************************** // //
- * Copyright 2016 Samsung Electronics All Rights Reserved. //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // //
- * 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. //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.base;
//
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.base.protocols.coap;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.base.protocols.coap;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.base.protocols.coap;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.base.protocols.coap;
uri_path.clear();
}
}
-}
\ No newline at end of file
+}
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.base.protocols.coap;
/*
- * //****************************************************************** // //
- * Copyright 2016 Samsung Electronics All Rights Reserved. //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // //
- * 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. //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.base.protocols.proxy;
//
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.util;
}
return cborData;
}
-}
\ No newline at end of file
+}
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.util;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.util;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.util;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.base;
/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.iotivity.cloud.base;
examples_env.AppendUnique(LIBS = ['-lpthread'])
examples_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-examples_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction',
- 'coap', 'rt'])
+examples_env.PrependUnique(LIBS = ['coap'])
+examples_env.AppendUnique(LIBS = ['connectivity_abstraction'])
+examples_env.AppendUnique(LIBS = ['oc_logger'])
+examples_env.AppendUnique(LIBS = ['octbstack'])
+examples_env.AppendUnique(LIBS = ['oc'])
+examples_env.AppendUnique(LIBS = ['rt'])
+
if env.get('SECURED') == '1':
examples_env.AppendUnique(LIBS = ['tinydtls'])
#Set the two variables below for the client build.
-CLIENTARCH=x86
-BUILDTYPE=release
+CLIENTARCH?=x86
+BUILDTYPE?=release
##
YOCTOCXXFLAGS=-I$(SDKTARGETSYSROOT)/usr/include/iotivity/resource/ -I$(SDKTARGETSYSROOT)/usr/include/iotivity/resource/stack -I$(SDKTARGETSYSROOT)/usr/include/iotivity/resource/ocrandom -I$(SDKTARGETSYSROOT)/usr/include/iotivity/resource/logger -I$(SDKTARGETSYSROOT)/usr/include/iotivity/resource/oc_logger
YOCTOLDFLAGS=-loc -loctbstack -loc_logger -lmraa
-CXXFLAGS=-I../../resource/include -I../../resource/csdk/stack/include -I../../resource/c_common/ocrandom/include -I../../resource/csdk/logger/include -I../../resource/oc_logger/include
+CXXFLAGS=-I../../resource/include -I../../resource/c_common -I../../resource/csdk/stack/include -I../../resource/c_common/ocrandom/include -I../../resource/csdk/logger/include -I../../resource/oc_logger/include
LDFLAGS=-L../../out/linux/$(CLIENTARCH)/$(BUILDTYPE) -loc -loctbstack -loc_logger
void *loop(void *threadid)
{
+ (void)threadid;
while (1)
{
sleep(SECOND);
root_dir = './'
tinydtls_src_path = root_dir
-env.AppendUnique(CPPPATH = [root_dir])
-env.AppendUnique(CPPPATH = [root_dir+'aes/'])
-env.AppendUnique(CPPPATH = [root_dir+'ecc/'])
-env.AppendUnique(CPPPATH = [root_dir+'sha2/'])
+dtls_env = env.Clone()
+
+dtls_env.PrependUnique(CPPPATH = [root_dir])
+dtls_env.AppendUnique(CPPPATH = [root_dir+'aes/'])
+dtls_env.AppendUnique(CPPPATH = [root_dir+'ecc/'])
+dtls_env.AppendUnique(CPPPATH = [root_dir+'sha2/'])
if target_os not in ['arduino', 'windows', 'winrt']:
- env.AppendUnique(CPPDEFINES = ['HAVE_SYS_TIME_H'])
+ dtls_env.AppendUnique(CPPDEFINES = ['HAVE_SYS_TIME_H'])
######################################################################
# Source files and Target(s)
'sha2/sha2.c',
]
-env.AppendUnique(TINYDTLS_SRC = tinydtls_src)
-
-if not env.get('RELEASE'):
+if not dtls_env.get('RELEASE'):
if(target_os) not in ['arduino']:
- env.AppendUnique(TINYDTLS_SRC = ['debug.c'])
+ tinydtls_src += ['debug.c']
else:
- env.AppendUnique(CPPDEFINES = ['NDEBUG'])
+ dtls_env.AppendUnique(CPPDEFINES = ['NDEBUG'])
else:
- env.AppendUnique(CPPDEFINES = ['NDEBUG'])
-
-env.AppendUnique(CPPDEFINES = ['DTLSV12', 'WITH_SHA256', 'DTLS_CHECK_CONTENTTYPE', 'SHA2_USE_INTTYPES_H'])
+ dtls_env.AppendUnique(CPPDEFINES = ['NDEBUG'])
+dtls_env.AppendUnique(CPPDEFINES = ['DTLSV12', 'WITH_SHA256', 'DTLS_CHECK_CONTENTTYPE', 'SHA2_USE_INTTYPES_H'])
+env.AppendUnique(CPPDEFINES = ['SHA2_USE_INTTYPES_H'])
-libtinydtls = env.StaticLibrary('libtinydtls', env.get('TINYDTLS_SRC'), OBJPREFIX='libtinydtls_')
+libtinydtls = dtls_env.StaticLibrary('tinydtls', tinydtls_src, OBJPREFIX='libtinydtls_')
######################################################################
# Generate tinydtls samples
# IOT-395
######################################################################
if not env.get('RELEASE'):
- samples_env = env.Clone()
+ samples_env = dtls_env.Clone()
if target_os not in ['arduino', 'windows', 'winrt']:
samples_env.AppendUnique(CPPDEFINES = ['_GNU_SOURCE'])
samples_env.AppendTarget('samples')
-env.InstallTarget(libtinydtls, 'libtinydtls');
+dtls_env.InstallTarget(libtinydtls, 'tinydtls');
errno = 0;
size_t sizeValue = sizeof(value);
int strRet = snprintf(value, sizeValue, "%d", level);
- if (strRet < 0 || (size_t)strRet >= sizeValue)
+
+ if (strRet < 0 || strRet >= (int)sizeValue)
{
OIC_LOG_V(ERROR, TAG, "Failed to parse string due to errno: %d", errno);
exit(1);
target_os = env.get('TARGET_OS')
src_dir = env.get('SRC_DIR')
-if target_os not in ['tizen']:
- # Build liblogger
- SConscript('csdk/logger/SConscript')
+# Build liblogger
+SConscript('csdk/logger/SConscript')
if target_os not in ['arduino', 'darwin', 'ios', 'android']:
env.AppendUnique(LIBS=['rt'])
#endif
#if (__STDC_VERSION__ >= 201112L)
- #include <stdassert.h>
+ #include <assert.h>
#define OC_STATIC_ASSERT(condition, msg) static_assert(condition, msg)
#else
#define OC_STATIC_ASSERT(condition, msg) ((void)sizeof(char[2*!!(condition) - 1]))
liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
if target_os not in ['arduino']:
liboctbstack_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
+if target_os == 'android':
+ liboctbstack_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,liboctbstack.so'])
if env.get('SECURED') == '1':
liboctbstack_env.AppendUnique(LIBS = ['tinydtls'])
env.AppendUnique(CPPDEFINES = ['NO_IP_ADAPTER'])
if with_tcp == True:
- if target_os in ['linux', 'tizen', 'android']:
+ if target_os in ['linux', 'tizen', 'android', 'arduino']:
env.AppendUnique(CPPDEFINES = ['TCP_ADAPTER', 'WITH_TCP'])
print "CA Transport is TCP"
else:
env.AppendUnique(CPPDEFINES = ['NO_NFC_ADAPTER'])
env.SConscript('./src/SConscript')
-
-if build_sample == 'ON':
- if target_os in ['linux', 'arduino', 'darwin']:
- target_path = target_os
-
- if target_os == 'darwin':
- target_path = 'linux'
- env.SConscript('./samples/' + target_path + '/SConscript')
-
- elif target_os in ['android']:
- env.SConscript('./samples/' + target_os + '/SConscript')
-
- #to build sample apk, uncomment below line after ca libraries are built
- #while building ca libraries comment the below line, to avoid build errors
-
- #env.SConscript('./samples/' + target_os + '/casample/SConscript')
#ifndef CA_COMMON_H_
#define CA_COMMON_H_
+#ifndef WITH_ARDUINO
#ifdef TCP_ADAPTER
#define HAVE_SYS_POLL_H
#endif
+#endif
#include <stdint.h>
#include <stdlib.h>
struct tcpsockets
{
void *threadpool; /**< threadpool between Initialize and Start */
+ CASocket_t ipv4; /**< IPv4 accept socket */
+ CASocket_t ipv6; /**< IPv6 accept socket */
void *svrlist; /**< unicast IPv4 TCP server information*/
int selectTimeout; /**< in seconds */
int listenBacklog; /**< backlog counts*/
bool started; /**< the TCP adapter has started */
bool terminate; /**< the TCP adapter needs to stop */
bool ipv4tcpenabled; /**< IPv4 TCP enabled by OCInit flags */
+ bool ipv6tcpenabled; /**< IPv6 TCP enabled by OCInit flags */
} tcp;
#endif
} CAGlobals_t;
* Callback function to pass the connection information from CA to RI.
* @param[out] object remote device information.
*/
-typedef void (*CAKeepAliveConnectedCallback)(const CAEndpoint_t *object);
+typedef void (*CAKeepAliveConnectionCallback)(const CAEndpoint_t *object, bool isConnected);
/**
- * Callback function to pass the disconnection information from CA to RI.
- * @param[out] object remote device information.
- */
-typedef void (*CAKeepAliveDisconnectedCallback)(const CAEndpoint_t *object);
-
-/**
- * Register connected callback and disconnected callback to process KeepAlive.
+ * Register connection status changes callback to process KeepAlive.
* connection informations are delivered these callbacks.
- * @param[in] ConnHandler Connected callback.
- * @param[in] DisconnHandler Disconnected Callback.
+ * @param[in] ConnHandler Connection status changes callback.
*/
-void CARegisterKeepAliveHandler(CAKeepAliveConnectedCallback ConnHandler,
- CAKeepAliveDisconnectedCallback DisconnHandler);
+void CARegisterKeepAliveHandler(CAKeepAliveConnectionCallback ConnHandler);
#endif
/**
* Initialize the connectivity abstraction module.
mkdir -p $sourcedir/tmp/con/c_common
cp -R ./resource/c_common/* $sourcedir/tmp/con/c_common/
cp -R ./resource/csdk/logger/include/* $sourcedir/tmp/con/common/inc/
+mkdir ./tmp/con/logger/
+cp -R ./resource/csdk/logger/* $sourcedir/tmp/con/logger
# copy dependency RPMs and conf files for tizen build
cp ./tools/tizen/*.rpm $sourcedir/tmp
env.SConscript(['../con/lib/libcoap-4.1.1/SConscript'])
env.SConscript(['../con/SConscript'])
env.SConscript(['../con/c_common/SConscript'])
+env.SConscript(['../con/logger/SConscript'])
\ No newline at end of file
void ca_mutex_lock(ca_mutex mutex);
/**
- * Checks if the mutex can be locked.
- *
- * @param mutex The mutex to be locked.
- *
- * @return true if the mutex is not locked currently, otherwise false.
- *
- */
-bool ca_mutex_trylock(ca_mutex mutex);
-
-/**
* Unlock the mutex.
*
* @param mutex The mutex to be unlocked.
return;
}
-bool ca_mutex_trylock(ca_mutex mutex)
-{
- return true;
-}
-
void ca_mutex_unlock(ca_mutex mutex)
{
return;
}
}
-bool ca_mutex_trylock(ca_mutex mutex)
-{
- if (NULL == mutex)
- {
- OIC_LOG_V(ERROR, TAG, "%s Invalid mutex !", __func__);
- return false;
- }
-
- bool bRet = false;
-
- ca_mutex_internal *mutexInfo = (ca_mutex_internal*) mutex;
-
- int result = pthread_mutex_trylock(&mutexInfo->mutex);
-
- switch (result)
- {
- case 0:
- // Success
- bRet = true;
- break;
- case EINVAL:
- OIC_LOG_V(ERROR, TAG, "%s: Invalid mutex !", __func__);
- break;
- case EBUSY:
- default:
- break;
- }
-
- return bRet;
-}
-
void ca_mutex_unlock(ca_mutex mutex)
{
ca_mutex_internal *mutexInfo = (ca_mutex_internal*) mutex;
if(!(*thread_pool)->details->list_lock)
{
OIC_LOG(ERROR, TAG, "Failed to create thread-pool mutex");
- OICFree((*thread_pool)->details);
- OICFree(*thread_pool);
- *thread_pool = NULL;
- return CA_STATUS_FAILED;
+ goto exit;
}
(*thread_pool)->details->threads_list = u_arraylist_create();
{
OIC_LOG(ERROR, TAG, "Failed to free thread-pool mutex");
}
-
- OICFree((*thread_pool)->details);
- OICFree(*thread_pool);
- *thread_pool = NULL;
- return CA_STATUS_FAILED;
+ goto exit;
}
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
+
+exit:
+ OICFree((*thread_pool)->details);
+ OICFree(*thread_pool);
+ *thread_pool = NULL;
+ return CA_STATUS_FAILED;
}
CAResult_t ca_thread_pool_add_task(ca_thread_pool_t thread_pool, ca_thread_func method,
/**
* This will be used to notify network changes to the connectivity common logic layer.
- * @see SendUnicastData(), SendMulticastData()
*/
-typedef void (*CANetworkChangeCallback)(const CAEndpoint_t *info, CANetworkStatus_t status);
+typedef void (*CAAdapterChangeCallback)(CATransportAdapter_t adapter, CANetworkStatus_t status);
+
+/**
+ * This will be used to notify connection changes to the connectivity common logic layer.
+ */
+typedef void (*CAConnectionChangeCallback)(const CAEndpoint_t *info, bool isConnected);
/**
* This will be used to notify error result to the connectivity common logic layer.
jobject *CANativeGetActivity();
/**
+ * get method ID for method Name and class
+ * @param[in] env JNI interface pointer.
+ * @param[in] className android class.
+ * @param[in] methodName android method name.
+ * @param[in] methodFormat method type of methodName.
+ * @return jmethodID iD of the method.
+ */
+jmethodID CAGetJNIMethodID(JNIEnv *env, const char* className,
+ const char* methodName,
+ const char* methodFormat);
+
+/**
* To Delete other Global References
* Called during CATerminate to remove global references
*/
#include "uarraylist.h"
#include "cacommon.h"
#include "caprotocolmessage.h"
+#include "camessagehandler.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
/**
* Callback to send block data.
CA_BLOCK_RECEIVED_ALREADY
} CABlockState_t;
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
/**
* Initializes the block-wise transfer context.
* @param[in] CASendThreadFunc function point to add data in send queue thread.
* @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
CAResult_t CANegotiateBlockSize(CABlockData_t *currData, coap_block_t *block,
- coap_pdu_t *pdu, uint16_t blockType);
+ const coap_pdu_t *pdu, uint16_t blockType);
/**
* Update the block option in block-wise transfer list.
CAResult_t CARemoveBlockDataFromList(const CABlockDataID_t *blockID);
/**
- * Check if data exist in block-wise transfer list.
- * @param[in] blockID ID set of CABlockData.
- * @return true or false.
+ * Remove all block data in block-wise transfer list.
+ * @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
-bool CAIsBlockDataInList(const CABlockDataID_t *blockID);
+CAResult_t CARemoveAllBlockDataFromList();
+/**
+ * Find the block data with seed info and remove it from block-wise transfer list.
+ * @param[in] token token of the message.
+ * @param[in] tokenLength token length of the message.
+ * @param[in] portNumber port.
+ * @return ::CASTATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CARemoveBlockDataFromListWithSeed(const CAToken_t token, uint8_t tokenLength,
+ uint16_t portNumber);
#ifdef __cplusplus
} /* extern "C" */
* Abstraction Layer.
* @param[in] reqRespCallback Callback to notify request and response messages from
* server(s) started at Connectivity Abstraction Layer.
- * @param[in] netCallback Callback to notify the network additions to Connectivity
+ * @param[in] netCallback Callback to notify the adapter changes to Connectivity
+ * Abstraction Layer.
+ * @param[in] connCallback Callback to notify the connection changes to Connectivity
* Abstraction Layer.
* @param[in] errorCallback errorCallback to notify error to connectivity common logic
* layer from adapter.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
- CANetworkPacketReceivedCallback reqRespCallback,
- CANetworkChangeCallback netCallback,
+ CANetworkPacketReceivedCallback packetReceivedCallback,
+ CAAdapterChangeCallback netCallback,
+ CAConnectionChangeCallback connCallback,
CAErrorHandleCallback errorCallback, ca_thread_pool_t handle);
/**
*/
CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback reqRespCallback,
- CANetworkChangeCallback netCallback);
+ CAAdapterChangeCallback netCallback);
/**
* @brief Starting EDR connectivity adapters. As its peer to peer it doesnot require to start
* OIC Transport Profile GATT request characteristic user description
* descriptor value.
*/
-#define CA_GATT_REQUEST_USER_DESCRIPTION "OIC Node Request"
+#define CA_GATT_REQUEST_USER_DESCRIPTION "OCF Node Request"
/// OIC Transport Profile GATT response characteristic UUID.
#define CA_GATT_RESPONSE_CHRC_UUID "E9241982-4580-42C4-8831-95048216B256"
* OIC Transport Profile GATT response characteristic user description
* descriptor value.
*/
-#define CA_GATT_RESPONSE_USER_DESCRIPTION "OIC Node Response"
+#define CA_GATT_RESPONSE_USER_DESCRIPTION "OCF Node Response"
/**
* Standard Bluetooth GATT client characteristic configuration
void CASetErrorHandleCallback(CAErrorHandleCallback errorCallback);
/**
- * Set the network status changed callback for message handler.
- * @param[in] callback message handler network status callback
- * to receive network changes.
+ * Set the network status changed callback for CAUtil.
+ * @param[in] adapterCB CAUtil callback to receive adapter status changes.
+ * @param[in] connCB CAUtil callback to receive connection status changes.
*/
-void CASetNetworkChangeCallback(CANetworkChangeCallback callback);
+void CASetNetworkMonitorCallbacks(CAAdapterChangeCallback adapterCB,
+ CAConnectionChangeCallback connCB);
/**
* Starting different connectivity adapters based on the network selection.
void CASetPacketReceivedCallback(CANetworkPacketReceivedCallback callback);
/**
- * @brief Set the network status changed callback for message handler
+ * @brief Set the adapter status changed callback for message handler
* @param callback [IN] message handler network status callback to receive network
* changes.
* @return none
*/
-void CASetNetworkChangeCallback(CANetworkChangeCallback callback);
+void CASetNetworkChangeCallback(CAAdapterChangeCallback callback);
/**
* @brief Set the error handler callback for message handler
*/
CAResult_t CAInitializeIP(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback networkPacketCallback,
- CANetworkChangeCallback netCallback,
+ CAAdapterChangeCallback netCallback,
CAErrorHandleCallback errorCallback, ca_thread_pool_t handle);
/**
uint32_t ipv4addr; /**< used for IPv4 only. */
} CAInterface_t;
+
+/**
+ * Callback to be notified when IP adapter connection state changes.
+ *
+ * @param[in] adapter Transport adapter.
+ * @param[in] status Connection status either ::CA_INTERFACE_UP or ::CA_INTERFACE_DOWN.
+ * @see CAIPSetConnectionStateChangeCallback() for registration.
+ */
+typedef void (*CAIPConnectionStateChangeCallback)(CATransportAdapter_t adapter, CANetworkStatus_t status);
+
+/**
+ * Set callback for receiving local IP adapter connection status.
+ *
+ * @param[in] adapter Callback to be notified when IP adapter connection state changes.
+ */
+void CAIPSetConnectionStateChangeCallback(CAIPConnectionStateChangeCallback callback);
+
+/**
+ * Set callback for receiving local IP adapter connection status.
+ *
+ * @param[in] callback Callback to be notified when IP adapter connection state changes.
+ */
+void CAIPSetNetworkMonitorCallback(CAIPConnectionStateChangeCallback callback);
+
/**
* Get a list of CAInterface_t items.
*
u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex);
/**
- * @brief Find a new network interface.
+ * Find a new network interface.
*
* @return Description of interface (or NULL if no change)
*/
CAInterface_t *CAFindInterfaceChange();
/**
- * @brief Let the network monitor update the polling interval.
+ * Let the network monitor update the polling interval.
* @param [in] current polling interval
*
* @return desired polling interval
int CAGetPollingInterval(int interval);
/**
- * @brief Tell the IP server an interface has been added.
+ * Tell the IP server an interface has been added.
*/
void CAWakeUpForChange();
CAResult_t CAIPStopNetworkMonitor();
/**
- * @brief Set callback for error handling.
+ * Set callback for error handling.
*
* @param[in] ipErrorCallback callback to notify error to the ipadapter.
*/
* @param[in] reqRespCallback Callback to notify request and response
* messages from server(s) started at
* Connectivity Abstraction Layer.
- * @param[in] netCallback Callback to notify the network additions
+ * @param[in] netCallback Callback to notify the adapter changes
+ * to Connectivity Abstraction Layer.
+ * @param[in] connCallback Callback to notify the connection changes
* to Connectivity Abstraction Layer.
* @param[in] errorCallback errorCallback to notify error to
* connectivity common logic layer from adapter.
*/
CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback reqRespCallback,
- CANetworkChangeCallback netCallback,
+ CAAdapterChangeCallback netCallback,
+ CAConnectionChangeCallback connCallback,
CAErrorHandleCallback errorCallback,
ca_thread_pool_t handle);
*/\r
CAResult_t CAInitializeNFC(CARegisterConnectivityCallback registerCallback,\r
CANetworkPacketReceivedCallback networkPacketCallback,\r
- CANetworkChangeCallback netCallback,\r
+ CAAdapterChangeCallback netCallback,\r
CAErrorHandleCallback errorCallback, ca_thread_pool_t handle);\r
\r
/**\r
*/
CAResult_t CAInitializeRA(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback networkPacketCallback,
- CANetworkChangeCallback netCallback,
+ CAAdapterChangeCallback netCallback,
ca_thread_pool_t handle);
#include "caadapterinterface.h"
#include "cathreadpool.h"
#include "cainterface.h"
+#include "pdu.h"
#ifdef __cplusplus
extern "C"
* @param[in] networkPacketCallback Callback to notify request and
* response messages from server(s)
* started at Connectivity Abstraction Layer.
- * @param[in] netCallback Callback to notify the network additions
+ * @param[in] netCallback Callback to notify the adapter changes
+ * to Connectivity Abstraction Layer.
+ * @param[in] connCallback Callback to notify the connection changes
* to Connectivity Abstraction Layer.
* @param[in] errorCallback Callback to notify the network errors to
* Connectivity Abstraction Layer.
*/
CAResult_t CAInitializeTCP(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback networkPacketCallback,
- CANetworkChangeCallback netCallback,
+ CAAdapterChangeCallback netCallback,
+ CAConnectionChangeCallback connCallback,
CAErrorHandleCallback errorCallback, ca_thread_pool_t handle);
/**
void CATerminateTCP();
/**
- * Set connected callback and disconnected callback to process KeepAlive.
+ * Set connection status changes callback to process KeepAlive.
* connection informations are delivered these callbacks.
- * @param[in] ConnHandler Connected callback.
- * @param[in] DisconnHandler Disconnected Callback.
+ * @param[in] ConnHandler Connection status changes callback.
*/
-void CATCPSetKeepAliveCallbacks(CAKeepAliveConnectedCallback ConnHandler,
- CAKeepAliveDisconnectedCallback DisconnHandler);
+void CATCPSetKeepAliveCallbacks(CAKeepAliveConnectionCallback ConnHandler);
#ifdef __cplusplus
} /* extern "C" */
* @param[in] isConnected Whether keepalive message needs to be sent.
* @see Callback must be registered using CATCPSetKeepAliveCallback().
*/
-typedef void (*CATCPKeepAliveHandleCallback)(const char *addr, uint16_t port, bool isConnected);
+typedef void (*CATCPConnectionHandleCallback)(const char *addr, uint16_t port, bool isConnected);
/**
* set error callback to notify error in TCP adapter.
*/
void CATCPSetErrorHandler(CATCPErrorHandleCallback errorHandleCallback);
+#ifdef SINGLE_THREAD
+
+CAResult_t CATCPStartServer();
+
+/**
+ * Pull the Received Data.
+ */
+void CATCPPullData();
+
+/**
+ * Get TCP Header Details.
+ * @param[in] recvBuffer index of array list.
+ * @param[out] transport TCP Server address.
+ * @param[out] headerlen TCP Server port.
+ */
+void CAGetTCPHeaderDetails(unsigned char *recvBuffer, coap_transport_type *transport,
+ size_t *headerlen);
+
+/**
+ * Get total length from CoAP over TCP header.
+ *
+ * @param[in] recvBuffer received header data.
+ * @param[in] size length of buffer.
+ * @return total data length
+ */
+size_t CAGetTotalLengthFromPacketHeader(const unsigned char *recvBuffer, size_t size);
+
+#else
/**
* set keepalive callback to notify connection information in TCP adapter.
*
* @param[in] keepaliveHandler Callback function to notify the connection information.
* in the TCP adapter.
*/
-void CATCPSetKeepAliveCallback(CATCPKeepAliveHandleCallback keepaliveHandler);
+void CATCPSetKeepAliveCallback(CAKeepAliveConnectionCallback keepaliveHandler);
/**
* Start TCP server.
*/
CAResult_t CATCPStartServer(const ca_thread_pool_t threadPool);
+#endif
+
/**
* Stop TCP server.
*/
{
- static DhcpClass s_dhcp;
_dhcp = &s_dhcp;
+
+
+diff -rupN ./libraries/Ethernet/src/EthernetClient.cpp ./arduino-1.5.8/libraries/Ethernet/src/EthernetClient.cpp
+--- ./libraries/Ethernet/src/EthernetClient.cpp 2014-10-01 20:45:35.000000000 +0530
++++ ./arduino-1.5.8/libraries/Ethernet/src/EthernetClient.cpp 2015-02-05 15:51:09.000000000 +0530
+@@ -92,6 +92,16 @@ int EthernetClient::available() {
+ return 0;
+ }
++void EthernetClient::getTCPClientIP(uint8_t *addr) {
++ if (_sock != MAX_SOCK_NUM)
++ W5100.readSnDIPR(_sock, addr);
++}
++
++void EthernetClient::getTCPClientPort(uint16_t *port) {
++ if (_sock != MAX_SOCK_NUM)
++ W5100.readSnDPORT(_sock);
++}
++
+ int EthernetClient::read() {
+ uint8_t b;
+ if ( recv(_sock, &b, 1) > 0 )
+diff -rupN ./libraries/Ethernet/src/EthernetClient.h ./arduino-1.5.8/libraries/Ethernet/src/EthernetClient.h
+--- ./libraries/Ethernet/src/EthernetClient.h 2014-10-01 20:45:35.000000000 +0530
++++ ./arduino-1.5.8/libraries/Ethernet/src/EthernetClient.h 2015-02-05 15:51:09.000000000 +0530
+@@ -1,6 +1,6 @@
+ #ifndef ethernetclient_h
+ #define ethernetclient_h
+-#include "Arduino.h"
++#include "Arduino.h"
+ #include "Print.h"
+ #include "Client.h"
+ #include "IPAddress.h"
+@@ -26,9 +26,11 @@ public:
+ virtual operator bool();
+ virtual bool operator==(const EthernetClient&);
+ virtual bool operator!=(const EthernetClient& rhs) { return !this->operator==(rhs); };
++ virtual void getTCPClientIP(uint8_t *addr);
++ virtual void getTCPClientPort(uint16_t *port);
+
+ friend class EthernetServer;
+-
++
+ using Print::write;
+
+ private:
+
diff -rupN ./libraries/Ethernet/src/utility/socket.cpp ./arduino-1.5.8/libraries/Ethernet/src/utility/socket.cpp
--- ./libraries/Ethernet/src/utility/socket.cpp 2014-10-01 20:45:35.000000000 +0530
libcoap_env.AppendUnique(CFLAGS = ['-Wall', '-ffunction-sections',
'-fdata-sections', '-fno-exceptions'])
-if target_os in ['linux', 'tizen', 'android', 'ios']:
+if target_os in ['linux', 'tizen', 'android', 'ios', 'arduino']:
if with_tcp == True:
libcoap_env.AppendUnique(CPPDEFINES = ['WITH_TCP'])
#if defined(WITH_POSIX)
coap_context_t *c = coap_malloc( sizeof( coap_context_t ) );
int reuse = 1;
-#endif /* WITH_POSIX */
-#ifdef WITH_LWIP
- coap_context_t *c = memp_malloc(MEMP_COAP_CONTEXT);
-#endif /* WITH_LWIP */
-#ifdef WITH_CONTIKI
- coap_context_t *c;
-
+#elif WITH_CONTIKI
+ coap_context_t *c =NULL;
if (initialized)
- return NULL;
-#endif /* WITH_CONTIKI */
-
+ {
+ return NULL;
+ }
+#elif WITH_LWIP
+ coap_context_t *c = memp_malloc(MEMP_COAP_CONTEXT);
+#endif /* WITH_POSIX */
if (!listen_addr)
{
coap_log(LOG_EMERG, "no listen address specified\n");
+#if defined(WITH_POSIX)
+ coap_free_context(c);
+#elif WITH_LWIP
+ memp_free(c);
+#endif
return NULL;
}
{
case 15:
if (*opt != COAP_PAYLOAD_START)
+ {
debug("ignored reserved option delta 15\n");
+ }
return 0;
case 14:
/* Handle two-byte value: First, the MSB + 269 is stored as delta value.
case coap_tcp:
length = COAP_TCP_HEADER_NO_FIELD;
break;
- case coap_tcp_8bit:
+ case coap_tcp_8bit: /* len(4bit) + TKL(4bit) + Len+bytes(1byte) + Code(1byte) */
length = COAP_TCP_HEADER_8_BIT;
break;
- case coap_tcp_16bit:
+ case coap_tcp_16bit: /* len(4bit) + TKL(4bit) + Len+bytes(2byte) + Code(1byte) */
length = COAP_TCP_HEADER_16_BIT;
break;
- case coap_tcp_32bit:
+ case coap_tcp_32bit: /* len(4bit) + TKL(4bit) + Len+bytes(4byte) + Code(1byte) */
length = COAP_TCP_HEADER_32_BIT;
break;
default:
#ifdef WITH_TCP
/**
- * Get total message length from header.
+ * Get total pdu size including header + option + payload (with marker) from pdu data.
*
* @param data The raw data to parse as CoAP PDU.
* @param size payload size of pdu.
size_t coap_get_total_message_length(const unsigned char *data, size_t size);
/**
- * Get transport type of coap header for coap over tcp through payload size.
+ * Get transport type of coap header for coap over tcp
+ * through payload size(including payload marker) + option size.
*
* @param size payload size of pdu.
* @return The transport type.
coap_transport_type coap_get_tcp_header_type_from_size(unsigned int size);
/**
- * Get transport type of coap header for coap over tcp through init-byte.
+ * Get transport type of coap header for coap over tcp
+ * through first nibble(0~E) of init-byte .
*
* @param legnth length value of init byte.
* @return The transport type.
coap_transport_type coap_get_tcp_header_type_from_initbyte(unsigned int length);
/**
- * Add length value in field of coap header for coap over tcp.
+ * Add length of option/payload into 'Len+ byte...' field of coap header
+ * for coap over tcp.
*
* @param pdu The pdu pointer.
* @param transport The transport type.
unsigned int length);
/**
- * Get the value of length field of coap header for coap over tcp.
+ * Get the length of option/payload field of coap header for coap over tcp.
*
* @param pdu The pdu pointer.
* @param transport The transport type.
unsigned int coap_get_length(const coap_pdu_t *pdu, coap_transport_type transport);
/**
- * Get pdu length from header of coap over tcp.
+ * Get the length of option/payload field of coap header for coap over tcp.
*
* @param header The header to parse.
* @return transport The transport type.
*/
-unsigned int coap_get_length_from_header(const unsigned char *header, coap_transport_type transport);
+unsigned int coap_get_length_from_header(const unsigned char *header,
+ coap_transport_type transport);
/**
- * Get length of header for coap over tcp.
+ * Get length of header including len, TKL, Len+bytes, Code, token bytes for coap over tcp.
*
* @param data The raw data to parse as CoAP PDU
* @return header length + token length
unsigned int coap_get_tcp_header_length(unsigned char *data);
/**
- * Get length of header without token length for coap over tcp.
+ * Get length of header including len, TKL, Len+bytes, Code
+ * without token bytes for coap over tcp.
*
* @param transport The transport type.
* @return header length.
coap_add_attr(coap_resource_t *resource, const unsigned char *name, size_t nlen,
const unsigned char *val, size_t vlen, int flags)
{
- coap_attr_t *attr;
+ coap_attr_t *attr = NULL;
if (!resource || !name)
return NULL;
int coap_delete_resource(coap_context_t *context, coap_key_t key)
{
- coap_resource_t *resource;
- coap_attr_t *attr, *tmp;
+ coap_resource_t *resource = NULL;
+ coap_attr_t *attr = NULL, *tmp = NULL;
#ifdef WITH_CONTIKI
coap_subscription_t *obs;
#endif
if 'IP' in ca_transport:
env.SConscript(os.path.join(ca_path, 'ip_adapter/SConscript'))
+ if ca_os == 'arduino':
+ if with_tcp:
+ transports = [ 'ip_adapter', 'tcp_adapter']
+ env.SConscript(dirs = [
+ os.path.join(ca_path, d) for d in transports ])
if 'BT' in ca_transport:
env.SConscript(os.path.join(ca_path, 'bt_edr_adapter/SConscript'))
print "Include path is %s" % env.get('CPPPATH')
print "Files path is %s" % env.get('CA_SRC')
+
+lib_env = env.Clone()
+
+if ca_os == 'android':
+ lib_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,libconnectivity_abstraction.so'])
+
if ca_os in ['android', 'tizen']:
- env.AppendUnique(LIBS = ['coap'])
- if env.get('SECURED') == '1':
- env.AppendUnique(LIBS = ['tinydtls'])
- env.AppendUnique(LIBS = ['timer'])
+ lib_env.AppendUnique(LIBS = ['coap'])
+ if lib_env.get('SECURED') == '1':
+ lib_env.AppendUnique(LIBS = ['tinydtls'])
+ lib_env.AppendUnique(LIBS = ['timer'])
if ca_os != 'android':
- env.AppendUnique(LIBS = ['rt'])
- calib = env.SharedLibrary('connectivity_abstraction', env.get('CA_SRC'))
+ lib_env.AppendUnique(LIBS = ['rt'])
+ calib = lib_env.SharedLibrary('connectivity_abstraction', lib_env.get('CA_SRC'))
else:
- calib = env.StaticLibrary('connectivity_abstraction', env.get('CA_SRC'))
-env.InstallTarget(calib, 'libconnectivity_abstraction')
-env.UserInstallTargetLib(calib, 'libconnectivity_abstraction')
+ calib = lib_env.StaticLibrary('connectivity_abstraction', lib_env.get('CA_SRC'))
+lib_env.InstallTarget(calib, 'libconnectivity_abstraction')
+lib_env.UserInstallTargetLib(calib, 'libconnectivity_abstraction')
return g_Activity;
}
+jmethodID CAGetJNIMethodID(JNIEnv *env, const char* className,
+ const char* methodName,
+ const char* methodFormat)
+{
+ VERIFY_NON_NULL_RET(env, CA_ADAPTER_UTILS_TAG, "env", NULL);
+ VERIFY_NON_NULL_RET(className, CA_ADAPTER_UTILS_TAG, "className", NULL);
+ VERIFY_NON_NULL_RET(methodName, CA_ADAPTER_UTILS_TAG, "methodName", NULL);
+ VERIFY_NON_NULL_RET(methodFormat, CA_ADAPTER_UTILS_TAG, "methodFormat", NULL);
+
+ jclass jni_cid = (*env)->FindClass(env, className);
+ if (!jni_cid)
+ {
+ OIC_LOG_V(ERROR, CA_ADAPTER_UTILS_TAG, "jni_cid [%s] is null", className);
+ return NULL;
+ }
+
+ jmethodID jni_midID = (*env)->GetMethodID(env, jni_cid, methodName, methodFormat);
+ if (!jni_midID)
+ {
+ OIC_LOG_V(ERROR, CA_ADAPTER_UTILS_TAG, "jni_midID [%s] is null", methodName);
+ (*env)->DeleteLocalRef(env, jni_cid);
+ return NULL;
+ }
+
+ (*env)->DeleteLocalRef(env, jni_cid);
+ return jni_midID;
+}
+
void CADeleteGlobalReferences(JNIEnv *env)
{
if (g_Context)
static jobject g_context;
/**
- * @var g_mutexUnicastServer
- * @brief Mutex to synchronize unicast server
- */
-static ca_mutex g_mutexUnicastServer = NULL;
-
-/**
- * @var g_stopUnicast
- * @brief Flag to control the Receive Unicast Data Thread
- */
-static bool g_stopUnicast = false;
-
-/**
- * @var g_mutexMulticastServer
- * @brief Mutex to synchronize secure multicast server
- */
-static ca_mutex g_mutexMulticastServer = NULL;
-
-/**
- * @var g_stopMulticast
- * @brief Flag to control the Receive Multicast Data Thread
- */
-static bool g_stopMulticast = false;
-
-/**
- * @var g_stopAccept
- * @brief Flag to control the Accept Thread
- */
-static bool g_stopAccept = false;
-
-/**
* @var g_mutexStateList
* @brief Mutex to synchronize device state list
*/
return CA_STATUS_FAILED;
}
- //getApplicationContext
- jclass contextClass = (*env)->FindClass(env, CLASSPATH_CONTEXT);
- if (!contextClass)
+
+ jmethodID mid_getApplicationContext = CAGetJNIMethodID(env, CLASSPATH_CONTEXT,
+ "getApplicationContext",
+ METHODID_CONTEXTNONPARAM);
+ if (!mid_getApplicationContext)
{
- OIC_LOG(ERROR, TAG, "Could not get context object class");
+ OIC_LOG(ERROR, TAG, "Could not get getApplicationContext method");
return CA_STATUS_FAILED;
}
- jmethodID getApplicationContextMethod = (*env)->GetMethodID(env, contextClass,
- "getApplicationContext",
- METHODID_CONTEXTNONPARAM);
- if (!getApplicationContextMethod)
+ jobject jApplicationContext = (*env)->CallObjectMethod(env, context,
+ mid_getApplicationContext);
+ if (!jApplicationContext)
{
- OIC_LOG(ERROR, TAG, "Could not get getApplicationContext method");
+ OIC_LOG(ERROR, TAG, "Could not get application context");
return CA_STATUS_FAILED;
}
return CA_STATUS_FAILED;
}
- (*env)->NewObject(env, EDRJniInterface, EDRInterfaceConstructorMethod, context);
+ (*env)->NewObject(env, EDRJniInterface, EDRInterfaceConstructorMethod, jApplicationContext);
OIC_LOG(DEBUG, TAG, "NewObject Success");
return CA_STATUS_OK;
static void CAEDRDestroyMutex()
{
- if (g_mutexUnicastServer)
- {
- ca_mutex_free(g_mutexUnicastServer);
- g_mutexUnicastServer = NULL;
- }
-
- if (g_mutexMulticastServer)
- {
- ca_mutex_free(g_mutexMulticastServer);
- g_mutexMulticastServer = NULL;
- }
-
if (g_mutexStateList)
{
ca_mutex_free(g_mutexStateList);
static CAResult_t CAEDRCreateMutex()
{
- g_mutexUnicastServer = ca_mutex_new();
- if (!g_mutexUnicastServer)
- {
- OIC_LOG(ERROR, TAG, "Failed to created mutex!");
- return CA_STATUS_FAILED;
- }
-
- g_mutexMulticastServer = ca_mutex_new();
- if (!g_mutexMulticastServer)
- {
- OIC_LOG(ERROR, TAG, "Failed to created mutex!");
-
- CAEDRDestroyMutex();
- return CA_STATUS_FAILED;
- }
-
g_mutexStateList = ca_mutex_new();
if (!g_mutexStateList)
{
isAttached = true;
}
- g_stopAccept = true;
- g_stopMulticast = true;
- g_stopUnicast = true;
-
if (isAttached)
{
(*g_jvm)->DetachCurrentThread(g_jvm);
if (g_context)
{
(*env)->DeleteGlobalRef(env, g_context);
+ g_context = NULL;
}
CAEDRNativeSocketCloseToAll(env);
return result;
}
- OIC_LOG(DEBUG, TAG, "sent data");
-
if (isAttached)
{
OIC_LOG(DEBUG, TAG, "DetachCurrentThread");
if (STATE_DISCONNECTED == CAEDRIsConnectedDevice(address))
{
// connect before send data
- OIC_LOG(DEBUG, TAG, "connect before send data");
+ OIC_LOG_V(DEBUG, TAG, "try to connect with [%s] before sending data", address);
CAResult_t res = CAEDRNativeConnect(env, address);
if (CA_STATUS_OK != res)
CAResult_t CAEDRNativeConnect(JNIEnv *env, const char *address)
{
VERIFY_NON_NULL(address, TAG, "address is null");
- OIC_LOG(DEBUG, TAG, "btConnect..");
if (!CAEDRNativeIsEnableBTAdapter(env))
{
CAEDRUpdateDeviceState(STATE_CONNECTED, address);
ca_mutex_unlock(g_mutexStateList);
- OIC_LOG(DEBUG, TAG, "connected");
+ OIC_LOG(DEBUG, TAG, "successfully connected");
return CA_STATUS_OK;
}
CAEDRUpdateDeviceState(STATE_DISCONNECTED, address);
ca_mutex_unlock(g_mutexStateList);
- OIC_LOG(DEBUG, TAG, "disconnected");
+ OIC_LOG_V(DEBUG, TAG, "disconnected with [%s]", address);
}
CAResult_t CAEDRClientInitialize()
CAResult_t CAEDRInitializeNetworkMonitor(const ca_thread_pool_t threadPool)
{
- OIC_LOG(DEBUG, TAG, "IN");
-
if (!threadPool)
{
return CA_STATUS_FAILED;
CANativeJNIGetJavaVM();
}
- OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
}
void CAEDRTerminateNetworkMonitor(void)
{
- OIC_LOG(DEBUG, TAG, "IN");
-
- OIC_LOG(DEBUG, TAG, "OUT");
}
CAResult_t CAEDRStartNetworkMonitor()
{
- OIC_LOG(DEBUG, TAG, "IN");
-
- OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
}
CAResult_t CAEDRStopNetworkMonitor()
{
- OIC_LOG(DEBUG, TAG, "IN");
-
- OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
}
CAResult_t CAEDRClientSetCallbacks(void)
{
- OIC_LOG(DEBUG, TAG, "IN");
-
- OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
}
jclass jni_cid_BTAdapter = (*env)->FindClass(env, CLASSPATH_BT_ADPATER);
if (!jni_cid_BTAdapter)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] jni_cid_BTAdapter is null");
+ OIC_LOG(ERROR, TAG, "jni_cid_BTAdapter is null");
return;
}
jfieldID id_state_on = (*env)->GetStaticFieldID(env, jni_cid_BTAdapter, "STATE_ON", "I");
if (!id_state_on)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] id_state_on is null");
+ OIC_LOG(ERROR, TAG, "id_state_on is null");
return;
}
jfieldID id_state_off = (*env)->GetStaticFieldID(env, jni_cid_BTAdapter, "STATE_OFF", "I");
if (!id_state_off)
{
- OIC_LOG(ERROR, TAG, "[EDR][Native] id_state_off is null");
+ OIC_LOG(ERROR, TAG, "id_state_off is null");
return;
}
{
CANetworkStatus_t newStatus = CA_INTERFACE_UP;
- CAResult_t res = CAEDRStartUnicastServer(false);
+ CAResult_t res = CAEDRStartReceiveThread(false);
if (CA_STATUS_OK != res)
{
- OIC_LOG(ERROR, TAG, "CAEDRStartUnicastServer failed");
+ OIC_LOG(ERROR, TAG, "Failed to CAEDRStartReceiveThread");
return;
}
CAEDRServerStartAcceptThread();
CAEDRNativeRemoveDevice(addr);
}
}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaEdrInterface_caEdrConnectionStateChangedCallback(JNIEnv *env,
+ jobject obj,
+ jstring addr,
+ jint isConnected)
+{
+ if (!env || !obj || !addr)
+ {
+ OIC_LOG(ERROR, TAG, "parameter is null");
+ return;
+ }
+
+ OIC_LOG_V(DEBUG, TAG, "CaEdrInterface - Connection State Changed : %d", isConnected);
+
+ if (!isConnected)
+ {
+ const char *address = (*env)->GetStringUTFChars(env, addr, NULL);
+ if (!address)
+ {
+ OIC_LOG(ERROR, TAG, "address is null");
+ return;
+ }
+
+ CAEDRNativeRemoveDeviceSocketBaseAddr(env, addr);
+ CAEDRNativeRemoveDevice(address);
+ (*env)->ReleaseStringUTFChars(env, addr, address);
+ }
+}
static const char METHODID_OBJECTNONPARAM[] = "()Landroid/bluetooth/BluetoothAdapter;";
static const char CLASSPATH_BT_ADPATER[] = "android/bluetooth/BluetoothAdapter";
static const char CLASSPATH_BT_UUID[] = "java/util/UUID";
+static const char CLASSPATH_BT_SERVER_SOCKET[] = "android/bluetooth/BluetoothServerSocket";
static ca_thread_pool_t g_threadPoolHandle = NULL;
#define EDR_MAX_HEADER_LEN 6
/**
- * server socket instance.
+ * Mutex to synchronize receive server.
*/
-static jobject g_serverSocketObject = NULL;
-
-/**
- * Mutex to synchronize unicast server.
- */
-static ca_mutex g_mutexUnicastServer = NULL;
+static ca_mutex g_mutexReceiveServer = NULL;
/**
* Flag to control the Receive Unicast Data Thread.
static bool g_stopUnicast = false;
/**
- * Mutex to synchronize secure multicast server.
- */
-static ca_mutex g_mutexMulticastServer = NULL;
-
-/**
- * Flag to control the Receive Multicast Data Thread.
- */
-static bool g_stopMulticast = false;
-
-/**
* Mutex to synchronize accept server.
*/
static ca_mutex g_mutexAcceptServer = NULL;
*/
static ca_mutex g_mutexServerSocket = NULL;
+/**
+ * Flag to control the server socket.
+ */
static jobject g_serverSocket = NULL;
/**
{
OIC_LOG(DEBUG, TAG, "AcceptThread start");
- VERIFY_NON_NULL_VOID(data, TAG, "CAAcceptHandler: data is null");
+ VERIFY_NON_NULL_VOID(data, TAG, "data is null");
bool isAttached = false;
JNIEnv* env;
jint res = (*g_jvm)->GetEnv(g_jvm, (void**) &env, JNI_VERSION_1_6);
if (JNI_OK != res)
{
- OIC_LOG(DEBUG, TAG, "CAAcceptHandler - Could not get JNIEnv pointer");
+ OIC_LOG(DEBUG, TAG, "Could not get JNIEnv pointer");
res = (*g_jvm)->AttachCurrentThread(g_jvm, &env, NULL);
if (JNI_OK != res)
jobject jni_obj_BTServerSocket = CAEDRNativeListen(env);
if (!jni_obj_BTServerSocket)
{
- OIC_LOG(ERROR, TAG, "AcceptThread: jni_obj_BTServerSocket is null");
+ OIC_LOG(ERROR, TAG, "jni_obj_BTServerSocket is null");
if (isAttached)
{
while (true != *(ctx->stopFlag))
{
- OIC_LOG(DEBUG, TAG, "AcceptThread running");
-
// when BT state is changed with Off. its thread will be stopped
if (!CAEDRNativeIsEnableBTAdapter(env))
{
return CA_STATUS_NOT_INITIALIZED;
}
- CAEDRServerStartAcceptThread();
- CAResult_t res = CAEDRStartUnicastServer(false);
- if (CA_STATUS_OK != res)
+ CAResult_t res = CAEDRServerStartAcceptThread();
+ if (CA_STATUS_OK == res)
{
- OIC_LOG(ERROR, TAG, "CAEDRStartUnicastServer failed");
- CAEDRServerStop();
- return CA_STATUS_FAILED;
+ res = CAEDRStartReceiveThread(false);
+ if (CA_STATUS_OK != res)
+ {
+ OIC_LOG(ERROR, TAG, "failed to start receive thread");
+ CAEDRServerStop();
+ return CA_STATUS_FAILED;
+ }
}
return res;
CAResult_t CAEDRServerStop()
{
- CAEDRStopUnicastServer();
- CAEDRStopMulticastServer();
+ CAEDRStopReceiveThread();
ca_mutex_lock(g_mutexAcceptServer);
g_stopAccept = true;
static void CAEDRServerDestroyMutex()
{
- if (g_mutexUnicastServer)
- {
- ca_mutex_free(g_mutexUnicastServer);
- g_mutexUnicastServer = NULL;
- }
-
- if (g_mutexMulticastServer)
+ if (g_mutexReceiveServer)
{
- ca_mutex_free(g_mutexMulticastServer);
- g_mutexMulticastServer = NULL;
+ ca_mutex_free(g_mutexReceiveServer);
+ g_mutexReceiveServer = NULL;
}
if (g_mutexAcceptServer)
static CAResult_t CAEDRServerCreateMutex()
{
- g_mutexUnicastServer = ca_mutex_new();
- if (!g_mutexUnicastServer)
+ g_mutexReceiveServer = ca_mutex_new();
+ if (!g_mutexReceiveServer)
{
OIC_LOG(ERROR, TAG, "Failed to created mutex!");
return CA_STATUS_FAILED;
}
- g_mutexMulticastServer = ca_mutex_new();
- if (!g_mutexMulticastServer)
- {
- OIC_LOG(ERROR, TAG, "Failed to created mutex!");
-
- CAEDRServerDestroyMutex();
- return CA_STATUS_FAILED;
- }
-
g_mutexAcceptServer = ca_mutex_new();
if (!g_mutexAcceptServer)
{
{
OIC_LOG(DEBUG, TAG, "CAEDRServerInitialize");
VERIFY_NON_NULL(handle, TAG, "handle is NULL");
+
g_threadPoolHandle = handle;
CAEDRServerJniInit();
- // init mutex
- CAResult_t result = CAEDRServerCreateMutex();
- return result;
+ return CAEDRServerCreateMutex();
}
CAResult_t CAEDRServerStartAcceptThread()
CAEDRServerDestroyMutex();
}
-CAResult_t CAEDRStartUnicastServer(bool isSecured)
+CAResult_t CAEDRStartReceiveThread(bool isSecured)
{
- OIC_LOG(DEBUG, TAG, "CAEDRStartUnicastServer");
+ OIC_LOG(DEBUG, TAG, "CAEDRStartReceiveThread");
- ca_mutex_lock(g_mutexUnicastServer);
+ ca_mutex_lock(g_mutexReceiveServer);
/**
* The task to listen for data from unicast is added to the thread pool.
if (!ctx)
{
OIC_LOG(ERROR, TAG, "Out of memory!");
- ca_mutex_unlock(g_mutexUnicastServer);
+ ca_mutex_unlock(g_mutexReceiveServer);
return CA_MEMORY_ALLOC_FAILED;
}
+ g_stopUnicast = false;
ctx->stopFlag = &g_stopUnicast;
ctx->type = isSecured ? CA_SECURED_UNICAST_SERVER : CA_UNICAST_SERVER;
if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPoolHandle, CAReceiveHandler, (void *) ctx))
{
OIC_LOG(ERROR, TAG, "Failed to create read thread!");
- ca_mutex_unlock(g_mutexUnicastServer);
- OICFree((void *) ctx);
- return CA_STATUS_FAILED;
- }
- ca_mutex_unlock(g_mutexUnicastServer);
-
- OIC_LOG(DEBUG, TAG, "OUT");
- return CA_STATUS_OK;
-}
-
-CAResult_t CAEDRStartMulticastServer()
-{
- OIC_LOG(DEBUG, TAG, "CAEDRStartMulticastServer");
-
- ca_mutex_lock(g_mutexMulticastServer);
-
- /**
- * The task to listen to data from multicast socket is added to the thread pool.
- * This is a blocking call is made where we try to receive some data.
- * We will keep waiting until some data is received.
- * This task will be terminated when thread pool is freed on stopping the adapters.
- * Thread context will be freed by thread on exit.
- */
- CAAdapterReceiveThreadContext_t *ctx = (CAAdapterReceiveThreadContext_t *) OICMalloc(
- sizeof(CAAdapterReceiveThreadContext_t));
- if (!ctx)
- {
- OIC_LOG(ERROR, TAG, "Out of memory!");
- ca_mutex_unlock(g_mutexMulticastServer);
-
- return CA_MEMORY_ALLOC_FAILED;
- }
-
- ctx->stopFlag = &g_stopMulticast;
- ctx->type = CA_MULTICAST_SERVER;
-
- g_stopMulticast = false;
- if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPoolHandle, CAReceiveHandler, (void *) ctx))
- {
- OIC_LOG(ERROR, TAG, "thread_pool_add_task failed!");
-
- g_stopMulticast = true;
- ca_mutex_unlock(g_mutexMulticastServer);
+ ca_mutex_unlock(g_mutexReceiveServer);
OICFree((void *) ctx);
-
return CA_STATUS_FAILED;
}
- ca_mutex_unlock(g_mutexMulticastServer);
+ ca_mutex_unlock(g_mutexReceiveServer);
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
}
-CAResult_t CAEDRStopUnicastServer()
+CAResult_t CAEDRStopReceiveThread()
{
- OIC_LOG(DEBUG, TAG, "CAEDRStopUnicastServer");
+ OIC_LOG(DEBUG, TAG, "CAEDRStopReceiveThread");
- ca_mutex_lock(g_mutexUnicastServer);
+ ca_mutex_lock(g_mutexReceiveServer);
g_stopUnicast = true;
- ca_mutex_unlock(g_mutexUnicastServer);
+ ca_mutex_unlock(g_mutexReceiveServer);
return CA_STATUS_OK;
}
-CAResult_t CAEDRStopMulticastServer()
-{
- OIC_LOG(DEBUG, TAG, "CAEDRStopMulticastServer");
-
- ca_mutex_lock(g_mutexMulticastServer);
- g_stopMulticast = true;
- ca_mutex_unlock(g_mutexMulticastServer);
-
- OIC_LOG(INFO, TAG, "Multicast server stopped");
-
- return CA_STATUS_OK;
-}
-
-CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t id)
+CAResult_t CAEDRNativeReadData(JNIEnv *env, uint32_t idx)
{
if ((*env)->ExceptionCheck(env))
{
return CA_STATUS_FAILED;
}
- // check whether this socket object is connected or not.
- jobject jni_obj_socket = CAEDRNativeGetDeviceSocket(id);
- if (!jni_obj_socket)
- {
- return CA_STATUS_INVALID_PARAM;
- }
-
- // check it whether is still connected or not through google api
- jboolean ret = CAEDRIsConnectedForSocket(env, jni_obj_socket);
- if (!ret)
- {
- OIC_LOG(ERROR, TAG, "it is not connected yet.");
-
- // remove socket to list
- CAEDRNativeRemoveDeviceSocket(env, jni_obj_socket);
- return CA_STATUS_FAILED;
- }
-
- // start to read through InputStream
- jclass jni_cid_BTsocket = (*env)->FindClass(env, "android/bluetooth/BluetoothSocket");
- if (!jni_cid_BTsocket)
- {
- OIC_LOG(ERROR, TAG, "jni_cid_BTsocket is null");
- return CA_STATUS_FAILED;
- }
- jmethodID jni_mid_getInputStream = (*env)->GetMethodID(env, jni_cid_BTsocket,
- "getInputStream",
- "()Ljava/io/InputStream;");
-
- jobject jni_obj_inputStream = (*env)->CallObjectMethod(env, jni_obj_socket,
- jni_mid_getInputStream);
+ jobject jni_obj_inputStream = CAEDRNativeGetInputStream(idx);
if (!jni_obj_inputStream)
{
OIC_LOG(ERROR, TAG, "jni_obj_inputStream is null");
- (*env)->DeleteLocalRef(env, jni_cid_BTsocket);
- return CA_STATUS_FAILED;
- }
-
- jclass jni_cid_InputStream = (*env)->FindClass(env, "java/io/InputStream");
- if (!jni_cid_InputStream)
- {
- OIC_LOG(ERROR, TAG, "jni_cid_InputStream is null");
- (*env)->DeleteLocalRef(env, jni_obj_inputStream);
- (*env)->DeleteLocalRef(env, jni_cid_BTsocket);
return CA_STATUS_FAILED;
}
- jmethodID jni_mid_available = (*env)->GetMethodID(env, jni_cid_InputStream,
- "available", "()I");
+ jmethodID jni_mid_available = CAGetJNIMethodID(env, "java/io/InputStream", "available", "()I");
if (!jni_mid_available)
{
OIC_LOG(ERROR, TAG, "jni_mid_available is null");
- goto exit;
+ return CA_STATUS_FAILED;
}
jint available = (*env)->CallIntMethod(env, jni_obj_inputStream, jni_mid_available);
- CAConnectedDeviceInfo_t *deviceInfo = NULL;
if (0 < available)
{
+ jobject jni_obj_socket = CAEDRNativeGetDeviceSocket(idx);
+ if (!jni_obj_socket)
+ {
+ OIC_LOG(ERROR, TAG, "jni_obj_socket is null");
+ return CA_STATUS_FAILED;
+ }
+
jstring jni_str_address = CAEDRNativeGetAddressFromDeviceSocket(env, jni_obj_socket);
if (!jni_str_address)
{
OIC_LOG(ERROR, TAG, "jni_str_address is null");
- goto exit;
+ return CA_STATUS_FAILED;
}
const char* address = (*env)->GetStringUTFChars(env, jni_str_address, NULL);
{
OIC_LOG(ERROR, TAG, "address is null");
(*env)->DeleteLocalRef(env, jni_str_address);
- goto exit;
- }
-
- OIC_LOG_V(DEBUG, TAG, "get InputStream..%d, %s", id, address);
- jmethodID jni_mid_read = (*env)->GetMethodID(env, jni_cid_InputStream,
- "read", "([BII)I");
- if (!jni_mid_read)
- {
- OIC_LOG(ERROR, TAG, "jni_mid_read is null");
- (*env)->ReleaseStringUTFChars(env, jni_str_address, address);
- (*env)->DeleteLocalRef(env, jni_str_address);
- goto exit;
+ return CA_STATUS_FAILED;
}
- deviceInfo = (CAConnectedDeviceInfo_t *) CAEDRGetDeviceInfoFromAddress(address);
+ CAConnectedDeviceInfo_t *deviceInfo =
+ (CAConnectedDeviceInfo_t *) CAEDRGetDeviceInfoFromAddress(address);
if (!deviceInfo)
{
OIC_LOG(ERROR, TAG, "failed to get device info from list");
(*env)->ReleaseStringUTFChars(env, jni_str_address, address);
(*env)->DeleteLocalRef(env, jni_str_address);
- goto exit;
+ return CA_STATUS_FAILED;
}
- jint bufSize = (deviceInfo->totalDataLen == 0) ?
- EDR_MAX_HEADER_LEN : deviceInfo->totalDataLen;
+ jint bufSize = (deviceInfo->totalDataLen == 0) ? EDR_MAX_HEADER_LEN
+ : deviceInfo->totalDataLen;
if (!deviceInfo->recvData)
{
deviceInfo->recvData = OICCalloc(1, bufSize);
OIC_LOG(ERROR, TAG, "out of memory");
(*env)->ReleaseStringUTFChars(env, jni_str_address, address);
(*env)->DeleteLocalRef(env, jni_str_address);
- goto exit;
+ return CA_STATUS_FAILED;
}
}
- jbyteArray jbuf = (*env)->NewByteArray(env, (jint) bufSize - deviceInfo->recvDataLen);
+ jint remainSize = (jint) bufSize - deviceInfo->recvDataLen;
+ if (0 >= remainSize)
+ {
+ OIC_LOG(ERROR, TAG, "remainSize value is invalid.");
+ (*env)->ReleaseStringUTFChars(env, jni_str_address, address);
+ (*env)->DeleteLocalRef(env, jni_str_address);
+ return CA_STATUS_FAILED;
+ }
+
+ jbyteArray jbuf = (*env)->NewByteArray(env, remainSize);
if (!jbuf)
{
OIC_LOG(ERROR, TAG, "jbuf is null");
(*env)->ReleaseStringUTFChars(env, jni_str_address, address);
(*env)->DeleteLocalRef(env, jni_str_address);
- goto exit;
+ return CA_STATUS_FAILED;
+ }
+
+ jmethodID jni_mid_read = CAGetJNIMethodID(env, "java/io/InputStream", "read", "([BII)I");
+ if (!jni_mid_read)
+ {
+ OIC_LOG(ERROR, TAG, "jni_mid_read is null");
+ (*env)->DeleteLocalRef(env, jbuf);
+ (*env)->ReleaseStringUTFChars(env, jni_str_address, address);
+ (*env)->DeleteLocalRef(env, jni_str_address);
+ return CA_STATUS_FAILED;
}
+ OIC_LOG_V(DEBUG, TAG, "read InputStream (idx:%d, addr:%s)", idx, address);
jint recvLen = (*env)->CallIntMethod(env, jni_obj_inputStream, jni_mid_read,
- jbuf, (jint) 0,
- (jint) bufSize - deviceInfo->recvDataLen);
+ jbuf, (jint) 0, remainSize);
if (-1 == recvLen)
{
OIC_LOG(ERROR, TAG, "recvLen is -1");
(*env)->DeleteLocalRef(env, jbuf);
(*env)->ReleaseStringUTFChars(env, jni_str_address, address);
(*env)->DeleteLocalRef(env, jni_str_address);
- goto exit;
+ return CA_STATUS_FAILED;
}
+ OIC_LOG_V(DEBUG, TAG, "read success (length: %d bytes)", recvLen);
jbyte* buf = (*env)->GetByteArrayElements(env, jbuf, NULL);
if (!buf)
(*env)->DeleteLocalRef(env, jbuf);
(*env)->ReleaseStringUTFChars(env, jni_str_address, address);
(*env)->DeleteLocalRef(env, jni_str_address);
- goto exit;
+ return CA_STATUS_FAILED;
}
memcpy(deviceInfo->recvData + deviceInfo->recvDataLen, (const char*) buf, recvLen);
deviceInfo->recvDataLen += recvLen;
- OIC_LOG(DEBUG, TAG, "read something from InputStream");
+ (*env)->ReleaseByteArrayElements(env, jbuf, buf, 0);
+ (*env)->DeleteLocalRef(env, jbuf);
if (!deviceInfo->totalDataLen)
{
if (!newBuf)
{
OIC_LOG(ERROR, TAG, "out of memory");
- (*env)->ReleaseByteArrayElements(env, jbuf, buf, 0);
- (*env)->DeleteLocalRef(env, jbuf);
(*env)->ReleaseStringUTFChars(env, jni_str_address, address);
(*env)->DeleteLocalRef(env, jni_str_address);
- goto exit;
+ return CA_STATUS_FAILED;
}
deviceInfo->recvData = newBuf;
}
CAEDRUpdateDeviceState(STATE_DISCONNECTED, address);
ca_mutex_unlock(g_mutexStateList);
- (*env)->ReleaseByteArrayElements(env, jbuf, buf, 0);
- (*env)->DeleteLocalRef(env, jbuf);
(*env)->ReleaseStringUTFChars(env, jni_str_address, address);
(*env)->DeleteLocalRef(env, jni_str_address);
- goto exit;
+ return CA_STATUS_FAILED;
}
if (g_edrPacketReceivedCallback)
{
- OIC_LOG_V(DEBUG, TAG,"data will be sent to callback routine: \
- %s, %d", deviceInfo->recvData, deviceInfo->recvDataLen);
+ OIC_LOG_V(DEBUG, TAG, "data will be sent to callback routine: %s, %d",
+ deviceInfo->recvData, deviceInfo->recvDataLen);
uint32_t sentLength = 0;
g_edrPacketReceivedCallback(address, (void*) deviceInfo->recvData,
deviceInfo->totalDataLen = 0;
}
}
- (*env)->ReleaseByteArrayElements(env, jbuf, buf, 0);
- (*env)->DeleteLocalRef(env, jbuf);
+
(*env)->ReleaseStringUTFChars(env, jni_str_address, address);
(*env)->DeleteLocalRef(env, jni_str_address);
}
- (*env)->DeleteLocalRef(env, jni_cid_InputStream);
- (*env)->DeleteLocalRef(env, jni_obj_inputStream);
- (*env)->DeleteLocalRef(env, jni_cid_BTsocket);
return CA_STATUS_OK;
-
-exit:
- (*env)->DeleteLocalRef(env, jni_cid_InputStream);
- (*env)->DeleteLocalRef(env, jni_obj_inputStream);
- (*env)->DeleteLocalRef(env, jni_cid_BTsocket);
-
- return CA_STATUS_FAILED;
-}
-
-jboolean CAEDRIsConnectedForSocket(JNIEnv *env, jobject socket)
-{
- if (!socket)
- {
- OIC_LOG(ERROR, TAG, "socket is null");
- return JNI_FALSE;
- }
-
- jclass jni_cid_BTsocket = (*env)->FindClass(env, "android/bluetooth/BluetoothSocket");
- if (!jni_cid_BTsocket)
- {
- OIC_LOG(ERROR, TAG, "jni_cid_BTsocket is null");
- return JNI_FALSE;
- }
-
- jmethodID jni_mid_isConnected = (*env)->GetMethodID(env, jni_cid_BTsocket, "isConnected",
- "()Z");
- if (!jni_mid_isConnected)
- {
- OIC_LOG(ERROR, TAG, "jni_mid_isConnected is null.");
- (*env)->DeleteLocalRef(env, jni_cid_BTsocket);
- return JNI_FALSE;
- }
-
- jboolean jni_isConnected = (*env)->CallBooleanMethod(env, socket, jni_mid_isConnected);
-
- (*env)->DeleteLocalRef(env, jni_cid_BTsocket);
-
- return jni_isConnected;
}
void CANativeStartListenTask(JNIEnv *env)
return NULL;
}
- g_serverSocketObject = (*env)->NewGlobalRef(env, jni_obj_BTServerSocket);
-
OIC_LOG(DEBUG, TAG, "CAEDRNativeListen - OUT");
return jni_obj_BTServerSocket;
if (NULL != serverSocketObject)
{
- jclass jni_cid_BTServerSocket = (*env)->FindClass(
- env, "android/bluetooth/BluetoothServerSocket");
- if (!jni_cid_BTServerSocket)
- {
- OIC_LOG(ERROR, TAG, "jni_cid_BTServerSocket is null");
- return;
- }
-
- jmethodID jni_mid_accept = (*env)->GetMethodID(env, jni_cid_BTServerSocket, "accept",
- "()Landroid/bluetooth/BluetoothSocket;");
+ jmethodID jni_mid_accept = CAGetJNIMethodID(env, CLASSPATH_BT_SERVER_SOCKET,
+ "accept",
+ "()Landroid/bluetooth/BluetoothSocket;");
if (!jni_mid_accept)
{
OIC_LOG(ERROR, TAG, "jni_mid_accept is null");
return;
}
- OIC_LOG(DEBUG, TAG, "initiating accept...");
+ OIC_LOG(DEBUG, TAG, "waiting for the new connection request...");
jobject jni_obj_BTSocket = (*env)->CallObjectMethod(env, serverSocketObject,
jni_mid_accept);
}
const char* address = (*env)->GetStringUTFChars(env, j_str_address, NULL);
- OIC_LOG_V(DEBUG, TAG, "address is %s", address);
-
- // set socket to list
- jobject jni_socket = (*env)->NewGlobalRef(env, jni_obj_BTSocket);
- ca_mutex_lock(g_mutexObjectList);
- CAEDRNativeAddDeviceSocketToList(env, jni_socket);
- ca_mutex_unlock(g_mutexObjectList);
- OIC_LOG(DEBUG, TAG, "Accepted!!");
+ OIC_LOG_V(INFO, TAG, "accept a new connection from [%s]", address);
// update state
ca_mutex_lock(g_mutexStateList);
(*env)->ReleaseStringUTFChars(env, j_str_address, address);
(*env)->DeleteLocalRef(env, j_str_address);
+
+ // set socket to list
+ jobject jni_socket = (*env)->NewGlobalRef(env, jni_obj_BTSocket);
+ if (!jni_socket)
+ {
+ OIC_LOG(ERROR, TAG, "jni_socket is null");
+ (*env)->DeleteLocalRef(env, jni_obj_BTSocket);
+ return;
+ }
+
+ ca_mutex_lock(g_mutexObjectList);
+ CAEDRNativeAddDeviceSocketToList(env, jni_socket);
+ ca_mutex_unlock(g_mutexObjectList);
+
+ (*env)->DeleteGlobalRef(env, jni_socket);
+ (*env)->DeleteLocalRef(env, jni_obj_BTSocket);
}
else
{
{
OIC_LOG(DEBUG, TAG, "Accept Resource will be close");
- jclass jni_cid_BTServerSocket = (*env)->FindClass(
- env, "android/bluetooth/BluetoothServerSocket");
- if (!jni_cid_BTServerSocket)
+ jmethodID jni_mid_close = CAGetJNIMethodID(env, CLASSPATH_BT_SERVER_SOCKET,
+ "close", "()V");
+ if (!jni_mid_close)
{
- OIC_LOG(ERROR, TAG, "jni_cid_BTServerSocket is null");
+ OIC_LOG(ERROR, TAG, "jni_mid_close is null");
return;
}
- jmethodID jni_mid_accept = (*env)->GetMethodID(env, jni_cid_BTServerSocket, "close", "()V");
- if (!jni_mid_accept)
- {
- OIC_LOG(ERROR, TAG, "jni_mid_accept is null");
- return;
- }
- (*env)->CallVoidMethod(env, g_serverSocket, jni_mid_accept);
+ (*env)->CallVoidMethod(env, g_serverSocket, jni_mid_close);
(*env)->DeleteGlobalRef(env, g_serverSocket);
g_serverSocket = NULL;
CAResult_t CAEDRServerStartAcceptThread();
/**
- * Start unicast server.
+ * Start receive thread.
* @param[in] isSecured unicast server type.
* @return ::CA_STATUS_OK or Appropriate error code.
*/
-CAResult_t CAEDRStartUnicastServer(bool isSecured);
+CAResult_t CAEDRStartReceiveThread(bool isSecured);
/**
- * Start multicast server.
+ * Stop receive thread.
* @return ::CA_STATUS_OK or Appropriate error code.
*/
-CAResult_t CAEDRStartMulticastServer();
-
-/**
- * Stop unicast server.
- * @return ::CA_STATUS_OK or Appropriate error code.
- */
-CAResult_t CAEDRStopUnicastServer();
-
-/**
- * Stop multicast server.
- * @return ::CA_STATUS_OK or Appropriate error code.
- */
-CAResult_t CAEDRStopMulticastServer();
+CAResult_t CAEDRStopReceiveThread();
/**
* This function will read the data from remote device.
jobject CAEDRNativeListen(JNIEnv *env);
/**
- * This function will listen the connection from remote device.
- * @param[in] env JNI interface pointer.
- * @param[in] socket server socket object.
- * @return JNI_TRUE or JNI_FALSE.
- */
-jboolean CAEDRIsConnectedForSocket(JNIEnv *env, jobject socket);
-
-/**
* This function will accept the connection from remote device.
* @param[in] env JNI interface pointer.
* @param[in] severSocketObject server socket object.
#include "oic_string.h"
#include "cathreadpool.h"
#include "uarraylist.h"
+#include "caadapterutils.h"
#define ERROR_CODE (-1)
#define TAG PCF("OIC_CA_EDR_UTILS")
// get address from bluetooth socket
jstring CAEDRNativeGetAddressFromDeviceSocket(JNIEnv *env, jobject bluetoothSocketObj)
{
- if (!bluetoothSocketObj)
- {
- OIC_LOG(ERROR, TAG, "bluetoothSocketObj is null");
- return NULL;
- }
+ VERIFY_NON_NULL_RET(bluetoothSocketObj, TAG, "bluetoothSocketObj", NULL);
- jclass jni_cid_BTSocket = (*env)->FindClass(env, CLASSPATH_BT_SOCKET);
- if (!jni_cid_BTSocket)
- {
- OIC_LOG(ERROR, TAG, "jni_cid_BTSocket is null");
- return NULL;
- }
-
- jmethodID jni_mid_getRemoteDevice = (*env)->GetMethodID(
- env, jni_cid_BTSocket, "getRemoteDevice", "()Landroid/bluetooth/BluetoothDevice;");
+ jmethodID jni_mid_getRemoteDevice = CAGetJNIMethodID(
+ env, CLASSPATH_BT_SOCKET, "getRemoteDevice", "()Landroid/bluetooth/BluetoothDevice;");
if (!jni_mid_getRemoteDevice)
{
OIC_LOG(ERROR, TAG, "jni_mid_getRemoteDevice is null");
- (*env)->DeleteLocalRef(env, jni_cid_BTSocket);
return NULL;
}
if (!jni_obj_remoteBTDevice)
{
OIC_LOG(ERROR, TAG, "jni_obj_remoteBTDevice is null");
- (*env)->DeleteLocalRef(env, jni_cid_BTSocket);
return NULL;
}
- jclass jni_cid_BTDevice = (*env)->FindClass(env, CLASSPATH_BT_DEVICE);
- if (!jni_cid_BTDevice)
- {
- OIC_LOG(ERROR, TAG, "jni_cid_BTDevice is null");
- (*env)->DeleteLocalRef(env, jni_obj_remoteBTDevice);
- (*env)->DeleteLocalRef(env, jni_cid_BTSocket);
- return NULL;
- }
- jmethodID j_mid_getAddress = (*env)->GetMethodID(env, jni_cid_BTDevice, "getAddress",
- METHODID_STRINGNONPARAM);
+ jmethodID j_mid_getAddress = CAGetJNIMethodID(env, CLASSPATH_BT_DEVICE,
+ "getAddress",
+ METHODID_STRINGNONPARAM);
if (!j_mid_getAddress)
{
OIC_LOG(ERROR, TAG, "j_mid_getAddress is null");
(*env)->DeleteLocalRef(env, jni_obj_remoteBTDevice);
- (*env)->DeleteLocalRef(env, jni_cid_BTDevice);
- (*env)->DeleteLocalRef(env, jni_cid_BTSocket);
return NULL;
}
- jstring j_str_address = (*env)->CallObjectMethod(env, jni_obj_remoteBTDevice, j_mid_getAddress);
+ jstring j_str_address = (*env)->CallObjectMethod(env, jni_obj_remoteBTDevice,
+ j_mid_getAddress);
if (!j_str_address)
{
OIC_LOG(ERROR, TAG, "j_str_address is null");
(*env)->DeleteLocalRef(env, jni_obj_remoteBTDevice);
- (*env)->DeleteLocalRef(env, jni_cid_BTDevice);
- (*env)->DeleteLocalRef(env, jni_cid_BTSocket);
return NULL;
}
(*env)->DeleteLocalRef(env, jni_obj_remoteBTDevice);
- (*env)->DeleteLocalRef(env, jni_cid_BTDevice);
- (*env)->DeleteLocalRef(env, jni_cid_BTSocket);
return j_str_address;
}
// Convert the set to an object array
// object[] array = Set<BluetoothDevice>.toArray();
- jclass jni_cid_Set = (*env)->FindClass(env, "java/util/Set");
- if (!jni_cid_Set)
- {
- OIC_LOG(ERROR, TAG, "jni_cid_Set is null");
- goto exit;
- }
- jmethodID jni_mid_toArray = (*env)->GetMethodID(env, jni_cid_Set, "toArray",
- "()[Ljava/lang/Object;");
-
+ jmethodID jni_mid_toArray = CAGetJNIMethodID(env, "java/util/Set",
+ "toArray", "()[Ljava/lang/Object;");
if (!jni_mid_toArray)
{
OIC_LOG(ERROR, TAG, "jni_mid_toArray is null");
jstring CAEDRNativeGetAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
{
- if (!bluetoothDevice)
- {
- OIC_LOG(ERROR, TAG, "bluetoothDevice is null");
- return NULL;
- }
- jclass jni_cid_device_list = (*env)->FindClass(env, "android/bluetooth/BluetoothDevice");
- if (!jni_cid_device_list)
- {
- OIC_LOG(ERROR, TAG, "jni_cid_device_list is null");
- return NULL;
- }
+ VERIFY_NON_NULL_RET(bluetoothDevice, TAG, "bluetoothDevice", NULL);
- jmethodID jni_mid_getAddress = (*env)->GetMethodID(env, jni_cid_device_list, "getAddress",
- METHODID_STRINGNONPARAM);
+ jmethodID jni_mid_getAddress = CAGetJNIMethodID(env,
+ CLASSPATH_BT_DEVICE,
+ "getAddress",
+ METHODID_STRINGNONPARAM);
if (!jni_mid_getAddress)
{
OIC_LOG(ERROR, TAG, "jni_mid_getAddress is null");
void CAEDRUpdateDeviceState(CAConnectedState_t state, const char *address)
{
- if (!address)
- {
- OIC_LOG(ERROR, TAG, "address is null");
- return;
- }
+ VERIFY_NON_NULL_VOID(address, TAG, "address");
+
CAConnectedDeviceInfo_t *deviceInfo =
(CAConnectedDeviceInfo_t *) OICCalloc(1, sizeof(CAConnectedDeviceInfo_t));
if (!deviceInfo)
void CAEDRNativeAddDeviceStateToList(CAConnectedDeviceInfo_t *deviceInfo)
{
- if (!deviceInfo)
- {
- OIC_LOG(ERROR, TAG, "device is null");
- return;
- }
+ VERIFY_NON_NULL_VOID(deviceInfo, TAG, "deviceInfo");
if (!g_deviceStateList)
{
CAEDRNativeRemoveDevice((const char*) deviceInfo->address);
}
u_arraylist_add(g_deviceStateList, deviceInfo); // update new state
- OIC_LOG_V(DEBUG, TAG, "Set State Info to List : %d", deviceInfo->state);
+ OIC_LOG_V(DEBUG, TAG, "add new device state[%d] to list", deviceInfo->state);
}
bool CAEDRNativeIsDeviceInList(const char* remoteAddress)
{
- if (!remoteAddress)
- {
- OIC_LOG(ERROR, TAG, "remoteAddress is null");
- return false;
- }
+ VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress", false);
jint length = u_arraylist_length(g_deviceStateList);
for (jint index = 0; index < length; index++)
void CAEDRNativeRemoveDevice(const char *remoteAddress)
{
OIC_LOG(DEBUG, TAG, "CAEDRNativeRemoveDeviceforStateList");
+ VERIFY_NON_NULL_VOID(remoteAddress, TAG, "remoteAddress");
if (!g_deviceStateList)
{
OIC_LOG(ERROR, TAG, "gdeviceStateList is null");
return;
}
- if (!remoteAddress)
- {
- OIC_LOG(ERROR, TAG, "remoteAddress is null");
- return;
- }
jint length = u_arraylist_length(g_deviceStateList);
for (jint index = 0; index < length; index++)
if (!strcmp((const char*) deviceInfo->address, remoteAddress))
{
- OIC_LOG_V(DEBUG, TAG, "remove state : %s", remoteAddress);
+ OIC_LOG_V(DEBUG, TAG, "remove [%s] info from list", remoteAddress);
OICFree(deviceInfo);
u_arraylist_remove(g_deviceStateList, index);
CAConnectedState_t CAEDRIsConnectedDevice(const char *remoteAddress)
{
OIC_LOG(DEBUG, TAG, "CAEDRIsConnectedDevice");
-
- if (!remoteAddress)
- {
- OIC_LOG(ERROR, TAG, "remoteAddress is null");
- return STATE_DISCONNECTED;
- }
+ VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress", STATE_DISCONNECTED);
if (!g_deviceStateList)
{
void CAEDRNativeAddDeviceSocketToList(JNIEnv *env, jobject deviceSocket)
{
OIC_LOG(DEBUG, TAG, "CANativeAddDeviceobjToList");
-
- if (!deviceSocket)
- {
- OIC_LOG(ERROR, TAG, "Device is null");
- return;
- }
+ VERIFY_NON_NULL_VOID(deviceSocket, TAG, "deviceSocket");
if (!g_deviceObjectList)
{
const char* remoteAddress = (*env)->GetStringUTFChars(env, jni_remoteAddress, NULL);
- if (!CAEDRNativeIsDeviceSocketInList(env, remoteAddress))
+ if (CAEDRNativeIsDeviceSocketInList(env, remoteAddress))
{
- jobject gDeviceSocker = (*env)->NewGlobalRef(env, deviceSocket);
- u_arraylist_add(g_deviceObjectList, gDeviceSocker);
- OIC_LOG(DEBUG, TAG, "Set Socket Object to Array");
+ OIC_LOG(DEBUG, TAG, "the address exists in deviceObjectList. remove it to add new");
+ CAEDRNativeRemoveDeviceSocketBaseAddr(env, jni_remoteAddress);
}
+
(*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
(*env)->DeleteLocalRef(env, jni_remoteAddress);
+
+ CAEDRSocketInfo_t *socketInfo = (CAEDRSocketInfo_t *) OICCalloc(1, sizeof(*socketInfo));
+ if (!socketInfo)
+ {
+ OIC_LOG(ERROR, TAG, "Out of memory");
+ return;
+ }
+
+ jmethodID jni_mid_getInputStream = CAGetJNIMethodID(env, "android/bluetooth/BluetoothSocket",
+ "getInputStream",
+ "()Ljava/io/InputStream;");
+ if (!jni_mid_getInputStream)
+ {
+ OIC_LOG(ERROR, TAG, "jni_mid_getInputStream is null");
+ return;
+ }
+
+ jobject jni_obj_inputStream = (*env)->CallObjectMethod(env, deviceSocket,
+ jni_mid_getInputStream);
+ if (!jni_obj_inputStream)
+ {
+ OIC_LOG(ERROR, TAG, "jni_obj_inputStream is null");
+ return;
+ }
+
+ socketInfo->deviceSocket = (*env)->NewGlobalRef(env, deviceSocket);
+ socketInfo->inputStream = (*env)->NewGlobalRef(env, jni_obj_inputStream);
+ (*env)->DeleteLocalRef(env, jni_obj_inputStream);
+
+ bool result = u_arraylist_add(g_deviceObjectList, (void *) socketInfo);
+ if (!result)
+ {
+ OIC_LOG(ERROR, TAG, "u_arraylist_add failed.");
+ OICFree(socketInfo);
+ return;
+ }
+
+ OIC_LOG(DEBUG, TAG, "add new device socket object to list");
}
bool CAEDRNativeIsDeviceSocketInList(JNIEnv *env, const char* remoteAddress)
{
OIC_LOG(DEBUG, TAG, "CANativeIsDeviceObjInList");
+ VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress", false);
- if (!remoteAddress)
- {
- OIC_LOG(ERROR, TAG, "remoteAddress is null");
- return false;
- }
-
- jint length = u_arraylist_length(g_deviceStateList);
+ jint length = u_arraylist_length(g_deviceObjectList);
for (jint index = 0; index < length; index++)
{
+ CAEDRSocketInfo_t *socketInfo = (CAEDRSocketInfo_t *) u_arraylist_get(g_deviceObjectList,
+ index);
+ if (!socketInfo)
+ {
+ OIC_LOG(DEBUG, TAG, "socketInfo is null");
+ return false;
+ }
- jobject jarrayObj = (jobject) u_arraylist_get(g_deviceObjectList, index);
+ jobject jarrayObj = socketInfo->deviceSocket;
if (!jarrayObj)
{
OIC_LOG(DEBUG, TAG, "jarrayObj is null");
}
}
- OIC_LOG(DEBUG, TAG, "there are no the Device obejct in list. we can add");
+ OIC_LOG(DEBUG, TAG, "there are no the Device obejct in list");
return false;
}
return;
}
- jclass jni_cid_BTSocket = (*env)->FindClass(env, CLASSPATH_BT_SOCKET);
- if (!jni_cid_BTSocket)
- {
- OIC_LOG(ERROR, TAG, "jni_cid_BTSocket is null");
- return;
- }
-
- jmethodID jni_mid_close = (*env)->GetMethodID(env, jni_cid_BTSocket, "close", "()V");
+ jmethodID jni_mid_close = CAGetJNIMethodID(env, CLASSPATH_BT_SOCKET,
+ "close", "()V");
if (!jni_mid_close)
{
OIC_LOG(ERROR, TAG, "jni_mid_close is null");
return;
}
- jint length = u_arraylist_length(g_deviceStateList);
+ jint length = u_arraylist_length(g_deviceObjectList);
for (jint index = 0; index < length; index++)
{
jobject jni_obj_socket = (jobject) u_arraylist_get(g_deviceObjectList, index);
return;
}
- jint length = u_arraylist_length(g_deviceStateList);
+ jint length = u_arraylist_length(g_deviceObjectList);
for (jint index = 0; index < length; index++)
{
- jobject jarrayObj = (jobject) u_arraylist_get(g_deviceObjectList, index);
- if (!jarrayObj)
+ CAEDRSocketInfo_t *socketInfo = (CAEDRSocketInfo_t *) u_arraylist_get(g_deviceObjectList,
+ index);
+ if (!socketInfo)
{
- OIC_LOG(ERROR, TAG, "jarrayObj is null");
- return;
+ OIC_LOG(ERROR, TAG, "socketInfo is null");
+ continue;
+ }
+
+ jobject jdeviceSocket = socketInfo->deviceSocket;
+ if (jdeviceSocket)
+ {
+ (*env)->DeleteGlobalRef(env, jdeviceSocket);
+ }
+
+ jobject jinputStream = socketInfo->inputStream;
+ if (jinputStream)
+ {
+ (*env)->DeleteGlobalRef(env, jinputStream);
}
- (*env)->DeleteGlobalRef(env, jarrayObj);
}
OICFree(g_deviceObjectList);
void CAEDRNativeRemoveDeviceSocket(JNIEnv *env, jobject deviceSocket)
{
OIC_LOG(DEBUG, TAG, "CAEDRNativeRemoveDeviceSocket");
+ VERIFY_NON_NULL_VOID(deviceSocket, TAG, "deviceSocket");
- if (!g_deviceObjectList)
+ jstring jni_address = CAEDRNativeGetAddressFromDeviceSocket(env, deviceSocket);
+ if (!jni_address)
{
- OIC_LOG(ERROR, TAG, "gdeviceObjectList is null");
+ OIC_LOG(ERROR, TAG, "jni_address is null");
return;
}
- jint length = u_arraylist_length(g_deviceStateList);
- for (jint index = 0; index < length; index++)
- {
- jobject jarrayObj = (jobject) u_arraylist_get(g_deviceObjectList, index);
- if (!jarrayObj)
- {
- OIC_LOG(DEBUG, TAG, "jarrayObj is null");
- continue;
- }
-
- jstring jni_setAddress = CAEDRNativeGetAddressFromDeviceSocket(env, jarrayObj);
- if (!jni_setAddress)
- {
- OIC_LOG(DEBUG, TAG, "jni_setAddress is null");
- continue;
- }
-
- jstring jni_remoteAddress = CAEDRNativeGetAddressFromDeviceSocket(env, deviceSocket);
- if (!jni_remoteAddress)
- {
- OIC_LOG(DEBUG, TAG, "jni_remoteAddress is null");
- continue;
- }
+ CAEDRNativeRemoveDeviceSocketBaseAddr(env, jni_address);
- const char* setAddress = (*env)->GetStringUTFChars(env, jni_setAddress, NULL);
- const char* remoteAddress = (*env)->GetStringUTFChars(env, jni_remoteAddress, NULL);
-
- if (!strcmp(setAddress, remoteAddress))
- {
- OIC_LOG_V(DEBUG, TAG, "remove object : %s", remoteAddress);
- (*env)->DeleteGlobalRef(env, jarrayObj);
- (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
- (*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
-
- u_arraylist_remove(g_deviceObjectList, index);
- break;
- }
- (*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
- (*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
- }
-
- OIC_LOG(DEBUG, TAG, "there are no target object");
return;
}
void CAEDRNativeRemoveDeviceSocketBaseAddr(JNIEnv *env, jstring address)
{
- OIC_LOG(DEBUG, TAG, "CAEDRNativeRemoveDeviceSocket");
+ OIC_LOG(DEBUG, TAG, "CAEDRNativeRemoveDeviceSocketBaseAddr");
+ VERIFY_NON_NULL_VOID(address, TAG, "address");
if (!g_deviceObjectList)
{
return;
}
- jint length = u_arraylist_length(g_deviceStateList);
+ const char* targetAddress = (*env)->GetStringUTFChars(env, address, NULL);
+
+ jint length = u_arraylist_length(g_deviceObjectList);
for (jint index = 0; index < length; index++)
{
- jobject jarrayObj = (jobject) u_arraylist_get(g_deviceObjectList, index);
+ CAEDRSocketInfo_t *socketInfo = (CAEDRSocketInfo_t *) u_arraylist_get(g_deviceObjectList,
+ index);
+ if (!socketInfo)
+ {
+ OIC_LOG(ERROR, TAG, "socketInfo is null");
+ continue;
+ }
+
+ jobject jarrayObj = socketInfo->deviceSocket;
if (!jarrayObj)
{
OIC_LOG(DEBUG, TAG, "jarrayObj is null");
OIC_LOG(ERROR, TAG, "jni_setAddress is null");
continue;
}
+
const char* setAddress = (*env)->GetStringUTFChars(env, jni_setAddress, NULL);
- const char* remoteAddress = (*env)->GetStringUTFChars(env, address, NULL);
- if (!strcmp(setAddress, remoteAddress))
+ if (!strcmp(setAddress, targetAddress))
{
- OIC_LOG_V(ERROR, TAG, "remove object : %s", remoteAddress);
+ OIC_LOG_V(DEBUG, TAG, "remove object : %s", targetAddress);
(*env)->DeleteGlobalRef(env, jarrayObj);
+ jobject jinputStream = socketInfo->inputStream;
+ if (jinputStream)
+ {
+ (*env)->DeleteGlobalRef(env, jinputStream);
+ }
+ (*env)->ReleaseStringUTFChars(env, address, targetAddress);
(*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
- (*env)->ReleaseStringUTFChars(env, address, remoteAddress);
+ (*env)->DeleteLocalRef(env, jni_setAddress);
u_arraylist_remove(g_deviceObjectList, index);
- break;
+ return;
}
(*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
- (*env)->ReleaseStringUTFChars(env, address, remoteAddress);
+ (*env)->DeleteLocalRef(env, jni_setAddress);
}
- OIC_LOG(DEBUG, TAG, "there are no target object");
+ OIC_LOG_V(DEBUG, TAG, "the target object doesn't exist in deviceObjectList (addr: %s)",
+ targetAddress);
+ (*env)->ReleaseStringUTFChars(env, address, targetAddress);
+
return;
}
-jobject CAEDRNativeGetDeviceSocket(uint32_t idx)
+jobject CAEDRNativeGetDeviceSocket(uint32_t index)
{
if (!g_deviceObjectList)
{
return NULL;
}
- jobject jarrayObj = (jobject) u_arraylist_get(g_deviceObjectList, idx);
+ CAEDRSocketInfo_t *socketInfo = (CAEDRSocketInfo_t *) u_arraylist_get(g_deviceObjectList,
+ index);
+ if (!socketInfo)
+ {
+ OIC_LOG(ERROR, TAG, "socketInfo is null");
+ return NULL;
+ }
+
+ jobject jarrayObj = socketInfo->deviceSocket;
if (!jarrayObj)
{
OIC_LOG(ERROR, TAG, "jarrayObj is not available");
jobject CAEDRNativeGetDeviceSocketBaseAddr(JNIEnv *env, const char* remoteAddress)
{
- OIC_LOG(DEBUG, TAG, "CAEDRNativeGetDeviceSocket");
+ OIC_LOG(DEBUG, TAG, "CAEDRNativeGetDeviceSocketBaseAddr");
+ VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress", NULL);
if (!g_deviceObjectList)
{
return NULL;
}
- jint length = u_arraylist_length(g_deviceStateList);
+ jint length = u_arraylist_length(g_deviceObjectList);
for (jint index = 0; index < length; index++)
{
- jobject jarrayObj = (jobject) u_arraylist_get(g_deviceObjectList, index);
+ CAEDRSocketInfo_t *socketInfo = (CAEDRSocketInfo_t *) u_arraylist_get(g_deviceObjectList,
+ index);
+ if (!socketInfo)
+ {
+ OIC_LOG(ERROR, TAG, "socketInfo is null");
+ continue;
+ }
+
+ jobject jarrayObj = socketInfo->deviceSocket;
if (!jarrayObj)
{
OIC_LOG(ERROR, TAG, "jarrayObj is null");
return NULL;
}
+jobject CAEDRNativeGetInputStream(uint32_t index)
+{
+ if (!g_deviceObjectList)
+ {
+ OIC_LOG(ERROR, TAG, "gdeviceObjectList is null");
+ return NULL;
+ }
+
+ CAEDRSocketInfo_t *socketInfo = (CAEDRSocketInfo_t *) u_arraylist_get(g_deviceObjectList,
+ index);
+ if (!socketInfo)
+ {
+ OIC_LOG(ERROR, TAG, "socketInfo is null");
+ return NULL;
+ }
+
+ jobject jarrayObj = socketInfo->inputStream;
+ if (!jarrayObj)
+ {
+ OIC_LOG(ERROR, TAG, "jarrayObj is not available");
+ return NULL;
+ }
+ return jarrayObj;
+}
+
uint32_t CAEDRGetSocketListLength()
{
if (!g_deviceObjectList)
return 0;
}
- uint32_t length = u_arraylist_length(g_deviceObjectList);
-
- return length;
+ return u_arraylist_length(g_deviceObjectList);
}
CAConnectedDeviceInfo_t *CAEDRGetDeviceInfoFromAddress(const char *remoteAddress)
{
OIC_LOG(DEBUG, TAG, "CAEDRGetDeviceInfoFromAddress");
+ VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress", NULL);
if (!g_deviceStateList)
{
OIC_LOG(ERROR, TAG, "gdeviceStateList is null");
return NULL;
}
- if (!remoteAddress)
- {
- OIC_LOG(ERROR, TAG, "remoteAddress is null");
- return NULL;
- }
jint length = u_arraylist_length(g_deviceStateList);
for (jint index = 0; index < length; index++)
#endif
/**
+ * EDR Socket Information for EDR transport
+ */
+typedef struct
+{
+ jobject deviceSocket; /**< Bluetooth device socket info */
+ jobject inputStream; /**< InputStream for read data */
+} CAEDRSocketInfo_t;
+
+/**
* Get address from device socket.
* @param[in] env JNI interface pointer.
* @param[in] bluetoothSocketObj bluetooth socket object.
/**
* Get device socket object from the list.
- * @param[in] idx index of device list.
+ * @param[in] index index of device list.
* @return Device socket object or NULL.
*/
-jobject CAEDRNativeGetDeviceSocket(uint32_t idx);
+jobject CAEDRNativeGetDeviceSocket(uint32_t index);
/**
* Get device socket address.
jobject CAEDRNativeGetDeviceSocketBaseAddr(JNIEnv *env, const char* remoteAddress);
/**
+ * Get input stream object from the list.
+ * @param[in] index index of device list.
+ * @return Input stream object or NULL.
+ */
+jobject CAEDRNativeGetInputStream(uint32_t index);
+
+/**
* Get length of device socket list.
* @return length of list.
*/
/*
* Class: org_iotivity_ca_CaEdrInterface
* Method: caEdrBondStateChangedCallback
- * Signature: (I)V
+ * Signature: (java/lang/String)V
*/
JNIEXPORT void JNICALL
Java_org_iotivity_ca_CaEdrInterface_caEdrBondStateChangedCallback
(JNIEnv *, jobject, jstring);
+/*
+ * Class: org_iotivity_ca_CaEdrInterface
+ * Method: caEdrConnectionStateChangedCallback
+ * Signature: (java/lang/String;I)V
+ */
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaEdrInterface_caEdrConnectionStateChangedCallback
+(JNIEnv *, jobject, jstring, jint);
+
#ifdef __cplusplus
}
#endif
#include "pdu.h"
/**
- * @var EDR_ADAPTER_TAG
- * @brief Logging tag for module name.
+ * Logging tag for module name.
*/
-#define EDR_ADAPTER_TAG "OIC_CA_EDR_ADAP"
+#define TAG "OIC_CA_EDR_ADAP"
/**
- * @var g_edrThreadPool
- * @brief Reference to threadpool.
+ * Reference to threadpool.
*/
static ca_thread_pool_t g_edrThreadPool = NULL;
/**
- * @var g_sendQueueHandle
- * @brief Queue handle for Send Data
+ * Queue handle for Send Data
*/
static CAQueueingThread_t *g_sendQueueHandle = NULL;
/**
- * @var g_recvQueueHandle
- * @brief Queue handle for Receive Data
+ * Queue handle for Receive Data
*/
static CAQueueingThread_t *g_recvQueueHandle = NULL;
/**
- * @var g_adapterState
- * @brief Storing Adapter state information
+ * Storing Adapter state information
*/
static bool g_adapterState = true;
/**
- * @var g_networkPacketReceivedCallback
- * @brief Maintains the callback to be notified on receival of network packets from other
- * Bluetooth devices.
+ * Maintains the callback to be notified on receival of network packets from other
+ * Bluetooth devices.
*/
static CANetworkPacketReceivedCallback g_networkPacketReceivedCallback = NULL;
/**
- * @var g_networkChangeCallback
- * @brief Maintains the callback to be notified on local bluetooth adapter status change.
+ * Maintains the callback to be notified on local bluetooth adapter status change.
*/
-static CANetworkChangeCallback g_networkChangeCallback = NULL;
+static CAAdapterChangeCallback g_adapterChangeCallback = NULL;
/**
- * @var g_errorCallback
- * @brief error Callback to CA adapter
+ * error Callback to CA adapter
*/
static CAErrorHandleCallback g_errorCallback = NULL;
/**
- * @var g_localConnectivity
- * @brief Information of local Bluetooth adapter.
+ * Information of local Bluetooth adapter.
*/
static CAEndpoint_t *g_localConnectivity = NULL;
/**
- * @var g_serverState
- * @brief Storing Rfcommserver state information
+ * Storing Rfcommserver state information
*/
static bool g_serverState = false;
CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback packetReceivedCallback,
- CANetworkChangeCallback networkStateChangeCallback,
+ CAAdapterChangeCallback netCallback,
+ CAConnectionChangeCallback connCallback,
CAErrorHandleCallback errorCallback, ca_thread_pool_t handle)
{
// Input validation
- VERIFY_NON_NULL(registerCallback, EDR_ADAPTER_TAG, "register callback is NULL");
- VERIFY_NON_NULL(packetReceivedCallback, EDR_ADAPTER_TAG, "data receive callback is NULL");
- VERIFY_NON_NULL(networkStateChangeCallback, EDR_ADAPTER_TAG,
- "network state change callback is NULL");
- VERIFY_NON_NULL(handle, EDR_ADAPTER_TAG, "Thread pool handle is NULL");
+ VERIFY_NON_NULL(registerCallback, TAG, "register callback is NULL");
+ VERIFY_NON_NULL(packetReceivedCallback, TAG, "data receive callback is NULL");
+ VERIFY_NON_NULL(netCallback, TAG, "adapter state change callback is NULL");
+ VERIFY_NON_NULL(connCallback, TAG, "connection state change callback is NULL");
+ VERIFY_NON_NULL(handle, TAG, "Thread pool handle is NULL");
// Register the callbacks
-
g_edrThreadPool = handle;
g_networkPacketReceivedCallback = packetReceivedCallback;
- g_networkChangeCallback = networkStateChangeCallback;
+ g_adapterChangeCallback = netCallback;
g_errorCallback = errorCallback;
// Initialize EDR Network Monitor
CAResult_t res = CAEDRInitializeNetworkMonitor(handle);
if (CA_STATUS_OK != res)
{
- OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "EDR N/w Monitor Initialize failed!, error number [%d]",
- res);
+ OIC_LOG_V(ERROR, TAG, "EDR N/w Monitor Initialize failed!, error number [%d]", res);
return res;
}
res = CAEDRClientInitialize();
if (CA_STATUS_OK != res)
{
- OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "EDR Client Initialize failed, error number [%d]", res);
+ OIC_LOG_V(ERROR, TAG, "EDR Client Initialize failed, error number [%d]", res);
return res;
}
res = CAEDRServerInitialize(handle);
if (CA_STATUS_OK != res)
{
- OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "EDR Server Initialize failed, error number [%d]", res);
+ OIC_LOG_V(ERROR, TAG, "EDR Server Initialize failed, error number [%d]", res);
return res;
}
};
registerCallback(handler);
- OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
}
CAResult_t ret = CAEDRStartNetworkMonitor();
if (CA_STATUS_OK != ret)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to Start n/w monitor");
+ OIC_LOG(ERROR, TAG, "Failed to Start n/w monitor");
}
// Get Bluetooth adapter state
bool adapterState = false;
if (CA_STATUS_OK != CAEDRGetAdapterEnableState(&adapterState))
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to get adapter enable state");
+ OIC_LOG(ERROR, TAG, "Failed to get adapter enable state");
return CA_STATUS_FAILED;
}
if (false == adapterState)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Bluetooth adapter is disabled!");
+ OIC_LOG(ERROR, TAG, "Bluetooth adapter is disabled!");
g_adapterState = false;
return CA_ADAPTER_NOT_ENABLED;
}
if (CA_STATUS_OK != (ret = CAEDRClientSetCallbacks()))
{
- OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Start Network Monitor failed!, error number [%d] ",
+ OIC_LOG_V(ERROR, TAG, "Start Network Monitor failed!, error number [%d] ",
ret);
}
// Initialize Send/Receive data message queues
if (CA_STATUS_OK != (ret = CAEDRInitializeQueueHandlers()))
{
- OIC_LOG_V(ERROR, EDR_ADAPTER_TAG,
+ OIC_LOG_V(ERROR, TAG,
"CAAdapterInitializeQueues failed!, error number [%d] ", ret);
CATerminateEDR();
return CA_STATUS_FAILED;
// Start Send/Receive data message queues
if (CA_STATUS_OK != (ret = CAAdapterStartQueue()))
{
- OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "CAAdapterStartQueue failed!, error number [%d] ", ret);
+ OIC_LOG_V(ERROR, TAG, "CAAdapterStartQueue failed!, error number [%d] ", ret);
}
return ret;
CAResult_t result = CAEDRStartDeviceDiscovery();
if(CA_STATUS_OK != result)
{
- OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Failed to Start Device discovery");
+ OIC_LOG(DEBUG, TAG, "Failed to Start Device discovery");
}
#endif
uint32_t dataLength)
{
// Input validation
- VERIFY_NON_NULL_RET(remoteEndpoint, EDR_ADAPTER_TAG, "Remote endpoint is null", -1);
- VERIFY_NON_NULL_RET(data, EDR_ADAPTER_TAG, "Data is null", -1);
+ VERIFY_NON_NULL_RET(remoteEndpoint, TAG, "Remote endpoint is null", -1);
+ VERIFY_NON_NULL_RET(data, TAG, "Data is null", -1);
if (0 == dataLength)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Invalid input: data length is zero!");
+ OIC_LOG(ERROR, TAG, "Invalid input: data length is zero!");
return -1;
}
if (0 == strlen(remoteEndpoint->addr))
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Invalid input: EDR Address is empty!");
+ OIC_LOG(ERROR, TAG, "Invalid input: EDR Address is empty!");
return -1;
}
CAResult_t err = CAAdapterSendData(address, serviceUUID, data, dataLength, &sentLength);
if (CA_STATUS_OK != err)
{
- OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Send unicast data failed!, error num [%d]", err);
+ OIC_LOG_V(ERROR, TAG, "Send unicast data failed!, error num [%d]", err);
g_errorCallback(remoteEndpoint, data, dataLength, err);
return -1;
}
int32_t CASendEDRMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength)
{
- OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN - CASendEDRMulticastData");
+ OIC_LOG(DEBUG, TAG, "IN - CASendEDRMulticastData");
// Input validation
- VERIFY_NON_NULL_RET(data, EDR_ADAPTER_TAG, "Data is null", -1);
+ VERIFY_NON_NULL_RET(data, TAG, "Data is null", -1);
if (0 == dataLength)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Invalid input: data length is zero!");
+ OIC_LOG(ERROR, TAG, "Invalid input: data length is zero!");
return -1;
}
CAResult_t err = CAAdapterSendData(NULL, serviceUUID, data, dataLength, &sentLen);
if (CA_STATUS_OK != err)
{
- OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Send multicast data failed!, error num [%d]", err);
+ OIC_LOG_V(ERROR, TAG, "Send multicast data failed!, error num [%d]", err);
g_errorCallback(endpoint, data, dataLength, err);
return -1;
}
- OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT - CASendEDRMulticastData");
+ OIC_LOG(DEBUG, TAG, "OUT - CASendEDRMulticastData");
return sentLen;
}
CAResult_t CAGetEDRInterfaceInformation(CAEndpoint_t **info, uint32_t *size)
{
- VERIFY_NON_NULL(info, EDR_ADAPTER_TAG, "LocalConnectivity info is null");
+ VERIFY_NON_NULL(info, TAG, "LocalConnectivity info is null");
CAResult_t err = CA_STATUS_OK;
*size = 0;
if (CA_STATUS_OK != (err = CAEDRGetInterfaceInformation(info)))
{
- OIC_LOG_V(ERROR, EDR_ADAPTER_TAG,
- "Failed to get local interface information!, error num [%d]", err);
+ OIC_LOG_V(ERROR, TAG, "Failed to get local interface information!, error num [%d]", err);
return err;
}
CAAdapterTerminateQueues();
g_networkPacketReceivedCallback = NULL;
- g_networkChangeCallback = NULL;
+ g_adapterChangeCallback = NULL;
// Terminate thread pool
g_edrThreadPool = NULL;
{
if (false == g_adapterState)
{
- OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Bluetooth adapter is disabled!");
+ OIC_LOG(DEBUG, TAG, "Bluetooth adapter is disabled!");
// Setting g_serverState for starting Rfcommserver when adapter starts
g_serverState = true;
return CA_STATUS_OK;
CAResult_t err = CA_STATUS_OK;
if (CA_STATUS_OK != (err = CAEDRServerStart()))
{
- OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Failed to start RFCOMM server!, error num [%d]",
+ OIC_LOG_V(ERROR, TAG, "Failed to start RFCOMM server!, error num [%d]",
err);
return err;
}
if (CA_STATUS_OK == CAEDRInitializeSendHandler()
&& CA_STATUS_OK == CAEDRInitializeReceiveHandler())
{
- OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Queue is initialized!");
+ OIC_LOG(DEBUG, TAG, "Queue is initialized!");
return CA_STATUS_OK;
}
// Check if the message queue is already initialized
if (g_sendQueueHandle)
{
- OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Already queue is initialized!");
+ OIC_LOG(DEBUG, TAG, "Already queue is initialized!");
return CA_STATUS_OK;
}
g_sendQueueHandle = (CAQueueingThread_t *) OICMalloc(sizeof(CAQueueingThread_t));
if (!g_sendQueueHandle)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Memory allocation failed!");
+ OIC_LOG(ERROR, TAG, "Memory allocation failed!");
return CA_MEMORY_ALLOC_FAILED;
}
if (CA_STATUS_OK != CAQueueingThreadInitialize(g_sendQueueHandle, g_edrThreadPool,
CAAdapterDataSendHandler, CAEDRDataDestroyer))
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to Initialize send queue thread");
+ OIC_LOG(ERROR, TAG, "Failed to Initialize send queue thread");
return CA_STATUS_FAILED;
}
return CA_STATUS_OK;
// Check if the message queue is already initialized
if (g_recvQueueHandle)
{
- OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Already queue is initialized!");
+ OIC_LOG(DEBUG, TAG, "Already queue is initialized!");
return CA_STATUS_OK;
}
g_recvQueueHandle = (CAQueueingThread_t *) OICMalloc(sizeof(CAQueueingThread_t));
if (!g_recvQueueHandle)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Memory allocation failed!");
+ OIC_LOG(ERROR, TAG, "Memory allocation failed!");
return CA_MEMORY_ALLOC_FAILED;
}
CAAdapterDataReceiverHandler,
CAEDRDataDestroyer))
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to Initialize send queue thread");
+ OIC_LOG(ERROR, TAG, "Failed to Initialize send queue thread");
OICFree(g_recvQueueHandle);
g_recvQueueHandle = NULL;
return CA_STATUS_FAILED;
void CAAdapterDataSendHandler(void *context)
{
- OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN - CAAdapterDataSendHandler");
+ OIC_LOG(DEBUG, TAG, "IN - CAAdapterDataSendHandler");
CAEDRData *message = (CAEDRData *) context;
if (!message)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to get message!");
+ OIC_LOG(ERROR, TAG, "Failed to get message!");
return;
}
if (!message->remoteEndpoint)
{
- OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "remoteEndpoint is not available");
+ OIC_LOG(DEBUG, TAG, "remoteEndpoint is not available");
return;
}
const char *remoteAddress = message->remoteEndpoint->addr;
if(!remoteAddress)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "EDR Send Message error");
+ OIC_LOG(ERROR, TAG, "EDR Send Message error");
//Error cannot be sent if remote address is NULL
return;
}
CAResult_t result = CAEDRClientSendData(remoteAddress, message->data, message->dataLen);
if(CA_STATUS_OK != result)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "CAEDRClientSendData API failed");
+ OIC_LOG(ERROR, TAG, "CAEDRClientSendData API failed");
CAEDRErrorHandler(remoteAddress, message->data, message->dataLen, result);
return;
}
- OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
}
CAResult_t CAEDRClientSendData(const char *remoteAddress, const uint8_t *data,
result = CAEDRClientSendUnicastData(remoteAddress, data, dataLength);
if (CA_STATUS_OK != result)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to send unicast data !");
+ OIC_LOG(ERROR, TAG, "Failed to send unicast data !");
return result;
}
}
else
{
- OIC_LOG_V(DEBUG, EDR_ADAPTER_TAG, "sending multicast data : %s", data);
+ OIC_LOG_V(DEBUG, TAG, "sending multicast data : %s", data);
result = CAEDRClientSendMulticastData(data, dataLength);
if (CA_STATUS_OK != result)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to send multicast data !");
+ OIC_LOG(ERROR, TAG, "Failed to send multicast data !");
return result;
}
}
void CAAdapterDataReceiverHandler(void *context)
{
- OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN_CAAdapterDataReceiverHandler");
+ OIC_LOG(DEBUG, TAG, "IN_CAAdapterDataReceiverHandler");
if (NULL == g_networkPacketReceivedCallback)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "g_networkPacketReceivedCallback is NULL");
+ OIC_LOG(ERROR, TAG, "g_networkPacketReceivedCallback is NULL");
return;
}
CAEDRData *message = (CAEDRData *) context;
if (NULL == message || NULL == message->remoteEndpoint)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to get message!");
+ OIC_LOG(ERROR, TAG, "Failed to get message!");
return;
}
if (!remoteEndpoint)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "remoteEndpoint is NULL");
+ OIC_LOG(ERROR, TAG, "remoteEndpoint is NULL");
return;
}
- OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Sending data up !");
+ OIC_LOG(DEBUG, TAG, "Sending data up !");
const CASecureEndpoint_t sep = { .endpoint = *remoteEndpoint };
CAFreeEndpoint(remoteEndpoint);
- OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT_CAAdapterDataReceiverHandler");
+ OIC_LOG(DEBUG, TAG, "OUT_CAAdapterDataReceiverHandler");
}
CAResult_t CAAdapterStartQueue()
// Start send queue thread
if (CA_STATUS_OK != CAQueueingThreadStart(g_sendQueueHandle))
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to Start Send Data Thread");
+ OIC_LOG(ERROR, TAG, "Failed to Start Send Data Thread");
CAEDRClientUnsetCallbacks();
//Disconnect all the client connections
CAEDRClientDisconnectAll();
// Start receive queue thread
if (CA_STATUS_OK != CAQueueingThreadStart(g_recvQueueHandle))
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to Start Receive Data Thread");
+ OIC_LOG(ERROR, TAG, "Failed to Start Receive Data Thread");
CAEDRClientUnsetCallbacks();
//Disconnect all the client connections
CAEDRClientDisconnectAll();
{
if (false == g_adapterState)
{
- OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Bluetooth adapter is disabled!");
+ OIC_LOG_V(ERROR, TAG, "Bluetooth adapter is disabled!");
*sentLength = 0;
return;
}
// Input validation
- VERIFY_NON_NULL_VOID(data, EDR_ADAPTER_TAG, "Data is null");
- VERIFY_NON_NULL_VOID(sentLength, EDR_ADAPTER_TAG, "Sent data length holder is null");
+ VERIFY_NON_NULL_VOID(data, TAG, "Data is null");
+ VERIFY_NON_NULL_VOID(sentLength, TAG, "Sent data length holder is null");
// Create remote endpoint
CAEndpoint_t *remoteEndpoint = CACreateEndpointObject(CA_DEFAULT_FLAGS,
remoteAddress, 0);
if (NULL == remoteEndpoint)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to create remote endpoint !");
+ OIC_LOG(ERROR, TAG, "Failed to create remote endpoint !");
return;
}
uint32_t dataLength, CAResult_t result)
{
// Input validation
- VERIFY_NON_NULL_VOID(data, EDR_ADAPTER_TAG, "Data is null");
+ VERIFY_NON_NULL_VOID(data, TAG, "Data is null");
// Create remote endpoint
CAEndpoint_t *remoteEndpoint = CACreateEndpointObject(0, CA_ADAPTER_RFCOMM_BTEDR,
remoteAddress, 0);
if (!remoteEndpoint)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to create remote endpoint !");
+ OIC_LOG(ERROR, TAG, "Failed to create remote endpoint !");
return;
}
CAResult_t CAAdapterSendData(const char *remoteAddress, const char *serviceUUID, const uint8_t *data,
uint32_t dataLength, uint32_t *sentLength)
{
- OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN - CAAdapterSendData");
+ OIC_LOG(DEBUG, TAG, "IN - CAAdapterSendData");
if (false == g_adapterState)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Bluetooth adapter is disabled!");
+ OIC_LOG(ERROR, TAG, "Bluetooth adapter is disabled!");
*sentLength = 0;
return CA_ADAPTER_NOT_ENABLED;
}
// Input validation
- VERIFY_NON_NULL(serviceUUID, EDR_ADAPTER_TAG, "service UUID is null");
- VERIFY_NON_NULL(data, EDR_ADAPTER_TAG, "Data is null");
- VERIFY_NON_NULL(sentLength, EDR_ADAPTER_TAG, "Sent data length holder is null");
+ VERIFY_NON_NULL(serviceUUID, TAG, "service UUID is null");
+ VERIFY_NON_NULL(data, TAG, "Data is null");
+ VERIFY_NON_NULL(sentLength, TAG, "Sent data length holder is null");
// Create remote endpoint
CAEndpoint_t *remoteEndpoint = CACreateEndpointObject(CA_DEFAULT_FLAGS,
remoteAddress, 0);
if (NULL == remoteEndpoint)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to create remote endpoint !");
+ OIC_LOG(ERROR, TAG, "Failed to create remote endpoint !");
return CA_MEMORY_ALLOC_FAILED;
}
// Free remote endpoint
CAFreeEndpoint(remoteEndpoint);
- OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT - CAAdapterSendData");
+ OIC_LOG(DEBUG, TAG, "OUT - CAAdapterSendData");
return CA_STATUS_OK;
}
bool adapterState = false;
if (CA_STATUS_OK != CAEDRGetAdapterEnableState(&adapterState))
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to get adapter enable state");
+ OIC_LOG(ERROR, TAG, "Failed to get adapter enable state");
return;
}
if (false == adapterState)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Bluetooth adapter is disabled!");
+ OIC_LOG(ERROR, TAG, "Bluetooth adapter is disabled!");
g_adapterState = false;
return;
}
}
// Notify to upper layer
- if (g_networkChangeCallback && g_localConnectivity && g_edrThreadPool)
+ if (g_adapterChangeCallback && g_localConnectivity && g_edrThreadPool)
{
// Add notification task to thread pool
CAEDRNetworkEvent *event = CAEDRCreateNetworkEvent(g_localConnectivity, status);
if (CA_STATUS_OK != ca_thread_pool_add_task(g_edrThreadPool,
CAEDROnNetworkStatusChanged,event))
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to create threadpool!");
+ OIC_LOG(ERROR, TAG, "Failed to create threadpool!");
return;
}
}
{
if (NULL == context)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "context is NULL!");
+ OIC_LOG(ERROR, TAG, "context is NULL!");
return;
}
CAEDRNetworkEvent *networkEvent = (CAEDRNetworkEvent *) context;
// Notify to upper layer
- if (g_networkChangeCallback)
+ if (g_adapterChangeCallback)
{
- g_networkChangeCallback(networkEvent->info, networkEvent->status);
+ g_adapterChangeCallback(networkEvent->info->adapter, networkEvent->status);
}
// Free the created Network event
CAEDRNetworkEvent *CAEDRCreateNetworkEvent(CAEndpoint_t *connectivity,
CANetworkStatus_t status)
{
- VERIFY_NON_NULL_RET(connectivity, EDR_ADAPTER_TAG, "connectivity is NULL", NULL);
+ VERIFY_NON_NULL_RET(connectivity, TAG, "connectivity is NULL", NULL);
// Create CAEDRNetworkEvent
CAEDRNetworkEvent *event = (CAEDRNetworkEvent *) OICMalloc(sizeof(CAEDRNetworkEvent));
if (NULL == event)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to allocate memory to network event!");
+ OIC_LOG(ERROR, TAG, "Failed to allocate memory to network event!");
return NULL;
}
CAEDRData *edrData = (CAEDRData *) OICCalloc(1, sizeof(*edrData));
if (!edrData)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Memory allocation failed!");
+ OIC_LOG(ERROR, TAG, "Memory allocation failed!");
return NULL;
}
edrData->data = OICMalloc(dataLength);
if (NULL == edrData->data)
{
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Memory allocation failed!");
+ OIC_LOG(ERROR, TAG, "Memory allocation failed!");
CAFreeEDRData(edrData);
return NULL;
}
void CAFreeEDRData(CAEDRData *edrData)
{
- VERIFY_NON_NULL_VOID(edrData, EDR_ADAPTER_TAG, "edrData is NULL");
+ VERIFY_NON_NULL_VOID(edrData, TAG, "edrData is NULL");
CAFreeEndpoint(edrData->remoteEndpoint);
OICFree(edrData->data);
{
if ((size_t)size < sizeof(CAEDRData))
{
- OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Destroy data too small %p %d", data, size);
+ OIC_LOG_V(ERROR, TAG, "Destroy data too small %p %d", data, size);
}
CAEDRData *edrdata = (CAEDRData *) data;
+++ /dev/null
-##########################################
-# Build BT EDR adapter for Linux
-##########################################
-
-Import('env')
-
-src_files = [ 'caedradapter.c']
-
-Return('src_files')
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2014 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * 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.
- *
- ******************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "caedradapter.h"
-#include "logger.h"
-
-#define TAG PCF("OIC_CA")
-
-static CANetworkPacketReceivedCallback g_edrReceivedCallback = NULL;
-static ca_thread_pool_t g_threadPoolHandle = NULL;
-
-CAResult_t CAInitializeEDR(CARegisterConnectivityCallback registerCallback,
- CANetworkPacketReceivedCallback reqRespCallback,
- CANetworkChangeCallback networkStateChangeCallback,
- CAErrorHandleCallback errorCallback, ca_thread_pool_t handle)
-{
- (void)networkStateChangeCallback;
- (void)errorCallback;
- OIC_LOG(DEBUG, TAG, "CAInitializeEDR");
-
- g_edrReceivedCallback = reqRespCallback;
- g_threadPoolHandle = handle;
-
- // register handlers
- CAConnectivityHandler_t handler = {
- .startAdapter = CAStartEDR,
- .startListenServer = CAStartEDRListeningServer,
- .stopListenServer = CAStopEDRListeningServer,
- .startDiscoveryServer = CAStartEDRDiscoveryServer,
- .sendData = CASendEDRUnicastData,
- .sendDataToAll = CASendEDRMulticastData,
- .GetnetInfo = CAGetEDRInterfaceInformation,
- .readData = CAReadEDRData,
- .stopAdapter = CAStopEDR,
- .terminate = CATerminateEDR,
- .cType = CA_ADAPTER_RFCOMM_BTEDR
- };
-
- registerCallback(handler);
-
- return CA_STATUS_OK;
-}
-
-CAResult_t CAStartEDR()
-{
- OIC_LOG(DEBUG, TAG, "CAStartEDR");
-
- return CA_STATUS_OK;
-}
-
-CAResult_t CAStartEDRListeningServer()
-{
- OIC_LOG(DEBUG, TAG, "CAStartEDRListeningServer");
-
- return CA_STATUS_OK;
-}
-
-CAResult_t CAStopEDRListeningServer()
-{
- OIC_LOG(DEBUG, TAG, "CAStopEDRListeningServer");
-
- return CA_STATUS_OK;
-}
-
-CAResult_t CAStartEDRDiscoveryServer()
-{
- OIC_LOG(DEBUG, TAG, "CAStartEDRDiscoveryServer");
-
- return CA_STATUS_OK;
-}
-
-int32_t CASendEDRUnicastData(const CAEndpoint_t *endpoint, const void *data,
- uint32_t dataLen)
-{
- (void)endpoint;
- (void)data;
- (void)dataLen;
- OIC_LOG(DEBUG, TAG, "CASendEDRUnicastData");
-
- return -1;
-}
-
-int32_t CASendEDRMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLen)
-{
- (void)endpoint;
- (void)data;
- (void)dataLen;
- OIC_LOG(DEBUG, TAG, "CASendEDRMulticastData");
-
- return -1;
-}
-
-CAResult_t CAGetEDRInterfaceInformation(CAEndpoint_t **info, uint32_t *size)
-{
- (void)info;
- (void)size;
- OIC_LOG(DEBUG, TAG, "CAGetEDRInterfaceInformation");
-
- return CA_STATUS_OK;
-}
-
-CAResult_t CAReadEDRData()
-{
- OIC_LOG(DEBUG, TAG, "Read EDR Data");
-
- return CA_STATUS_OK;
-}
-
-CAResult_t CAStopEDR()
-{
- OIC_LOG(DEBUG, TAG, "CAStopEDR");
-
- return CA_STATUS_OK;
-}
-
-void CATerminateEDR()
-{
- OIC_LOG(DEBUG, TAG, "CATerminateEDR");
-}
-
#include "caqueueingthread.h"
#include "caremotehandler.h"
+#define MICROSECS_PER_SEC 1000000
+
+static uint64_t const INITIALIZE_TIMEOUT = 1 * MICROSECS_PER_SEC;
+
static GMainLoop *g_mainloop = NULL;
static ca_thread_pool_t g_threadPoolHandle = NULL;
static CAEDRNetworkStatusCallback g_edrNetworkChangeCallback = NULL;
/**
+ * Mutex to synchronize access to
+ */
+static ca_mutex g_btinitializeMutex = NULL;
+
+/**
+ * Condition for gmainloop to run.
+ */
+static ca_cond g_initializeCond = NULL;
+
+/**
+ * Flag to check if BT stack is initialised.
+ */
+static bool g_isBTStackInitialised = false;
+
+/**
* @fn CAEDRAdapterStateChangeCallback
* @brief This callback is registered to receive bluetooth adapter state changes.
*/
void CAEDRMainLoopThread(void *param)
{
+ OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
+ // Initialize Bluetooth service
+ int ret = bt_initialize();
+ if (BT_ERROR_NONE != ret)
+ {
+ OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Bluetooth initialization failed!, error num [%x]",
+ ret);
+ return;
+ }
+
+ ret = bt_adapter_set_state_changed_cb(CAEDRAdapterStateChangeCallback, NULL);
+ if(BT_ERROR_NONE != ret)
+ {
+ OIC_LOG(ERROR, EDR_ADAPTER_TAG, "bt_adapter_set_state_changed_cb failed");
+ return;
+ }
+
+ g_mainloop = g_main_loop_new(g_main_context_default(), FALSE);
+
+ ca_mutex_lock(g_btinitializeMutex);
+ g_isBTStackInitialised = true;
+ ca_mutex_unlock(g_btinitializeMutex);
+ ca_cond_signal(g_initializeCond);
+
+ // Run gmainloop to handle the events from bt stack
g_main_loop_run(g_mainloop);
+
+ OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
}
CAResult_t CAEDRInitializeNetworkMonitor(const ca_thread_pool_t threadPool)
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
g_threadPoolHandle = threadPool;
+
+ if (NULL == g_btinitializeMutex)
+ {
+ g_btinitializeMutex = ca_mutex_new();
+ if (NULL == g_btinitializeMutex)
+ {
+ OIC_LOG(ERROR, EDR_ADAPTER_TAG, "ca_mutex_new failed");
+ return CA_STATUS_FAILED;
+ }
+ }
+
+ if (NULL == g_initializeCond)
+ {
+ g_initializeCond = ca_cond_new();
+ if (NULL == g_initializeCond)
+ {
+ OIC_LOG(ERROR, EDR_ADAPTER_TAG, "ca_cond_new failed");
+ ca_mutex_free(g_btinitializeMutex);
+ return CA_STATUS_FAILED;
+ }
+ }
+
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
return CA_STATUS_OK;
}
g_edrNetworkChangeCallback = NULL;
- // Terminate Bluetooth service
- bt_deinitialize();
+ ca_mutex_free(g_btinitializeMutex);
+ g_btinitializeMutex = NULL;
+
+ ca_cond_free(g_initializeCond);
+ g_initializeCond = NULL;
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
}
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
- g_mainloop = g_main_loop_new(NULL, 0);
- if(!g_mainloop)
- {
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "g_main_loop_new failed\n");
- return CA_STATUS_FAILED;
- }
-
- if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPoolHandle, CAEDRMainLoopThread, (void *) NULL))
+ if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPoolHandle, CAEDRMainLoopThread,
+ (void *) NULL))
{
OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Failed to create thread!");
return CA_STATUS_FAILED;
}
- // Initialize Bluetooth service
- int err = bt_initialize();
- if (BT_ERROR_NONE != err)
- {
- OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Bluetooth initialization failed!, error num [%x]",
- err);
- return CA_STATUS_FAILED;
- }
-
- int ret = bt_adapter_set_state_changed_cb(CAEDRAdapterStateChangeCallback, NULL);
- if(BT_ERROR_NONE != ret)
- {
- OIC_LOG(ERROR, EDR_ADAPTER_TAG, "bt_adapter_set_state_changed_cb failed");
- return CA_STATUS_FAILED;
- }
-
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
return CA_STATUS_OK;
}
return CA_STATUS_FAILED;
}
+ ret = bt_deinitialize();
+ if (BT_ERROR_NONE != ret)
+ {
+ OIC_LOG(ERROR, EDR_ADAPTER_TAG, "bt_deinitialize failed");
+ return CA_STATUS_FAILED;
+ }
+
if (g_mainloop)
{
g_main_loop_quit(g_mainloop);
CAResult_t CAEDRGetAdapterEnableState(bool *state)
{
OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");
-
- // Input validation
VERIFY_NON_NULL(state, EDR_ADAPTER_TAG, "state holder is NULL!");
+ ca_mutex_lock(g_btinitializeMutex);
+ if (!g_isBTStackInitialised)
+ {
+ OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Wait till BT is initialised");
+ CAWaitResult_t ret = ca_cond_wait_for(g_initializeCond, g_btinitializeMutex,
+ INITIALIZE_TIMEOUT);
+ if (CA_WAIT_TIMEDOUT == ret)
+ {
+ OIC_LOG(ERROR, EDR_ADAPTER_TAG, "Timeout before BT initialize");
+ ca_mutex_unlock(g_btinitializeMutex);
+ return CA_STATUS_FAILED;
+ }
+ }
+ ca_mutex_unlock(g_btinitializeMutex);
bt_adapter_state_e adapterState;
int err = bt_adapter_get_state(&adapterState);
static ca_cond g_deviceScanRetryDelayCond = NULL;
static ca_mutex g_scanMutex = NULL;
+static ca_mutex g_threadSendStateMutex = NULL;
static CABLEDataReceivedCallback g_CABLEClientDataReceivedCallback = NULL;
isAttached = true;
}
+ jmethodID mid_getApplicationContext = CAGetJNIMethodID(env, "android/content/Context",
+ "getApplicationContext",
+ "()Landroid/content/Context;");
+
+ if (!mid_getApplicationContext)
+ {
+ OIC_LOG(ERROR, TAG, "Could not get getApplicationContext method");
+ return CA_STATUS_FAILED;
+ }
+
+ jobject jApplicationContext = (*env)->CallObjectMethod(env, g_context,
+ mid_getApplicationContext);
+ if (!jApplicationContext)
+ {
+ OIC_LOG(ERROR, TAG, "Could not get application context");
+ return CA_STATUS_FAILED;
+ }
+
jclass jni_LEInterface = (*env)->FindClass(env, "org/iotivity/ca/CaLeClientInterface");
if (!jni_LEInterface)
{
goto error_exit;
}
- (*env)->NewObject(env, jni_LEInterface, LeInterfaceConstructorMethod, g_context);
+ (*env)->NewObject(env, jni_LEInterface, LeInterfaceConstructorMethod, jApplicationContext);
OIC_LOG(DEBUG, TAG, "Create instance for CaLeClientInterface");
if (isAttached)
{
OIC_LOG(ERROR, TAG, "CALEClientStartScan has failed");
ca_mutex_unlock(g_threadSendMutex);
- return res;
+ return ret;
}
ca_mutex_unlock(g_threadSendMutex);
OIC_LOG(INFO, TAG, "unicast - send logic has finished");
- return CALECheckSendState(address);
+ if (CALEClientIsValidState(address, CA_LE_SEND_STATE,
+ STATE_SEND_SUCCESS))
+ {
+ ret = CA_STATUS_OK;
+ }
+ else
+ {
+ ret = CA_SEND_FAILED;
+ }
+
+ // reset send state
+ ret = CALEClientUpdateDeviceState(address, CA_LE_SEND_STATE,
+ STATE_SEND_NONE);
+ if (CA_STATUS_OK != ret)
+ {
+ OIC_LOG(ERROR, TAG, "CALEClientUpdateDeviceState has failed");
+ }
+
+ return ret;
// error label.
error_exit:
{
(*g_jvm)->DetachCurrentThread(g_jvm);
}
- return res;
+ return ret;
}
if (isAttached)
(*g_jvm)->DetachCurrentThread(g_jvm);
}
- if (g_clientErrorCallback)
- {
- g_clientErrorCallback(address, data, dataLen, CA_SEND_FAILED);
- }
ca_mutex_unlock(g_threadSendMutex);
return CA_SEND_FAILED;
}
return CA_SEND_FAILED;
}
-CAResult_t CALECheckSendState(const char* address)
-{
- VERIFY_NON_NULL(address, TAG, "address is null");
-
- ca_mutex_lock(g_deviceStateListMutex);
- CALEState_t* state = CALEClientGetStateInfo(address);
- if (NULL == state)
- {
- OIC_LOG(ERROR, TAG, "state is null");
- ca_mutex_unlock(g_deviceStateListMutex);
- return CA_SEND_FAILED;
- }
-
- if (STATE_SEND_SUCCESS != state->sendState)
- {
- OIC_LOG(ERROR, TAG, "sendstate is not STATE_SEND_SUCCESS");
- ca_mutex_unlock(g_deviceStateListMutex);
- return CA_SEND_FAILED;
- }
-
- OIC_LOG(INFO, TAG, "sendstate is STATE_SEND_SUCCESS");
- ca_mutex_unlock(g_deviceStateListMutex);
- return CA_STATUS_OK;
-}
-
CAResult_t CALEClientSendData(JNIEnv *env, jobject device)
{
OIC_LOG(DEBUG, TAG, "IN - CALEClientSendData");
ca_mutex_lock(g_deviceStateListMutex);
state = CALEClientGetStateInfo(address);
ca_mutex_unlock(g_deviceStateListMutex);
- (*env)->ReleaseStringUTFChars(env, jni_address, address);
}
if (!state)
// if there is gatt object in g_gattObjectList.
if (jni_address)
{
- address = (char*)(*env)->GetStringUTFChars(env, jni_address, NULL);
- if (!address)
- {
- OIC_LOG(ERROR, TAG, "address is not available");
- return CA_STATUS_FAILED;
- }
-
jobject gatt = CALEClientGetGattObjInList(env, address);
if (gatt)
{
}
else
{
- if (STATE_CONNECTED == state->connectedState)
+ if (CALEClientIsValidState(address, CA_LE_CONNECTION_STATE,
+ STATE_SERVICE_CONNECTED))
{
OIC_LOG(INFO, TAG, "GATT has already connected");
- if (!jni_address)
- {
- OIC_LOG(ERROR, TAG, "jni_address is not available");
- return CA_STATUS_FAILED;
- }
-
- address = (char*)(*env)->GetStringUTFChars(env, jni_address, NULL);
- if (!address)
- {
- OIC_LOG(ERROR, TAG, "address is not available");
- return CA_STATUS_FAILED;
- }
jobject gatt = CALEClientGetGattObjInList(env, address);
if (!gatt)
}
(*env)->ReleaseStringUTFChars(env, jni_address, address);
}
- else
+ else if(CALEClientIsValidState(address, CA_LE_CONNECTION_STATE,
+ STATE_CONNECTED))
+ {
+ OIC_LOG(INFO, TAG, "service connecting...");
+ }
+ else if(CALEClientIsValidState(address, CA_LE_CONNECTION_STATE,
+ STATE_DISCONNECTED))
{
OIC_LOG(INFO, TAG, "STATE_DISCONNECTED - start to connect LE");
// if there is gatt object in g_gattObjectList.
if (jni_address)
{
- address = (char*)(*env)->GetStringUTFChars(env, jni_address, NULL);
- if (!address)
- {
- OIC_LOG(ERROR, TAG, "address is not available");
- return CA_STATUS_FAILED;
- }
-
jobject gatt = CALEClientGetGattObjInList(env, address);
if (gatt)
{
OIC_LOG(DEBUG, TAG, "start to connect LE");
jobject gatt = CALEClientConnect(env, device,
- CALEClientGetAutoConnectFlag(env, jni_address));
+ CALEClientGetFlagFromState(env, jni_address,
+ CA_LE_AUTO_CONNECT_FLAG));
+
if (NULL == gatt)
{
OIC_LOG(ERROR, TAG, "CALEClientConnect has failed");
VERIFY_NON_NULL_RET(gatt, TAG, "gatt is null", NULL);
VERIFY_NON_NULL_RET(env, TAG, "env is null", NULL);
- jmethodID jni_mid_getDevice = CALEGetJNIMethodID(env, CLASSPATH_BT_GATT, "getDevice",
- "()Landroid/bluetooth/BluetoothDevice;");
+ jmethodID jni_mid_getDevice = CAGetJNIMethodID(env, CLASSPATH_BT_GATT, "getDevice",
+ "()Landroid/bluetooth/BluetoothDevice;");
if (!jni_mid_getDevice)
{
OIC_LOG(ERROR, TAG, "jni_mid_getDevice is null");
// get BluetoothGatt method
OIC_LOG(DEBUG, TAG, "get BluetoothGatt method");
- jmethodID jni_mid_closeGatt = CALEGetJNIMethodID(env, CLASSPATH_BT_GATT, "close", "()V");
+ jmethodID jni_mid_closeGatt = CAGetJNIMethodID(env, CLASSPATH_BT_GATT, "close", "()V");
if (!jni_mid_closeGatt)
{
OIC_LOG(ERROR, TAG, "jni_mid_closeGatt is null");
}
// call start le scan method
+ OIC_LOG(INFO, TAG, "CALL API - startLeScan");
jboolean jni_obj_startLeScan = (*env)->CallBooleanMethod(env, jni_obj_BTAdapter,
jni_mid_startLeScan, callback);
if (!jni_obj_startLeScan)
{
- OIC_LOG(INFO, TAG, "startLeScan is failed");
+ OIC_LOG(INFO, TAG, "startLeScan has failed");
}
else
{
- OIC_LOG(DEBUG, TAG, "startLeScan is started");
+ OIC_LOG(DEBUG, TAG, "LeScan has started");
CALEClientSetScanFlag(true);
}
}
// call start le scan method
+ OIC_LOG(INFO, TAG, "CALL API - startLeScan (with UUID)");
jboolean jni_obj_startLeScan = (*env)->CallBooleanMethod(env, jni_obj_BTAdapter,
jni_mid_startLeScan, uuids, callback);
if (!jni_obj_startLeScan)
{
- OIC_LOG(INFO, TAG, "startLeScan With UUID is failed");
+ OIC_LOG(INFO, TAG, "startLeScan has failed");
}
else
{
- OIC_LOG(DEBUG, TAG, "startLeScan With UUID is started");
+ OIC_LOG(DEBUG, TAG, "LeScan has started");
CALEClientSetScanFlag(true);
}
return CA_STATUS_FAILED;
}
- OIC_LOG(DEBUG, TAG, "CALL API - request to stop LE Scan");
+ OIC_LOG(INFO, TAG, "CALL API - stopLeScan");
// call start le scan method
(*env)->CallVoidMethod(env, jni_obj_BTAdapter, jni_mid_stopLeScan, callback);
if ((*env)->ExceptionCheck(env))
return CA_STATUS_OK;
}
-CAResult_t CALEClientSetAutoConnectFlag(JNIEnv *env, jstring jni_address, jboolean flag)
+CAResult_t CALEClientSetFlagToState(JNIEnv *env, jstring jni_address, jint state_idx, jboolean flag)
{
- OIC_LOG(DEBUG, TAG, "IN - CALEClientSetAutoConnectFlag");
+ OIC_LOG(DEBUG, TAG, "IN - CALEClientSetFlagToState");
VERIFY_NON_NULL(env, TAG, "env");
VERIFY_NON_NULL(jni_address, TAG, "jni_address");
ca_mutex_unlock(g_deviceStateListMutex);
return CA_STATUS_FAILED;
}
- OIC_LOG_V(INFO, TAG, "auto connect flag is set %d", flag);
+ OIC_LOG_V(INFO, TAG, "%d flag is set : %d", state_idx, flag);
- curState->autoConnectFlag = flag;
+ switch(state_idx)
+ {
+ case CA_LE_AUTO_CONNECT_FLAG:
+ curState->autoConnectFlag = flag;
+ break;
+ case CA_LE_DESCRIPTOR_FOUND:
+ curState->isDescriptorFound = flag;
+ break;
+ default:
+ break;
+ }
}
(*env)->ReleaseStringUTFChars(env, jni_address, address);
ca_mutex_unlock(g_deviceStateListMutex);
- OIC_LOG(DEBUG, TAG, "OUT - CALEClientSetAutoConnectFlag");
+ OIC_LOG(DEBUG, TAG, "OUT - CALEClientSetFlagToState");
return CA_STATUS_OK;
}
-jboolean CALEClientGetAutoConnectFlag(JNIEnv *env, jstring jni_address)
+jboolean CALEClientGetFlagFromState(JNIEnv *env, jstring jni_address, jint state_idx)
{
- OIC_LOG(DEBUG, TAG, "IN - CALEClientGetAutoConnectFlag");
+ OIC_LOG(DEBUG, TAG, "IN - CALEClientGetFlagFromState");
VERIFY_NON_NULL_RET(env, TAG, "env", false);
VERIFY_NON_NULL_RET(jni_address, TAG, "jni_address", false);
if (!address)
{
OIC_LOG(ERROR, TAG, "address is not available");
+ ca_mutex_unlock(g_deviceStateListMutex);
return JNI_FALSE;
}
CALEState_t* curState = CALEClientGetStateInfo(address);
+ (*env)->ReleaseStringUTFChars(env, jni_address, address);
if(!curState)
{
OIC_LOG(INFO, TAG, "there is no information. auto connect flag is false");
- (*env)->ReleaseStringUTFChars(env, jni_address, address);
ca_mutex_unlock(g_deviceStateListMutex);
return JNI_FALSE;
}
- OIC_LOG_V(INFO, TAG, "auto connect flag is %d", curState->autoConnectFlag);
- (*env)->ReleaseStringUTFChars(env, jni_address, address);
+ jboolean ret = JNI_FALSE;
+ switch(state_idx)
+ {
+ case CA_LE_AUTO_CONNECT_FLAG:
+ ret = curState->autoConnectFlag;
+ break;
+ case CA_LE_DESCRIPTOR_FOUND:
+ ret = curState->isDescriptorFound;
+ break;
+ default:
+ break;
+ }
ca_mutex_unlock(g_deviceStateListMutex);
- OIC_LOG(DEBUG, TAG, "OUT - CALEClientGetAutoConnectFlag");
- return curState->autoConnectFlag;
+ OIC_LOG_V(INFO, TAG, "%d flag is %d", state_idx, ret);
+ OIC_LOG(DEBUG, TAG, "OUT - CALEClientGetFlagFromState");
+ return ret;
}
jobject CALEClientConnect(JNIEnv *env, jobject bluetoothDevice, jboolean autoconnect)
// get BluetoothDevice method
OIC_LOG(DEBUG, TAG, "get BluetoothDevice method");
- jmethodID jni_mid_connectGatt = CALEGetJNIMethodID(env, "android/bluetooth/BluetoothDevice",
- "connectGatt",
- "(Landroid/content/Context;ZLandroid/"
- "bluetooth/BluetoothGattCallback;)"
- "Landroid/bluetooth/BluetoothGatt;");
+ jmethodID jni_mid_connectGatt = CAGetJNIMethodID(env, "android/bluetooth/BluetoothDevice",
+ "connectGatt",
+ "(Landroid/content/Context;ZLandroid/"
+ "bluetooth/BluetoothGattCallback;)"
+ "Landroid/bluetooth/BluetoothGatt;");
if (!jni_mid_connectGatt)
{
OIC_LOG(ERROR, TAG, "bleConnect: jni_mid_connectGatt is null");
// get BluetoothGatt method
OIC_LOG(DEBUG, TAG, "get gatt disconnect method");
- jmethodID jni_mid_disconnectGatt = CALEGetJNIMethodID(env, CLASSPATH_BT_GATT,
- "disconnect", "()V");
+ jmethodID jni_mid_disconnectGatt = CAGetJNIMethodID(env, CLASSPATH_BT_GATT,
+ "disconnect", "()V");
if (!jni_mid_disconnectGatt)
{
OIC_LOG(ERROR, TAG, "jni_mid_disconnectGatt is null");
}
// call disconnect gatt method
- OIC_LOG(DEBUG, TAG, "CALL API - request disconnect gatt");
+ OIC_LOG(INFO, TAG, "CALL API - disconnect");
(*env)->CallVoidMethod(env, bluetoothGatt, jni_mid_disconnectGatt);
if ((*env)->ExceptionCheck(env))
{
// get BluetoothGatt.discoverServices method
OIC_LOG(DEBUG, TAG, "get BluetoothGatt.discoverServices method");
- jmethodID jni_mid_discoverServices = CALEGetJNIMethodID(env, CLASSPATH_BT_GATT,
- "discoverServices", "()Z");
+ jmethodID jni_mid_discoverServices = CAGetJNIMethodID(env, CLASSPATH_BT_GATT,
+ "discoverServices", "()Z");
if (!jni_mid_discoverServices)
{
OIC_LOG(ERROR, TAG, "jni_mid_discoverServices is null");
}
// call disconnect gatt method
- OIC_LOG(DEBUG, TAG, "CALL API - request discovery gatt services");
+ OIC_LOG(INFO, TAG, "CALL API - discoverServices");
jboolean ret = (*env)->CallBooleanMethod(env, bluetoothGatt, jni_mid_discoverServices);
if (!ret)
{
CAResult_t CALESetValueAndWriteCharacteristic(JNIEnv* env, jobject gatt)
{
+ OIC_LOG(DEBUG, TAG, "CALESetValueAndWriteCharacteristic");
+
VERIFY_NON_NULL(gatt, TAG, "gatt is null");
VERIFY_NON_NULL(env, TAG, "env is null");
+ jstring jni_address = CALEClientGetAddressFromGattObj(env, gatt);
+ if (!jni_address)
+ {
+ CALEClientSendFinish(env, gatt);
+ return CA_STATUS_FAILED;
+ }
+
+ const char* address = (*env)->GetStringUTFChars(env, jni_address, NULL);
+ if (!address)
+ {
+ CALEClientSendFinish(env, gatt);
+ return CA_STATUS_FAILED;
+ }
+
+ ca_mutex_lock(g_threadSendStateMutex);
+
+ if (CALEClientIsValidState(address, CA_LE_SEND_STATE, STATE_SENDING))
+ {
+ OIC_LOG(INFO, TAG, "current state is SENDING");
+ (*env)->ReleaseStringUTFChars(env, jni_address, address);
+ ca_mutex_unlock(g_threadSendStateMutex);
+ return CA_STATUS_OK;
+ }
+
+ if (CA_STATUS_OK != CALEClientUpdateDeviceState(address, CA_LE_SEND_STATE,
+ STATE_SENDING))
+ {
+ OIC_LOG(ERROR, TAG, "CALEClientUpdateDeviceState has failed");
+ (*env)->ReleaseStringUTFChars(env, jni_address, address);
+ CALEClientSendFinish(env, gatt);
+ ca_mutex_unlock(g_threadSendStateMutex);
+ return CA_STATUS_FAILED;
+ }
+
+ (*env)->ReleaseStringUTFChars(env, jni_address, address);
+
+ ca_mutex_unlock(g_threadSendStateMutex);
+
// send data
jobject jni_obj_character = CALEClientCreateGattCharacteristic(env, gatt, g_sendBuffer);
if (!jni_obj_character)
// get BluetoothGatt.write characteristic method
OIC_LOG(DEBUG, TAG, "write characteristic method");
- jmethodID jni_mid_writeCharacteristic = CALEGetJNIMethodID(env, CLASSPATH_BT_GATT,
- "writeCharacteristic",
- "(Landroid/bluetooth/"
- "BluetoothGattCharacteristic;)Z");
+ jmethodID jni_mid_writeCharacteristic = CAGetJNIMethodID(env, CLASSPATH_BT_GATT,
+ "writeCharacteristic",
+ "(Landroid/bluetooth/"
+ "BluetoothGattCharacteristic;)Z");
if (!jni_mid_writeCharacteristic)
{
OIC_LOG(ERROR, TAG, "jni_mid_writeCharacteristic is null");
}
// call disconnect gatt method
- OIC_LOG(DEBUG, TAG, "CALL API - request to write gatt characteristic");
+ OIC_LOG(INFO, TAG, "CALL API - writeCharacteristic");
jboolean ret = (jboolean)(*env)->CallBooleanMethod(env, bluetoothGatt,
jni_mid_writeCharacteristic,
gattCharacteristic);
}
OIC_LOG(DEBUG, TAG, "read characteristic method");
- jmethodID jni_mid_readCharacteristic = CALEGetJNIMethodID(env, CLASSPATH_BT_GATT,
- "readCharacteristic",
- "(Landroid/bluetooth/"
- "BluetoothGattCharacteristic;)Z");
+ jmethodID jni_mid_readCharacteristic = CAGetJNIMethodID(env, CLASSPATH_BT_GATT,
+ "readCharacteristic",
+ "(Landroid/bluetooth/"
+ "BluetoothGattCharacteristic;)Z");
if (!jni_mid_readCharacteristic)
{
OIC_LOG(ERROR, TAG, "jni_mid_readCharacteristic is null");
}
// call disconnect gatt method
- OIC_LOG(DEBUG, TAG, "CALL API - request to read gatt characteristic");
+ OIC_LOG(INFO, TAG, "CALL API - readCharacteristic");
jboolean ret = (*env)->CallBooleanMethod(env, bluetoothGatt, jni_mid_readCharacteristic,
jni_obj_GattCharacteristic);
if (ret)
// get BluetoothGatt.setCharacteristicNotification method
OIC_LOG(DEBUG, TAG, "CALEClientSetCharacteristicNotification");
- jmethodID jni_mid_setNotification = CALEGetJNIMethodID(env, CLASSPATH_BT_GATT,
- "setCharacteristicNotification",
- "(Landroid/bluetooth/"
- "BluetoothGattCharacteristic;Z)Z");
+ jmethodID jni_mid_setNotification = CAGetJNIMethodID(env, CLASSPATH_BT_GATT,
+ "setCharacteristicNotification",
+ "(Landroid/bluetooth/"
+ "BluetoothGattCharacteristic;Z)Z");
if (!jni_mid_setNotification)
{
OIC_LOG(ERROR, TAG, "jni_mid_getService is null");
return CA_STATUS_FAILED;
}
+ OIC_LOG(INFO, TAG, "CALL API - setCharacteristicNotification");
jboolean ret = (*env)->CallBooleanMethod(env, bluetoothGatt, jni_mid_setNotification,
characteristic, JNI_TRUE);
if (JNI_TRUE == ret)
{
- OIC_LOG(DEBUG, TAG, "CALL API - setCharacteristicNotification success");
+ OIC_LOG(DEBUG, TAG, "setCharacteristicNotification success");
}
else
{
- OIC_LOG(ERROR, TAG, "CALL API - setCharacteristicNotification has failed");
+ OIC_LOG(ERROR, TAG, "setCharacteristicNotification has failed");
return CA_STATUS_FAILED;
}
// get BluetoothGatt.getService method
OIC_LOG(DEBUG, TAG, "BluetoothGatt.getService");
- jmethodID jni_mid_getService = CALEGetJNIMethodID(env, CLASSPATH_BT_GATT,
- "getService",
- "(Ljava/util/UUID;)Landroid/bluetooth/"
- "BluetoothGattService;");
+ jmethodID jni_mid_getService = CAGetJNIMethodID(env, CLASSPATH_BT_GATT,
+ "getService",
+ "(Ljava/util/UUID;)Landroid/bluetooth/"
+ "BluetoothGattService;");
if (!jni_mid_getService)
{
OIC_LOG(ERROR, TAG, "jni_mid_getService is null");
}
// get bluetooth gatt service method
- jmethodID jni_mid_getCharacteristic = CALEGetJNIMethodID(env, "android/bluetooth/"
- "BluetoothGattService",
- "getCharacteristic",
- "(Ljava/util/UUID;)"
- "Landroid/bluetooth/"
- "BluetoothGattCharacteristic;");
+ jmethodID jni_mid_getCharacteristic = CAGetJNIMethodID(env, "android/bluetooth/"
+ "BluetoothGattService",
+ "getCharacteristic",
+ "(Ljava/util/UUID;)"
+ "Landroid/bluetooth/"
+ "BluetoothGattCharacteristic;");
if (!jni_mid_getCharacteristic)
{
OIC_LOG(ERROR, TAG, "jni_mid_getCharacteristic is null");
return NULL;
}
- jmethodID jni_mid_getValue = CALEGetJNIMethodID(env, "android/bluetooth/"
- "BluetoothGattCharacteristic",
- "getValue", "()[B");
+ jmethodID jni_mid_getValue = CAGetJNIMethodID(env, "android/bluetooth/"
+ "BluetoothGattCharacteristic",
+ "getValue", "()[B");
if (!jni_mid_getValue)
{
OIC_LOG(ERROR, TAG, "jni_mid_getValue is null");
}
OIC_LOG(DEBUG, TAG, "CALEClientSetUUIDToDescriptor");
- jmethodID jni_mid_getDescriptor = CALEGetJNIMethodID(env, "android/bluetooth/"
- "BluetoothGattCharacteristic",
- "getDescriptor",
- "(Ljava/util/UUID;)Landroid/bluetooth/"
- "BluetoothGattDescriptor;");
+ jmethodID jni_mid_getDescriptor = CAGetJNIMethodID(env, "android/bluetooth/"
+ "BluetoothGattCharacteristic",
+ "getDescriptor",
+ "(Ljava/util/UUID;)Landroid/bluetooth/"
+ "BluetoothGattDescriptor;");
if (!jni_mid_getDescriptor)
{
OIC_LOG(ERROR, TAG, "jni_mid_getDescriptor is null");
return CA_STATUS_FAILED;
}
- jmethodID jni_mid_writeDescriptor = CALEGetJNIMethodID(env, "android/bluetooth/BluetoothGatt",
- "writeDescriptor",
- "(Landroid/bluetooth/"
- "BluetoothGattDescriptor;)Z");
+ jmethodID jni_mid_writeDescriptor = CAGetJNIMethodID(env, "android/bluetooth/BluetoothGatt",
+ "writeDescriptor",
+ "(Landroid/bluetooth/"
+ "BluetoothGattDescriptor;)Z");
if (!jni_mid_writeDescriptor)
{
OIC_LOG(ERROR, TAG, "jni_mid_writeDescriptor is null");
return CA_STATUS_FAILED;
}
- OIC_LOG(DEBUG, TAG, "request to write descriptor");
+ OIC_LOG(INFO, TAG, "CALL API - writeDescriptor");
jboolean jni_ret = (*env)->CallBooleanMethod(env, bluetoothGatt, jni_mid_writeDescriptor,
jni_obj_descriptor);
if (jni_ret)
OIC_LOG(ERROR, TAG, "gdevice_list is null");
CALEClientSetScanFlag(false);
- if(CA_STATUS_OK != CALEClientStopScan())
+ if (CA_STATUS_OK != CALEClientStopScan())
{
OIC_LOG(ERROR, TAG, "CALEClientStopScan has failed");
}
jobject gdevice = (*env)->NewGlobalRef(env, device);
u_arraylist_add(g_deviceList, gdevice);
ca_cond_signal(g_deviceDescCond);
- OIC_LOG_V(DEBUG, TAG, "Added this BT Device[%s] in the List", remoteAddress);
+ OIC_LOG_V(DEBUG, TAG, "Added a new BT Device in deviceList [%s]", remoteAddress);
}
(*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
(*env)->ReleaseStringUTFChars(env, jni_setAddress, setAddress);
}
- OIC_LOG(DEBUG, TAG, "there are no the device in list. we can add");
+ OIC_LOG_V(DEBUG, TAG, "[%s] doesn't exist in scanned device list", remoteAddress);
return false;
}
CAResult_t CALEClientAddGattobjToList(JNIEnv *env, jobject gatt)
{
- OIC_LOG(INFO, TAG, "CALEClientAddGattobjToList");
+ OIC_LOG(DEBUG, TAG, "CALEClientAddGattobjToList");
VERIFY_NON_NULL(env, TAG, "env is null");
VERIFY_NON_NULL(gatt, TAG, "gatt is null");
return CA_STATUS_FAILED;
}
- OIC_LOG_V(INFO, TAG, "remote address : %s", remoteAddress);
+ OIC_LOG_V(DEBUG, TAG, "remote address : %s", remoteAddress);
if (!CALEClientIsGattObjInList(env, remoteAddress))
{
jobject newGatt = (*env)->NewGlobalRef(env, gatt);
u_arraylist_add(g_gattObjectList, newGatt);
- OIC_LOG(INFO, TAG, "Set GATT Object to Array as Element");
+ OIC_LOG(INFO, TAG, "added a newGatt object to gattObjectList");
}
(*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
jstring CALEClientGetLEAddressFromBTDevice(JNIEnv *env, jobject bluetoothDevice)
{
- OIC_LOG(DEBUG, TAG, "IN - CALEClientGetLEAddressFromBTDevice");
+ OIC_LOG(DEBUG, TAG, "CALEClientGetLEAddressFromBTDevice");
VERIFY_NON_NULL_RET(env, TAG, "env", NULL);
VERIFY_NON_NULL_RET(bluetoothDevice, TAG, "bluetoothDevice", NULL);
}
// get method ID of getDevice()
- jmethodID jni_mid_getDevice = CALEGetJNIMethodID(env, CLASSPATH_BT_GATT,
- "getDevice", METHODID_BT_DEVICE);
+ jmethodID jni_mid_getDevice = CAGetJNIMethodID(env, CLASSPATH_BT_GATT,
+ "getDevice", METHODID_BT_DEVICE);
if (!jni_mid_getDevice)
{
OIC_LOG(ERROR, TAG, "jni_mid_getDevice is null");
return NULL;
}
+ ca_mutex_lock(g_gattObjectMutex);
+
size_t length = u_arraylist_length(g_gattObjectList);
+ OIC_LOG_V(DEBUG, TAG, "length of gattObjectList : %d", length);
+ OIC_LOG_V(DEBUG, TAG, "targetAddress : %s", targetAddress);
+
for (size_t index = 0; index < length; index++)
{
jobject jarrayObj = (jobject) u_arraylist_get(g_gattObjectList, index);
if (!jarrayObj)
{
+ ca_mutex_unlock(g_gattObjectMutex);
OIC_LOG(ERROR, TAG, "jarrayObj is null");
(*env)->ReleaseStringUTFChars(env, jni_btTargetAddress, targetAddress);
return NULL;
}
- OIC_LOG(DEBUG, TAG, "CALL API - bluetoothGatt.getDevice()");
jobject jni_obj_device = (*env)->CallObjectMethod(env, jarrayObj, jni_mid_getDevice);
if (!jni_obj_device)
{
+ ca_mutex_unlock(g_gattObjectMutex);
OIC_LOG(ERROR, TAG, "jni_obj_device is null");
(*env)->ReleaseStringUTFChars(env, jni_btTargetAddress, targetAddress);
return NULL;
jstring jni_btAddress = CALEGetAddressFromBTDevice(env, jni_obj_device);
if (!jni_btAddress)
{
+ ca_mutex_unlock(g_gattObjectMutex);
OIC_LOG(ERROR, TAG, "CALEGetAddressFromBTDevice has failed");
(*env)->ReleaseStringUTFChars(env, jni_btTargetAddress, targetAddress);
return NULL;
const char* btAddress = (*env)->GetStringUTFChars(env, jni_btAddress, NULL);
if (!btAddress)
{
+ ca_mutex_unlock(g_gattObjectMutex);
OIC_LOG(ERROR, TAG, "btAddress is not available");
(*env)->ReleaseStringUTFChars(env, jni_btTargetAddress, targetAddress);
return NULL;
}
- OIC_LOG_V(DEBUG, TAG, "targetAddress : %s", targetAddress);
- OIC_LOG_V(DEBUG, TAG, "btAddress : %s", btAddress);
+ OIC_LOG_V(DEBUG, TAG, "btAddress : %s (idx: %d)", btAddress, index);
if (!strcmp(targetAddress, btAddress))
{
OIC_LOG(DEBUG, TAG, "Found Gatt object from BT device");
{
OIC_LOG(ERROR, TAG, "jni_LEAddress is null");
}
+ ca_mutex_unlock(g_gattObjectMutex);
(*env)->ReleaseStringUTFChars(env, jni_btTargetAddress, targetAddress);
(*env)->ReleaseStringUTFChars(env, jni_btAddress, btAddress);
(*env)->DeleteLocalRef(env, jni_btAddress);
(*env)->DeleteLocalRef(env, jni_btAddress);
(*env)->DeleteLocalRef(env, jni_obj_device);
}
+ ca_mutex_unlock(g_gattObjectMutex);
- OIC_LOG(DEBUG, TAG, "OUT - CALEClientGetLEAddressFromBTDevice");
+ (*env)->ReleaseStringUTFChars(env, jni_btTargetAddress, targetAddress);
+ OIC_LOG_V(DEBUG, TAG, "[%s] doesn't exist in gattObjectList", targetAddress);
return NULL;
}
* BT State List
*/
-CAResult_t CALEClientUpdateDeviceState(const char* address, uint32_t connectedState,
- uint16_t notificationState, uint16_t sendState)
+CAResult_t CALEClientUpdateDeviceState(const char* address, uint16_t state_type,
+ uint16_t target_state)
{
VERIFY_NON_NULL(address, TAG, "address is null");
-
- CALEState_t *newstate = (CALEState_t*) OICCalloc(1, sizeof(*newstate));
- if (!newstate)
- {
- OIC_LOG(ERROR, TAG, "out of memory");
- return CA_MEMORY_ALLOC_FAILED;
- }
-
- if (strlen(address) > CA_MACADDR_SIZE)
- {
- OIC_LOG(ERROR, TAG, "address is not proper");
- OICFree(newstate);
- return CA_STATUS_FAILED;
- }
-
- OICStrcpy(newstate->address, sizeof(newstate->address), address);
- newstate->connectedState = connectedState;
- newstate->notificationState = notificationState;
- newstate->sendState = sendState;
- return CALEClientAddDeviceStateToList(newstate);
-}
-
-CAResult_t CALEClientAddDeviceStateToList(CALEState_t* state)
-{
- VERIFY_NON_NULL(state, TAG, "state is null");
-
- ca_mutex_lock(g_deviceStateListMutex);
+ VERIFY_NON_NULL(address, TAG, "state_type is null");
+ VERIFY_NON_NULL(address, TAG, "target_state is null");
if (!g_deviceStateList)
{
OIC_LOG(ERROR, TAG, "gdevice_list is null");
- ca_mutex_unlock(g_deviceStateListMutex);
return CA_STATUS_FAILED;
}
- if (CALEClientIsDeviceInList(state->address))
+ ca_mutex_lock(g_deviceStateListMutex);
+
+ if (CALEClientIsDeviceInList(address))
{
- CALEState_t* curState = CALEClientGetStateInfo(state->address);
+ CALEState_t* curState = CALEClientGetStateInfo(address);
if(!curState)
{
OIC_LOG(ERROR, TAG, "curState is null");
return CA_STATUS_FAILED;
}
- if (STATE_CHARACTER_NO_CHANGE == state->notificationState)
+ switch(state_type)
{
- state->notificationState = curState->notificationState;
+ case CA_LE_CONNECTION_STATE:
+ curState->connectedState = target_state;
+ break;
+ case CA_LE_SEND_STATE:
+ curState->sendState = target_state;
+ break;
+ default:
+ break;
+ }
+ OIC_LOG_V(INFO, TAG, "update state - addr : %s, conn : %d, send : %d, ACFlag : %d",
+ curState->address, curState->connectedState, curState->sendState,
+ curState->autoConnectFlag);
+ }
+ else /** state is added newly **/
+ {
+ if (strlen(address) > CA_MACADDR_SIZE)
+ {
+ OIC_LOG(ERROR, TAG, "address is not proper");
+ ca_mutex_unlock(g_deviceStateListMutex);
+ return CA_STATUS_INVALID_PARAM;
}
- state->autoConnectFlag = curState->autoConnectFlag;
- // delete previous state for update new state
- CAResult_t res = CALEClientRemoveDeviceState(state->address);
- if (CA_STATUS_OK != res)
+ CALEState_t *newstate = (CALEState_t*) OICCalloc(1, sizeof(*newstate));
+ if (!newstate)
{
- OIC_LOG(ERROR, TAG, "CALEClientRemoveDeviceState has failed");
+ OIC_LOG(ERROR, TAG, "out of memory");
ca_mutex_unlock(g_deviceStateListMutex);
- return res;
+ return CA_MEMORY_ALLOC_FAILED;
}
- }
- u_arraylist_add(g_deviceStateList, state); // update new state
- OIC_LOG_V(INFO, TAG, "Set State Info to List : %d, %d, %s, %d",
- state->connectedState, state->notificationState,
- state->address, state->autoConnectFlag);
+ OICStrcpy(newstate->address, sizeof(newstate->address), address);
+
+ switch(state_type)
+ {
+ case CA_LE_CONNECTION_STATE:
+ newstate->connectedState = target_state;
+ newstate->sendState = STATE_SEND_NONE;
+ break;
+ case CA_LE_SEND_STATE:
+ newstate->connectedState = STATE_DISCONNECTED;
+ newstate->sendState = target_state;
+ break;
+ default:
+ break;
+ }
+ OIC_LOG_V(INFO, TAG, "add a new state to List - addr : %s, "
+ "conn : %d, send : %d, ACFlag : %d",
+ newstate->address, newstate->connectedState, newstate->sendState,
+ newstate->autoConnectFlag);
+ u_arraylist_add(g_deviceStateList, newstate); // update new state
+ }
ca_mutex_unlock(g_deviceStateListMutex);
+
return CA_STATUS_OK;
}
// autoConnectFlag value will be not changed,
// since it has reset only termination case.
state->connectedState = STATE_DISCONNECTED;
- state->notificationState = STATE_CHARACTER_UNSET;
state->sendState = STATE_SEND_NONE;
}
ca_mutex_unlock(g_deviceStateListMutex);
CALEState_t* CALEClientGetStateInfo(const char* remoteAddress)
{
- OIC_LOG(DEBUG, TAG, "CALEClientGetStateInfo");
VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress is null", NULL);
if (!g_deviceStateList)
}
uint32_t length = u_arraylist_length(g_deviceStateList);
- OIC_LOG_V(DEBUG, TAG, "CALEClientGetStateInfo : %d", length);
+ OIC_LOG_V(DEBUG, TAG, "length of deviceStateList : %d", length);
+ OIC_LOG_V(DEBUG, TAG, "target address : %s", remoteAddress);
for (uint32_t index = 0; index < length; index++)
{
continue;
}
- OIC_LOG_V(DEBUG, TAG, "target address : %s", remoteAddress);
- OIC_LOG_V(DEBUG, TAG, "state address : %s", state->address);
+ OIC_LOG_V(DEBUG, TAG, "state address : %s (idx: %d)", state->address, index);
if (!strcmp(state->address, remoteAddress))
{
- OIC_LOG_V(DEBUG, TAG, "get state : %s", remoteAddress);
+ OIC_LOG(DEBUG, TAG, "found state");
return state;
}
}
+
+ OIC_LOG_V(DEBUG, TAG, "[%s] doesn't exist in deviceStateList", remoteAddress);
return NULL;
}
-bool CALEClientIsConnectedDevice(const char* remoteAddress)
+bool CALEClientIsValidState(const char* remoteAddress, uint16_t state_type,
+ uint16_t target_state)
{
- OIC_LOG(DEBUG, TAG, "CALEClientIsConnectedDevice");
+ OIC_LOG_V(DEBUG, TAG, "CALEClientIsValidState : type[%d], target state[%d]",
+ state_type, target_state);
VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress is null", false);
ca_mutex_lock(g_deviceStateListMutex);
return false;
}
- uint32_t length = u_arraylist_length(g_deviceStateList);
- for (uint32_t index = 0; index < length; index++)
+ CALEState_t* state = CALEClientGetStateInfo(remoteAddress);
+ if (NULL == state)
{
- CALEState_t* state = (CALEState_t*) u_arraylist_get(g_deviceStateList, index);
- if (!state)
- {
- OIC_LOG(ERROR, TAG, "CALEState_t object is null");
- continue;
- }
-
- if (!strcmp(state->address, remoteAddress))
- {
- OIC_LOG(DEBUG, TAG, "check whether it is connected or not");
-
- if (STATE_CONNECTED == state->connectedState)
- {
- ca_mutex_unlock(g_deviceStateListMutex);
- return true;
- }
- else
- {
- ca_mutex_unlock(g_deviceStateListMutex);
- return false;
- }
- }
+ OIC_LOG(ERROR, TAG, "state is null");
+ ca_mutex_unlock(g_deviceStateListMutex);
+ return false;
}
- ca_mutex_unlock(g_deviceStateListMutex);
- return false;
-}
-bool CALEClientIsSetCharacteristic(const char* remoteAddress)
-{
- OIC_LOG(DEBUG, TAG, "CALEClientIsSetCharacteristic");
- VERIFY_NON_NULL_RET(remoteAddress, TAG, "remoteAddress is null", false);
+ uint16_t curValue = 0;
+ switch(state_type)
+ {
+ case CA_LE_CONNECTION_STATE:
+ curValue = state->connectedState;
+ break;
+ case CA_LE_SEND_STATE:
+ curValue = state->sendState;
+ break;
+ default:
+ break;
+ }
- ca_mutex_lock(g_deviceStateListMutex);
- if (!g_deviceStateList)
+ if (target_state == curValue)
{
- OIC_LOG(ERROR, TAG, "g_deviceStateList is null");
ca_mutex_unlock(g_deviceStateListMutex);
- return false;
+ return true;
}
-
- uint32_t length = u_arraylist_length(g_deviceStateList);
- for (uint32_t index = 0; index < length; index++)
+ else
{
- CALEState_t* state = (CALEState_t*) u_arraylist_get(g_deviceStateList, index);
- if (!state)
- {
- OIC_LOG(ERROR, TAG, "CALEState_t object is null");
- continue;
- }
-
- if (!strcmp(state->address, remoteAddress))
- {
- OIC_LOG_V(DEBUG, TAG, "check whether it was set or not:%d", state->notificationState);
-
- if (STATE_CHARACTER_SET == state->notificationState)
- {
- ca_mutex_unlock(g_deviceStateListMutex);
- return true;
- }
- else
- {
- ca_mutex_unlock(g_deviceStateListMutex);
- return false;
- }
- }
+ ca_mutex_unlock(g_deviceStateListMutex);
+ return false;
}
ca_mutex_unlock(g_deviceStateListMutex);
}
}
+ if (NULL == g_threadSendStateMutex)
+ {
+ g_threadSendStateMutex = ca_mutex_new();
+ if (NULL == g_threadSendStateMutex)
+ {
+ OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ return CA_STATUS_FAILED;
+ }
+ }
+
return CA_STATUS_OK;
}
ca_mutex_free(g_deviceScanRetryDelayMutex);
g_deviceScanRetryDelayMutex = NULL;
+
+ ca_mutex_free(g_threadSendStateMutex);
+ g_threadSendStateMutex = NULL;
}
void CALEClientSetSendFinishFlag(bool flag)
CALEClientTerminate();
}
-CAResult_t CAUpdateCharacteristicsToGattServer(const char *remoteAddress, const uint8_t *data,
- uint32_t dataLen, CALETransferType_t type,
- int32_t position)
+CAResult_t CAUpdateCharacteristicsToGattServer(const char *remoteAddress, const uint8_t *data,
+ uint32_t dataLen, CALETransferType_t type,
+ int32_t position)
{
OIC_LOG(DEBUG, TAG, "call CALEClientSendUnicastMessage");
VERIFY_NON_NULL(data, TAG, "data is null");
VERIFY_NON_NULL_RET(env, TAG, "env is null", NULL);
VERIFY_NON_NULL_RET(gatt, TAG, "gatt is null", NULL);
- jmethodID jni_mid_getDevice = CALEGetJNIMethodID(env, CLASSPATH_BT_GATT,
- "getDevice", METHODID_BT_DEVICE);
+ jmethodID jni_mid_getDevice = CAGetJNIMethodID(env, CLASSPATH_BT_GATT,
+ "getDevice", METHODID_BT_DEVICE);
if (!jni_mid_getDevice)
{
OIC_LOG(ERROR, TAG, "jni_mid_getDevice is null");
*/
JNIEXPORT void JNICALL
Java_org_iotivity_ca_CaLeClientInterface_caLeGattConnectionStateChangeCallback(JNIEnv *env,
- jobject obj,
- jobject gatt,
- jint status,
- jint newstate)
+ jobject obj,
+ jobject gatt,
+ jint status,
+ jint newstate)
{
- OIC_LOG_V(DEBUG, TAG, "CALeGattConnectionStateChangeCallback - status %d, newstate %d", status,
- newstate);
+ OIC_LOG_V(INFO, TAG, "CALeGattConnectionStateChangeCallback - status %d, newstate %d", status,
+ newstate);
VERIFY_NON_NULL_VOID(env, TAG, "env is null");
VERIFY_NON_NULL_VOID(obj, TAG, "obj is null");
VERIFY_NON_NULL_VOID(gatt, TAG, "gatt is null");
jint state_connected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE, "STATE_CONNECTED");
- jint state_disconnected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE, "STATE_DISCONNECTED");
- jint gatt_success = CALEGetConstantsValue(env, CLASSPATH_BT_GATT, "GATT_SUCCESS");
- if (gatt_success == status && state_connected == newstate) // le connected
+ jstring jni_address = CALEClientGetAddressFromGattObj(env, gatt);
+ if (!jni_address)
{
- jstring jni_address = CALEClientGetAddressFromGattObj(env, gatt);
- if (!jni_address)
- {
- goto error_exit;
- }
+ OIC_LOG(ERROR, TAG, "CALEClientGetAddressFromGattObj has failed");
+ goto error_exit;
+ }
- const char* address = (*env)->GetStringUTFChars(env, jni_address, NULL);
- if (address)
+ const char* address = (*env)->GetStringUTFChars(env, jni_address, NULL);
+ if (!address)
+ {
+ OIC_LOG(ERROR, TAG, "address is null");
+ goto error_exit;
+ }
+ OIC_LOG_V(DEBUG, TAG, "CALeGattConnectionStateChangeCallback - address [%s]", address);
+
+ CAResult_t res;
+ if (state_connected == newstate)
+ {
+ OIC_LOG(DEBUG, TAG, "LE is connected");
+ if (GATT_SUCCESS == status)
{
- CAResult_t res = CALEClientUpdateDeviceState(address, STATE_CONNECTED,
- STATE_CHARACTER_NO_CHANGE,
- STATE_SEND_NONE);
+ res = CALEClientUpdateDeviceState(address, CA_LE_CONNECTION_STATE, STATE_CONNECTED);
+ (*env)->ReleaseStringUTFChars(env, jni_address, address);
if (CA_STATUS_OK != res)
{
OIC_LOG(ERROR, TAG, "CALEClientUpdateDeviceState has failed");
- (*env)->ReleaseStringUTFChars(env, jni_address, address);
goto error_exit;
}
- OIC_LOG_V(INFO, TAG, "ConnectionStateCB - remote address : %s", address);
- (*env)->ReleaseStringUTFChars(env, jni_address, address);
- }
+ res = CALEClientAddGattobjToList(env, gatt);
+ if (CA_STATUS_OK != res)
+ {
+ OIC_LOG(ERROR, TAG, "CALEClientAddGattobjToList has failed");
+ goto error_exit;
+ }
- CAResult_t res = CALEClientAddGattobjToList(env, gatt);
- if (CA_STATUS_OK != res)
- {
- OIC_LOG(ERROR, TAG, "CALEClientAddGattobjToList has failed");
- goto error_exit;
+ res = CALEClientDiscoverServices(env, gatt);
+ if (CA_STATUS_OK != res)
+ {
+ OIC_LOG(ERROR, TAG, "CALEClientDiscoverServices has failed");
+ goto error_exit;
+ }
}
-
- res = CALEClientDiscoverServices(env, gatt);
- if (CA_STATUS_OK != res)
+ else
{
- OIC_LOG(ERROR, TAG, "CALEClientDiscoverServices has failed");
- goto error_exit;
+ OIC_LOG(INFO, TAG, "unknown status");
+ (*env)->ReleaseStringUTFChars(env, jni_address, address);
}
}
- else if (state_disconnected == newstate) // le disconnected
+ else // STATE_DISCONNECTED == newstate
{
- jstring jni_address = CALEClientGetAddressFromGattObj(env, gatt);
- if (!jni_address)
- {
- OIC_LOG(ERROR, TAG, "CALEClientGetAddressFromGattObj has failed");
- goto error_exit;
- }
+ OIC_LOG(DEBUG, TAG, "LE is disconnected");
- const char* address = (*env)->GetStringUTFChars(env, jni_address, NULL);
- if (address)
+ res = CALEClientUpdateDeviceState(address, CA_LE_CONNECTION_STATE, STATE_DISCONNECTED);
+ (*env)->ReleaseStringUTFChars(env, jni_address, address);
+ if (CA_STATUS_OK != res)
{
- CAResult_t res = CALEClientUpdateDeviceState(address, STATE_DISCONNECTED,
- STATE_CHARACTER_UNSET,
- STATE_SEND_NONE);
- if (CA_STATUS_OK != res)
- {
- OIC_LOG(ERROR, TAG, "CALEClientUpdateDeviceState has failed");
- (*env)->ReleaseStringUTFChars(env, jni_address, address);
- goto error_exit;
- }
- OIC_LOG_V(INFO, TAG, "ConnectionStateCB - remote address : %s", address);
-
- (*env)->ReleaseStringUTFChars(env, jni_address, address);
+ OIC_LOG(ERROR, TAG, "CALEClientUpdateDeviceState has failed");
+ goto error_exit;
}
- CAResult_t res = CALEClientGattClose(env, gatt);
+ res = CALEClientGattClose(env, gatt);
if (CA_STATUS_OK != res)
{
OIC_LOG(ERROR, TAG, "CALEClientGattClose has failed");
{
// other reason except for gatt_success is expected to running
// background connection in BT platform.
- OIC_LOG(INFO, TAG, "unknown state or manual disconnected state");
+ OIC_LOG(INFO, TAG, "unknown status or manual disconnected state");
CALEClientUpdateSendCnt(env);
return;
}
// error label.
error_exit:
-
CALEClientSendFinish(env, gatt);
return;
}
*/
JNIEXPORT void JNICALL
Java_org_iotivity_ca_CaLeClientInterface_caLeGattServicesDiscoveredCallback(JNIEnv *env,
- jobject obj,
- jobject gatt,
- jint status)
+ jobject obj,
+ jobject gatt,
+ jint status)
{
- OIC_LOG_V(DEBUG, TAG, "CALeGattServicesDiscoveredCallback - status %d: ", status);
+ OIC_LOG_V(INFO, TAG, "CALeGattServicesDiscoveredCallback - status %d", status);
VERIFY_NON_NULL_VOID(env, TAG, "env is null");
VERIFY_NON_NULL_VOID(obj, TAG, "obj is null");
VERIFY_NON_NULL_VOID(gatt, TAG, "gatt is null");
- if (0 != status) // discovery error
+ if (GATT_SUCCESS != status) // discovery error
{
CALEClientSendFinish(env, gatt);
return;
return;
}
- if (!CALEClientIsSetCharacteristic(address))
+ jstring jni_uuid = (*env)->NewStringUTF(env, OIC_GATT_CHARACTERISTIC_RESPONSE_UUID);
+ if (!jni_uuid)
{
- jstring jni_uuid = (*env)->NewStringUTF(env, OIC_GATT_CHARACTERISTIC_RESPONSE_UUID);
- if (!jni_uuid)
- {
- OIC_LOG(ERROR, TAG, "jni_uuid is null");
- goto error_exit;
- }
+ OIC_LOG(ERROR, TAG, "jni_uuid is null");
+ goto error_exit;
+ }
- jobject jni_obj_GattCharacteristic = CALEClientGetGattService(env, gatt, jni_uuid);
- if (!jni_obj_GattCharacteristic)
- {
- OIC_LOG(ERROR, TAG, "jni_obj_GattCharacteristic is null");
- goto error_exit;
- }
+ jobject jni_obj_GattCharacteristic = CALEClientGetGattService(env, gatt, jni_uuid);
+ if (!jni_obj_GattCharacteristic)
+ {
+ OIC_LOG(ERROR, TAG, "jni_obj_GattCharacteristic is null");
+ goto error_exit;
+ }
- CAResult_t res = CALEClientSetCharacteristicNotification(env, gatt,
- jni_obj_GattCharacteristic);
- if (CA_STATUS_OK != res)
- {
- OIC_LOG(ERROR, TAG, "CALEClientSetCharacteristicNotification has failed");
- goto error_exit;
- }
+ CAResult_t res = CALEClientSetCharacteristicNotification(env, gatt,
+ jni_obj_GattCharacteristic);
+ if (CA_STATUS_OK != res)
+ {
+ OIC_LOG(ERROR, TAG, "CALEClientSetCharacteristicNotification has failed");
+ goto error_exit;
+ }
+
+ res = CALEClientSetUUIDToDescriptor(env, gatt, jni_obj_GattCharacteristic);
+ if (CA_STATUS_OK != res)
+ {
+ OIC_LOG_V(INFO, TAG, "Descriptor is not found : %d", res);
- res = CALEClientSetUUIDToDescriptor(env, gatt, jni_obj_GattCharacteristic);
+ res = CALEClientSetFlagToState(env, jni_address, CA_LE_DESCRIPTOR_FOUND, JNI_FALSE);
if (CA_STATUS_OK != res)
{
- OIC_LOG_V(INFO, TAG, "Descriptor is not found : %d", res);
- if (g_sendBuffer)
- {
- CAResult_t res = CALEClientWriteCharacteristic(env, gatt);
- if (CA_STATUS_OK != res)
- {
- OIC_LOG(ERROR, TAG, "CALEClientWriteCharacteristic has failed");
- goto error_exit;
- }
- }
+ OIC_LOG(ERROR, TAG, "CALEClientSetFlagToState has failed");
+ goto error_exit;
}
- res = CALEClientUpdateDeviceState(address, STATE_CONNECTED, STATE_CHARACTER_SET,
- STATE_SEND_NONE);
+ res = CALEClientUpdateDeviceState(address, CA_LE_CONNECTION_STATE,
+ STATE_SERVICE_CONNECTED);
if (CA_STATUS_OK != res)
{
OIC_LOG(ERROR, TAG, "CALEClientUpdateDeviceState has failed");
goto error_exit;
}
- }
- else
- {
+
if (g_sendBuffer)
{
CAResult_t res = CALEClientWriteCharacteristic(env, gatt);
}
}
}
+ else
+ {
+ res = CALEClientSetFlagToState(env, jni_address, CA_LE_DESCRIPTOR_FOUND, JNI_TRUE);
+ if (CA_STATUS_OK != res)
+ {
+ OIC_LOG(ERROR, TAG, "CALEClientSetFlagToState has failed");
+ goto error_exit;
+ }
+ }
+
OIC_LOG(INFO, TAG, "ServicesDiscovery is successful");
(*env)->ReleaseStringUTFChars(env, jni_address, address);
return;
*/
JNIEXPORT void JNICALL
Java_org_iotivity_ca_CaLeClientInterface_caLeGattCharacteristicWriteCallback(
- JNIEnv *env, jobject obj, jobject gatt, jbyteArray data,
- jint status)
+ JNIEnv *env, jobject obj, jobject gatt, jbyteArray data, jint status)
{
- OIC_LOG_V(DEBUG, TAG, "CALeGattCharacteristicWriteCallback - status : %d", status);
+ OIC_LOG_V(INFO, TAG, "CALeGattCharacteristicWriteCallback - status : %d", status);
VERIFY_NON_NULL_VOID(env, TAG, "env is null");
VERIFY_NON_NULL_VOID(obj, TAG, "obj is null");
VERIFY_NON_NULL_VOID(gatt, TAG, "gatt is null");
goto error_exit;
}
- jint gatt_success = CALEGetConstantsValue(env, CLASSPATH_BT_GATT, "GATT_SUCCESS");
- if (gatt_success != status) // error case
+ if (GATT_SUCCESS != status) // error case
{
OIC_LOG(ERROR, TAG, "send failure");
ca_cond_signal(g_threadWriteCharacteristicCond);
ca_mutex_unlock(g_threadWriteCharacteristicMutex);
- CAResult_t res = CALEClientUpdateDeviceState(address, STATE_CONNECTED,
- STATE_CHARACTER_SET,
- STATE_SEND_FAILED);
+ CAResult_t res = CALEClientUpdateDeviceState(address, CA_LE_SEND_STATE,
+ STATE_SEND_FAIL);
if (CA_STATUS_OK != res)
{
OIC_LOG(ERROR, TAG, "CALEClientUpdateDeviceState has failed");
g_clientErrorCallback(address, data, length, CA_SEND_FAILED);
}
- CALEClientSendFinish(env, gatt);
+ (*env)->ReleaseStringUTFChars(env, jni_address, address);
goto error_exit;
}
}
else
{
OIC_LOG(DEBUG, TAG, "send success");
- CAResult_t res = CALEClientUpdateDeviceState(address, STATE_CONNECTED, STATE_CHARACTER_SET,
+ CAResult_t res = CALEClientUpdateDeviceState(address, CA_LE_SEND_STATE,
STATE_SEND_SUCCESS);
if (CA_STATUS_OK != res)
{
Java_org_iotivity_ca_CaLeClientInterface_caLeGattCharacteristicChangedCallback(
JNIEnv *env, jobject obj, jobject gatt, jbyteArray data)
{
- OIC_LOG(DEBUG, TAG, "CALeGattCharacteristicChangedCallback");
+ OIC_LOG(INFO, TAG, "CALeGattCharacteristicChangedCallback");
VERIFY_NON_NULL_VOID(env, TAG, "env is null");
VERIFY_NON_NULL_VOID(obj, TAG, "obj is null");
VERIFY_NON_NULL_VOID(gatt, TAG, "gatt is null");
OIC_LOG_V(DEBUG, TAG, "CALeGattCharacteristicChangedCallback - data. : %p, %d",
receivedData, length);
- ca_mutex_lock(g_bleServerBDAddressMutex);
uint32_t sentLength = 0;
- g_CABLEClientDataReceivedCallback(address, receivedData, length,
- &sentLength);
+ ca_mutex_lock(g_bleServerBDAddressMutex);
+ g_CABLEClientDataReceivedCallback(address, receivedData, length, &sentLength);
ca_mutex_unlock(g_bleServerBDAddressMutex);
(*env)->ReleaseStringUTFChars(env, jni_address, address);
jobject gatt,
jint status)
{
- OIC_LOG_V(DEBUG, TAG, "CALeGattDescriptorWriteCallback - status %d: ", status);
+ OIC_LOG_V(INFO, TAG, "CALeGattDescriptorWriteCallback - status %d", status);
VERIFY_NON_NULL_VOID(env, TAG, "env is null");
VERIFY_NON_NULL_VOID(obj, TAG, "obj is null");
VERIFY_NON_NULL_VOID(gatt, TAG, "gatt is null");
- jint gatt_success = CALEGetConstantsValue(env, CLASSPATH_BT_GATT, "GATT_SUCCESS");
- if (gatt_success != status) // error
+ if (GATT_SUCCESS != status) // error
+ {
+ goto error_exit;
+ }
+
+ jstring jni_address = CALEClientGetAddressFromGattObj(env, gatt);
+ if (!jni_address)
+ {
+ goto error_exit;
+ }
+
+ const char* address = (*env)->GetStringUTFChars(env, jni_address, NULL);
+ if (!address)
+ {
+ goto error_exit;
+ }
+
+ CAResult_t res = CALEClientUpdateDeviceState(address, CA_LE_CONNECTION_STATE,
+ STATE_SERVICE_CONNECTED);
+ (*env)->ReleaseStringUTFChars(env, jni_address, address);
+ if (CA_STATUS_OK != res)
{
+ OIC_LOG(ERROR, TAG, "CALEClientUpdateDeviceState has failed");
goto error_exit;
}
static const uint16_t GATT_ERROR = 133;
-static const uint16_t STATE_CHARACTER_SET = 2;
-static const uint16_t STATE_CHARACTER_UNSET = 1;
-static const uint16_t STATE_CHARACTER_NO_CHANGE = 0;
-
-static const uint16_t STATE_SEND_NONE = 0;
-static const uint16_t STATE_SEND_SUCCESS = 1;
-static const uint16_t STATE_SEND_FAILED = 2;
+static const uint16_t STATE_SEND_NONE = 1;
+static const uint16_t STATE_SEND_SUCCESS = 2;
+static const uint16_t STATE_SEND_FAIL = 3;
+static const uint16_t STATE_SENDING = 4;
typedef struct le_state_info
{
char address[CA_MACADDR_SIZE];
- jint connectedState;
- uint16_t notificationState;
+ uint16_t connectedState;
uint16_t sendState;
jboolean autoConnectFlag;
+ jboolean isDescriptorFound;
} CALEState_t;
/**
const uint32_t dataLen);
/**
- * check whether it is connected or not with remote address.
- * @param[in] address remote address.
- * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
- */
-CAResult_t CALECheckSendState(const char* address);
-
-/**
* send data to remote device.
* if it isn't connected yet. connect LE before try to send data.
* @param[in] env JNI interface pointer.
CAResult_t CALEClientStopScanImpl(JNIEnv *env, jobject callback);
/**
- * set auto connect flag for connectGatt API.
+ * set flag into State List.
* @param[in] env JNI interface pointer.
* @param[in] jni_address remote address.
+ * @param[in] state_idx state index.
* @param[in] flag auto connect flag.
*/
-CAResult_t CALEClientSetAutoConnectFlag(JNIEnv *env, jstring jni_address, jboolean flag);
+CAResult_t CALEClientSetFlagToState(JNIEnv *env, jstring jni_address,
+ jint state_idx, jboolean flag);
/**
- * get auto connect flag.
+ * get flag from State List.
* @param[in] env JNI interface pointer.
* @param[in] jni_address remote address.
- * @return current auto connect flag;
+ * @param[in] state_idx state index.
+ * @return current flag;
*/
-jboolean CALEClientGetAutoConnectFlag(JNIEnv *env, jstring jni_address);
+jboolean CALEClientGetFlagFromState(JNIEnv *env, jstring jni_address, jint state_idx);
/**
* connect to gatt server hosted.
/**
* update new state information.
* @param[in] address remote address.
- * @param[in] connectedState connection state.
- * @param[in] notificationState whether characteristic notification already set or not.
- * @param[in] sendState whether sending was success or not.
+ * @param[in] state_type state type.
+ * @param[in] target_state state index to update.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
-CAResult_t CALEClientUpdateDeviceState(const char* address, uint32_t connectedState,
- uint16_t notificationState, uint16_t sendState);
-
-/**
- * add new state to state list.
- * @param[in] state new state.
- * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
- */
-CAResult_t CALEClientAddDeviceStateToList(CALEState_t* state);
+CAResult_t CALEClientUpdateDeviceState(const char* address, uint16_t state_type,
+ uint16_t target_state);
/**
* check whether the remote address is existed or not.
CALEState_t* CALEClientGetStateInfo(const char* remoteAddress);
/**
- * check whether the remote address is connected or not.
- * @param[in] remoteAddress remote address.
- * @return true or false.
- */
-bool CALEClientIsConnectedDevice(const char* remoteAddress);
-
-/**
- * check whether the remote address set CharacteristicNotification or not.
+ * check whether the remote address has same state with target state.
* @param[in] remoteAddress remote address.
+ * @param[in] state_type state_type.
+ * @param[in] target_state state index to check.
* @return true or false.
*/
-bool CALEClientIsSetCharacteristic(const char* remoteAddress);
+bool CALEClientIsValidState(const char* remoteAddress, uint16_t state_type,
+ uint16_t target_state);
/**
* create scan device list.
#define TAG PCF("OIC_CA_LE_MONITOR")
+static const jint CONNECTION_FAILED_TO_BE_EASTABLISHED = 62;
+
static JavaVM *g_jvm;
/**
return CA_STATUS_OK;
}
+static CAResult_t CALEStateConnectedCallback(JNIEnv *env, jstring jni_address,
+ jboolean isDescriptorFound)
+{
+ VERIFY_NON_NULL(env, TAG, "env");
+ VERIFY_NON_NULL(jni_address, TAG, "jni_address");
+
+ if (CALEClientGetFlagFromState(env, jni_address, CA_LE_DESCRIPTOR_FOUND) == isDescriptorFound)
+ {
+ if (g_bleConnectionStateChangedCallback)
+ {
+ const char* address = (*env)->GetStringUTFChars(env, jni_address, NULL);
+ if (!address)
+ {
+ OIC_LOG(ERROR, TAG, "address is null");
+ return CA_STATUS_FAILED;
+ }
+
+ g_bleConnectionStateChangedCallback(CA_ADAPTER_GATT_BTLE, address, true);
+ OIC_LOG(DEBUG, TAG, "BLE is connected");
+
+ (*env)->ReleaseStringUTFChars(env, jni_address, address);
+ }
+ }
+
+ return CA_STATUS_OK;
+}
+
JNIEXPORT void JNICALL
Java_org_iotivity_ca_CaLeClientInterface_caLeStateChangedCallback(JNIEnv *env, jobject obj,
jint status)
jobject obj,
jobject gatt,
jint status,
- jint newstate)
+ jint newState)
{
- VERIFY_NON_NULL_VOID(env, TAG, "env is null");
- VERIFY_NON_NULL_VOID(obj, TAG, "obj is null");
- VERIFY_NON_NULL_VOID(gatt, TAG, "gatt is null");
-
OIC_LOG_V(DEBUG, TAG, "CALeGattNWConnectionStateChangeCallback - status %d, newstate %d",
- status, newstate);
+ status, newState);
+ VERIFY_NON_NULL_VOID(env, TAG, "env");
+ VERIFY_NON_NULL_VOID(obj, TAG, "obj");
+ VERIFY_NON_NULL_VOID(gatt, TAG, "gatt");
jint state_disconnected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE,
"STATE_DISCONNECTED");
- if (state_disconnected == newstate)
+ if (state_disconnected == newState)
{
jstring jni_address = CALEClientGetAddressFromGattObj(env, gatt);
if (!jni_address)
return;
}
- if (g_bleConnectionStateChangedCallback)
+ if (CONNECTION_FAILED_TO_BE_EASTABLISHED != status)
{
- g_bleConnectionStateChangedCallback(CA_ADAPTER_GATT_BTLE, address, false);
+ if (g_bleConnectionStateChangedCallback)
+ {
+ OIC_LOG_V(DEBUG, TAG, "LE Disconnected state is %d, %s", newState, address);
+ g_bleConnectionStateChangedCallback(CA_ADAPTER_GATT_BTLE, address, false);
+ }
}
(*env)->ReleaseStringUTFChars(env, jni_address, address);
Java_org_iotivity_ca_CaLeServerInterface_caLeGattServerNWConnectionStateChangeCallback(
JNIEnv *env, jobject obj, jobject device, jint status, jint newState)
{
- OIC_LOG(DEBUG, TAG, " Gatt Server NWConnectionStateChange Callback");
-
+ OIC_LOG_V(DEBUG, TAG, "caLeGattServerNWConnectionStateChangeCallback - status %d, newstate %d",
+ status, newState);
VERIFY_NON_NULL_VOID(env, TAG, "env");
VERIFY_NON_NULL_VOID(obj, TAG, "obj");
VERIFY_NON_NULL_VOID(device, TAG, "device");
- (void)status;
- // STATE_DISCONNECTED
- jint state_disconnected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE,
- "STATE_DISCONNECTED");
- if (state_disconnected == newState)
+ if (CONNECTION_FAILED_TO_BE_EASTABLISHED != status)
+ {
+ if (g_bleConnectionStateChangedCallback)
+ {
+ jstring jni_remoteAddress = CALEGetAddressFromBTDevice(env, device);
+ if (!jni_remoteAddress)
+ {
+ OIC_LOG(ERROR, TAG, "jni_remoteAddress is null");
+ return;
+ }
+
+ const char* address = (*env)->GetStringUTFChars(env, jni_remoteAddress, NULL);
+ if (!address)
+ {
+ OIC_LOG(ERROR, TAG, "address is null");
+ return;
+ }
+
+ // STATE_DISCONNECTED
+ jint state_disconnected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE,
+ "STATE_DISCONNECTED");
+
+ // STATE_CONNECTED
+ jint state_connected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE,
+ "STATE_CONNECTED");
+
+ if (state_disconnected == newState)
+ {
+ OIC_LOG_V(DEBUG, TAG, "LE Disconnected state is %d, %s", newState, address);
+ g_bleConnectionStateChangedCallback(CA_ADAPTER_GATT_BTLE, address, false);
+ }
+ else if (state_connected == newState)
+ {
+ OIC_LOG_V(DEBUG, TAG, "LE Connected state is %d, %s", newState, address);
+ g_bleConnectionStateChangedCallback(CA_ADAPTER_GATT_BTLE, address, true);
+ }
+ else
+ {
+ OIC_LOG_V(DEBUG, TAG, "Unknown state : %d, %s", newState, address);
+ }
+
+ (*env)->ReleaseStringUTFChars(env, jni_remoteAddress, address);
+ }
+ }
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaLeClientInterface_caLeGattNWServicesDiscoveredCallback(JNIEnv *env,
+ jobject obj,
+ jobject gatt,
+ jint status)
+{
+ OIC_LOG_V(DEBUG, TAG, "caLeGattNWServicesDiscoveredCallback - status %d", status);
+ VERIFY_NON_NULL_VOID(env, TAG, "env");
+ VERIFY_NON_NULL_VOID(obj, TAG, "obj");
+ VERIFY_NON_NULL_VOID(gatt, TAG, "gatt");
+
+ if (GATT_SUCCESS == status)
{
- jstring jni_remoteAddress = CALEGetAddressFromBTDevice(env, device);
- if (!jni_remoteAddress)
+ jstring jni_address = CALEGetAddressFromGatt(env, gatt);
+ if (!jni_address)
{
- OIC_LOG(ERROR, TAG, "jni_remoteAddress is null");
+ OIC_LOG(ERROR, TAG, "jni_address is null");
return;
}
- const char* address = (*env)->GetStringUTFChars(env, jni_remoteAddress, NULL);
- if (!address)
+ if (CA_STATUS_OK != CALEStateConnectedCallback(env, jni_address, JNI_FALSE))
{
- OIC_LOG(ERROR, TAG, "address is null");
+ OIC_LOG(ERROR, TAG, "CALEStateConnectedCallback has failed");
+ }
+
+ (*env)->DeleteLocalRef(env, jni_address);
+ }
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaLeClientInterface_caLeGattNWDescriptorWriteCallback(JNIEnv *env,
+ jobject obj,
+ jobject gatt,
+ jint status)
+{
+ OIC_LOG_V(DEBUG, TAG, "caLeGattNWDescriptorWriteCallback - status %d", status);
+ VERIFY_NON_NULL_VOID(env, TAG, "env");
+ VERIFY_NON_NULL_VOID(obj, TAG, "obj");
+ VERIFY_NON_NULL_VOID(gatt, TAG, "gatt");
+
+ if (GATT_SUCCESS == status)
+ {
+ jstring jni_address = CALEGetAddressFromGatt(env, gatt);
+ if (!jni_address)
+ {
+ OIC_LOG(ERROR, TAG, "jni_address is null");
return;
}
- if (g_bleConnectionStateChangedCallback)
+ if (CA_STATUS_OK != CALEStateConnectedCallback(env, jni_address, JNI_TRUE))
{
- g_bleConnectionStateChangedCallback(CA_ADAPTER_GATT_BTLE, address, false);
+ OIC_LOG(ERROR, TAG, "CALEStateConnectedCallback has failed");
}
- (*env)->ReleaseStringUTFChars(env, jni_remoteAddress, address);
+ (*env)->DeleteLocalRef(env, jni_address);
}
}
#define TAG PCF("OIC_CA_LE_SERVER")
#define WAIT_TIME_WRITE_CHARACTERISTIC 10000000
+#define INVALID_STATE -1
static JavaVM *g_jvm = NULL;
static jobject g_context = NULL;
static ca_cond g_threadSendNotifyCond = NULL;
static bool g_isSignalSetFlag = false;
+static jint g_state_connected = INVALID_STATE;
+static jint g_state_disconnected = INVALID_STATE;
+
static const char CLASSPATH_BT_ADVERTISE_CB[] = "android/bluetooth/le/AdvertiseCallback";
static const char CLASSPATH_BT_GATTSERVER[] = "android/bluetooth/BluetoothGattServer";
VERIFY_NON_NULL_RET(env, TAG, "env", -1);
VERIFY_NON_NULL_RET(device, TAG, "device", -1);
- jmethodID jni_mid_getConnectionState = CALEGetJNIMethodID(env, "android/bluetooth/BluetoothManager",
- "getConnectionState",
- "(Landroid/bluetooth/BluetoothDevice"
- ";I)I");
+ jmethodID jni_mid_getConnectionState = CAGetJNIMethodID(env, "android/bluetooth"
+ "/BluetoothManager",
+ "getConnectionState",
+ "(Landroid/bluetooth/BluetoothDevice"
+ ";I)I");
if (!jni_mid_getConnectionState)
{
OIC_LOG(ERROR, TAG, "jni_mid_getConnectionState is null");
}
OIC_LOG(DEBUG, TAG, "CALEServerSetResponseData");
- jmethodID jni_mid_getService = CALEGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
- "getService",
- "(Ljava/util/UUID;)Landroid/bluetooth/"
- "BluetoothGattService;");
+ jmethodID jni_mid_getService = CAGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
+ "getService",
+ "(Ljava/util/UUID;)Landroid/bluetooth/"
+ "BluetoothGattService;");
if (!jni_mid_getService)
{
OIC_LOG(ERROR, TAG, "jni_mid_getService is null");
return NULL;
}
- jmethodID jni_mid_getCharacteristic = CALEGetJNIMethodID(env, "android/bluetooth/"
- "BluetoothGattService",
- "getCharacteristic",
- "(Ljava/util/UUID;)"
- "Landroid/bluetooth/"
- "BluetoothGattCharacteristic;");
+ jmethodID jni_mid_getCharacteristic = CAGetJNIMethodID(env, "android/bluetooth/"
+ "BluetoothGattService",
+ "getCharacteristic",
+ "(Ljava/util/UUID;)"
+ "Landroid/bluetooth/"
+ "BluetoothGattCharacteristic;");
if (!jni_mid_getCharacteristic)
{
OIC_LOG(ERROR, TAG, "jni_mid_getCharacteristic is null");
return NULL;
}
- jmethodID jni_mid_setValue = CALEGetJNIMethodID(env, "android/bluetooth/"
- "BluetoothGattCharacteristic",
- "setValue", "([B)Z");
+ jmethodID jni_mid_setValue = CAGetJNIMethodID(env, "android/bluetooth/"
+ "BluetoothGattCharacteristic",
+ "setValue", "([B)Z");
if (!jni_mid_setValue)
{
OIC_LOG(ERROR, TAG, "jni_mid_setValue is null");
return CA_ADAPTER_NOT_ENABLED;
}
- if (STATE_CONNECTED != CALEServerGetConnectionState(env, device))
+ if (!g_bluetoothGattServer)
+ {
+ OIC_LOG(ERROR, TAG, "g_bluetoothGattServer is not available");
+ return CA_STATUS_FAILED;
+ }
+
+ if (g_state_connected != CALEServerGetConnectionState(env, device))
{
OIC_LOG(ERROR, TAG, "it is not connected state");
return CA_STATUS_FAILED;
}
- jmethodID jni_mid_notifyCharacteristicChanged = CALEGetJNIMethodID(env,
+ jmethodID jni_mid_notifyCharacteristicChanged = CAGetJNIMethodID(env,
CLASSPATH_BT_GATTSERVER,
"notifyCharacteristicChanged",
"(Landroid/bluetooth/BluetoothDevice;"
return CA_ADAPTER_NOT_ENABLED;
}
- jmethodID jni_mid_sendResponse = CALEGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
- "sendResponse",
- "(Landroid/bluetooth/BluetoothDevice;"
- "III[B)Z");
+ if (!g_bluetoothGattServer)
+ {
+ OIC_LOG(ERROR, TAG, "g_bluetoothGattServer is not available");
+ return CA_STATUS_FAILED;
+ }
+
+ jmethodID jni_mid_sendResponse = CAGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
+ "sendResponse",
+ "(Landroid/bluetooth/BluetoothDevice;"
+ "III[B)Z");
if (!jni_mid_sendResponse)
{
OIC_LOG(ERROR, TAG, "jni_mid_sendResponse is null");
return CA_STATUS_FAILED;
}
- jmethodID jni_mid_startAdvertising = CALEGetJNIMethodID(env, "android/bluetooth/le/"
- "BluetoothLeAdvertiser",
- "startAdvertising",
- "(Landroid/bluetooth/le/"
- "AdvertiseSettings;Landroid/bluetooth/"
- "le/AdvertiseData;Landroid/bluetooth/"
- "le/AdvertiseData;Landroid/bluetooth/"
- "le/AdvertiseCallback;)V");
+ jmethodID jni_mid_startAdvertising = CAGetJNIMethodID(env, "android/bluetooth/le/"
+ "BluetoothLeAdvertiser",
+ "startAdvertising",
+ "(Landroid/bluetooth/le/"
+ "AdvertiseSettings;Landroid/bluetooth/"
+ "le/AdvertiseData;Landroid/bluetooth/"
+ "le/AdvertiseData;Landroid/bluetooth/"
+ "le/AdvertiseCallback;)V");
if (!jni_mid_startAdvertising)
{
- OIC_LOG(ERROR, TAG, "jni_mid_startAdvertising is null");
- return CA_STATUS_FAILED;
+ OIC_LOG(ERROR, TAG, "jni_mid_startAdvertising is null");
+ return CA_STATUS_FAILED;
}
(*env)->CallVoidMethod(env, jni_obj_getBluetoothLeAdvertiser, jni_mid_startAdvertising,
return CA_STATUS_FAILED;
}
- jmethodID jni_mid_stopAdvertising = CALEGetJNIMethodID(env, "android/bluetooth/le/"
- "BluetoothLeAdvertiser",
- "stopAdvertising",
- "(Landroid/bluetooth/le/"
- "AdvertiseCallback;)V");
+ jmethodID jni_mid_stopAdvertising = CAGetJNIMethodID(env, "android/bluetooth/le/"
+ "BluetoothLeAdvertiser",
+ "stopAdvertising",
+ "(Landroid/bluetooth/le/"
+ "AdvertiseCallback;)V");
if (!jni_mid_stopAdvertising)
{
OIC_LOG(ERROR, TAG, "jni_mid_stopAdvertising is null");
return NULL;
}
- jmethodID jni_mid_openGattServer = CALEGetJNIMethodID(env, "android/bluetooth/"
- "BluetoothManager",
- "openGattServer",
- "(Landroid/content/Context;"
- "Landroid/bluetooth/"
- "BluetoothGattServerCallback;)"
- "Landroid/bluetooth/"
- "BluetoothGattServer;");
+ jmethodID jni_mid_openGattServer = CAGetJNIMethodID(env, "android/bluetooth/"
+ "BluetoothManager",
+ "openGattServer",
+ "(Landroid/content/Context;"
+ "Landroid/bluetooth/"
+ "BluetoothGattServerCallback;)"
+ "Landroid/bluetooth/"
+ "BluetoothGattServer;");
if (!jni_mid_openGattServer)
{
OIC_LOG(ERROR, TAG, "jni_mid_openGattServer is null");
return CA_ADAPTER_NOT_ENABLED;
}
- jmethodID jni_mid_addService = CALEGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
- "addService",
- "(Landroid/bluetooth/BluetoothGattService;)"
- "Z");
+ jmethodID jni_mid_addService = CAGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
+ "addService",
+ "(Landroid/bluetooth/BluetoothGattService;)"
+ "Z");
if (!jni_mid_addService)
{
OIC_LOG(ERROR, TAG, "jni_mid_addService is null");
return CA_ADAPTER_NOT_ENABLED;
}
- jmethodID jni_mid_connect = CALEGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
- "connect",
- "(Landroid/bluetooth/BluetoothDevice;Z)Z");
+ jmethodID jni_mid_connect = CAGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
+ "connect",
+ "(Landroid/bluetooth/BluetoothDevice;Z)Z");
if (!jni_mid_connect)
{
OIC_LOG(ERROR, TAG, "jni_mid_connect is null");
return CA_ADAPTER_NOT_ENABLED;
}
- jmethodID jni_mid_cancelConnection = CALEGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
- "cancelConnection",
- "(Landroid/bluetooth/BluetoothDevice;)"
- "V");
+ jmethodID jni_mid_cancelConnection = CAGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
+ "cancelConnection",
+ "(Landroid/bluetooth/BluetoothDevice;)"
+ "V");
if (!jni_mid_cancelConnection)
{
OIC_LOG(ERROR, TAG, "jni_mid_cancelConnection is null");
// get BluetoothGatt class
OIC_LOG(DEBUG, TAG, "get BluetoothGatt class");
- jmethodID jni_mid_closeGatt = CALEGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
- "close", "()V");
+ jmethodID jni_mid_closeGatt = CAGetJNIMethodID(env, CLASSPATH_BT_GATTSERVER,
+ "close", "()V");
if (!jni_mid_closeGatt)
{
OIC_LOG(ERROR, TAG, "jni_mid_closeGatt is null");
OIC_LOG(ERROR, TAG, "CALEServerStartAdvertise has failed");
}
+ // get Constants Value from Android Platform
+ g_state_connected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE, "STATE_CONNECTED");
+ g_state_disconnected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE, "STATE_DISCONNECTED");
+
if (isAttached)
{
(*g_jvm)->DetachCurrentThread(g_jvm);
VERIFY_NON_NULL_VOID(obj, TAG, "obj");
VERIFY_NON_NULL_VOID(device, TAG, "device");
- // STATE_CONNECTED
- jint state_connected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE, "STATE_CONNECTED");
-
- // STATE_DISCONNECTED
- jint state_disconnected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE, "STATE_DISCONNECTED");
-
- if (newState == state_connected)
+ if (newState == g_state_connected)
{
OIC_LOG(DEBUG, TAG, "LE CONNECTED");
}
(*env)->ReleaseStringUTFChars(env, jni_remoteAddress, remoteAddress);
}
- else if (newState == state_disconnected)
+ else if (newState == g_state_disconnected)
{
OIC_LOG(DEBUG, TAG, "LE DISCONNECTED");
jint data_too_large = CALEGetConstantsValue(env, CLASSPATH_BT_ADVERTISE_CB,
"ADVERTISE_FAILED_DATA_TOO_LARGE");
+ jint already_started = CALEGetConstantsValue(env, CLASSPATH_BT_ADVERTISE_CB,
+ "ADVERTISE_FAILED_ALREADY_STARTED");
+
if (data_too_large == errorCode)
{
OIC_LOG_V(ERROR, TAG, "advertise data too large. please check length of device name");
}
+ else if (already_started == errorCode)
+ {
+ OIC_LOG_V(INFO, TAG, "advertising is already started");
+ }
}
/**
#define TAG PCF("OIC_CA_LE_UTILS")
-jmethodID CALEGetJNIMethodID(JNIEnv *env, const char* className,
- const char* methodName,
- const char* methodFormat)
-{
- VERIFY_NON_NULL_RET(env, TAG, "env", NULL);
- VERIFY_NON_NULL_RET(className, TAG, "className", NULL);
- VERIFY_NON_NULL_RET(methodName, TAG, "methodName", NULL);
- VERIFY_NON_NULL_RET(methodFormat, TAG, "methodFormat", NULL);
-
- jclass jni_cid = (*env)->FindClass(env, className);
- if (!jni_cid)
- {
- OIC_LOG_V(ERROR, TAG, "jni_cid [%s] is null", className);
- return NULL;
- }
-
- jmethodID jni_midID = (*env)->GetMethodID(env, jni_cid, methodName, methodFormat);
- if (!jni_midID)
- {
- OIC_LOG_V(ERROR, TAG, "jni_midID [%s] is null", methodName);
- return NULL;
- }
-
- return jni_midID;
-}
-
jobject CALEGetUuidFromString(JNIEnv *env, const char* uuid)
{
VERIFY_NON_NULL_RET(uuid, TAG, "uuid is null", NULL);
VERIFY_NON_NULL_RET(env, TAG, "env is null", false);
VERIFY_NON_NULL_RET(bluetoothDevice, TAG, "bluetoothDevice is null", false);
- jmethodID jni_mid_getBondState = CALEGetJNIMethodID(env, "android/bluetooth/BluetoothDevice",
- "getBondState",
- "()I");
+ jmethodID jni_mid_getBondState = CAGetJNIMethodID(env, "android/bluetooth/BluetoothDevice",
+ "getBondState",
+ "()I");
if (!jni_mid_getBondState)
{
OIC_LOG(ERROR, TAG, "jni_mid_getBondState is null");
return NULL;
}
- jmethodID jni_mid_toArray = CALEGetJNIMethodID(env, "java/util/Set", "toArray",
- "()[Ljava/lang/Object;");
+ jmethodID jni_mid_toArray = CAGetJNIMethodID(env, "java/util/Set", "toArray",
+ "()[Ljava/lang/Object;");
if (!jni_mid_toArray)
{
OIC_LOG(ERROR, TAG, "getBondedDevices: jni_mid_toArray is null");
VERIFY_NON_NULL_RET(env, TAG, "env is null", NULL);
VERIFY_NON_NULL_RET(bluetoothDevice, TAG, "bluetoothDevice is null", NULL);
- jmethodID jni_mid_getAddress = CALEGetJNIMethodID(env, "android/bluetooth/BluetoothDevice",
- "getAddress",
- "()Ljava/lang/String;");
+ jmethodID jni_mid_getAddress = CAGetJNIMethodID(env, "android/bluetooth/BluetoothDevice",
+ "getAddress",
+ "()Ljava/lang/String;");
if (!jni_mid_getAddress)
{
OIC_LOG(ERROR, TAG, "jni_mid_getAddress is null");
jint CALEGetConstantsValue(JNIEnv *env, const char* classType, const char* name)
{
- OIC_LOG(DEBUG, TAG, "CALEGetConstantsValue");
-
VERIFY_NON_NULL_RET(env, TAG, "env", -1);
VERIFY_NON_NULL_RET(classType, TAG, "classType", -1);
VERIFY_NON_NULL_RET(name, TAG, "name", -1);
OIC_LOG(DEBUG, TAG, "OUT - CALEGetRemoteDevice");
return jni_obj_device;
}
+
+jstring CALEGetAddressFromGatt(JNIEnv *env, jobject gatt)
+{
+ OIC_LOG(DEBUG, TAG, "IN - CALEGetAddressFromGatt");
+
+ VERIFY_NON_NULL_RET(env, TAG, "env is null", NULL);
+ VERIFY_NON_NULL_RET(gatt, TAG, "gatt is null", NULL);
+
+ jmethodID jni_mid_getDevice = CAGetJNIMethodID(env, CLASSPATH_BT_GATT, "getDevice",
+ METHODID_BT_DEVICE);
+ if (!jni_mid_getDevice)
+ {
+ OIC_LOG(ERROR, TAG, "jni_mid_getDevice is null");
+ return NULL;
+ }
+
+ jobject jni_obj_device = (*env)->CallObjectMethod(env, gatt, jni_mid_getDevice);
+ if (!jni_obj_device)
+ {
+ OIC_LOG(ERROR, TAG, "jni_obj_device is null");
+ return NULL;
+ }
+
+ jstring jni_address = CALEGetAddressFromBTDevice(env, jni_obj_device);
+ if (!jni_address)
+ {
+ OIC_LOG(ERROR, TAG, "jni_address is null");
+ return NULL;
+ }
+
+ OIC_LOG(DEBUG, TAG, "OUT - CALEGetAddressFromGatt");
+ return jni_address;
+}
{
#endif
+#define CA_LE_AUTO_CONNECT_FLAG 1
+#define CA_LE_CONNECTION_STATE 2
+#define CA_LE_SEND_STATE 3
+#define CA_LE_DESCRIPTOR_FOUND 4
+
/* Service UUID */
static const char OIC_GATT_SERVICE_UUID[] = CA_GATT_SERVICE_UUID;
static const char OIC_GATT_CHARACTERISTIC_REQUEST_UUID[] = CA_GATT_REQUEST_CHRC_UUID;
static const jint BOND_BONDING = 11;
static const jint BOND_NONE = 10;
-static const jint STATE_CONNECTED = 2;
-static const jint STATE_DISCONNECTED = 0;
-
-/**
- * get method ID for method Name and class
- * @param[in] env JNI interface pointer.
- * @param[in] className android class.
- * @param[in] methodName android method name.
- * @param[in] methodFormat method type of methodName.
- * @return jmethodID of the method.
- */
-jmethodID CALEGetJNIMethodID(JNIEnv *env, const char* className,
- const char* methodName,
- const char* methodFormat);
+static const uint16_t STATE_CONNECTED = 3;
+static const uint16_t STATE_SERVICE_CONNECTED = 2;
+static const uint16_t STATE_DISCONNECTED = 1;
/**
* get uuid(jni object) from uuid(character).
*/
jobject CALEGetRemoteDevice(JNIEnv *env, jstring address);
+/**
+ * get address from gatt profile object.
+ * @param[in] env JNI interface pointer.
+ * @param[in] gatt gatt profile object.
+ * @return LE address.
+ */
+jstring CALEGetAddressFromGatt(JNIEnv *env, jobject gatt);
+
#ifdef __cplusplus
} /* extern "C" */
#endif
/*
* Class: org_iotivity_ca_caLeClientInterface
* Method: caLeScanCallback
- * Signature: (Landroid/bluetooth/BluetoothDevice;I[B)V
+ * Signature: (Landroid/bluetooth/BluetoothDevice;)V
*/
JNIEXPORT void JNICALL
Java_org_iotivity_ca_caLeClientInterface_caLeScanCallback
/*
* Class: org_iotivity_ca_caLeClientInterface
+ * Method: caLeGattNWServicesDiscoveredCallback
+ * Signature: (Landroid/bluetooth/BluetoothGatt;I)V
+ */
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaLeClientInterface_caLeGattNWServicesDiscoveredCallback
+(JNIEnv *, jobject, jobject, jint);
+/*
+ * Class: org_iotivity_ca_caLeClientInterface
* Method: caLeGattCharacteristicWritjclasseCallback
- * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattCharacteristic;I)V
+ * Signature: (Landroid/bluetooth/BluetoothGatt;[BI)V
*/
JNIEXPORT void JNICALL
Java_org_iotivity_ca_caLeClientInterface_caLeGattCharacteristicWriteCallback
/*
* Class: org_iotivity_ca_caLeClientInterface
* Method: caLeGattDescriptorWriteCallback
- * Signature: (Landroid/bluetooth/BluetoothGatt;Landroid/bluetooth/BluetoothGattDescriptor;I)V
+ * Signature: (Landroid/bluetooth/BluetoothGatt;I)V
*/
JNIEXPORT void JNICALL
Java_org_iotivity_ca_caLeClientInterface_caLeGattDescriptorWriteCallback
/*
* Class: org_iotivity_ca_jar_caleinterface
* Method: caManagerLeRemoteRssiCallback
- * Signature: (Landroid/bluetooth/BluetoothGatt;I)V
+ * Signature: (Landroid/bluetooth/BluetoothGatt;II)V
*/
JNIEXPORT void JNICALL
Java_org_iotivity_ca_CaLeClientInterface_caManagerLeRemoteRssiCallback
* Signature: (Landroid/bluetooth/BluetoothGattServerCallback;)V
*/
JNIEXPORT void JNICALL
-
Java_org_iotivity_ca_caLeServerInterface_caLeRegisterGattServerCallback
(JNIEnv *, jobject, jobject);
/*
* Class: org_iotivity_ca_caLeServerInterface
* Method: caLeGattServerCharacteristicReadRequestCallback
- * Signature: (Landroid/bluetooth/BluetoothDevice;IILandroid/
- * bluetooth/BluetoothGattCharacteristic;)V
+ * Signature: (Landroid/bluetooth/BluetoothDevice;[B)V
*/
JNIEXPORT void JNICALL
Java_org_iotivity_ca_caLeServerInterface_caLeGattServerCharacteristicReadRequestCallback
/*
* Class: org_iotivity_ca_caLeServerInterface
* Method: caLeGattServerCharacteristicWriteRequestCallback
- * Signature: (Landroid/bluetooth/BluetoothDevice;ILandroid/bluetooth/
- * BluetoothGattCharacteristic;ZZI[B)V
+ * Signature: (Landroid/bluetooth/BluetoothDevice;[B)V
*/
JNIEXPORT void JNICALL
Java_org_iotivity_ca_caLeServerInterface_caLeGattServerCharacteristicWriteRequestCallback
/**
* Callback to provide the status of the network change to CA layer.
*/
-static CANetworkChangeCallback g_networkCallback = NULL;
+static CAAdapterChangeCallback g_networkCallback = NULL;
+
+/**
+ * Callback to provide the status of the connection change to CA layer.
+ */
+static CAConnectionChangeCallback g_connectionCallback = NULL;
/**
* bleAddress of the local adapter. Value will be initialized to zero,
/**
* Register network change notification callback.
*
- * @param[in] netCallback CANetworkChangeCallback callback which will
- * be set for the change in network.
+ * @param[in] netCallback CAAdapterChangeCallback callback which will
+ * be set for the change in adapter.
+ * @param[in] connCallback CAConnectionChangeCallback callback which will
+ * be set for the change in connection.
*
* @return 0 on success otherwise a positive error value.
* @retval ::CA_STATUS_OK Successful.
* @retval ::CA_STATUS_FAILED Operation failed.
*
*/
-static CAResult_t CALERegisterNetworkNotifications(CANetworkChangeCallback netCallback);
+static CAResult_t CALERegisterNetworkNotifications(CAAdapterChangeCallback netCallback,
+ CAConnectionChangeCallback connCallback);
/**
* Set the thread pool handle which is required for spawning new
CAResult_t CAInitializeLE(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback reqRespCallback,
- CANetworkChangeCallback netCallback,
+ CAAdapterChangeCallback netCallback,
+ CAConnectionChangeCallback connCallback,
CAErrorHandleCallback errorCallback,
ca_thread_pool_t handle)
{
VERIFY_NON_NULL(registerCallback, CALEADAPTER_TAG, "RegisterConnectivity callback is null");
VERIFY_NON_NULL(reqRespCallback, CALEADAPTER_TAG, "PacketReceived Callback is null");
VERIFY_NON_NULL(netCallback, CALEADAPTER_TAG, "NetworkChange Callback is null");
+ VERIFY_NON_NULL(connCallback, CALEADAPTER_TAG, "ConnectionChange Callback is null");
CAResult_t result = CA_STATUS_OK;
result = CAInitLEAdapterMutex();
CASetBLEClientErrorHandleCallback(CALEErrorHandler);
CASetBLEServerErrorHandleCallback(CALEErrorHandler);
- CALERegisterNetworkNotifications(netCallback);
+ CALERegisterNetworkNotifications(netCallback, connCallback);
g_errorHandler = errorCallback;
CASetLEReqRespServerCallback(NULL);
CASetLEReqRespClientCallback(NULL);
- CALERegisterNetworkNotifications(NULL);
+ CALERegisterNetworkNotifications(NULL, NULL);
CASetLEReqRespAdapterCallback(NULL);
CATerminateLENetworkMonitor();
return CA_STATUS_OK;
}
-static CAResult_t CALERegisterNetworkNotifications(CANetworkChangeCallback netCallback)
+static CAResult_t CALERegisterNetworkNotifications(CAAdapterChangeCallback netCallback,
+ CAConnectionChangeCallback connCallback)
{
OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN");
ca_mutex_lock(g_bleNetworkCbMutex);
g_networkCallback = netCallback;
+ g_connectionCallback = connCallback;
ca_mutex_unlock(g_bleNetworkCbMutex);
CAResult_t res = CA_STATUS_OK;
if (netCallback)
{
OIC_LOG(ERROR, CALEADAPTER_TAG, "CASetLEAdapterStateChangedCb failed!");
}
-
- res = CASetLENWConnectionStateChangedCb(CALEConnectionStateChangedCb);
- if (CA_STATUS_OK != res)
- {
- OIC_LOG(ERROR, CALEADAPTER_TAG, "CALEConnectionStateChangedCb failed!");
- }
}
else
{
}
}
+ if (g_connectionCallback)
+ {
+ res = CASetLENWConnectionStateChangedCb(CALEConnectionStateChangedCb);
+ if (CA_STATUS_OK != res)
+ {
+ OIC_LOG(ERROR, CALEADAPTER_TAG, "CASetLENWConnectionStateChangedCb failed!");
+ }
+ }
+
OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
return res;
}
#endif
}
+ CAEndpoint_t localEndpoint = { .adapter = CA_ADAPTER_GATT_BTLE };
+ OICStrcpy(localEndpoint.addr, sizeof(localEndpoint.addr), address);
+
+ ca_mutex_lock(g_bleNetworkCbMutex);
+ if (g_connectionCallback)
+ {
+ g_connectionCallback(&localEndpoint, isConnected);
+ }
+ ca_mutex_unlock(g_bleNetworkCbMutex);
+
OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT");
}
{
OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN - CALEDeviceStateChangedCb");
- VERIFY_NON_NULL_VOID(g_localBLEAddress, CALEADAPTER_TAG, "g_localBLEAddress is null");
- CAEndpoint_t localEndpoint = { .adapter = CA_ADAPTER_GATT_BTLE };
-
- ca_mutex_lock(g_bleLocalAddressMutex);
- OICStrcpy(localEndpoint.addr,
- sizeof(localEndpoint.addr),
- g_localBLEAddress);
- ca_mutex_unlock(g_bleLocalAddressMutex);
-
if (CA_ADAPTER_ENABLED == adapter_state)
{
ca_mutex_lock(g_bleIsServerMutex);
ca_mutex_lock(g_bleNetworkCbMutex);
if (NULL != g_networkCallback)
{
- g_networkCallback(&localEndpoint, adapter_state);
+ g_networkCallback(CA_ADAPTER_GATT_BTLE, adapter_state);
}
else
{
static void CALERemoveReceiveQueueData(u_arraylist_t *dataInfoList, const char* address)
{
- OIC_LOG(DEBUG, CALEADAPTER_TAG, "CALERemoveSendQueueData");
+ OIC_LOG(DEBUG, CALEADAPTER_TAG, "CALERemoveReceiveQueueData");
VERIFY_NON_NULL_VOID(dataInfoList, CALEADAPTER_TAG, "dataInfoList");
VERIFY_NON_NULL_VOID(address, CALEADAPTER_TAG, "address");
* @param[in] descriptor_path @c GattDescriptor1 object path for the
* user description descriptor.
* @param[in] value User description descriptor value,
- * e.g. @c "OIC Node Request" or
- * @c "OIC Node Response".
+ * e.g. @c "OCF Node Request" or
+ * @c "OCF Node Response".
*
* @note This function does not allocate the @a descriptor object
* itself. The caller is responsible for allocating that
*/
#define TAG "OIC_CA_LE_MONITOR"
+#define MICROSECS_PER_SEC 1000000
+
+static uint64_t const INITIALIZE_TIMEOUT = 1 * MICROSECS_PER_SEC;
+
static GMainLoop *g_mainloop = NULL;
static ca_thread_pool_t g_threadPoolHandle = NULL;
static ca_mutex g_bleConnectionStateChangedCbMutex = NULL;
/**
+ * Mutex to synchronize access to
+ */
+static ca_mutex g_btinitializeMutex = NULL;
+
+/**
+ * Condition for gmainloop to run.
+ */
+static ca_cond g_initializeCond = NULL;
+
+/**
+ * Flag to check if BT stack is initialised.
+ */
+static bool g_isBTStackInitialised = false;
+
+/**
* This is the callback which will be called when the adapter state gets changed.
*
* @param result [IN] Result of the query done to the platform.
* @param adapter_state [IN] State of the LE adapter.
-* @param user_data [IN] Any user_data passed by the caller when querying for the state changed cb.
+* @param user_data [IN] User data passed by the caller when querying for the state changed cb.
*
* @return None.
*/
* @param result [IN] Result of the query done to the platform.
* @param connected [IN] State of connection.
* @param remoteAddress [IN] LE address of the device to be notified.
-* @param user_data [IN] Any user_data passed by the caller when querying for the state changed cb.
+* @param user_data [IN] User data passed by the caller when querying for the state changed cb.
*
* @return None.
*/
void CALEMainLoopThread(void *param)
{
+ OIC_LOG(DEBUG, TAG, "IN");
+
+ int ret = bt_initialize();
+ if (BT_ERROR_NONE != ret)
+ {
+ OIC_LOG(ERROR, TAG, "bt_initialize failed");
+ return;
+ }
+ ret = bt_adapter_set_visibility(BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE, 0);
+ if (BT_ERROR_NONE != ret)
+ {
+ OIC_LOG(ERROR, TAG, "bt_adapter_set_visibility failed");
+ return;
+ }
+
+ ret = bt_adapter_set_state_changed_cb(CALEAdapterStateChangedCb, NULL);
+ if (BT_ERROR_NONE != ret)
+ {
+ OIC_LOG(DEBUG, TAG, "bt_adapter_set_state_changed_cb failed");
+ return;
+ }
+
+ ret = bt_gatt_set_connection_state_changed_cb(CALENWConnectionStateChangedCb, NULL);
+ if (BT_ERROR_NONE != ret)
+ {
+ OIC_LOG_V(ERROR, TAG,
+ "bt_gatt_set_connection_state_changed_cb has failed");
+ return;
+ }
+
+ g_mainloop = g_main_loop_new(g_main_context_default(), FALSE);
+
+ ca_mutex_lock(g_btinitializeMutex);
+ g_isBTStackInitialised = true;
+ ca_mutex_unlock(g_btinitializeMutex);
+ ca_cond_signal(g_initializeCond);
+
+ // Run gmainloop to handle the events from bt stack
g_main_loop_run(g_mainloop);
+ OIC_LOG(DEBUG, TAG, "OUT");
}
CAResult_t CAInitializeLENetworkMonitor()
return CA_STATUS_FAILED;
}
}
+
+ if (NULL == g_btinitializeMutex)
+ {
+ g_btinitializeMutex = ca_mutex_new();
+ if (NULL == g_btinitializeMutex)
+ {
+ OIC_LOG(ERROR, TAG, "ca_mutex_new failed");
+ ca_mutex_free(g_bleDeviceStateChangedCbMutex);
+ ca_mutex_free(g_bleConnectionStateChangedCbMutex);
+ return CA_STATUS_FAILED;
+ }
+ }
+
+ if (NULL == g_initializeCond)
+ {
+ g_initializeCond = ca_cond_new();
+ if (NULL == g_initializeCond)
+ {
+ OIC_LOG(ERROR, TAG, "ca_cond_new failed");
+ ca_mutex_free(g_bleDeviceStateChangedCbMutex);
+ ca_mutex_free(g_bleConnectionStateChangedCbMutex);
+ ca_mutex_free(g_btinitializeMutex);
+ return CA_STATUS_FAILED;
+ }
+ }
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
ca_mutex_free(g_bleConnectionStateChangedCbMutex);
g_bleConnectionStateChangedCbMutex = NULL;
+
+ ca_mutex_free(g_btinitializeMutex);
+ g_btinitializeMutex = NULL;
+
+ ca_cond_free(g_initializeCond);
+ g_initializeCond = NULL;
OIC_LOG(DEBUG, TAG, "OUT");
}
CAResult_t CAStartLEAdapter()
{
OIC_LOG(DEBUG, TAG, "IN");
- g_mainloop = g_main_loop_new(NULL, 0);
- if(!g_mainloop)
- {
- OIC_LOG(ERROR, TAG, "g_main_loop_new failed\n");
- return CA_STATUS_FAILED;
- }
if (CA_STATUS_OK != ca_thread_pool_add_task(g_threadPoolHandle, CALEMainLoopThread, (void *) NULL))
{
return CA_STATUS_FAILED;
}
- int ret = bt_initialize();
- if (0 != ret)
- {
- OIC_LOG(ERROR, TAG, "bt_initialize failed");
- return CA_STATUS_FAILED;
- }
-
- ret = bt_adapter_set_visibility(BT_ADAPTER_VISIBILITY_MODE_GENERAL_DISCOVERABLE, 0);
- if (0 != ret)
- {
- OIC_LOG(ERROR, TAG, "bt_adapter_set_visibility failed");
- return CA_STATUS_FAILED;
- }
-
- ret = bt_adapter_set_state_changed_cb(CALEAdapterStateChangedCb, NULL);
- if (BT_ERROR_NONE != ret)
- {
- OIC_LOG(DEBUG, TAG, "bt_adapter_set_state_changed_cb failed");
- return CA_STATUS_FAILED;
- }
-
- ret = bt_gatt_set_connection_state_changed_cb(CALENWConnectionStateChangedCb, NULL);
- if (BT_ERROR_NONE != ret)
- {
- OIC_LOG_V(ERROR, TAG,
- "bt_gatt_set_connection_state_changed_cb has failed");
- return CA_STATUS_FAILED;
- }
-
OIC_LOG(DEBUG, TAG, "OUT");
return CA_STATUS_OK;
}
}
ret = bt_deinitialize();
- if (0 != ret)
+ if (BT_ERROR_NONE != ret)
{
OIC_LOG(ERROR, TAG, "bt_deinitialize failed");
return CA_STATUS_FAILED;
{
OIC_LOG(DEBUG, TAG, "IN");
+ ca_mutex_lock(g_btinitializeMutex);
+ if (!g_isBTStackInitialised)
+ {
+ OIC_LOG(INFO, TAG, "Wait for BT initialization");
+ CAWaitResult_t ret = ca_cond_wait_for(g_initializeCond, g_btinitializeMutex,
+ INITIALIZE_TIMEOUT);
+ if (CA_WAIT_TIMEDOUT == ret)
+ {
+ OIC_LOG(ERROR, TAG, "Timeout before BT initialize");
+ ca_mutex_unlock(g_btinitializeMutex);
+ return CA_STATUS_FAILED;
+ }
+ }
+ ca_mutex_unlock(g_btinitializeMutex);
+
bt_adapter_state_e adapterState = BT_ADAPTER_DISABLED;
//Get Bluetooth adapter state
*/
static GMainLoop *g_eventLoop = NULL;
-static CALEConnectionStateChangedCallback g_connStateCb = NULL;
-
-void CASetLEConnectionStateChangedCallback(CALEConnectionStateChangedCallback connStateCb)
-{
- g_connStateCb = connStateCb;
-}
-
void CALEGattServerConnectionStateChanged(bool connected, const char *remoteAddress)
{
VERIFY_NON_NULL_VOID(remoteAddress, TAG, "remote address");
if (connected)
{
OIC_LOG_V(DEBUG, TAG, "Connected to [%s]", remoteAddress);
- if (g_connStateCb)
- {
- g_connStateCb(CA_ADAPTER_GATT_BTLE, remoteAddress, true);
- }
}
else
{
OIC_LOG_V(DEBUG, TAG, "Disconnected from [%s]", remoteAddress);
- if (g_connStateCb)
- {
- g_connStateCb(CA_ADAPTER_GATT_BTLE, remoteAddress, false);
- }
}
}
return CA_STATUS_FAILED;
}
- res = bt_adapter_le_start_advertising(g_hAdvertiser, NULL, NULL, NULL);
+ res = bt_adapter_le_set_advertising_device_name(g_hAdvertiser,
+ BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true);
+ if (BT_ERROR_NONE != res)
+ {
+ OIC_LOG_V(ERROR, TAG, "bt_adapter_le_set_advertising_device_name failed with ret[%s]",
+ CALEGetErrorMsg(res));
+ return CA_STATUS_FAILED;
+ }
+
+ res = bt_adapter_le_start_advertising_new(g_hAdvertiser, NULL, NULL);
if (BT_ERROR_NONE != res)
{
- OIC_LOG_V(ERROR, TAG, "bt_adapter_le_start_advertising failed with ret[%s]",
+ OIC_LOG_V(ERROR, TAG, "bt_adapter_le_start_advertising_new failed with ret[%s]",
CALEGetErrorMsg(res));
return CA_STATUS_FAILED;
}
OIC_LOG(DEBUG, TAG, "IN");
int permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE;
- int properties = BT_GATT_PROPERTY_WRITE | BT_GATT_PROPERTY_NOTIFY;
+ int properties;
if(read)
{
properties = BT_GATT_PROPERTY_NOTIFY | BT_GATT_PROPERTY_READ;
char desc_value[2] = {1, 0}; // Notification enabled.
bt_gatt_h descriptor = NULL;
permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE;
- ret = bt_gatt_descriptor_create(CA_GATT_CONFIGURATION_DESC_UUID,
- permissions, desc_value, sizeof(desc_value), &descriptor);
+ ret = bt_gatt_descriptor_create(CA_GATT_CONFIGURATION_DESC_UUID, permissions,
+ desc_value, sizeof(desc_value),
+ &descriptor);
if (0 != ret)
{
OIC_LOG_V(ERROR, TAG,
case BT_ERROR_NOT_SUPPORTED:
errStr = "BT_ERROR_NOT_SUPPORTED";
break;
+ case BT_ERROR_QUOTA_EXCEEDED:
+ errStr = "BT_ERROR_QUOTA_EXCEEDED";
+ break;
+ case BT_ERROR_NO_DATA:
+ errStr = "BT_ERROR_NO_DATA";
+ break;
+ case BT_ERROR_AGAIN:
+ errStr = "BT_ERROR_AGAIN";
+ break;
default:
errStr = "NOT Defined";
break;
#include "caremotehandler.h"
#include "cablockwisetransfer.h"
#include "oic_malloc.h"
+#include "oic_string.h"
#include "camutex.h"
#include "logger.h"
if (g_context.dataList)
{
+ CARemoveAllBlockDataFromList();
u_arraylist_free(&g_context.dataList);
}
}
CAResult_t CANegotiateBlockSize(CABlockData_t *currData, coap_block_t *block,
- coap_pdu_t *pdu, uint16_t blockType)
+ const coap_pdu_t *pdu, uint16_t blockType)
{
OIC_LOG(DEBUG, TAG, "IN-NegotiateBlockSize");
// get resource uri information from received response message
// to send next request message to remote device
- CAResponseInfo_t resInfo = { 0 };
- CAGetResponseInfoFromPDU(pdu, &resInfo, endpoint);
+ CAResponseInfo_t* resInfo = (CAResponseInfo_t*)OICCalloc(1, sizeof(*resInfo));
+ if (!resInfo)
+ {
+ OIC_LOG(ERROR, TAG, "memory allocation failed");
+ OICFree(requestData.token);
+ return NULL;
+ }
+ CAGetResponseInfoFromPDU(pdu, resInfo, endpoint);
requestInfo->method = CA_GET;
- requestInfo->info.resourceUri = resInfo.info.resourceUri;
+ requestInfo->info.resourceUri = OICStrdup(resInfo->info.resourceUri);
+
+ // after copying the resource uri, destroy response info.
+ CADestroyResponseInfoInternal(resInfo);
}
CAData_t *data = (CAData_t *) OICCalloc(1, sizeof(CAData_t));
return CA_STATUS_OK;
}
+CAResult_t CARemoveAllBlockDataFromList()
+{
+ OIC_LOG(DEBUG, TAG, "CARemoveAllBlockDataFromList");
+
+ ca_mutex_lock(g_context.blockDataListMutex);
+
+ size_t len = u_arraylist_length(g_context.dataList);
+ for (size_t i = len; i > 0; i--)
+ {
+ CABlockData_t *removedData = u_arraylist_remove(g_context.dataList, i - 1);
+ if (removedData)
+ {
+ // destroy memory
+ if (removedData->sentData)
+ {
+ CADestroyDataSet(removedData->sentData);
+ }
+ CADestroyBlockID(removedData->blockDataId);
+ OICFree(removedData->payload);
+ OICFree(removedData);
+ }
+ }
+ ca_mutex_unlock(g_context.blockDataListMutex);
+
+ return CA_STATUS_OK;
+}
+
void CADestroyDataSet(CAData_t* data)
{
VERIFY_NON_NULL_VOID(data, TAG, "data");
OIC_LOG_V(DEBUG, TAG, "block option-szx : %d", block->szx);
}
+
+CAResult_t CARemoveBlockDataFromListWithSeed(const CAToken_t token, uint8_t tokenLength,
+ uint16_t portNumber)
+{
+ CABlockDataID_t* blockDataID = CACreateBlockDatablockId(token, tokenLength, portNumber);
+ if (NULL == blockDataID || blockDataID->idLength < 1)
+ {
+ OIC_LOG(ERROR, TAG, "blockId is null");
+ CADestroyBlockID(blockDataID);
+ return CA_STATUS_FAILED;
+ }
+
+ CAResult_t res = CA_STATUS_OK;
+
+ if (NULL != CAGetBlockDataFromBlockDataList(blockDataID))
+ {
+ res = CARemoveBlockDataFromList(blockDataID);
+ if (CA_STATUS_OK != res)
+ {
+ OIC_LOG(ERROR, TAG, "CARemoveBlockDataFromList failed");
+ }
+ }
+
+ CADestroyBlockID(blockDataID);
+
+ return res;
+}
#endif /* __WITH_DTLS__ */
#ifdef TCP_ADAPTER
-void CARegisterKeepAliveHandler(CAKeepAliveConnectedCallback ConnHandler,
- CAKeepAliveDisconnectedCallback DisconnHandler)
+void CARegisterKeepAliveHandler(CAKeepAliveConnectionCallback ConnHandler)
{
- CATCPSetKeepAliveCallbacks(ConnHandler, DisconnHandler);
+ CATCPSetKeepAliveCallbacks(ConnHandler);
}
#endif
#define CA_MEMORY_ALLOC_CHECK(arg) {if (arg == NULL) \
{OIC_LOG(ERROR, TAG, "memory error");goto memory_error_exit;} }
-
-
static CAConnectivityHandler_t *g_adapterHandler = NULL;
static uint32_t g_numberOfAdapters = 0;
static CANetworkPacketReceivedCallback g_networkPacketReceivedCallback = NULL;
-static CANetworkChangeCallback g_networkChangeCallback = NULL;
+static CAAdapterChangeCallback g_adapterChangeCallback = NULL;
+
+static CAConnectionChangeCallback g_connChangeCallback = NULL;
static CAErrorHandleCallback g_errorHandleCallback = NULL;
}
}
-static void CANetworkChangedCallback(const CAEndpoint_t *info, CANetworkStatus_t status)
+static void CAAdapterChangedCallback(CATransportAdapter_t adapter, CANetworkStatus_t status)
+{
+ // Call the callback.
+ if (g_adapterChangeCallback != NULL)
+ {
+ g_adapterChangeCallback(adapter, status);
+ }
+ OIC_LOG_V(DEBUG, TAG, "[%d]adapter status is changed to [%d]", adapter, status);
+}
+
+static void CAConnectionChangedCallback(const CAEndpoint_t *info, bool isConnected)
{
// Call the callback.
- if (g_networkChangeCallback != NULL)
+ if (g_connChangeCallback != NULL)
{
- g_networkChangeCallback(info, status);
+ g_connChangeCallback(info, isConnected);
}
+ OIC_LOG_V(DEBUG, TAG, "[%s] connection status is changed to [%d]", info->addr, isConnected);
}
static void CAAdapterErrorHandleCallback(const CAEndpoint_t *endpoint,
// Initialize adapters and register callback.
#ifdef IP_ADAPTER
- CAInitializeIP(CARegisterCallback, CAReceivedPacketCallback, CANetworkChangedCallback,
+ CAInitializeIP(CARegisterCallback, CAReceivedPacketCallback, CAAdapterChangedCallback,
CAAdapterErrorHandleCallback, handle);
#endif /* IP_ADAPTER */
#ifdef EDR_ADAPTER
- CAInitializeEDR(CARegisterCallback, CAReceivedPacketCallback, CANetworkChangedCallback,
- CAAdapterErrorHandleCallback, handle);
+ CAInitializeEDR(CARegisterCallback, CAReceivedPacketCallback, CAAdapterChangedCallback,
+ CAConnectionChangedCallback, CAAdapterErrorHandleCallback, handle);
#endif /* EDR_ADAPTER */
#ifdef LE_ADAPTER
- CAInitializeLE(CARegisterCallback, CAReceivedPacketCallback, CANetworkChangedCallback,
- CAAdapterErrorHandleCallback, handle);
+ CAInitializeLE(CARegisterCallback, CAReceivedPacketCallback, CAAdapterChangedCallback,
+ CAConnectionChangedCallback, CAAdapterErrorHandleCallback, handle);
#endif /* LE_ADAPTER */
#ifdef RA_ADAPTER
- CAInitializeRA(CARegisterCallback, CAReceivedPacketCallback, CANetworkChangedCallback,
+ CAInitializeRA(CARegisterCallback, CAReceivedPacketCallback, CAAdapterChangedCallback,
handle);
#endif /* RA_ADAPTER */
#ifdef TCP_ADAPTER
- CAInitializeTCP(CARegisterCallback, CAReceivedPacketCallback, CANetworkChangedCallback,
- CAAdapterErrorHandleCallback, handle);
+ CAInitializeTCP(CARegisterCallback, CAReceivedPacketCallback, CAAdapterChangedCallback,
+ CAConnectionChangedCallback, CAAdapterErrorHandleCallback, handle);
#endif /* TCP_ADAPTER */
#ifdef NFC_ADAPTER
- CAInitializeNFC(CARegisterCallback, CAReceivedPacketCallback, CANetworkChangedCallback,
+ CAInitializeNFC(CARegisterCallback, CAReceivedPacketCallback, CAAdapterChangedCallback,
CAAdapterErrorHandleCallback, handle);
#endif /* NFC_ADAPTER */
}
g_networkPacketReceivedCallback = callback;
}
-void CASetNetworkChangeCallback(CANetworkChangeCallback callback)
+void CASetNetworkMonitorCallbacks(CAAdapterChangeCallback adapterCB,
+ CAConnectionChangeCallback connCB)
{
- OIC_LOG(DEBUG, TAG, "Set network handle callback");
+ OIC_LOG(DEBUG, TAG, "Set network monitoring callback");
- g_networkChangeCallback = callback;
+ g_adapterChangeCallback = adapterCB;
+ g_connChangeCallback = connCB;
}
void CASetErrorHandleCallback(CAErrorHandleCallback errorCallback)
cadata->requestInfo = NULL;
cadata->responseInfo = resInfo;
+#ifdef WITH_BWT
+ if (CAIsSupportedBlockwiseTransfer(endpoint->adapter))
+ {
+ res = CARemoveBlockDataFromListWithSeed(resInfo->info.token, resInfo->info.tokenLength,
+ endpoint->port);
+ if (CA_STATUS_OK != res)
+ {
+ OIC_LOG(ERROR, TAG, "CARemoveBlockDataFromListWithSeed failed");
+ }
+ }
+#endif // WITH_BWT
+
#ifdef SINGLE_THREAD
CAProcessReceivedData(cadata);
#else
coap_delete_pdu(pdu);
}
-static void CANetworkChangedCallback(const CAEndpoint_t *info, CANetworkStatus_t status)
-{
- (void)info;
- (void)status;
-
- if (g_nwMonitorHandler)
- {
- g_nwMonitorHandler(info, status);
- }
-}
-
void CAHandleRequestResponseCallbacks()
{
#ifdef SINGLE_THREAD
CAResult_t CAInitializeMessageHandler()
{
CASetPacketReceivedCallback(CAReceivedPacketCallback);
-
- CASetNetworkChangeCallback(CANetworkChangedCallback);
CASetErrorHandleCallback(CAErrorHandler);
#ifndef SINGLE_THREAD
#define CA_BUFSIZE (128)
#define CA_PDU_MIN_SIZE (4)
-#define CA_PORT_BUFFER_SIZE (4)
+#define CA_ENCODE_BUFFER_SIZE (4)
static const char COAP_URI_HEADER[] = "coap://[::]/";
if (0 >= ret)
{
OIC_LOG(ERROR, TAG, "pdu parse failed");
- coap_delete_pdu(outpdu);
- return NULL;
+ goto exit;
}
#ifdef WITH_TCP
{
OIC_LOG_V(ERROR, TAG, "coap version is not available : %d",
outpdu->hdr->coap_hdr_udp_t.version);
- coap_delete_pdu(outpdu);
- return NULL;
+ goto exit;
}
if (outpdu->hdr->coap_hdr_udp_t.token_length > CA_MAX_TOKEN_LEN)
{
OIC_LOG_V(ERROR, TAG, "token length has been exceed : %d",
outpdu->hdr->coap_hdr_udp_t.token_length);
- coap_delete_pdu(outpdu);
- return NULL;
+ goto exit;
}
}
}
return outpdu;
+
+exit:
+ coap_delete_pdu(outpdu);
+ return NULL;
}
coap_pdu_t *CAGeneratePDUImpl(code_t code, const CAInfo_t *info,
if (uri.port != COAP_DEFAULT_PORT)
{
- unsigned char portbuf[CA_PORT_BUFFER_SIZE] = { 0 };
+ unsigned char portbuf[CA_ENCODE_BUFFER_SIZE] = { 0 };
int ret = coap_insert(optlist,
CACreateNewOptionNode(COAP_OPTION_URI_PORT,
coap_encode_var_bytes(portbuf, uri.port),
if (CA_FORMAT_UNDEFINED != info->payloadFormat)
{
coap_list_t* node = NULL;
- uint8_t buf[3] = {0};
+ uint8_t buf[CA_ENCODE_BUFFER_SIZE] = {0};
switch (info->payloadFormat)
{
case CA_FORMAT_APPLICATION_CBOR:
node = CACreateNewOptionNode(
COAP_OPTION_CONTENT_FORMAT,
- coap_encode_var_bytes(buf, (uint16_t)COAP_MEDIATYPE_APPLICATION_CBOR),
+ coap_encode_var_bytes(buf, (unsigned short)COAP_MEDIATYPE_APPLICATION_CBOR),
(char *)buf);
break;
default:
if (CA_FORMAT_UNDEFINED != info->acceptFormat)
{
coap_list_t* node = NULL;
- uint8_t buf[3] = {0};
+ uint8_t buf[CA_ENCODE_BUFFER_SIZE] = {0};
switch (info->acceptFormat)
{
case CA_FORMAT_APPLICATION_CBOR:
node = CACreateNewOptionNode(
COAP_OPTION_ACCEPT,
- coap_encode_var_bytes(buf, (uint16_t)COAP_MEDIATYPE_APPLICATION_CBOR),
+ coap_encode_var_bytes(buf, (unsigned short)COAP_MEDIATYPE_APPLICATION_CBOR),
(char *)buf);
break;
default:
&& COAP_OPTION_BLOCK1 != opt_iter.type && COAP_OPTION_BLOCK2 != opt_iter.type
&& COAP_OPTION_SIZE1 != opt_iter.type && COAP_OPTION_SIZE2 != opt_iter.type
&& COAP_OPTION_CONTENT_FORMAT != opt_iter.type
- && COAP_OPTION_ACCEPT != opt_iter.type)
+ && COAP_OPTION_ACCEPT != opt_iter.type
+ && COAP_OPTION_URI_HOST != opt_iter.type && COAP_OPTION_URI_PORT != opt_iter.type
+ && COAP_OPTION_ETAG != opt_iter.type && COAP_OPTION_MAXAGE != opt_iter.type
+ && COAP_OPTION_PROXY_URI != opt_iter.type && COAP_OPTION_PROXY_SCHEME != opt_iter.type)
{
count++;
}
{
outInfo->payloadFormat = CA_FORMAT_UNSUPPORTED;
OIC_LOG_V(DEBUG, TAG, "option[%d] has an unsupported format [%d]",
- opt_iter.type, (uint8_t)buf[0]);
+ opt_iter.type, (uint8_t)buf[0]);
}
}
else if (COAP_OPTION_ACCEPT == opt_iter.type)
outInfo->acceptFormat = CA_FORMAT_UNSUPPORTED;
}
OIC_LOG_V(DEBUG, TAG, "option[%d] has an unsupported format [%d]",
- opt_iter.type, (uint8_t)buf[0]);
+ opt_iter.type, (uint8_t)buf[0]);
+ }
+ else if (COAP_OPTION_URI_PORT == opt_iter.type ||
+ COAP_OPTION_URI_HOST == opt_iter.type ||
+ COAP_OPTION_ETAG == opt_iter.type ||
+ COAP_OPTION_MAXAGE == opt_iter.type ||
+ COAP_OPTION_PROXY_URI == opt_iter.type ||
+ COAP_OPTION_PROXY_SCHEME== opt_iter.type)
+ {
+ OIC_LOG_V(INFO, TAG, "option[%d] has an unsupported format [%d]",
+ opt_iter.type, (uint8_t)buf[0]);
}
else
{
OICFree(message);
}
- // remove all remained list data.
- while (u_queue_get_size(thread->dataQueue) > 0)
- {
- // get data
- u_queue_message_t *message = u_queue_get_element(thread->dataQueue);
-
- // free
- if(NULL != message)
- {
- if (NULL != thread->destroy)
- {
- thread->destroy(message->msg, message->size);
- }
- else
- {
- OICFree(message->msg);
- }
-
- OICFree(message);
- }
- }
-
ca_mutex_lock(thread->threadMutex);
ca_cond_signal(thread->threadCond);
ca_mutex_unlock(thread->threadMutex);
ca_mutex_free(thread->threadMutex);
thread->threadMutex = NULL;
ca_cond_free(thread->threadCond);
+
+ // remove all remained list data.
+ while (u_queue_get_size(thread->dataQueue) > 0)
+ {
+ // get data
+ u_queue_message_t *message = u_queue_get_element(thread->dataQueue);
+
+ // free
+ if(NULL != message)
+ {
+ if (NULL != thread->destroy)
+ {
+ thread->destroy(message->msg, message->size);
+ }
+ else
+ {
+ OICFree(message->msg);
+ }
+
+ OICFree(message);
+ }
+ }
+
u_queue_delete(thread->dataQueue);
return CA_STATUS_OK;
#define TAG "OIC_CA_IP_MONITOR"
+static CAIPConnectionStateChangeCallback g_networkChangeCallback;
+
static CAInterface_t *CANewInterfaceItem(int index, const char *name, int family,
uint32_t addr, int flags);
return interval;
}
+void CAIPSetNetworkMonitorCallback(CAIPConnectionStateChangeCallback callback)
+{
+ g_networkChangeCallback = callback;
+}
+
CAInterface_t *CAFindInterfaceChange()
{
char buf[MAX_INTERFACE_INFO_LENGTH] = { 0 };
return CA_STATUS_FAILED;
}
- jclass cls_Context = (*env)->FindClass(env, "android/content/Context");
- if (!cls_Context)
- {
- OIC_LOG(ERROR, TAG, "Could not get context object class");
- return CA_STATUS_FAILED;
- }
+ jmethodID mid_getApplicationContext = CAGetJNIMethodID(env, "android/content/Context",
+ "getApplicationContext",
+ "()Landroid/content/Context;");
- jmethodID mid_getApplicationContext = (*env)->GetMethodID(env, cls_Context,
- "getApplicationContext",
- "()Landroid/content/Context;");
if (!mid_getApplicationContext)
{
OIC_LOG(ERROR, TAG, "Could not get getApplicationContext method");
{
(void)env;
(void)class;
- OIC_LOG(DEBUG, TAG, "caIpStateEnabled");
- CAWakeUpForChange();
+ OIC_LOG(DEBUG, TAG, "Wifi is in Activated State");
+ g_networkChangeCallback(CA_ADAPTER_IP, CA_INTERFACE_UP);
}
JNIEXPORT void JNICALL
{
(void)env;
(void)class;
- OIC_LOG(DEBUG, TAG, "caIpStateDisabled");
- u_arraylist_t *iflist = CAIPGetInterfaceInformation(0);
- if (!iflist)
- {
- OIC_LOG_V(ERROR, TAG, "get interface info failed");
- return;
- }
- u_arraylist_destroy(iflist);
+ OIC_LOG(DEBUG, TAG, "Wifi is in Deactivated State");
+ g_networkChangeCallback(CA_ADAPTER_IP, CA_INTERFACE_DOWN);
}
/**
* Network Changed Callback to CA.
*/
-static CANetworkChangeCallback g_networkChangeCallback = NULL;
+static CAAdapterChangeCallback g_networkChangeCallback = NULL;
/**
* error Callback to CA adapter.
#endif // SINGLE_THREAD
-void CAIPConnectionStateCB(const char *ipAddress, CANetworkStatus_t status)
+void CAIPConnectionStateCB(CATransportAdapter_t adapter, CANetworkStatus_t status)
{
- (void)ipAddress;
- (void)status;
+ if (g_networkChangeCallback)
+ {
+ g_networkChangeCallback(adapter, status);
+ }
+ else
+ {
+ OIC_LOG(ERROR, TAG, "g_networkChangeCallback is NULL");
+ }
}
#ifdef __WITH_DTLS__
CAResult_t CAInitializeIP(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback networkPacketCallback,
- CANetworkChangeCallback netCallback,
+ CAAdapterChangeCallback netCallback,
CAErrorHandleCallback errorCallback, ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, TAG, "IN");
caglobals.ip.threadpool = handle;
CAIPSetPacketReceiveCallback(CAIPPacketReceivedCB);
+#ifndef SINGLE_THREAD
+ CAIPSetConnectionStateChangeCallback(CAIPConnectionStateCB);
+#endif
#ifdef __WITH_DTLS__
CAAdapterNetDtlsInit();
close(caglobals.ip.m4s.fd);
caglobals.ip.m4s.fd = -1;
}
+
+ if (caglobals.ip.netlinkFd != -1)
+ {
+ close(caglobals.ip.netlinkFd);
+ caglobals.ip.netlinkFd = -1;
+ }
}
static void CAReceiveHandler(void *data)
else ISSET(m4s, readFds, CA_MULTICAST | CA_IPV4 | CA_SECURE)
else if (FD_ISSET(caglobals.ip.netlinkFd, readFds))
{
- CAHandleNetlink();
+ CAInterface_t *ifchanged = CAFindInterfaceChange();
+ if (ifchanged)
+ {
+ CAProcessNewInterface(ifchanged);
+ OICFree(ifchanged);
+ }
break;
}
else if (FD_ISSET(caglobals.ip.shutdownFds[0], readFds))
{
continue;
}
-
- CAInterface_t *ifchanged = CAFindInterfaceChange();
- if (ifchanged)
- {
- CAProcessNewInterface(ifchanged);
- OICFree(ifchanged);
- }
break;
}
else
OIC_LOG(DEBUG, TAG, "ifitem is null");
return;
}
-
- applyMulticastToInterface6(ifitem->index);
- struct in_addr inaddr = { .s_addr = ifitem->ipv4addr };
- applyMulticastToInterface4(inaddr);
-}
-static void CAHandleNetlink()
-{
-#ifdef __linux__
- char buf[4096];
- struct nlmsghdr *nh;
- struct sockaddr_nl sa;
- struct iovec iov = { buf, sizeof (buf) };
- struct msghdr msg = { (void *)&sa, sizeof (sa), &iov, 1, NULL, 0, 0 };
-
- size_t len = recvmsg(caglobals.ip.netlinkFd, &msg, 0);
-
- for (nh = (struct nlmsghdr *)buf; NLMSG_OK(nh, len); nh = NLMSG_NEXT(nh, len))
+ if (ifitem->family == AF_INET6)
{
- if (nh != NULL && nh->nlmsg_type != RTM_NEWLINK)
- {
- continue;
- }
-
- struct ifinfomsg *ifi = (struct ifinfomsg *)NLMSG_DATA(nh);
- if (!ifi || (ifi->ifi_flags & IFF_LOOPBACK) || !(ifi->ifi_flags & IFF_RUNNING))
- {
- continue;
- }
-
- int newIndex = ifi->ifi_index;
-
- u_arraylist_t *iflist = CAIPGetInterfaceInformation(newIndex);
- if (!iflist)
- {
- OIC_LOG_V(ERROR, TAG, "get interface info failed: %s", strerror(errno));
- return;
- }
-
- uint32_t listLength = u_arraylist_length(iflist);
- for (uint32_t i = 0; i < listLength; i++)
- {
- CAInterface_t *ifitem = (CAInterface_t *)u_arraylist_get(iflist, i);
- if (!ifitem)
- {
- continue;
- }
-
- if ((int)ifitem->index != newIndex)
- {
- continue;
- }
-
- CAProcessNewInterface(ifitem);
- break; // we found the one we were looking for
- }
- u_arraylist_destroy(iflist);
+ applyMulticastToInterface6(ifitem->index);
+ }
+ if (ifitem->family == AF_INET)
+ {
+ struct in_addr inaddr = { .s_addr = ifitem->ipv4addr };
+ applyMulticastToInterface4(inaddr);
}
-#endif // __linux__
}
void CAIPSetPacketReceiveCallback(CAIPPacketReceivedCallback callback)
g_exceptionCallback = callback;
}
+void CAIPSetConnectionStateChangeCallback(CAIPConnectionStateChangeCallback callback)
+{
+ CAIPSetNetworkMonitorCallback(callback);
+}
+
static void sendData(int fd, const CAEndpoint_t *endpoint,
const void *data, uint32_t dlen,
const char *cast, const char *fam)
#include "caipinterface.h"
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
#include <sys/types.h>
+#include <sys/select.h>
#include <ifaddrs.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
#include <net/if.h>
-#include <sys/socket.h>
#include <netdb.h>
-#include <string.h>
#include <errno.h>
-#include <unistd.h>
+#ifdef __linux__
+#include <linux/netlink.h>
+#include <linux/rtnetlink.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#endif
+
+#include "camutex.h"
#include "caadapterutils.h"
#include "logger.h"
#include "oic_malloc.h"
#define TAG "OIC_CA_IP_MONITOR"
-CAResult_t CAIPStartNetworkMonitor()
+/**
+ * Mutex for synchronizing access to cached interface and IP address information.
+ */
+static ca_mutex g_networkMonitorContextMutex = NULL;
+
+/**
+ * Used to storing network interface.
+ */
+static u_arraylist_t *g_netInterfaceList = NULL;
+
+static CAIPConnectionStateChangeCallback g_networkChangeCallback = NULL;
+
+static CAResult_t CAIPInitializeNetworkMonitorList();
+static void CAIPDestroyNetworkMonitorList();
+static CAInterface_t *CANewInterfaceItem(int index, const char *name, int family,
+ uint32_t addr, int flags);
+
+static CAResult_t CAIPInitializeNetworkMonitorList()
+{
+ if (!g_networkMonitorContextMutex)
+ {
+ g_networkMonitorContextMutex = ca_mutex_new();
+ if (!g_networkMonitorContextMutex)
+ {
+ OIC_LOG(ERROR, TAG, "ca_mutex_new has failed");
+ return CA_STATUS_FAILED;
+ }
+ }
+
+ if (!g_netInterfaceList)
+ {
+ g_netInterfaceList = u_arraylist_create();
+ if (!g_netInterfaceList)
+ {
+ OIC_LOG(ERROR, TAG, "u_arraylist_create has failed");
+ CAIPDestroyNetworkMonitorList();
+ return CA_STATUS_FAILED;
+ }
+ }
+}
+
+static void CAIPDestroyNetworkMonitorList()
+{
+ if (g_netInterfaceList)
+ {
+ u_arraylist_destroy(g_netInterfaceList);
+ g_netInterfaceList = NULL;
+ }
+
+ if (g_networkMonitorContextMutex)
+ {
+ ca_mutex_free(g_networkMonitorContextMutex);
+ g_networkMonitorContextMutex = NULL;
+ }
+}
+
+static bool CACmpNetworkList(uint32_t ifiindex)
+{
+ if (!g_netInterfaceList)
+ {
+ OIC_LOG(ERROR, TAG, "g_netInterfaceList is NULL");
+ return false;
+ }
+
+ ca_mutex_lock(g_networkMonitorContextMutex);
+
+ uint32_t list_length = u_arraylist_length(g_netInterfaceList);
+ for (uint32_t list_index = 0; list_index < list_length; list_index++)
+ {
+ CAInterface_t *currItem = (CAInterface_t *) u_arraylist_get(g_netInterfaceList, list_index);
+ if (currItem->index == ifiindex)
+ {
+ ca_mutex_unlock(g_networkMonitorContextMutex);
+ return true;
+ }
+ }
+ ca_mutex_unlock(g_networkMonitorContextMutex);
+ return false;
+}
+
+static CAResult_t CAAddNetworkMonitorList(CAInterface_t *ifitem)
{
+ VERIFY_NON_NULL(g_netInterfaceList, TAG, "g_netInterfaceList is NULL");
+ VERIFY_NON_NULL(ifitem, TAG, "ifitem is NULL");
+
+ ca_mutex_lock(g_networkMonitorContextMutex);
+ bool result = u_arraylist_add(g_netInterfaceList, (void *) ifitem);
+ if (!result)
+ {
+ OIC_LOG(ERROR, TAG, "u_arraylist_add failed.");
+ ca_mutex_unlock(g_networkMonitorContextMutex);
+ return CA_STATUS_FAILED;
+ }
+ ca_mutex_unlock(g_networkMonitorContextMutex);
return CA_STATUS_OK;
}
+static void CARemoveNetworkMonitorList(int ifiindex)
+{
+ VERIFY_NON_NULL_VOID(g_netInterfaceList, TAG, "g_netInterfaceList is NULL");
+
+ ca_mutex_lock(g_networkMonitorContextMutex);
+
+ uint32_t list_length = u_arraylist_length(g_netInterfaceList);
+ for (uint32_t list_index = 0; list_index < list_length; list_index++)
+ {
+ CAInterface_t *removedifitem = (CAInterface_t *) u_arraylist_get(
+ g_netInterfaceList, list_index);
+ if (removedifitem && removedifitem->index == ifiindex)
+ {
+ if (u_arraylist_remove(g_netInterfaceList, list_index))
+ {
+ OICFree(removedifitem);
+ ca_mutex_unlock(g_networkMonitorContextMutex);
+ return;
+ }
+ continue;
+ }
+ }
+ ca_mutex_unlock(g_networkMonitorContextMutex);
+ return;
+}
+
+CAResult_t CAIPStartNetworkMonitor()
+{
+ return CAIPInitializeNetworkMonitorList();
+}
+
CAResult_t CAIPStopNetworkMonitor()
{
+ CAIPDestroyNetworkMonitorList();
return CA_STATUS_OK;
}
return interval;
}
+void CAIPSetNetworkMonitorCallback(CAIPConnectionStateChangeCallback callback)
+{
+ g_networkChangeCallback = callback;
+}
+
+static CAInterface_t *CANewInterfaceItem(int index, const char *name, int family,
+ uint32_t addr, int flags)
+{
+ CAInterface_t *ifitem = (CAInterface_t *)OICCalloc(1, sizeof (CAInterface_t));
+ if (!ifitem)
+ {
+ OIC_LOG(ERROR, TAG, "Malloc failed");
+ return NULL;
+ }
+
+ OICStrcpy(ifitem->name, sizeof (ifitem->name), name);
+ ifitem->index = index;
+ ifitem->family = family;
+ ifitem->ipv4addr = addr;
+ ifitem->flags = flags;
+
+ return ifitem;
+}
+
CAInterface_t *CAFindInterfaceChange()
{
- return NULL;
+ CAInterface_t *foundNewInterface = NULL;
+#ifdef __linux__
+ char buf[4096];
+ struct nlmsghdr *nh;
+ struct sockaddr_nl sa;
+ struct iovec iov = { buf, sizeof (buf) };
+ struct msghdr msg = { (void *)&sa, sizeof (sa), &iov, 1, NULL, 0, 0 };
+
+ size_t len = recvmsg(caglobals.ip.netlinkFd, &msg, 0);
+
+ for (nh = (struct nlmsghdr *)buf; NLMSG_OK(nh, len); nh = NLMSG_NEXT(nh, len))
+ {
+ if (nh != NULL && nh->nlmsg_type != RTM_NEWLINK)
+ {
+ continue;
+ }
+
+ struct ifinfomsg *ifi = (struct ifinfomsg *)NLMSG_DATA(nh);
+
+ int ifiIndex = ifi->ifi_index;
+ u_arraylist_t *iflist = CAIPGetInterfaceInformation(ifiIndex);
+
+ if ((!ifi || (ifi->ifi_flags & IFF_LOOPBACK) || !(ifi->ifi_flags & IFF_RUNNING)))
+ {
+ bool isFound = CACmpNetworkList(ifiIndex);
+ if (isFound)
+ {
+ CARemoveNetworkMonitorList(ifiIndex);
+ if (g_networkChangeCallback)
+ {
+ g_networkChangeCallback(CA_ADAPTER_IP ,CA_INTERFACE_DOWN);
+ }
+ }
+ continue;
+ }
+
+ if (!iflist)
+ {
+ OIC_LOG_V(ERROR, TAG, "get interface info failed: %s", strerror(errno));
+ return NULL;
+ }
+
+ uint32_t listLength = u_arraylist_length(iflist);
+ for (uint32_t i = 0; i < listLength; i++)
+ {
+ CAInterface_t *ifitem = (CAInterface_t *)u_arraylist_get(iflist, i);
+ if (!ifitem)
+ {
+ continue;
+ }
+
+ if ((int)ifitem->index != ifiIndex)
+ {
+ continue;
+ }
+
+ foundNewInterface = CANewInterfaceItem(ifitem->index, ifitem->name, ifitem->family,
+ ifitem->ipv4addr, ifitem->flags);
+ break; // we found the one we were looking for
+ }
+ u_arraylist_destroy(iflist);
+ }
+#endif
+ return foundNewInterface;
}
u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex)
goto exit;
}
- OIC_LOG_V(DEBUG, TAG, "Added interface: %s (%d)", ifitem->name, family);
+ bool isFound = CACmpNetworkList(ifitem->index);
+ if (!isFound)
+ {
+ CAInterface_t *newifitem = CANewInterfaceItem(ifitem->index, ifitem->name, ifitem->family,
+ ifitem->ipv4addr, ifitem->flags);
+ CAResult_t ret = CAAddNetworkMonitorList(newifitem);
+ if (CA_STATUS_OK != ret)
+ {
+ OICFree(newifitem);
+ goto exit;
+ }
+ if (g_networkChangeCallback)
+ {
+ g_networkChangeCallback(CA_ADAPTER_IP, CA_INTERFACE_UP);
+ }
+ OIC_LOG_V(DEBUG, TAG, "Added interface: %s (%d)", ifitem->name, ifitem->family);
+ }
}
-
freeifaddrs(ifp);
return iflist;
#define TAG "IP_MONITOR"
#define MAX_INTERFACE_INFO_LENGTH (1024)
+static CAIPConnectionStateChangeCallback g_networkChangeCallback;
+
static CAInterface_t *CANewInterfaceItem(int index, char *name, int family,
uint32_t addr, int flags);
return interval;
}
+void CAIPSetNetworkMonitorCallback(CAIPConnectionStateChangeCallback callback)
+{
+ g_networkChangeCallback = callback;
+}
+
CAInterface_t *CAFindInterfaceChange()
{
char buf[MAX_INTERFACE_INFO_LENGTH] = { 0 };
if (WIFI_CONNECTION_STATE_CONNECTED == state)
{
- CAWakeUpForChange();
+ g_networkChangeCallback(CA_ADAPTER_IP, CA_INTERFACE_UP);
}
else
{
- u_arraylist_t *iflist = CAIPGetInterfaceInformation(0);
- if (!iflist)
- {
- OIC_LOG_V(ERROR, TAG, "get interface info failed");
- return;
- }
- u_arraylist_destroy(iflist);
+ g_networkChangeCallback(CA_ADAPTER_IP, CA_INTERFACE_DOWN);
}
OIC_LOG(DEBUG, TAG, "OUT");
isAttached = true;\r
}\r
\r
- jclass jni_NfcInterface = (*env)->FindClass(env, "org/iotivity/ca/CaNfcInterface");\r
+ jmethodID mid_getApplicationContext = CAGetJNIMethodID(env, "android/content/Context",\r
+ "getApplicationContext",\r
+ "()Landroid/content/Context;");\r
+\r
+ if (!mid_getApplicationContext)\r
+ {\r
+ OIC_LOG(ERROR, TAG, "Could not get getApplicationContext method");\r
+ return CA_STATUS_FAILED;\r
+ }\r
+\r
+ jobject jApplicationContext = (*env)->CallObjectMethod(env, g_context,\r
+ mid_getApplicationContext);\r
+ if (!jApplicationContext)\r
+ {\r
+ OIC_LOG(ERROR, TAG, "Could not get application context");\r
+ return CA_STATUS_FAILED;\r
+ }\r
+\r
+ jclass jni_NfcInterface = (*env)->FindClass(env, CLASS_NFCINTERFACE);\r
if (!jni_NfcInterface)\r
{\r
OIC_LOG(ERROR, TAG, "Could not get CaNfcInterface class");\r
}\r
\r
jobject jni_nfcInstance = (*env)->NewObject(env, jni_NfcInterface,\r
- NfcInterfaceConstructorMethod, g_context,\r
+ NfcInterfaceConstructorMethod, jApplicationContext,\r
g_activity);\r
if (!jni_nfcInstance)\r
{\r
isAttached = true;\r
}\r
\r
- jclass jni_NfcInterface = (*env)->FindClass(env, "org/iotivity/ca/CaNfcInterface");\r
+ jclass jni_NfcInterface = (*env)->FindClass(env, CLASS_NFCINTERFACE);\r
if (!jni_NfcInterface)\r
{\r
OIC_LOG(ERROR, TAG, "Could not get CaNFCClientInterface class");\r
return NULL;\r
}\r
\r
- jclass cid_string = (*env)->FindClass(env, "java/lang/String");\r
- if (!cid_string)\r
- {\r
- OIC_LOG(ERROR, TAG, "Could not get NfcAdapter class for cid_string");\r
- return NULL;\r
- }\r
-\r
- jmethodID mid_getBytes = (*env)->GetMethodID(env, cid_string, "getBytes",\r
- "(Ljava/lang/String;)[B");\r
+ jmethodID mid_getBytes = CAGetJNIMethodID(env, "java/lang/String", "getBytes",\r
+ "(Ljava/lang/String;)[B");\r
if (!mid_getBytes)\r
{\r
OIC_LOG(ERROR, TAG, "Could not get methodId for mid_getBytes");\r
static CANetworkPacketReceivedCallback g_packetReceivedCallback = NULL;
/**
- * Network Changed Callback to CA
+ * Adapter Changed Callback to CA
*/
-static CANetworkChangeCallback g_connectionStateCallback = NULL;
+static CAAdapterChangeCallback g_adapterStateCallback = NULL;
/**
* error Callback to CA adapter
CAResult_t CAInitializeNFC(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback packetReceivedCallback,
- CANetworkChangeCallback connectionStateCallback,
+ CAAdapterChangeCallback netCallback,
CAErrorHandleCallback errorCallback, ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, TAG, "IN");
VERIFY_NON_NULL(registerCallback, TAG, "registerCallback");
VERIFY_NON_NULL(packetReceivedCallback, TAG, "packetReceivedCallback");
- VERIFY_NON_NULL(connectionStateCallback, TAG, "connectionStateCallback");
+ VERIFY_NON_NULL(netCallback, TAG, "netCallback");
VERIFY_NON_NULL(handle, TAG, "thread pool handle");
- g_connectionStateCallback = connectionStateCallback;
+ g_adapterStateCallback = netCallback;
g_packetReceivedCallback = packetReceivedCallback;
g_errorCallback = errorCallback;
/**
* Network Changed Callback to CA.
*/
-static CANetworkChangeCallback g_networkChangeCallback = NULL;
+static CAAdapterChangeCallback g_networkChangeCallback = NULL;
/**
* Holds XMPP data information.
g_xmppData.connectionStatus = status;
- CAEndpoint_t *localEndpoint = CACreateEndpointObject(CA_DEFAULT_FLAGS,
- CA_ADAPTER_REMOTE_ACCESS,
- address, 0);
- if (!localEndpoint)
- {
- OIC_LOG(ERROR, RA_ADAPTER_TAG, "localEndpoint creation failed!");
- return;
- }
- CANetworkChangeCallback networkChangeCallback = g_networkChangeCallback;
+ CAAdapterChangeCallback networkChangeCallback = g_networkChangeCallback;
if (networkChangeCallback)
{
- networkChangeCallback(localEndpoint, status);
+ networkChangeCallback(CA_ADAPTER_REMOTE_ACCESS, status);
}
else
{
OIC_LOG(ERROR, RA_ADAPTER_TAG, "g_networkChangeCallback is NULL");
}
- CAFreeEndpoint(localEndpoint);
-
OIC_LOG(DEBUG, RA_ADAPTER_TAG, "CARANotifyNetworkChange OUT");
}
}
CAResult_t CAInitializeRA(CARegisterConnectivityCallback registerCallback,
- CANetworkPacketReceivedCallback networkPacketCallback,
- CANetworkChangeCallback netCallback, ca_thread_pool_t handle)
+ CANetworkPacketReceivedCallback networkPacketCallback,
+ CAAdapterChangeCallback netCallback, ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, RA_ADAPTER_TAG, "CAInitializeRA IN");
if (!registerCallback || !networkPacketCallback || !netCallback || !handle)
/**
* Network Changed Callback to CA.
*/
-static CANetworkChangeCallback g_networkChangeCallback = NULL;
+static CAAdapterChangeCallback g_networkChangeCallback = NULL;
/**
* Holds XMPP data information.
{
OIC_LOG(DEBUG, RA_ADAPTER_TAG, "CARANotifyNetworkChange IN");
- CAEndpoint_t *localEndpoint = CACreateEndpointObject(CA_DEFAULT_FLAGS,
- CA_ADAPTER_REMOTE_ACCESS,
- address, 0);
- if (!localEndpoint)
- {
- OIC_LOG(ERROR, RA_ADAPTER_TAG, "localEndpoint creation failed!");
- return;
- }
- CANetworkChangeCallback networkChangeCallback = g_networkChangeCallback;
+ CAAdapterChangeCallback networkChangeCallback = g_networkChangeCallback;
if (networkChangeCallback)
{
- networkChangeCallback(localEndpoint, status);
+ networkChangeCallback(CA_ADAPTER_REMOTE_ACCESS, status);
}
else
{
OIC_LOG(ERROR, RA_ADAPTER_TAG, "g_networkChangeCallback is NULL");
}
- CAFreeEndpoint(localEndpoint);
-
OIC_LOG(DEBUG, RA_ADAPTER_TAG, "CARANotifyNetworkChange OUT");
}
}
CAResult_t CAInitializeRA(CARegisterConnectivityCallback registerCallback,
- CANetworkPacketReceivedCallback networkPacketCallback,
- CANetworkChangeCallback netCallback, ca_thread_pool_t handle)
+ CANetworkPacketReceivedCallback networkPacketCallback,
+ CAAdapterChangeCallback netCallback, ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, RA_ADAPTER_TAG, "CAInitializeRA IN");
if (!registerCallback || !networkPacketCallback || !netCallback || !handle)
common_files = [
os.path.join(src_dir, 'catcpadapter.c'),
os.path.join(src_dir, 'catcpserver.c') ]
+else :
+ common_files = [os.path.join(src_dir, 'catcpadapter.c')]
# Get list of target-specific source file base names, i.e. no parent
# directories prepended to the path.
--- /dev/null
+#######################################################
+# Build TCP adapter for Ardunino
+#######################################################
+
+Import('env', 'src_dir')
+import os.path
+
+env.AppendUnique(CPPPATH = [ os.path.join(src_dir, 'arduino') ])
+
+if env.get('SHIELD') == 'ETH':
+ src_files = [ 'catcpserver_eth.cpp' ,
+ 'catcpadapterutils_eth.cpp']
+
+Return('src_files')
--- /dev/null
+/******************************************************************
+*
+* Copyright 2015 Samsung Electronics All Rights Reserved.
+*
+*
+*
+* 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.
+*
+******************************************************************/
+#include "catcpadapterutils_eth.h"
+
+#include <Arduino.h>
+#include <Ethernet.h>
+#include <socket.h>
+#include <w5100.h>
+#include <EthernetUdp.h>
+#include <IPAddress.h>
+
+#include "logger.h"
+#include "cacommon.h"
+#include "caadapterinterface.h"
+#include "caadapterutils.h"
+
+#define TAG "IPU"
+
+CAResult_t CAArduinoGetAvailableTCPSocket(int *sockID)
+{
+ VERIFY_NON_NULL(sockID, TAG, "sockID");
+ //Is any socket available to work with ?
+ *sockID = 0;
+ for (int i = 1; i < MAX_SOCK_NUM; i++)
+ {
+ uint8_t state = W5100.readSnSR(i);
+ if (state == SnSR::CLOSED || state == SnSR::FIN_WAIT)
+ {
+ *sockID = i;
+ break;
+ }
+ }
+
+ if (*sockID == 0)
+ {
+ OIC_LOG(ERROR, TAG, "sockID 0");
+ return CA_SOCKET_OPERATION_FAILED;
+ }
+
+ return CA_STATUS_OK;
+}
+
+CAResult_t CAArduinoInitTCPSocket(uint16_t *port, int *socketID)
+{
+ OIC_LOG(DEBUG, TAG, "IN");
+ VERIFY_NON_NULL(port, TAG, "port");
+ VERIFY_NON_NULL(socketID, TAG, "socketID");
+
+ CAResult_t ret = CAArduinoGetAvailableTCPSocket(socketID);
+ if (ret != CA_STATUS_OK)
+ {
+ OIC_LOG(ERROR, TAG, "get sock fail");
+ return ret;
+ }
+
+ //Create a tcp socket on which to recv/send.
+ if (!socket(*socketID, SnMR::TCP, *port, 0))
+ {
+ OIC_LOG(ERROR, TAG, "sock fail");
+ return CA_STATUS_FAILED;
+ }
+ OIC_LOG_V(DEBUG, TAG, "socketId:%d", *socketID);
+ OIC_LOG(DEBUG, TAG, "OUT");
+ return CA_STATUS_OK;
+}
--- /dev/null
+/* ****************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+/**
+ * @file
+ * This file provides APIs ethernet client/server/network monitor modules.
+ */
+
+#ifndef CA_ETHERNET_ADAPTER_UTILS_
+#define CA_ETHERNET_ADAPTER_UTILS_
+
+#include <Arduino.h>
+#include <Ethernet.h>
+#include <socket.h>
+#include <w5100.h>
+#include <IPAddress.h>
+
+#include "logger.h"
+#include "cacommon.h"
+#include "caadapterinterface.h"
+#include "caipadapter.h"
+#include "caadapterutils.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * Get available TCP socket.
+ * @param[out] sockID Available UDP socket ID.
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ */
+CAResult_t CAArduinoGetAvailableTCPSocket(int *sockID);
+
+/**
+ * Initialize Unicast TCP socket.
+ * @param[in/out] port Port to start the unicast server.
+ * @param[out] socketID Unicast socket ID.
+ * @return ::CA_STATUS_OK or Appropriate error code.
+ */
+CAResult_t CAArduinoInitTCPSocket(uint16_t *port, int *socketID);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CA_ETHERNET_ADAPTER_UTILS_ */
+
--- /dev/null
+/* ****************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+#include <stdio.h>
+#include <errno.h>
+
+#include <Arduino.h>
+#include <Ethernet.h>
+#include <SPI.h>
+#include <w5100.h>
+#include <IPAddress.h>
+
+#include "catcpadapterutils_eth.h"
+#include "catcpinterface.h"
+#include "pdu.h"
+#include "caadapterutils.h"
+#include "camutex.h"
+#include "oic_malloc.h"
+#include "oic_string.h"
+
+/**
+ * Logging tag for module name.
+ */
+#define TAG "TCP_SERVER"
+
+/**
+ * Maximum CoAP over TCP header length
+ * to know the total data length.
+ */
+#define TCP_MAX_HEADER_LEN 6
+
+#define TCP_UNICAST_PORT 55556
+
+uint16_t tcpClientPort = 0;
+uint8_t tcpClientIP[4] = {0};
+
+/**
+ * Maintains the callback to be notified when data received from remote device.
+ */
+static CATCPPacketReceivedCallback g_packetReceivedCallback = NULL;
+
+/**
+ * Error callback to update error in TCP.
+ */
+static CATCPErrorHandleCallback g_TCPErrorHandler = NULL;
+
+static uint16_t g_unicastPort = 0;
+
+static int g_unicastSocket = -1;
+
+static EthernetServer server(TCP_UNICAST_PORT);
+
+/**
+ * @var g_receivedDataLen
+ * @brief Actual length of data received.
+ */
+static uint32_t g_receivedDataLen = 0;
+
+static void CATCPReadDataInternal();
+
+uint16_t CAGetTcpServerPortNum(const char *ipAddress, bool isSecured)
+{
+ return g_unicastPort;
+}
+
+void CATCPPullData()
+{
+ CATCPReadDataInternal();
+}
+
+CAResult_t CATCPStartServer()
+{
+ OIC_LOG(DEBUG, TAG, "IN");
+
+ if (caglobals.tcp.started)
+ {
+ return CA_STATUS_OK;
+ }
+
+ if (!caglobals.tcp.ipv4tcpenabled)
+ {
+ caglobals.tcp.ipv4tcpenabled = true; // only needed to run CA tests
+ }
+
+ uint8_t rawIPAddr[4] = {0};
+ char address[16] = {0};
+ W5100.getIPAddress(rawIPAddr);
+ int ret = snprintf(address, sizeof(address), "%d.%d.%d.%d", rawIPAddr[0], rawIPAddr[1], rawIPAddr[2],
+ rawIPAddr[3]);
+ if(0 > ret)
+ {
+ OIC_LOG(ERROR, TAG, "Error getting IP");
+ return CA_STATUS_FAILED;
+ }
+
+ OIC_LOG_V(DEBUG, TAG, "address:%s", address);
+ int serverFD = 1;
+ g_unicastPort = TCP_UNICAST_PORT;
+
+ if (CAArduinoInitTCPSocket(&g_unicastPort, &serverFD) != CA_STATUS_OK)
+ {
+ OIC_LOG(DEBUG, TAG, "Init TCP Socket failed");
+ return CA_STATUS_FAILED;
+ }
+
+ listen(serverFD);
+ EthernetClass::_server_port[serverFD] = g_unicastPort;
+ g_unicastSocket = serverFD;
+ caglobals.ip.u4.port = TCP_UNICAST_PORT;
+
+ caglobals.tcp.terminate = false;
+ caglobals.tcp.started = true;
+
+ OIC_LOG_V(DEBUG, TAG, "g_unicastPort: %u", g_unicastPort);
+ OIC_LOG_V(DEBUG, TAG, "g_unicastSocket: %d", g_unicastSocket);
+ OIC_LOG(DEBUG, TAG, "OUT");
+ return CA_STATUS_OK;
+}
+
+void CATCPStopServer()
+{
+ OIC_LOG(DEBUG, TAG, "IN");
+ caglobals.tcp.terminate = true;
+ caglobals.tcp.started = false;
+
+ if (-1 != g_unicastSocket)
+ {
+ close(g_unicastSocket);
+ g_unicastSocket = -1;
+ }
+
+ caglobals.ip.u4.port = 0;
+ OIC_LOG(DEBUG, TAG, "OUT");
+}
+
+void CATCPSetPacketReceiveCallback(CATCPPacketReceivedCallback callback)
+{
+ OIC_LOG(DEBUG, TAG, "IN");
+
+ g_packetReceivedCallback = callback;
+
+ OIC_LOG(DEBUG, TAG, "OUT");
+}
+
+void CATCPSetErrorHandler(CATCPErrorHandleCallback errorHandleCallback)
+{
+ return;
+}
+
+void CATCPReadDataInternal()
+{
+ OIC_LOG(DEBUG, TAG, "CATCPReadDataInternal IN");
+ if (false == caglobals.tcp.started)
+ {
+ OIC_LOG(ERROR, TAG, "Server is not running");
+ return;
+ }
+
+ EthernetClient client = server.available();
+
+ if (client && client.connected())
+ {
+ client.getTCPClientIP(tcpClientIP);
+ client.getTCPClientPort(&tcpClientPort);
+ OIC_LOG_V(DEBUG, TAG, "Client ip is %d.%d.%d.%d , Port is : %d", tcpClientIP[0],
+ tcpClientIP[1], tcpClientIP[2], tcpClientIP[3], tcpClientPort);
+
+ OIC_LOG(DEBUG, TAG, "DATA Available");
+ unsigned char *recvBuffer = NULL;
+ size_t bufSize = TCP_MAX_HEADER_LEN;
+
+ recvBuffer = (unsigned char *) OICCalloc(1, bufSize);
+ if (!recvBuffer)
+ {
+ OIC_LOG(ERROR, TAG, "out of memory");
+ }
+
+ bool isHeaderChecked = false;
+ size_t totalLen = 0;
+ size_t totalReceivedLen = 0;
+
+ do
+ {
+ size_t bufferLen = 0;
+ if (client.available())
+ {
+ bufferLen = client.read(recvBuffer, bufSize);
+ totalReceivedLen += bufferLen;
+ }
+
+ if (!isHeaderChecked && totalReceivedLen)
+ {
+ coap_transport_type transport;
+ size_t headerLen;
+ CAGetTCPHeaderDetails(recvBuffer, &transport, &headerLen);
+ if (totalReceivedLen >= headerLen)
+ {
+ // get actual data length from coap over tcp header
+ totalLen = CAGetTotalLengthFromPacketHeader((const unsigned char *) recvBuffer,
+ bufferLen);
+ bufSize = totalLen;
+ unsigned char *newBuf = (unsigned char *) OICRealloc(recvBuffer, bufSize);
+ if (NULL == newBuf)
+ {
+ OIC_LOG(ERROR, TAG, "out of memory");
+ OICFree(recvBuffer);
+ return;
+ }
+
+ recvBuffer = newBuf;
+ isHeaderChecked = true;
+ }
+ }
+
+ if (totalLen == totalReceivedLen)
+ {
+ CASecureEndpoint_t ep =
+ {.endpoint = {.adapter = CA_ADAPTER_TCP, .port = tcpClientPort}};
+
+ IPAddress clientIP = tcpClientIP;
+ int ret = snprintf(ep.endpoint.addr, sizeof(ep.endpoint.addr), "%d.%d.%d.%d",
+ clientIP[0], clientIP[1], clientIP[2], clientIP[3]);
+ if(0 > ret)
+ {
+ OIC_LOG(ERROR, TAG, "Error parsing client IP");
+ OICFree(recvBuffer);
+ return;
+ }
+
+ OIC_LOG_V(DEBUG, TAG, "Client ip is %d.%d.%d.%d", clientIP[0],
+ clientIP[1], clientIP[2], clientIP[3]);
+ if (g_packetReceivedCallback)
+ {
+ g_packetReceivedCallback(&ep, recvBuffer, totalLen);
+ }
+
+ OIC_LOG_V(DEBUG, TAG, "received data len:%d", totalLen);
+ break;
+ }
+ } while (!totalLen || totalLen > totalReceivedLen);
+
+ OICFree(recvBuffer);
+
+ OIC_LOG(DEBUG, TAG, "OUT");
+ }
+ else
+ {
+ OIC_LOG(DEBUG, TAG, "NoData");
+ }
+ return;
+}
+
+CAResult_t CAGetTCPInterfaceInformation(CAEndpoint_t **info, uint32_t *size)
+{
+ OIC_LOG(DEBUG, TAG, "IN");
+
+ VERIFY_NON_NULL(info, TAG, "info is NULL");
+ VERIFY_NON_NULL(size, TAG, "size is NULL");
+
+ return CA_NOT_SUPPORTED;
+}
+
+static void sendData(const CAEndpoint_t *endpoint,
+ const void *data, size_t dlen)
+{
+ uint16_t port = endpoint->port;
+ uint8_t ipAddr[4] = { 0 };
+ uint16_t parsedPort = 0;
+ if (CAParseIPv4AddressInternal(endpoint->addr, ipAddr, sizeof(ipAddr),
+ &parsedPort) != CA_STATUS_OK)
+ {
+ OIC_LOG(ERROR, TAG, "parse fail");
+ return;
+ }
+
+ if (dlen > 65535) // Max value for uint16_t
+ {
+ // This will never happen as max buffer size we are dealing with is COAP_MAX_PDU_SIZE
+ OIC_LOG(ERROR, TAG, "Size exceeded");
+ return;
+ }
+
+ uint32_t ret = send(g_unicastSocket, (const uint8_t *)data, (uint16_t)dlen);
+ if (ret <= 0)
+ {
+ OIC_LOG_V(ERROR, TAG, "SendData failed: %d", ret);
+ }
+
+ OIC_LOG(DEBUG, TAG, "OUT");
+}
+
+void CATCPSendData(CAEndpoint_t *endpoint, const void *data, uint32_t datalen,
+ bool isMulticast)
+{
+ VERIFY_NON_NULL_VOID(endpoint, TAG, "endpoint is NULL");
+ VERIFY_NON_NULL_VOID(data, TAG, "data is NULL");
+
+ if (!isMulticast)
+ {
+ if (caglobals.tcp.ipv4tcpenabled && (endpoint->adapter & CA_ADAPTER_TCP))
+ {
+ sendData(endpoint, data, datalen);
+ }
+ }
+}
\ No newline at end of file
static CANetworkPacketReceivedCallback g_networkPacketCallback = NULL;
/**
- * Network Changed Callback to CA.
+ * Adapter Changed Callback to CA.
*/
-static CANetworkChangeCallback g_networkChangeCallback = NULL;
+static CAAdapterChangeCallback g_networkChangeCallback = NULL;
+
+/**
+ * Connection Changed Callback to CA.
+ */
+static CAConnectionChangeCallback g_connectionChangeCallback = NULL;
/**
* error Callback to CA adapter.
const void *data, uint32_t dataLength);
/**
- * KeepAlive Connected Callback to CA adapter.
+ * KeepAlive Connected or Disconnected Callback to CA adapter.
*/
-static CAKeepAliveConnectedCallback g_connCallback = NULL;
-
-/**
- * KeepAlive Disconnected Callback to CA adapter.
- */
-static CAKeepAliveDisconnectedCallback g_disconnCallback = NULL;
+static CAKeepAliveConnectionCallback g_connKeepAliveCallback = NULL;
static CAResult_t CATCPInitializeQueueHandles();
}
}
-static void CATCPKeepAliveHandler(const char *addr, uint16_t port, bool isConnected)
+static void CATCPConnectionHandler(const char *addr, uint16_t port, bool isConnected)
{
CAEndpoint_t endpoint = { .adapter = CA_ADAPTER_TCP,
.port = port };
OICStrcpy(endpoint.addr, sizeof(endpoint.addr), addr);
- if (isConnected)
+ // Pass the changed connection status to RI Layer for keepalive.
+ if (g_connKeepAliveCallback)
{
- g_connCallback(&endpoint);
+ g_connKeepAliveCallback(&endpoint, isConnected);
}
- else
+
+ // Pass the changed connection status to CAUtil.
+ if (g_connectionChangeCallback)
{
- g_disconnCallback(&endpoint);
+ g_connectionChangeCallback(&endpoint, isConnected);
}
}
-void CATCPSetKeepAliveCallbacks(CAKeepAliveConnectedCallback ConnHandler,
- CAKeepAliveDisconnectedCallback DisconnHandler)
+void CATCPSetKeepAliveCallbacks(CAKeepAliveConnectionCallback ConnHandler)
{
- g_connCallback = ConnHandler;
- g_disconnCallback = DisconnHandler;
-
- CATCPSetKeepAliveCallback(CATCPKeepAliveHandler);
+ g_connKeepAliveCallback = ConnHandler;
}
static void CAInitializeTCPGlobals()
{
+ caglobals.tcp.ipv4.fd = -1;
+ caglobals.tcp.ipv4.port = 0;
+ caglobals.tcp.ipv6.fd = -1;
+ caglobals.tcp.ipv6.port = 0;
caglobals.tcp.selectTimeout = CA_TCP_SELECT_TIMEOUT;
caglobals.tcp.listenBacklog = CA_TCP_LISTEN_BACKLOG;
caglobals.tcp.svrlist = NULL;
}
caglobals.tcp.ipv4tcpenabled = flags & CA_IPV4;
+ caglobals.tcp.ipv6tcpenabled = flags & CA_IPV6;
}
CAResult_t CAInitializeTCP(CARegisterConnectivityCallback registerCallback,
CANetworkPacketReceivedCallback networkPacketCallback,
- CANetworkChangeCallback netCallback,
+ CAAdapterChangeCallback netCallback,
+ CAConnectionChangeCallback connCallback,
CAErrorHandleCallback errorCallback, ca_thread_pool_t handle)
{
OIC_LOG(DEBUG, TAG, "IN");
VERIFY_NON_NULL(registerCallback, TAG, "registerCallback");
VERIFY_NON_NULL(networkPacketCallback, TAG, "networkPacketCallback");
VERIFY_NON_NULL(netCallback, TAG, "netCallback");
+#ifndef SINGLE_THREAD
VERIFY_NON_NULL(handle, TAG, "thread pool handle");
+#endif
g_networkChangeCallback = netCallback;
+ g_connectionChangeCallback = connCallback;
g_networkPacketCallback = networkPacketCallback;
g_errorCallback = errorCallback;
CAInitializeTCPGlobals();
+#ifndef SINGLE_THREAD
caglobals.tcp.threadpool = handle;
+#endif
+ CATCPSetConnectionChangedCallback(CATCPConnectionHandler);
CATCPSetPacketReceiveCallback(CATCPPacketReceivedCB);
CATCPSetErrorHandler(CATCPErrorHandler);
CAResult_t CAStartTCP()
{
+ OIC_LOG(DEBUG, TAG, "IN");
+
+#ifndef SINGLE_THREAD
if (CA_STATUS_OK != CATCPInitializeQueueHandles())
{
OIC_LOG(ERROR, TAG, "Failed to Initialize Queue Handle");
return CA_STATUS_FAILED;
}
+#else
+ CAResult_t ret = CATCPStartServer();
+ if (CA_STATUS_OK != ret)
+ {
+ OIC_LOG_V(DEBUG, TAG, "CATCPStartServer failed[%d]", ret);
+ return ret;
+ }
+#endif
+
return CA_STATUS_OK;
}
CAResult_t CAStartTCPListeningServer()
{
+#ifndef SINGLE_THREAD
if (!caglobals.server)
{
caglobals.server = true; // only needed to run CA tests
OIC_LOG_V(ERROR, TAG, "Failed to start listening server![%d]", ret);
return ret;
}
+#endif
return CA_STATUS_OK;
}
int32_t CASendTCPUnicastData(const CAEndpoint_t *endpoint,
const void *data, uint32_t dataLength)
{
+ OIC_LOG(DEBUG, TAG, "IN");
+#ifndef SINGLE_THREAD
return CAQueueTCPData(false, endpoint, data, dataLength);
+#else
+ CATCPSendData(endpoint, data, dataLength, false);
+ return dataLength;
+#endif
}
int32_t CASendTCPMulticastData(const CAEndpoint_t *endpoint,
CAResult_t CAReadTCPData()
{
+ OIC_LOG(DEBUG, TAG, "IN");
+#ifdef SINGLE_THREAD
+ CATCPPullData();
+#endif
return CA_STATUS_OK;
}
CAResult_t CAStopTCP()
{
+#ifndef SINGLE_THREAD
if (g_sendQueueHandle && g_sendQueueHandle->threadMutex)
{
CAQueueingThreadStop(g_sendQueueHandle);
}
+#endif
CATCPStopServer();
{
CATCPSetPacketReceiveCallback(NULL);
+#ifndef SINGLE_THREAD
CATCPDeinitializeQueueHandles();
+#endif
}
void CATCPSendDataThread(void *threadData)
CAFreeTCPData(TCPData);
}
+
+#ifdef SINGLE_THREAD
+size_t CAGetTotalLengthFromPacketHeader(const unsigned char *recvBuffer, size_t size)
+{
+ OIC_LOG(DEBUG, TAG, "IN - CAGetTotalLengthFromHeader");
+
+ if (NULL == recvBuffer || !size)
+ {
+ OIC_LOG(ERROR, TAG, "recvBuffer is NULL");
+ return 0;
+ }
+
+ coap_transport_type transport = coap_get_tcp_header_type_from_initbyte(
+ ((unsigned char *)recvBuffer)[0] >> 4);
+ size_t optPaylaodLen = coap_get_length_from_header((unsigned char *)recvBuffer,
+ transport);
+ size_t headerLen = coap_get_tcp_header_length((unsigned char *)recvBuffer);
+
+ OIC_LOG_V(DEBUG, TAG, "option/paylaod length [%d]", optPaylaodLen);
+ OIC_LOG_V(DEBUG, TAG, "header length [%d]", headerLen);
+ OIC_LOG_V(DEBUG, TAG, "total data length [%d]", headerLen + optPaylaodLen);
+
+ OIC_LOG(DEBUG, TAG, "OUT - CAGetTotalLengthFromHeader");
+ return headerLen + optPaylaodLen;
+}
+
+void CAGetTCPHeaderDetails(unsigned char* recvBuffer, coap_transport_type *transport,
+ size_t *headerlen)
+{
+ if (NULL == recvBuffer)
+ {
+ OIC_LOG(ERROR, TAG, "recvBuffer is NULL");
+ return;
+ }
+
+ if (NULL == transport)
+ {
+ OIC_LOG(ERROR, TAG, "transport is NULL");
+ return;
+ }
+
+ if (NULL == headerlen)
+ {
+ OIC_LOG(ERROR, TAG, "headerlen is NULL");
+ return;
+ }
+
+ *transport = coap_get_tcp_header_type_from_initbyte(
+ ((unsigned char *)recvBuffer)[0] >> 4);
+ *headerlen = coap_get_tcp_header_length_for_transport(*transport);
+}
+#endif
#include <sys/types.h>
#include <sys/socket.h>
+#include <sys/select.h>
#include <sys/ioctl.h>
+#include <sys/poll.h>
#include <stdio.h>
#include <unistd.h>
-#include <sys/types.h>
#include <fcntl.h>
-#include <sys/select.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <net/if.h>
#include <errno.h>
-#include <sys/poll.h>
#ifndef WITH_ARDUINO
#include <sys/socket.h>
#define TCP_MAX_HEADER_LEN 6
/**
- * Accept server file descriptor.
- */
-static int g_acceptServerFD = -1;
-
-/**
* Mutex to synchronize device object list.
*/
static ca_mutex g_mutexObjectList = NULL;
/**
* Connected Callback to pass the connection information to RI.
*/
-static CATCPKeepAliveHandleCallback g_keepaliveCallback = NULL;
+static CATCPConnectionHandleCallback g_connectionCallback = NULL;
static CAResult_t CATCPCreateMutex();
static void CATCPDestroyMutex();
static CAResult_t CATCPCreateCond();
static void CATCPDestroyCond();
-static CAResult_t CACreateAcceptSocket();
-static void CAAcceptConnection();
+static int CACreateAcceptSocket(int family, CASocket_t *sock);
+static void CAAcceptConnection(CATransportFlags_t flag, CASocket_t *sock);
static void CAFindReadyMessage();
static void CASelectReturned(fd_set *readFds, int ret);
static void CAReceiveMessage(int fd);
FD_ZERO(&readFds);
- if (-1 != g_acceptServerFD)
+ if (-1 != caglobals.tcp.ipv4.fd)
{
- FD_SET(g_acceptServerFD, &readFds);
+ FD_SET(caglobals.tcp.ipv4.fd, &readFds);
+ }
+ if (-1 != caglobals.tcp.ipv6.fd)
+ {
+ FD_SET(caglobals.tcp.ipv6.fd, &readFds);
}
if (-1 != caglobals.tcp.shutdownFds[0])
{
static void CASelectReturned(fd_set *readFds, int ret)
{
- (void)ret;
+ VERIFY_NON_NULL_VOID(readFds, TAG, "readFds is NULL");
- if (g_acceptServerFD != -1 && FD_ISSET(g_acceptServerFD, readFds))
+ if (caglobals.tcp.ipv4.fd != -1 && FD_ISSET(caglobals.tcp.ipv4.fd, readFds))
{
- CAAcceptConnection();
+ CAAcceptConnection(CA_IPV4, &caglobals.tcp.ipv4);
+ return;
+ }
+ else if (caglobals.tcp.ipv6.fd != -1 && FD_ISSET(caglobals.tcp.ipv6.fd, readFds))
+ {
+ CAAcceptConnection(CA_IPV6, &caglobals.tcp.ipv6);
+ return;
+ }
+ else if (-1 != caglobals.tcp.connectionFds[0] &&
+ FD_ISSET(caglobals.tcp.connectionFds[0], readFds))
+ {
+ // new connection was created from remote device.
+ // exit the function to update read file descriptor.
+ char buf[MAX_ADDR_STR_SIZE_CA] = {0};
+ ssize_t len = read(caglobals.tcp.connectionFds[0], buf, sizeof (buf));
+ if (-1 == len)
+ {
+ return;
+ }
+ OIC_LOG_V(DEBUG, TAG, "Received new connection event with [%s]", buf);
+ FD_CLR(caglobals.tcp.connectionFds[0], readFds);
return;
}
else if (-1 != caglobals.tcp.connectionFds[0] &&
}
}
-static void CAAcceptConnection()
+static void CAAcceptConnection(CATransportFlags_t flag, CASocket_t *sock)
{
+ VERIFY_NON_NULL_VOID(sock, TAG, "sock is NULL");
+
struct sockaddr_storage clientaddr;
socklen_t clientlen = sizeof (struct sockaddr_in);
- int sockfd = accept(g_acceptServerFD, (struct sockaddr *)&clientaddr,
- &clientlen);
+ int sockfd = accept(sock->fd, (struct sockaddr *)&clientaddr, &clientlen);
if (-1 != sockfd)
{
CATCPSessionInfo_t *svritem =
}
svritem->fd = sockfd;
+ svritem->sep.endpoint.flags = flag;
CAConvertAddrToName((struct sockaddr_storage *)&clientaddr, clientlen,
(char *) &svritem->sep.endpoint.addr, &svritem->sep.endpoint.port);
}
}
+static CAResult_t CATCPConvertNameToAddr(int family, const char *host, uint16_t port,
+ struct sockaddr_storage *sockaddr)
+{
+ struct addrinfo *addrs = NULL;
+ struct addrinfo hints = { .ai_family = family,
+ .ai_protocol = IPPROTO_TCP,
+ .ai_socktype = SOCK_STREAM,
+ .ai_flags = AI_NUMERICHOST };
+
+ int r = getaddrinfo(host, NULL, &hints, &addrs);
+ if (r)
+ {
+ if (EAI_SYSTEM == r)
+ {
+ OIC_LOG_V(ERROR, TAG, "getaddrinfo failed: errno %s", strerror(errno));
+ }
+ else
+ {
+ OIC_LOG_V(ERROR, TAG, "getaddrinfo failed: %s", gai_strerror(r));
+ }
+ freeaddrinfo(addrs);
+ return CA_STATUS_FAILED;
+ }
+ // assumption: in this case, getaddrinfo will only return one addrinfo
+ // or first is the one we want.
+ if (addrs[0].ai_family == AF_INET6)
+ {
+ memcpy(sockaddr, addrs[0].ai_addr, sizeof (struct sockaddr_in6));
+ ((struct sockaddr_in6 *)sockaddr)->sin6_port = htons(port);
+ }
+ else
+ {
+ memcpy(sockaddr, addrs[0].ai_addr, sizeof (struct sockaddr_in));
+ ((struct sockaddr_in *)sockaddr)->sin_port = htons(port);
+ }
+ freeaddrinfo(addrs);
+ return CA_STATUS_OK;
+}
+
static int CATCPCreateSocket(int family, CATCPSessionInfo_t *svritem)
{
- // create tcp socket
+ // #1. create tcp socket.
int fd = socket(family, SOCK_STREAM, IPPROTO_TCP);
if (-1 == fd)
{
OIC_LOG_V(ERROR, TAG, "create socket failed: %s", strerror(errno));
- goto exit;
+ return -1;
}
+ // #2. convert address from string to binary.
struct sockaddr_storage sa = { .ss_family = family };
- CAConvertNameToAddr(svritem->sep.endpoint.addr, svritem->sep.endpoint.port, &sa);
- socklen_t socklen = sizeof (struct sockaddr_in);
+ CAResult_t res = CATCPConvertNameToAddr(family, svritem->sep.endpoint.addr,
+ svritem->sep.endpoint.port, &sa);
+ if (CA_STATUS_OK != res)
+ {
+ close(fd);
+ return -1;
+ }
- // connect to TCP server
- int ret = connect(fd, (struct sockaddr *)&sa, socklen);
- if (0 == ret)
+ // #3. set socket length.
+ socklen_t socklen;
+ if (sa.ss_family == AF_INET6)
{
- OIC_LOG(DEBUG, TAG, "connect socket success");
- CAWakeUpForReadFdsUpdate(svritem->sep.endpoint.addr);
+ struct sockaddr_in6 *sock6 = (struct sockaddr_in6 *)&sa;
+ if (!sock6->sin6_scope_id)
+ {
+ sock6->sin6_scope_id = svritem->sep.endpoint.interface;
+ }
+ socklen = sizeof(struct sockaddr_in6);
}
else
{
- OIC_LOG(ERROR, TAG, "failed to connect socket");
- goto exit;
+ socklen = sizeof(struct sockaddr_in);
}
- return fd;
-
-exit:
- if (fd >= 0)
+ // #4. connect to remote server device.
+ if (connect(fd, (struct sockaddr *)&sa, socklen) < 0)
{
+ OIC_LOG_V(ERROR, TAG, "failed to connect socket, %s", strerror(errno));
close(fd);
+ return -1;
}
- return -1;
+
+ OIC_LOG(DEBUG, TAG, "connect socket success");
+ CAWakeUpForReadFdsUpdate(svritem->sep.endpoint.addr);
+ return fd;
}
-static CAResult_t CACreateAcceptSocket()
+static int CACreateAcceptSocket(int family, CASocket_t *sock)
{
- if (g_acceptServerFD != -1)
+ VERIFY_NON_NULL_RET(sock, TAG, "sock", -1);
+
+ if (sock->fd != -1)
{
OIC_LOG(DEBUG, TAG, "accept socket created already");
- return CA_STATUS_OK;
+ return sock->fd;
}
- int reuse = 1;
- struct sockaddr_in server = { .sin_addr.s_addr = INADDR_ANY,
- .sin_family = AF_INET,
- .sin_port = htons(SERVER_PORT),
- .sin_zero = { 0 } };
+ socklen_t socklen;
+ struct sockaddr_storage server = { .ss_family = family };
- g_acceptServerFD = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (g_acceptServerFD < 0)
+ int fd = socket(family, SOCK_STREAM, IPPROTO_TCP);
+ if (fd < 0)
{
OIC_LOG(ERROR, TAG, "Failed to create socket");
goto exit;
}
- if (-1 == setsockopt(g_acceptServerFD, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)))
+ if (family == AF_INET6)
+ {
+ // the socket is re‐stricted to sending and receiving IPv6 packets only.
+ int on = 1;
+ if (-1 == setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof (on)))
+ {
+ OIC_LOG_V(ERROR, TAG, "IPV6_V6ONLY failed: %s", strerror(errno));
+ goto exit;
+ }
+ ((struct sockaddr_in6 *)&server)->sin6_port = htons(sock->port);
+ socklen = sizeof (struct sockaddr_in6);
+ }
+ else
+ {
+ ((struct sockaddr_in *)&server)->sin_port = htons(sock->port);
+ socklen = sizeof (struct sockaddr_in);
+ }
+
+ int reuse = 1;
+ if (-1 == setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)))
{
OIC_LOG(ERROR, TAG, "setsockopt SO_REUSEADDR");
goto exit;
}
- int serverlen = sizeof(server);
- if (-1 == bind(g_acceptServerFD, (struct sockaddr *)&server, serverlen))
+ if (-1 == bind(fd, (struct sockaddr *)&server, socklen))
{
- OIC_LOG(ERROR, TAG, "bind() error");
+ OIC_LOG_V(ERROR, TAG, "bind socket failed: %s", strerror(errno));
goto exit;
}
- if (listen(g_acceptServerFD, caglobals.tcp.listenBacklog) != 0)
+ if (listen(fd, caglobals.tcp.listenBacklog) != 0)
{
OIC_LOG(ERROR, TAG, "listen() error");
goto exit;
}
- CHECKFD(g_acceptServerFD);
+ if (!sock->port) // return the assigned port
+ {
+ if (-1 == getsockname(fd, (struct sockaddr *)&server, &socklen))
+ {
+ OIC_LOG_V(ERROR, TAG, "getsockname failed: %s", strerror(errno));
+ goto exit;
+ }
+ sock->port = ntohs(family == AF_INET6 ?
+ ((struct sockaddr_in6 *)&server)->sin6_port :
+ ((struct sockaddr_in *)&server)->sin_port);
+ }
- return CA_STATUS_OK;
+ return fd;
exit:
- if (g_acceptServerFD >= 0)
+ if (fd >= 0)
{
- close(g_acceptServerFD);
- g_acceptServerFD = -1;
+ close(fd);
}
- return CA_STATUS_FAILED;
+ return -1;
}
static void CAInitializePipe(int *fds)
{
caglobals.tcp.ipv4tcpenabled = true; // only needed to run CA tests
}
+ if (!caglobals.tcp.ipv6tcpenabled)
+ {
+ caglobals.tcp.ipv6tcpenabled = true; // only needed to run CA tests
+ }
CAResult_t res = CATCPCreateMutex();
if (CA_STATUS_OK == res)
if (caglobals.server)
{
- res = CACreateAcceptSocket();
- if (CA_STATUS_OK != res)
- {
- OIC_LOG(ERROR, TAG, "failed to create accept socket");
- return res;
- }
+ caglobals.tcp.ipv4.fd = CACreateAcceptSocket(AF_INET, &caglobals.tcp.ipv4);
+ CHECKFD(caglobals.tcp.ipv4.fd);
+ caglobals.tcp.ipv6.fd = CACreateAcceptSocket(AF_INET6, &caglobals.tcp.ipv6);
+ CHECKFD(caglobals.tcp.ipv6.fd);
+
+ OIC_LOG_V(DEBUG, TAG, "IPv4 socket fd=%d, port=%d",
+ caglobals.tcp.ipv4.fd, caglobals.tcp.ipv4.port);
+ OIC_LOG_V(DEBUG, TAG, "IPv6 socket fd=%d, port=%d",
+ caglobals.tcp.ipv6.fd, caglobals.tcp.ipv6.port);
}
// create pipe for fast shutdown
// mutex unlock
ca_mutex_unlock(g_mutexObjectList);
- if (-1 != g_acceptServerFD)
+ if (-1 != caglobals.tcp.ipv4.fd)
+ {
+ close(caglobals.tcp.ipv4.fd);
+ caglobals.tcp.ipv4.fd = -1;
+ }
+
+ if (-1 != caglobals.tcp.ipv6.fd)
{
- close(g_acceptServerFD);
- g_acceptServerFD = -1;
+ close(caglobals.tcp.ipv6.fd);
+ caglobals.tcp.ipv6.fd = -1;
}
CATCPDisconnectAll();
g_packetReceivedCallback = callback;
}
-void CATCPSetKeepAliveCallback(CATCPKeepAliveHandleCallback keepaliveHandler)
+void CATCPSetConnectionChangedCallback(CATCPConnectionHandleCallback connHandler)
{
- g_keepaliveCallback = keepaliveHandler;
+ g_connectionCallback = connHandler;
}
static size_t CACheckPayloadLength(const void *data, size_t dlen)
return payloadLen;
}
-static void sendData(const CAEndpoint_t *endpoint,
- const void *data, size_t dlen)
+static void sendData(const CAEndpoint_t *endpoint, const void *data,
+ size_t dlen, const char *fam)
{
// #1. get TCP Server object from list
size_t index = 0;
remainLen -= len;
} while (remainLen > 0);
- OIC_LOG_V(INFO, TAG, "unicast ipv4tcp sendTo is successful: %zu bytes", dlen);
+ OIC_LOG_V(INFO, TAG, "unicast %stcp sendTo is successful: %zu bytes", fam, dlen);
}
void CATCPSendData(CAEndpoint_t *endpoint, const void *data, uint32_t datalen,
if (!isMulticast)
{
- if (caglobals.tcp.ipv4tcpenabled && (endpoint->adapter & CA_ADAPTER_TCP))
+ if (caglobals.tcp.ipv6tcpenabled && (endpoint->flags & CA_IPV6))
+ {
+ sendData(endpoint, data, datalen, "ipv6");
+ }
+ if (caglobals.tcp.ipv4tcpenabled && (endpoint->flags & CA_IPV4))
{
- sendData(endpoint, data, datalen);
+ sendData(endpoint, data, datalen, "ipv4");
}
}
}
}
memcpy(svritem->sep.endpoint.addr, endpoint->addr, sizeof(svritem->sep.endpoint.addr));
svritem->sep.endpoint.port = endpoint->port;
+ svritem->sep.endpoint.flags = endpoint->flags;
+ svritem->sep.endpoint.interface = endpoint->interface;
// #2. create the socket and connect to TCP server
- if (caglobals.tcp.ipv4tcpenabled)
+ int family = (svritem->sep.endpoint.flags & CA_IPV6) ? AF_INET6 : AF_INET;
+ int fd = CATCPCreateSocket(family, svritem);
+ if (-1 == fd)
{
- int fd = CATCPCreateSocket(AF_INET, svritem);
- if (-1 == fd)
+ OICFree(svritem);
+ return NULL;
+ }
+
+ // #3. add TCP connection info to list
+ svritem->fd = fd;
+ ca_mutex_lock(g_mutexObjectList);
+ if (caglobals.tcp.svrlist)
+ {
+ bool res = u_arraylist_add(caglobals.tcp.svrlist, svritem);
+ if (!res)
{
+ OIC_LOG(ERROR, TAG, "u_arraylist_add failed.");
+ close(svritem->fd);
OICFree(svritem);
+ ca_mutex_unlock(g_mutexObjectList);
return NULL;
}
+ }
+ ca_mutex_unlock(g_mutexObjectList);
- // #3. add TCP connection info to list
- svritem->fd = fd;
- ca_mutex_lock(g_mutexObjectList);
- if (caglobals.tcp.svrlist)
- {
- bool res = u_arraylist_add(caglobals.tcp.svrlist, svritem);
- if (!res)
- {
- OIC_LOG(ERROR, TAG, "u_arraylist_add failed.");
- close(svritem->fd);
- OICFree(svritem);
- ca_mutex_unlock(g_mutexObjectList);
- return NULL;
- }
- }
- ca_mutex_unlock(g_mutexObjectList);
-
- CHECKFD(fd);
+ CHECKFD(fd);
- // pass the connection information to RI for keepalive.
- if (g_keepaliveCallback)
- {
- g_keepaliveCallback(svritem->sep.endpoint.addr, svritem->sep.endpoint.port, true);
- }
+ // pass the connection information to CA Common Layer.
+ if (g_connectionCallback)
+ {
+ g_connectionCallback(svritem->sep.endpoint.addr, svritem->sep.endpoint.port, true);
}
return svritem;
}
u_arraylist_remove(caglobals.tcp.svrlist, index);
OICFree(svritem->recvData);
- OICFree(svritem);
- ca_mutex_unlock(g_mutexObjectList);
- // pass the connection information to RI for keepalive.
- if (g_keepaliveCallback)
+ // pass the connection information to CA Common Layer.
+ if (g_connectionCallback)
{
- g_keepaliveCallback(svritem->sep.endpoint.addr, svritem->sep.endpoint.port, false);
+ g_connectionCallback(svritem->sep.endpoint.addr, svritem->sep.endpoint.port, false);
}
+ OICFree(svritem);
+ ca_mutex_unlock(g_mutexObjectList);
+
return CA_STATUS_OK;
}
ca_mutex_unlock(g_mutexObjectList);
}
-CATCPSessionInfo_t *CAGetTCPSessionInfoFromEndpoint(const CAEndpoint_t *endpoint,
- size_t *index)
+CATCPSessionInfo_t *CAGetTCPSessionInfoFromEndpoint(const CAEndpoint_t *endpoint, size_t *index)
{
VERIFY_NON_NULL_RET(endpoint, TAG, "endpoint is NULL", NULL);
VERIFY_NON_NULL_RET(index, TAG, "index is NULL", NULL);
if (!strncmp(svritem->sep.endpoint.addr, endpoint->addr,
sizeof(svritem->sep.endpoint.addr))
- && (svritem->sep.endpoint.port == endpoint->port))
+ && (svritem->sep.endpoint.port == endpoint->port)
+ && (svritem->sep.endpoint.flags & endpoint->flags))
{
*index = i;
return svritem;
######################################################################
# Source files and Targets
######################################################################
-catests = catest_env.Program('catests', ['catests.cpp',
- 'caprotocolmessagetest.cpp',
- 'ca_api_unittest.cpp',
- 'camutex_tests.cpp',
- 'uarraylist_test.cpp'
- ])
+
+target_os = env.get('TARGET_OS')
+target_transport = env.get('TARGET_TRANSPORT')
+
+if (('IP' in target_transport) or ('ALL' in target_transport)):
+ if target_os != 'arduino':
+ catests = catest_env.Program('catests', ['catests.cpp',
+ 'caprotocolmessagetest.cpp',
+ 'cablocktransfertest.cpp',
+ 'ca_api_unittest.cpp',
+ 'camutex_tests.cpp',
+ 'uarraylist_test.cpp'
+ ])
+else:
+ catests = catest_env.Program('catests', ['catests.cpp',
+ 'caprotocolmessagetest.cpp',
+ 'ca_api_unittest.cpp',
+ 'camutex_tests.cpp',
+ 'uarraylist_test.cpp'
+ ])
Alias("test", [catests])
env.AppendTarget('test')
if env.get('TEST') == '1':
- target_os = env.get('TARGET_OS')
if target_os == 'linux':
from tools.scons.RunTest import *
run_test(catest_env,
return;
}
-void adapter_handler(CATransportAdapter_t adapter,
- bool enabled)
+void adapter_handler(CATransportAdapter_t /*adapter*/,
+ bool /*enabled*/)
{
-
}
-void connection_handler(CATransportAdapter_t adapter,
- const char *remote_address,
- bool connected)
+void connection_handler(CATransportAdapter_t /*adapter*/,
+ const char * /*remote_address*/,
+ bool /*connected*/)
{
-
}
static char* addr = NULL;
// check return value
TEST_F(CATests, RegisterNetworkMonitorHandler)
{
-#ifdef LE_ADAPTER
EXPECT_EQ(CA_STATUS_OK, CARegisterNetworkMonitorHandler(adapter_handler,
connection_handler));
-#else
- EXPECT_EQ(CA_NOT_SUPPORTED, CARegisterNetworkMonitorHandler(adapter_handler,
- connection_handler));
-#endif
}
// CASetAutoConnectionDeviceInfo TC
--- /dev/null
+/* ****************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+#include "gtest/gtest.h"
+#include "cainterface.h"
+#include "cautilinterface.h"
+#include "cacommon.h"
+#include "caprotocolmessage.h"
+#include "cablockwisetransfer.h"
+
+#define LARGE_PAYLOAD_LENGTH 1024
+
+class CABlockTransferTests : public testing::Test {
+ protected:
+ virtual void SetUp() {
+ CAInitialize();
+ }
+
+ virtual void TearDown()
+ {
+ CATerminate();
+ }
+};
+
+TEST_F(CABlockTransferTests, CACreateNewDataSetTest)
+{
+ CAEndpoint_t* tempRep = NULL;
+ CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+ coap_pdu_t *pdu = NULL;
+ coap_list_t *options = NULL;
+ coap_transport_type transport = coap_udp;
+
+ CAToken_t tempToken = NULL;
+ CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+ CAInfo_t requestData;
+ memset(&requestData, 0, sizeof(CAInfo_t));
+ requestData.token = tempToken;
+ requestData.tokenLength = CA_MAX_TOKEN_LEN;
+ requestData.type = CA_MSG_NONCONFIRM;
+
+ requestData.payload = (CAPayload_t) calloc(LARGE_PAYLOAD_LENGTH, sizeof(char));
+ if (!requestData.payload)
+ {
+ CADestroyToken(tempToken);
+ FAIL() << "requestData.payload allocation failed";
+ }
+ memset(requestData.payload, '1', sizeof(requestData.payload) - 1);
+ requestData.payloadSize = sizeof(requestData.payload);
+ requestData.type = CA_MSG_NONCONFIRM;
+
+ pdu = CAGeneratePDU(CA_GET, &requestData, tempRep, &options, &transport);
+
+ CAData_t *cadata = CACreateNewDataSet(pdu, tempRep);
+ EXPECT_TRUE(cadata != NULL);
+
+ CABlockData_t *currData = CACreateNewBlockData(cadata);
+ EXPECT_TRUE(currData != NULL);
+
+ if (currData)
+ {
+ CAData_t *getData = CAGetDataSetFromBlockDataList(currData->blockDataId);
+ EXPECT_TRUE(getData != NULL);
+
+ CARemoveBlockDataFromList(currData->blockDataId);
+ }
+
+ CADestroyDataSet(cadata);
+ coap_delete_list(options);
+ coap_delete_pdu(pdu);
+
+ CADestroyToken(tempToken);
+ CADestroyEndpoint(tempRep);
+ free(requestData.payload);
+}
+
+TEST_F(CABlockTransferTests, CAGetBlockDataFromBlockDataListTest)
+{
+ CAEndpoint_t* tempRep = NULL;
+ CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+ coap_pdu_t *pdu = NULL;
+ coap_list_t *options = NULL;
+ coap_transport_type transport = coap_udp;
+
+ CAToken_t tempToken = NULL;
+ CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+ CAInfo_t requestData;
+ memset(&requestData, 0, sizeof(CAInfo_t));
+ requestData.token = tempToken;
+ requestData.tokenLength = CA_MAX_TOKEN_LEN;
+ requestData.type = CA_MSG_NONCONFIRM;
+
+ pdu = CAGeneratePDU(CA_GET, &requestData, tempRep, &options, &transport);
+
+ CAData_t *cadata = CACreateNewDataSet(pdu, tempRep);
+ EXPECT_TRUE(cadata != NULL);
+
+ CABlockData_t *currData = CACreateNewBlockData(cadata);
+ EXPECT_TRUE(currData != NULL);
+
+ if (currData)
+ {
+ CABlockData_t *data = CAGetBlockDataFromBlockDataList(currData->blockDataId);
+ EXPECT_TRUE(data != NULL);
+
+ CARemoveBlockDataFromList(currData->blockDataId);
+ }
+
+ CADestroyDataSet(cadata);
+ coap_delete_list(options);
+ coap_delete_pdu(pdu);
+
+ CADestroyToken(tempToken);
+ CADestroyEndpoint(tempRep);
+ free(requestData.payload);
+}
+
+TEST_F(CABlockTransferTests, CAGetPayloadFromBlockDataListTest)
+{
+ CAEndpoint_t* tempRep = NULL;
+ CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+ coap_pdu_t *pdu = NULL;
+ coap_list_t *options = NULL;
+ coap_transport_type transport = coap_udp;
+
+ CAToken_t tempToken = NULL;
+ CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+ CAInfo_t requestData;
+ memset(&requestData, 0, sizeof(CAInfo_t));
+ requestData.token = tempToken;
+ requestData.tokenLength = CA_MAX_TOKEN_LEN;
+ requestData.type = CA_MSG_NONCONFIRM;
+
+ pdu = CAGeneratePDU(CA_GET, &requestData, tempRep, &options, &transport);
+
+ CAData_t *cadata = CACreateNewDataSet(pdu, tempRep);
+ EXPECT_TRUE(cadata != NULL);
+
+ CABlockData_t *currData = CACreateNewBlockData(cadata);
+ EXPECT_TRUE(currData != NULL);
+
+ size_t fullPayload = 0;
+ CAPayload_t payload = CAGetPayloadFromBlockDataList(currData->blockDataId,
+ &fullPayload);
+
+ size_t payloadLen = (payload != NULL) ? strlen((const char*) payload) : 0;
+ EXPECT_TRUE(fullPayload == payloadLen);
+
+ CARemoveBlockDataFromList(currData->blockDataId);
+ CADestroyDataSet(cadata);
+ coap_delete_list(options);
+ coap_delete_pdu(pdu);
+
+ CADestroyToken(tempToken);
+ CADestroyEndpoint(tempRep);
+ free(requestData.payload);
+}
+
+// request and block option1
+TEST_F(CABlockTransferTests, CAAddBlockOptionTest)
+{
+ CAEndpoint_t* tempRep = NULL;
+ CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+ coap_pdu_t *pdu = NULL;
+ coap_list_t *options = NULL;
+ coap_transport_type transport = coap_udp;
+
+ CAToken_t tempToken = NULL;
+ CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+ CAInfo_t requestData;
+ memset(&requestData, 0, sizeof(CAInfo_t));
+ requestData.token = tempToken;
+ requestData.tokenLength = CA_MAX_TOKEN_LEN;
+
+ requestData.payload = (CAPayload_t) calloc(LARGE_PAYLOAD_LENGTH, sizeof(char));
+ if(!requestData.payload)
+ {
+ CADestroyToken(tempToken);
+ FAIL() << "requestData.payload allocation failed";
+ }
+ memset(requestData.payload, '1', sizeof(requestData.payload) - 1);
+ requestData.payloadSize = sizeof(requestData.payload);
+ requestData.type = CA_MSG_NONCONFIRM;
+
+ pdu = CAGeneratePDU(CA_GET, &requestData, tempRep, &options, &transport);
+
+ EXPECT_EQ(CA_STATUS_OK, CAAddBlockOption(&pdu, &requestData, tempRep, &options));
+
+ coap_delete_list(options);
+ coap_delete_pdu(pdu);
+
+ CADestroyToken(tempToken);
+ CADestroyEndpoint(tempRep);
+ free(requestData.payload);
+}
+
+// request and block option1
+TEST_F(CABlockTransferTests, CAAddBlockOption1InRequest)
+{
+ CAEndpoint_t* tempRep = NULL;
+ CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+ coap_pdu_t *pdu = NULL;
+ coap_list_t *options = NULL;
+ coap_transport_type transport = coap_udp;
+
+ CAToken_t tempToken = NULL;
+ CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+ CAInfo_t requestData;
+ memset(&requestData, 0, sizeof(CAInfo_t));
+ requestData.token = tempToken;
+ requestData.tokenLength = CA_MAX_TOKEN_LEN;
+
+ requestData.payload = (CAPayload_t) calloc(LARGE_PAYLOAD_LENGTH, sizeof(char));
+ if(!requestData.payload)
+ {
+ CADestroyToken(tempToken);
+ FAIL() << "requestData.payload allocation failed";
+ }
+ memset(requestData.payload, '1', sizeof(requestData.payload) - 1);
+ requestData.payloadSize = sizeof(requestData.payload);
+ requestData.type = CA_MSG_NONCONFIRM;
+
+ pdu = CAGeneratePDU(CA_GET, &requestData, tempRep, &options, &transport);
+
+ CAData_t *cadata = CACreateNewDataSet(pdu, tempRep);
+ EXPECT_TRUE(cadata != NULL);
+
+ CABlockData_t *currData = CACreateNewBlockData(cadata);
+ EXPECT_TRUE(currData != NULL);
+
+ EXPECT_EQ(CA_STATUS_OK, CAUpdateBlockOptionType(currData->blockDataId,
+ COAP_OPTION_BLOCK1));
+
+ EXPECT_EQ(CA_STATUS_OK, CAAddBlockOption1(&pdu, &requestData,
+ requestData.payloadSize,
+ currData->blockDataId, &options));
+
+ CADestroyDataSet(cadata);
+ coap_delete_list(options);
+ coap_delete_pdu(pdu);
+
+ CADestroyToken(tempToken);
+ CADestroyEndpoint(tempRep);
+ free(requestData.payload);
+}
+
+// response and block option1
+TEST_F(CABlockTransferTests, CAAddBlockOption1InResponse)
+{
+ CAEndpoint_t* tempRep = NULL;
+ CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+ coap_pdu_t *pdu = NULL;
+ coap_list_t *options = NULL;
+ coap_transport_type transport = coap_udp;
+
+ CAToken_t tempToken = NULL;
+ CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+ CAInfo_t responseData;
+ memset(&responseData, 0, sizeof(CAInfo_t));
+ responseData.token = tempToken;
+ responseData.tokenLength = CA_MAX_TOKEN_LEN;
+ responseData.type = CA_MSG_NONCONFIRM;
+ responseData.messageId = 1;
+
+ responseData.payload = (CAPayload_t) calloc(LARGE_PAYLOAD_LENGTH, sizeof(char));
+ if(!responseData.payload)
+ {
+ CADestroyToken(tempToken);
+ FAIL() << "requestData.payload allocation failed";
+ }
+ memset(responseData.payload, '1', sizeof(responseData.payload) - 1);
+ responseData.payloadSize = sizeof(responseData.payload);
+
+ pdu = CAGeneratePDU(CA_CREATED, &responseData, tempRep, &options, &transport);
+
+ CAData_t *cadata = CACreateNewDataSet(pdu, tempRep);
+ EXPECT_TRUE(cadata != NULL);
+
+ CABlockData_t *currData = CACreateNewBlockData(cadata);
+ EXPECT_TRUE(currData != NULL);
+
+ EXPECT_EQ(CA_STATUS_OK, CAUpdateBlockOptionType(currData->blockDataId,
+ COAP_OPTION_BLOCK1));
+
+ EXPECT_EQ(CA_STATUS_OK, CAAddBlockOption1(&pdu, &responseData,
+ responseData.payloadSize,
+ currData->blockDataId, &options));
+
+ CADestroyDataSet(cadata);
+ coap_delete_list(options);
+ coap_delete_pdu(pdu);
+
+ CADestroyToken(tempToken);
+ CADestroyEndpoint(tempRep);
+ free(responseData.payload);
+}
+
+// response and block option2
+TEST_F(CABlockTransferTests, CAAddBlockOption2InResponse)
+{
+ CAEndpoint_t* tempRep = NULL;
+ CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+ coap_pdu_t *pdu = NULL;
+ coap_list_t *options = NULL;
+ coap_transport_type transport = coap_udp;
+
+ CAToken_t tempToken = NULL;
+ CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+ CAInfo_t responseData;
+ memset(&responseData, 0, sizeof(CAInfo_t));
+ responseData.token = tempToken;
+ responseData.tokenLength = CA_MAX_TOKEN_LEN;
+ responseData.type = CA_MSG_NONCONFIRM;
+ responseData.messageId = 1;
+
+ responseData.payload = (CAPayload_t) calloc(LARGE_PAYLOAD_LENGTH, sizeof(char));
+ if(!responseData.payload)
+ {
+ CADestroyToken(tempToken);
+ FAIL() << "requestData.payload allocation failed";
+ }
+ memset(responseData.payload, '1', sizeof(responseData.payload) - 1);
+ responseData.payloadSize = sizeof(responseData.payload);
+
+ pdu = CAGeneratePDU(CA_CREATED, &responseData, tempRep, &options, &transport);
+
+ CAData_t *cadata = CACreateNewDataSet(pdu, tempRep);
+ EXPECT_TRUE(cadata != NULL);
+
+ CABlockData_t *currData = CACreateNewBlockData(cadata);
+ EXPECT_TRUE(currData != NULL);
+
+ EXPECT_EQ(CA_STATUS_OK, CAUpdateBlockOptionType(currData->blockDataId,
+ COAP_OPTION_BLOCK2));
+
+ EXPECT_EQ(CA_STATUS_OK, CAAddBlockOption2(&pdu, &responseData,
+ responseData.payloadSize,
+ currData->blockDataId, &options));
+
+ CADestroyDataSet(cadata);
+ coap_delete_list(options);
+ coap_delete_pdu(pdu);
+
+ CADestroyToken(tempToken);
+ CADestroyEndpoint(tempRep);
+ free(responseData.payload);
+}
+
+// request and block option1
+TEST_F(CABlockTransferTests, CAAddBlockOption2InRequest)
+{
+ CAEndpoint_t* tempRep = NULL;
+ CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+ coap_pdu_t *pdu = NULL;
+ coap_list_t *options = NULL;
+ coap_transport_type transport = coap_udp;
+
+ CAToken_t tempToken = NULL;
+ CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+ CAInfo_t requestData;
+ memset(&requestData, 0, sizeof(CAInfo_t));
+ requestData.token = tempToken;
+ requestData.tokenLength = CA_MAX_TOKEN_LEN;
+
+ requestData.payload = (CAPayload_t) calloc(LARGE_PAYLOAD_LENGTH, sizeof(char));
+ if(!requestData.payload)
+ {
+ CADestroyToken(tempToken);
+ FAIL() << "requestData.payload allocation failed";
+ }
+ memset(requestData.payload, '1', sizeof(requestData.payload) - 1);
+ requestData.payloadSize = sizeof(requestData.payload);
+ requestData.type = CA_MSG_NONCONFIRM;
+
+ pdu = CAGeneratePDU(CA_GET, &requestData, tempRep, &options, &transport);
+
+ CAData_t *cadata = CACreateNewDataSet(pdu, tempRep);
+ EXPECT_TRUE(cadata != NULL);
+
+ CABlockData_t *currData = CACreateNewBlockData(cadata);
+ EXPECT_TRUE(currData != NULL);
+
+ EXPECT_EQ(CA_STATUS_OK, CAUpdateBlockOptionType(currData->blockDataId,
+ COAP_OPTION_BLOCK2));
+
+ EXPECT_EQ(CA_STATUS_OK, CAAddBlockOption2(&pdu, &requestData,
+ requestData.payloadSize,
+ currData->blockDataId, &options));
+
+ CARemoveBlockDataFromList(currData->blockDataId);
+ CADestroyDataSet(cadata);
+ coap_delete_list(options);
+ coap_delete_pdu(pdu);
+
+ CADestroyToken(tempToken);
+ CADestroyEndpoint(tempRep);
+ free(requestData.payload);
+}
+
+TEST_F(CABlockTransferTests, CAGetBlockSizeOptionFromPduTest)
+{
+ CAEndpoint_t* tempRep = NULL;
+ CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+ coap_pdu_t *pdu = NULL;
+ coap_list_t *options = NULL;
+ coap_transport_type transport = coap_udp;
+
+ CAToken_t tempToken = NULL;
+ CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+ CAInfo_t requestData;
+ memset(&requestData, 0, sizeof(CAInfo_t));
+ requestData.token = tempToken;
+ requestData.tokenLength = CA_MAX_TOKEN_LEN;
+ requestData.type = CA_MSG_NONCONFIRM;
+
+ pdu = CAGeneratePDU(CA_GET, &requestData, tempRep, &options, &transport);
+
+ size_t totalPayloadLen = 0;
+ EXPECT_FALSE(CAIsPayloadLengthInPduWithBlockSizeOption(pdu, COAP_OPTION_SIZE1,
+ &totalPayloadLen));
+
+ coap_delete_list(options);
+ coap_delete_pdu(pdu);
+
+ CADestroyToken(tempToken);
+ CADestroyEndpoint(tempRep);
+ free(requestData.payload);
+}
+
+TEST_F(CABlockTransferTests, CASetNextBlockOption1Test)
+{
+ CAEndpoint_t* tempRep = NULL;
+ CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+ coap_pdu_t *pdu = NULL;
+ coap_list_t *options = NULL;
+ coap_transport_type transport = coap_udp;
+
+ CAToken_t tempToken = NULL;
+ CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+ CAInfo_t responseData;
+ memset(&responseData, 0, sizeof(CAInfo_t));
+ responseData.token = tempToken;
+ responseData.tokenLength = CA_MAX_TOKEN_LEN;
+ responseData.type = CA_MSG_NONCONFIRM;
+ responseData.messageId = 1;
+
+ pdu = CAGeneratePDU(CA_CREATED, &responseData, tempRep, &options, &transport);
+
+ CAData_t *cadata = CACreateNewDataSet(pdu, tempRep);
+ EXPECT_TRUE(cadata != NULL);
+
+ CABlockData_t *currData = CACreateNewBlockData(cadata);
+ EXPECT_TRUE(currData != NULL);
+
+ coap_block_t block = {0, 0, 0};
+ EXPECT_EQ(CA_STATUS_OK, CASetNextBlockOption1(pdu, tempRep, cadata, block, pdu->length));
+
+ EXPECT_EQ(CA_STATUS_OK, CAHandleRequestResponse());
+
+ CADestroyDataSet(cadata);
+ coap_delete_list(options);
+ coap_delete_pdu(pdu);
+
+ CADestroyToken(tempToken);
+ CADestroyEndpoint(tempRep);
+ free(responseData.payload);
+}
+
+TEST_F(CABlockTransferTests, CASetNextBlockOption2Test)
+{
+ CAEndpoint_t* tempRep = NULL;
+ CACreateEndpoint(CA_DEFAULT_FLAGS, CA_ADAPTER_IP, "127.0.0.1", 5683, &tempRep);
+
+ coap_pdu_t *pdu = NULL;
+ coap_list_t *options = NULL;
+ coap_transport_type transport = coap_udp;
+
+ CAToken_t tempToken = NULL;
+ CAGenerateToken(&tempToken, CA_MAX_TOKEN_LEN);
+
+ CAInfo_t requestData;
+ memset(&requestData, 0, sizeof(CAInfo_t));
+ requestData.token = tempToken;
+ requestData.tokenLength = CA_MAX_TOKEN_LEN;
+ requestData.type = CA_MSG_NONCONFIRM;
+
+ pdu = CAGeneratePDU(CA_GET, &requestData, tempRep, &options, &transport);
+
+ CAData_t *cadata = CACreateNewDataSet(pdu, tempRep);
+ EXPECT_TRUE(cadata != NULL);
+
+ CABlockData_t *currData = CACreateNewBlockData(cadata);
+ EXPECT_TRUE(currData != NULL);
+
+ coap_block_t block = {0, 0, 0};
+ EXPECT_EQ(CA_STATUS_OK, CASetNextBlockOption2(pdu, tempRep, cadata, block, pdu->length));
+
+ CADestroyDataSet(cadata);
+ coap_delete_list(options);
+ coap_delete_pdu(pdu);
+
+ CADestroyToken(tempToken);
+ CADestroyEndpoint(tempRep);
+ free(requestData.payload);
+}
}
}
-TEST(MutexTests, TC_02_TRY_LOCK)
-{
- ca_mutex mymutex = ca_mutex_new();
-
- EXPECT_TRUE(mymutex != NULL);
- if (mymutex != NULL)
- {
- EXPECT_TRUE(ca_mutex_trylock(mymutex)); // acquire it
-
- ca_mutex_unlock(mymutex); // release it
-
- ca_mutex_lock(mymutex); // acquire it
-
- EXPECT_FALSE(ca_mutex_trylock(mymutex)); // he should be lock
-
- EXPECT_FALSE(ca_mutex_trylock(NULL));
-
- ca_mutex_unlock(mymutex); // release it
- ca_mutex_free(mymutex);
-
- EXPECT_FALSE(ca_mutex_trylock(NULL));
- }
-}
-
typedef struct _tagFunc1
{
ca_mutex mutex;
ca_os = env.get('TARGET_OS')
ca_transport = env.get('TARGET_TRANSPORT')
-src_dir = env.get('SRC_DIR')
-root_dir = './../'
-src_dir = './../util/src/'
-
-env.PrependUnique(CPPPATH = [ os.path.join(root_dir, 'api') ])
-env.AppendUnique(CPPPATH = [ os.path.join(root_dir, 'inc'),
- os.path.join(root_dir, 'lib/libcoap-4.1.1'),
- os.path.join(src_dir, '/resource/csdk/logger/include/'),
- os.path.join(root_dir, 'common/inc'),
- os.path.join(root_dir, 'util/inc') ])
-
-if ca_os == 'android':
- env.AppendUnique(CPPPATH = [ os.path.join(root_dir, 'util/src/android') ])
+target_os = env.get('TARGET_OS')
+project_root = env.get('SRC_DIR')
+root_dir = os.path.join(project_root, 'resource', 'csdk', 'connectivity')
+src_dir = os.path.join(root_dir, 'util', 'src')
######################################################################
# Source files to build common for platforms
######################################################################
-env.AppendUnique(CA_SRC = [os.path.join(src_dir,'cautilinterface.c')])
-
-if (('BLE' in ca_transport) or ('ALL' in ca_transport)):
- if ca_os in ['linux', 'tizen', 'arduino']:
- env.AppendUnique(CA_SRC = [
- os.path.join(src_dir,'camanager/' + ca_os + '/caleconnectionmanager.c')])
+env.AppendUnique(CA_SRC = [os.path.join('./../util/src/cautilinterface.c')])
- if ca_os == 'android':
- env.AppendUnique(CA_SRC = [
- os.path.join(src_dir,'camanager/android/caleconnectionmanager.c'),
- os.path.join(src_dir,'camanager/android/caleautoconnector.c'),
- os.path.join(src_dir,'camanager/android/camanagerleutil.c'),
- os.path.join(src_dir,'camanager/android/camanagerdevice.c')])
+if target_os == 'android':
+ if (('BLE' in ca_transport) or ('ALL' in ca_transport)):
+ env.AppendUnique(CA_SRC = [
+ os.path.join(src_dir, 'camanager', 'android', 'caleconnectionmanager.c'),
+ os.path.join(src_dir, 'camanager', 'android', 'caleautoconnector.c'),
+ os.path.join(src_dir, 'camanager', 'android', 'camanagerleutil.c'),
+ os.path.join(src_dir, 'camanager', 'android', 'camanagerdevice.c')])
-if (('BT' in ca_transport) or ('ALL' in ca_transport)):
- if ca_os == 'android':
- env.AppendUnique(CA_SRC = [
- os.path.join(src_dir,'btpairing/android/cabtpairing.c')])
\ No newline at end of file
+ if (('BT' in ca_transport) or ('ALL' in ca_transport)):
+ env.AppendUnique(CA_SRC = [
+ os.path.join(src_dir, 'btpairing' ,'android', 'cabtpairing.c')])
\ No newline at end of file
*/
CAResult_t CAUnsetLEClientAutoConnectionDeviceInfo();
-/**
- * Start advertise to receive request for scanning or connecting.
- */
-void CAStartServerLEAdvertising();
-
-/**
- * Stop advertise to destroy advertiser.
- */
-void CAStopServerLEAdvertising();
-
-#ifdef __ANDROID__
-#ifdef LE_ADAPTER
+#if defined(__ANDROID__) && defined(LE_ADAPTER)
/**
* initialize client connection manager
* @param[in] env JNI interface pointer.
*/
CAResult_t CAManagerLEClientTerminate(JNIEnv *env);
#endif
-#endif
#ifdef __cplusplus
} /* extern "C" */
/*
* Class: org_iotivity_ca_OicBtUtilClientInterface
* Method: oicEdrFoundDeviceCallback
- * Signature: (BluetoothDevice)V
+ * Signature: (Landroid/bluetooth/BluetoothDevice;)V
*/
JNIEXPORT void JNICALL
org_iotivity_ca_CaBtPairingInterface_oicEdrFoundDeviceCallback
VERIFY_NON_NULL(remote_le_address, TAG, "remote_le_address is null");
OIC_LOG(DEBUG, TAG, "IN - CAManagerStartAutoConnection");
+ ca_mutex_lock(g_connectRetryMutex);
- if (true == CAManagerGetAutoConnectionFlag(env, remote_le_address))
+ bool isAutoConnecting = false;
+ if (CA_STATUS_OK != CAManagerGetAutoConnectingFlag(env, remote_le_address, &isAutoConnecting))
{
- OIC_LOG(INFO, TAG, "auto connecting.");
+ OIC_LOG(DEBUG, TAG, "CAManagerIsAutoConnecting has failed");
+ ca_mutex_unlock(g_connectRetryMutex);
return CA_STATUS_FAILED;
}
- ca_mutex_lock(g_connectRetryMutex);
+ if (isAutoConnecting)
+ {
+ OIC_LOG(INFO, TAG, "connection has been already in progress or completed");
+ ca_mutex_unlock(g_connectRetryMutex);
+ return CA_STATUS_FAILED;
+ }
for (size_t retry_cnt = 0 ; retry_cnt < MAX_RETRY_COUNT ; retry_cnt++)
{
MAX_RETRY_COUNT - retry_cnt - 1);
if (ca_cond_wait_for(g_connectRetryCond, g_connectRetryMutex, TIMEOUT) == 0)
{
- OIC_LOG(INFO, TAG, "request to connect gatt was canceled");
ca_mutex_unlock(g_connectRetryMutex);
+ OIC_LOG(INFO, TAG, "request to connect gatt was canceled");
return CA_STATUS_OK;
}
// time out. retry connection
}
// request to connection with AutoConnection Flag
- OIC_LOG(INFO, TAG, "request to gatt connection for auto connection");
+ OIC_LOG(INFO, TAG, "request gatt connection by CM auto connector");
jobject newGatt = (jobject)CALEClientConnect(env, jni_bluetooth, JNI_TRUE);
if (NULL == newGatt)
{
}
// set flag auto connection is requested.
- CAManagerSetAutoConnectionFlag(env, remote_le_address, true);
+ CAManagerSetAutoConnectingFlag(env, remote_le_address, true);
OIC_LOG(DEBUG, TAG, "OUT - CAManagerConnectGatt");
return newGatt;
#define TAG "OIC_CA_MANAGER_LE"
-static CAAdapterStateChangedCB g_adapterStateCB = NULL;
-static CAConnectionStateChangedCB g_connStateCB = NULL;
-
static const jint SUPPORT_ADNROID_API_LEVEL = 18;
static const jint AUTH_FAIL = 5;
static const jint LINK_LOSS = 8;
static const jint ACCEPT_TIMEOUT_EXCEPTION = 16;
static const jint REMOTE_DISCONNECT = 19;
static const jint LOCAL_DISCONNECT = 22;
-static const jint CONNECTION_FAILED_TO_BE_EASTABLISHED = 62;
static const jint USER_REMOVED_BOND = 68;
static JavaVM *g_jvm = NULL;
static jobject g_context = NULL;
static jobject g_connectedDeviceSet = NULL;
-void CASetLENetworkMonitorCallbacks(CAAdapterStateChangedCB adapterStateCB,
- CAConnectionStateChangedCB connStateCB)
-{
- OIC_LOG(DEBUG, TAG, "CASetLENetworkMonitorCallbacks");
-
- g_adapterStateCB = adapterStateCB;
- g_connStateCB = connStateCB;
-}
CAResult_t CASetLEClientAutoConnectionDeviceInfo(const char* address)
{
}
isAttached = true;
}
-
OIC_LOG_V(DEBUG, TAG, "set [%s] for Auto Connection", address);
+
jstring jni_leAddress = (*env)->NewStringUTF(env, address);
+ if (!jni_leAddress)
+ {
+ OIC_LOG(ERROR, TAG, "jni_leAddress is null");
+ goto error_exit;
+ }
if (!CAManagerCheckBTAddress(env, jni_leAddress))
{
OIC_LOG(ERROR, TAG, "this address is not BT address string format");
- if (isAttached)
- {
- (*g_jvm)->DetachCurrentThread(g_jvm);
- }
- return CA_STATUS_FAILED;
+ goto error_exit;
}
- // if there is target address in SharedPreference. it will be reseted.
- if (CAManagerIsConnectedDeviceAddress(env, g_context,
- jni_leAddress,
- g_connectedDeviceSet))
+ // if there is target address in SharedPreference, it will be reset.
+ if (CAManagerIsConnectedDeviceAddress(env, g_context, jni_leAddress, g_connectedDeviceSet))
{
- if (!CAManagerRemoveConnectedDeviceAddress(env, g_context,
- jni_leAddress,
+ if (!CAManagerRemoveConnectedDeviceAddress(env, g_context, jni_leAddress,
g_connectedDeviceSet))
{
OIC_LOG(ERROR, TAG, "Preference - remove has failed");
}
// it will be added new target address.
- if (!CAManagerAddConnectedDeviceAddress(env, g_context,
- jni_leAddress, g_connectedDeviceSet))
+ if (!CAManagerAddConnectedDeviceAddress(env, g_context, jni_leAddress, g_connectedDeviceSet))
{
OIC_LOG(ERROR, TAG, "Preference - putting has failed");
}
}
return CA_STATUS_OK;
+
+error_exit:
+
+ if (isAttached)
+ {
+ (*g_jvm)->DetachCurrentThread(g_jvm);
+ }
+
+ return CA_STATUS_FAILED;
}
CAResult_t CAUnsetLEClientAutoConnectionDeviceInfo(const char* address)
}
isAttached = true;
}
-
OIC_LOG_V(DEBUG, TAG, "unset [%s] for Auto Connection", address);
+
jstring jni_leAddress = (*env)->NewStringUTF(env, address);
+ if (!jni_leAddress)
+ {
+ OIC_LOG(ERROR, TAG, "jni_leAddress is null");
+ goto error_exit;
+ }
if (!CAManagerCheckBTAddress(env, jni_leAddress))
{
OIC_LOG(ERROR, TAG, "this address is not BT address string format");
- if (isAttached)
- {
- (*g_jvm)->DetachCurrentThread(g_jvm);
- }
- return CA_STATUS_FAILED;
+ goto error_exit;
}
- // if there is target address in SharedPreference. it would be removed
- if (CAManagerIsConnectedDeviceAddress(env, g_context,
- jni_leAddress,
- g_connectedDeviceSet))
+ // if there is target address in SharedPreference, it will be removed
+ if (CAManagerIsConnectedDeviceAddress(env, g_context, jni_leAddress, g_connectedDeviceSet))
{
- if (!CAManagerRemoveConnectedDeviceAddress(env, g_context,
- jni_leAddress,
+ if (!CAManagerRemoveConnectedDeviceAddress(env, g_context, jni_leAddress,
g_connectedDeviceSet))
{
OIC_LOG(ERROR, TAG, "Preference - remove has failed");
}
// remove target device for auto connection
- CAResult_t ret = CAManagerRemoveData(env, jni_leAddress);
+ CAResult_t ret = CAManagerRemoveACData(env, jni_leAddress);
if (CA_STATUS_OK != ret)
{
- OIC_LOG(ERROR, TAG, "CAManagerRemoveData has failed");
+ OIC_LOG(ERROR, TAG, "CAManagerRemoveACData has failed");
}
if (isAttached)
(*g_jvm)->DetachCurrentThread(g_jvm);
}
- return CA_STATUS_OK;
+ return ret;
+
+error_exit:
+
+ if (isAttached)
+ {
+ (*g_jvm)->DetachCurrentThread(g_jvm);
+ }
+
+ return CA_STATUS_FAILED;
}
CAResult_t CAManagerLEClientInitialize(JNIEnv *env, JavaVM *jvm, jobject context)
g_jvm = jvm;
g_context = (*env)->NewGlobalRef(env, context);;
+
CAManagerInitMutexVaraibles();
CAManagerInitLEAutoConnection();
-
- CAManagerCreateACDataList(env);
+ CAManagerCreateACDataList();
// get last connected device list
jobject set = NULL;
{
// create new set<String> object
set = CAManagerCreateSetString(env);
- if (set)
- {
- OIC_LOG(DEBUG, TAG, "created new SetString");
- }
- else
+ if (!set)
{
OIC_LOG(ERROR, TAG, "CAManagerCreateSetString has failed");
return CA_STATUS_FAILED;
}
+ OIC_LOG(DEBUG, TAG, "created new SetString");
}
else
{
OIC_LOG(ERROR, TAG, "CALEClientDisconnectAll has failed");
}
- res = CAManagerRemoveAllData(env);
+ res = CAManagerRemoveAllACData(env);
if (CA_STATUS_OK != res)
{
- OIC_LOG(ERROR, TAG, "CAManagerRemoveAllData has failed");
+ OIC_LOG(ERROR, TAG, "CAManagerRemoveAllACData has failed");
}
+ CAManagerDestroyACDataList();
CAManagerTerminateLEAutoConnection();
CAManagerTerminateMutexVariables();
Java_org_iotivity_ca_CaLeClientInterface_caManagerAdapterStateChangedCallback(
JNIEnv *env, jobject obj, jint state)
{
- OIC_LOG(DEBUG, TAG, "caManagerAdapterStateChangedCallback");
+ OIC_LOG_V(INFO, TAG, "caManagerAdapterStateChangedCallback - state %d", state);
VERIFY_NON_NULL_VOID(env, TAG, "env");
VERIFY_NON_NULL_VOID(obj, TAG, "obj");
if (state_on == state)
{
OIC_LOG(DEBUG, TAG, "AdapterStateChangedCallback : state_on");
- if (g_adapterStateCB)
- {
- g_adapterStateCB(CA_ADAPTER_GATT_BTLE, true);
- }
// when BT state is on. recovery flag has to be reset.
CAManagerSetBTRecovery(false);
// find target device for autoconnect
size_t length = CAManagerGetACDataLength();
- OIC_LOG_V(DEBUG, TAG, "target device : %d", length);
+ OIC_LOG_V(DEBUG, TAG, "length of ACDataList : %d", length);
for (size_t idx = 0; idx < length; idx++)
{
jstring leAddress = CAManagerGetLEAddressFromACData(env, idx);
else if (state_off == state)
{
OIC_LOG(DEBUG, TAG, "AdapterStateChangedCallback : state_off");
- if (g_adapterStateCB)
- {
- g_adapterStateCB(CA_ADAPTER_GATT_BTLE, false);
- }
- // reset autoconnect flag for all target devices
+ // reset isAutoConnecting flag for all target devices
size_t length = CAManagerGetACDataLength();
+ OIC_LOG_V(DEBUG, TAG, "length of ACDataList : %d", length);
for (size_t idx = 0; idx < length; idx++)
{
jstring address = CAManagerGetLEAddressFromACData(env, idx);
if (address)
{
- CAManagerSetAutoConnectionFlag(env, address, false);
+ CAManagerSetAutoConnectingFlag(env, address, false);
}
}
else if (state_turning_off == state)
{
OIC_LOG(DEBUG, TAG, "AdapterStateChangedCallback : state_turning_off");
- return;
}
else
{
OIC_LOG(INFO, TAG, "AdapterStateChangedCallback state is not available");
- return;
}
}
Java_org_iotivity_ca_CaLeClientInterface_caManagerBondStateChangedCallback(
JNIEnv *env, jobject obj, jobject device)
{
- OIC_LOG(DEBUG, TAG, "caManagerBondStateChangedCallback");
+ OIC_LOG(INFO, TAG, "caManagerBondStateChangedCallback");
+ // this callback is called by CaLeClientInterface
+ // only when bond state is changed from BOND_BONDED to BOND_NONE
+ OIC_LOG(DEBUG, TAG, "bond state is changed from BOND_BONDED to BOND_NONE");
VERIFY_NON_NULL_VOID(env, TAG, "env");
VERIFY_NON_NULL_VOID(obj, TAG, "obj");
VERIFY_NON_NULL_VOID(device, TAG, "device");
// if there is no data, CAData will be created.
OIC_LOG_V(DEBUG, TAG, "bond none device : %s", leAddress);
- CAResult_t res = CAManagerRemoveData(env, jni_leAddress);
+ CAResult_t res = CAManagerRemoveACData(env, jni_leAddress);
if (CA_STATUS_OK != res)
{
- OIC_LOG(ERROR, TAG, "CAManagerRemoveData has failed");
+ OIC_LOG(ERROR, TAG, "CAManagerRemoveACData has failed");
}
(*env)->ReleaseStringUTFChars(env, jni_leAddress, leAddress);
- if (!CAManagerRemoveConnectedDeviceAddress(env, g_context,
- jni_leAddress,
+ if (!CAManagerRemoveConnectedDeviceAddress(env, g_context, jni_leAddress,
g_connectedDeviceSet))
{
OIC_LOG(ERROR, TAG, "CAManagerRemoveConnectedDeviceAddress has failed");
}
-
- OIC_LOG(INFO, TAG, "bonded state changed bone_none");
}
JNIEXPORT void JNICALL
Java_org_iotivity_ca_CaLeClientInterface_caManagerLeGattConnectionStateChangeCB(
JNIEnv *env, jobject obj, jobject gatt, jint status, jint newState)
{
- OIC_LOG_V(DEBUG, TAG, "caManagerLeGattConnectionStateChangeCB-status(%d), newState(%d)",
+ OIC_LOG_V(INFO, TAG, "caManagerLeGattConnectionStateChangeCB - status %d, newState %d",
status, newState);
VERIFY_NON_NULL_VOID(env, TAG, "env");
jint state_connected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE, "STATE_CONNECTED");
jint state_disconnected = CALEGetConstantsValue(env, CLASSPATH_BT_PROFILE, "STATE_DISCONNECTED");
- jint gatt_success = CALEGetConstantsValue(env, CLASSPATH_BT_GATT, "GATT_SUCCESS");
- jstring jni_address = CAManagerGetAddressFromGatt(env, gatt);
+ jstring jni_address = CALEGetAddressFromGatt(env, gatt);
if (!jni_address)
{
- OIC_LOG(ERROR, TAG, "CAManagerGetAddressFromGatt is null");
+ OIC_LOG(ERROR, TAG, "CALEGetAddressFromGatt is null");
return;
}
if (!address)
{
OIC_LOG(ERROR, TAG, "address is null");
+ (*env)->DeleteLocalRef(env, jni_address);
return;
}
- OIC_LOG_V(INFO, TAG, "connection state : status(%d), addr:(%s), newState(%d)",
- status, address, newState);
+ OIC_LOG_V(DEBUG, TAG, "caManagerLeGattConnectionStateChangeCB - address [%s]", address);
- if (gatt_success == status && state_connected == newState) // le connected
+ if (GATT_SUCCESS == status && state_connected == newState) // le connected
{
OIC_LOG(DEBUG, TAG, "LE is connected");
+
CAResult_t res = CAManagerReadRemoteRssi(env, gatt);
if (CA_STATUS_OK != res)
{
OIC_LOG(ERROR, TAG, "CAManagerReadRemoteRssi has failed");
- (*env)->ReleaseStringUTFChars(env, jni_address, address);
- return;
+ goto exit;
}
}
else if (state_disconnected == newState)// le disconnected
{
+ OIC_LOG(DEBUG, TAG, "LE is disconnected");
+
if (LINK_LOSS == status || REMOTE_DISCONNECT == status)
{
- OIC_LOG(DEBUG, TAG, "LE is disconnected");
-
- if (g_connStateCB)
- {
- OIC_LOG_V(DEBUG, TAG, "LE Disconnected state is %d, %s", newState, address);
- g_connStateCB(CA_ADAPTER_GATT_BTLE, address, false);
- OIC_LOG(DEBUG, TAG, "LE Disconnected state callback is called");
- }
-
- if (!CAManagerIsMatchedACData(env, jni_address))
+ if (!CAManagerIsInACDataList(env, jni_address))
{
OIC_LOG_V(DEBUG, TAG, "this[%s] is not target address for Auto Connection",
address);
- (*env)->ReleaseStringUTFChars(env, jni_address, address);
- return;
+ goto exit;
}
- CAManagerSetAutoConnectionFlag(env, jni_address, false);
+ CAManagerSetAutoConnectingFlag(env, jni_address, false);
CAResult_t res = CAManagerStartAutoConnection(env, jni_address);
if (CA_STATUS_OK != res)
{
- (*env)->ReleaseStringUTFChars(env, jni_address, address);
OIC_LOG(ERROR, TAG, "CAManagerStartAutoConnection has failed");
- return;
+ goto exit;
}
}
else if (ACCEPT_TIMEOUT_EXCEPTION == status)
CAManagerProcessRecovery(env, START_RECOVERY);
}
}
+
+exit:
(*env)->ReleaseStringUTFChars(env, jni_address, address);
(*env)->DeleteLocalRef(env, jni_address);
}
jobject gatt,
jint status)
{
- OIC_LOG_V(DEBUG, TAG, "caManagerLeServicesDiscoveredCallback - status %d: ", status);
+ OIC_LOG_V(INFO, TAG, "caManagerLeServicesDiscoveredCallback - status %d", status);
VERIFY_NON_NULL_VOID(env, TAG, "env");
VERIFY_NON_NULL_VOID(obj, TAG, "obj");
VERIFY_NON_NULL_VOID(gatt, TAG, "gatt");
return;
}
- jstring jni_address = CAManagerGetAddressFromGatt(env, gatt);
+ jstring jni_address = CALEGetAddressFromGatt(env, gatt);
if (!jni_address)
{
- OIC_LOG(ERROR, TAG, "CAManagerGetAddressFromGatt is null");
+ OIC_LOG(ERROR, TAG, "CALEGetAddressFromGatt is null");
return;
}
(*env)->DeleteLocalRef(env, jni_address);
return;
}
- OIC_LOG_V(DEBUG, TAG, "ServicesDiscovered device : %s", address);
- // target address for auto connection will be set in device list.
- // check set connected address information by user
- jclass jni_cls_set = (*env)->FindClass(env, "java/util/HashSet");
- if (!jni_cls_set)
- {
- OIC_LOG(ERROR, TAG, "jni_cls_set is null");
- (*env)->ReleaseStringUTFChars(env, jni_address, address);
- (*env)->DeleteLocalRef(env, jni_address);
- return;
- }
-
- jmethodID jni_mid_iterator = (*env)->GetMethodID(env, jni_cls_set, "iterator",
- "()Ljava/util/Iterator;");
- if (!jni_mid_iterator)
- {
- OIC_LOG(ERROR, TAG, "jni_mid_iterator is null");
- (*env)->DeleteLocalRef(env, jni_cls_set);
- (*env)->ReleaseStringUTFChars(env, jni_address, address);
- (*env)->DeleteLocalRef(env, jni_address);
- return;
- }
-
- jobject jni_obj_iter = (*env)->CallObjectMethod(env, g_connectedDeviceSet, jni_mid_iterator);
- if (!jni_obj_iter)
- {
- OIC_LOG(ERROR, TAG, "jni_obj_iter is null");
- (*env)->DeleteLocalRef(env, jni_cls_set);
- (*env)->ReleaseStringUTFChars(env, jni_address, address);
- (*env)->DeleteLocalRef(env, jni_address);
- return;
- }
-
- // Get the Iterator method IDs
- jclass jni_cls_iterator = (*env)->FindClass(env, "java/util/Iterator");
- if (!jni_cls_iterator)
- {
- OIC_LOG(ERROR, TAG, "jni_cls_iterator is null");
- (*env)->DeleteLocalRef(env, jni_obj_iter);
- (*env)->DeleteLocalRef(env, jni_cls_set);
- (*env)->ReleaseStringUTFChars(env, jni_address, address);
- (*env)->DeleteLocalRef(env, jni_address);
- return;
- }
-
- jmethodID jni_mid_hasNext = (*env)->GetMethodID(env, jni_cls_iterator, "hasNext", "()Z");
- if (!jni_mid_hasNext)
- {
- OIC_LOG(ERROR, TAG, "jni_mid_hasNext is null");
- (*env)->DeleteLocalRef(env, jni_cls_iterator);
- (*env)->DeleteLocalRef(env, jni_obj_iter);
- (*env)->DeleteLocalRef(env, jni_cls_set);
- (*env)->ReleaseStringUTFChars(env, jni_address, address);
- (*env)->DeleteLocalRef(env, jni_address);
- return;
- }
-
- jmethodID jni_mid_next = (*env)->GetMethodID(env, jni_cls_iterator, "next",
- "()Ljava/lang/Object;");
- if (!jni_mid_next)
- {
- OIC_LOG(ERROR, TAG, "jni_mid_next is null");
- (*env)->DeleteLocalRef(env, jni_cls_iterator);
- (*env)->DeleteLocalRef(env, jni_obj_iter);
- (*env)->DeleteLocalRef(env, jni_cls_set);
- (*env)->ReleaseStringUTFChars(env, jni_address, address);
- (*env)->DeleteLocalRef(env, jni_address);
- return;
- }
+ OIC_LOG_V(DEBUG, TAG, "ServicesDiscovered device : %s", address);
- // Iterate over the entry Set
- while ((*env)->CallBooleanMethod(env, jni_obj_iter, jni_mid_hasNext))
+ if (CAManagerIsConnectedDeviceAddress(env, g_context, jni_address, g_connectedDeviceSet))
{
- jstring jni_str_entry = (jstring)(*env)->CallObjectMethod(env, jni_obj_iter,
- jni_mid_next);
- if (!jni_str_entry)
- {
- OIC_LOG(ERROR, TAG, "jni_str_entry is null");
- (*env)->DeleteLocalRef(env, jni_cls_iterator);
- (*env)->DeleteLocalRef(env, jni_obj_iter);
- (*env)->DeleteLocalRef(env, jni_cls_set);
- (*env)->ReleaseStringUTFChars(env, jni_address, address);
- (*env)->DeleteLocalRef(env, jni_address);
- return;
- }
- const char* foundAddress = (*env)->GetStringUTFChars(env, jni_str_entry, NULL);
- if (!foundAddress)
- {
- OIC_LOG(ERROR, TAG, "addr is null");
- (*env)->DeleteLocalRef(env, jni_str_entry);
- (*env)->DeleteLocalRef(env, jni_cls_iterator);
- (*env)->DeleteLocalRef(env, jni_obj_iter);
- (*env)->DeleteLocalRef(env, jni_cls_set);
- (*env)->ReleaseStringUTFChars(env, jni_address, address);
- (*env)->DeleteLocalRef(env, jni_address);
- return;
- }
- OIC_LOG_V(INFO, TAG, "found last connected address [%s] from SharedPreferences",
- foundAddress);
-
- if (!strcmp(foundAddress, address))
- {
- // if BLE address is matched each other
- // this address will be added into auto connection list.
- OIC_LOG(INFO, TAG, "AC list - address will be added into ACData list");
- CAManagerAddACData(env, jni_address);
- CAManagerSetAutoConnectionFlag(env, jni_address, false);
-
- // next connection will be requested as JNI_TRUE flag
- // after first connection
- CALEClientSetAutoConnectFlag(env, jni_str_entry, JNI_TRUE);
- }
- else
- {
- OIC_LOG(INFO, TAG, "AC list - device is not matched");
- }
+ OIC_LOG(INFO, TAG, "AC list - the address will be added to ACData list");
+ CAManagerAddACData(env, jni_address);
+ CAManagerSetAutoConnectingFlag(env, jni_address, false);
- (*env)->ReleaseStringUTFChars(env, jni_str_entry, foundAddress);
- (*env)->DeleteLocalRef(env, jni_str_entry);
+ // next connection will be requested with JNI_TRUE on autoConnect flag
+ // after first connection
+ CALEClientSetFlagToState(env, jni_address, CA_LE_AUTO_CONNECT_FLAG, JNI_TRUE);
}
-
- if (g_connStateCB)
+ else
{
- g_connStateCB(CA_ADAPTER_GATT_BTLE, address, true);
- OIC_LOG(DEBUG, TAG, "LE Connected callback is called");
+ OIC_LOG(DEBUG, TAG, "AC list - the address is not set to AutoConnect");
}
- (*env)->DeleteLocalRef(env, jni_cls_iterator);
- (*env)->DeleteLocalRef(env, jni_obj_iter);
- (*env)->DeleteLocalRef(env, jni_cls_set);
(*env)->ReleaseStringUTFChars(env, jni_address, address);
(*env)->DeleteLocalRef(env, jni_address);
+
OIC_LOG(INFO, TAG, "ServicesDiscovery is successful");
}
else
jstring CAManagerGetLEAddressFromACData(JNIEnv *env, size_t idx)
{
- OIC_LOG(DEBUG, TAG, "CAManagerGetLEAddressFromACData");
- OIC_LOG_V(DEBUG, TAG, "idx : %d", idx);
+ OIC_LOG_V(DEBUG, TAG, "CAManagerGetLEAddressFromACData (idx : %d)", idx);
if (idx <= u_arraylist_length(g_deviceACDataList))
{
CAManagerACData_t *curData = (CAManagerACData_t *) u_arraylist_get(
OIC_LOG(ERROR, TAG, "address is null");
return NULL;
}
- OIC_LOG_V(INFO, TAG, "found out target address : %s", address);
+ OIC_LOG_V(INFO, TAG, "found target address : %s", address);
(*env)->ReleaseStringUTFChars(env, curData->address, address);
return curData->address;
}
+ OIC_LOG(DEBUG, TAG, "idx is greater than the length of ACDataList");
return NULL;
}
-void CAManagerCreateACDataList(JNIEnv *env)
+void CAManagerCreateACDataList()
{
OIC_LOG(DEBUG, TAG, "CAManagerCreateACDataList");
- VERIFY_NON_NULL_VOID(env, TAG, "env");
ca_mutex_lock(g_deviceACDataListMutex);
- // create new object array
- if (g_deviceACDataList == NULL)
+ if (NULL == g_deviceACDataList)
{
OIC_LOG(DEBUG, TAG, "Create AC Data list");
-
g_deviceACDataList = u_arraylist_create();
}
ca_mutex_unlock(g_deviceACDataListMutex);
}
+void CAManagerDestroyACDataList()
+{
+ OIC_LOG(DEBUG, TAG, "CAManagerDestroyACDataList");
+ if (g_deviceACDataList)
+ {
+ OIC_LOG(DEBUG, TAG, "Destroy AC Data list");
+ u_arraylist_free(&g_deviceACDataList);
+ g_deviceACDataList = NULL;
+ }
+}
+
CAResult_t CAManagerInitMutexVaraibles()
{
if (NULL == g_deviceACDataListMutex)
static CAManagerACData_t *CAManagerCreateACData(jstring jaddress)
{
- OIC_LOG(DEBUG, TAG, "IN-CAManagerCreateACData");
+ OIC_LOG(DEBUG, TAG, "IN - CAManagerCreateACData");
VERIFY_NON_NULL_RET(jaddress, TAG, "jaddress", NULL);
- // create block data
+ // create AC data
CAManagerACData_t *data = (CAManagerACData_t *) OICCalloc(1, sizeof(*data));
if (!data)
{
}
data->address = jaddress;
- data->isAutoConnect = false;
+ data->isAutoConnecting = false;
- OIC_LOG(DEBUG, TAG, "OUT-CAManagerCreateACData");
+ OIC_LOG(DEBUG, TAG, "OUT - CAManagerCreateACData");
return data;
}
-bool CAManagerIsMatchedACData(JNIEnv *env, jstring jaddress)
+bool CAManagerIsInACDataList(JNIEnv *env, jstring jaddress)
{
VERIFY_NON_NULL_RET(env, TAG, "env", NULL);
VERIFY_NON_NULL_RET(jaddress, TAG, "jaddress", false);
+ ca_mutex_lock(g_deviceACDataListMutex);
+
const char* address = (*env)->GetStringUTFChars(env, jaddress, NULL);
if (!address)
{
OIC_LOG(ERROR, TAG, "address is null");
+ ca_mutex_unlock(g_deviceACDataListMutex);
return false;
}
{
OIC_LOG(ERROR, TAG, "curData is null");
(*env)->ReleaseStringUTFChars(env, jaddress, address);
+ ca_mutex_unlock(g_deviceACDataListMutex);
return false;
}
{
OIC_LOG(ERROR, TAG, "address is null");
(*env)->ReleaseStringUTFChars(env, jaddress, address);
+ ca_mutex_unlock(g_deviceACDataListMutex);
return false;
}
{
(*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
(*env)->ReleaseStringUTFChars(env, jaddress, address);
+ ca_mutex_unlock(g_deviceACDataListMutex);
return true;
}
(*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
}
+
+ OIC_LOG_V(DEBUG, TAG, "[%s] doesn't exist in list", address);
(*env)->ReleaseStringUTFChars(env, jaddress, address);
+ ca_mutex_unlock(g_deviceACDataListMutex);
return false;
}
void CAManagerAddACData(JNIEnv *env, jstring jaddress)
{
- OIC_LOG(DEBUG, TAG, "IN-CAManagerAddACData");
+ OIC_LOG(DEBUG, TAG, "IN - CAManagerAddACData");
VERIFY_NON_NULL_VOID(env, TAG, "env");
VERIFY_NON_NULL_VOID(jaddress, TAG, "jaddress");
- ca_mutex_lock(g_deviceACDataListMutex);
-
- if(!CAManagerIsMatchedACData(env, jaddress))
+ if(!CAManagerIsInACDataList(env, jaddress))
{
- OIC_LOG(DEBUG, TAG, "ACdata will be added");
+ OIC_LOG(DEBUG, TAG, "new ACdata will be added in List");
// add CAManagerACData
jobject gaddress = (*env)->NewGlobalRef(env, jaddress);
CAManagerACData_t *data = CAManagerCreateACData(gaddress);
+
+ ca_mutex_lock(g_deviceACDataListMutex);
u_arraylist_add(g_deviceACDataList, data);
+ ca_mutex_unlock(g_deviceACDataListMutex);
+ }
+ else
+ {
+ OIC_LOG(DEBUG, TAG, "the address is already in ACData list");
}
- ca_mutex_unlock(g_deviceACDataListMutex);
- OIC_LOG(DEBUG, TAG, "OUT-CAManagerAddACData");
+ OIC_LOG(DEBUG, TAG, "OUT - CAManagerAddACData");
}
-CAResult_t CAManagerRemoveData(JNIEnv *env, jstring jaddress)
+CAResult_t CAManagerRemoveACData(JNIEnv *env, jstring jaddress)
{
- OIC_LOG(DEBUG, TAG, "IN-CAManagerRemoveData");
+ OIC_LOG(DEBUG, TAG, "CAManagerRemoveACData");
VERIFY_NON_NULL(env, TAG, "env");
VERIFY_NON_NULL(jaddress, TAG, "jaddress");
return CA_STATUS_FAILED;
}
- OIC_LOG_V(DEBUG, TAG, "(%s) will be removed", address);
+ OIC_LOG_V(DEBUG, TAG, "[%s] will be removed", address);
size_t length = u_arraylist_length(g_deviceACDataList);
for (size_t idx = 0; idx < length; idx++)
(*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
}
+ OIC_LOG_V(DEBUG, TAG, "[%s] doesn't exist in list", address);
(*env)->ReleaseStringUTFChars(env, jaddress, address);
ca_mutex_unlock(g_deviceACDataListMutex);
- OIC_LOG(DEBUG, TAG, "OUT-CAManagerRemoveData");
+
return CA_STATUS_OK;
}
-CAResult_t CAManagerRemoveAllData(JNIEnv *env)
+CAResult_t CAManagerRemoveAllACData(JNIEnv *env)
{
- OIC_LOG(DEBUG, TAG, "IN-CAManagerRemoveAllData");
+ OIC_LOG(DEBUG, TAG, "IN - CAManagerRemoveAllACData");
VERIFY_NON_NULL(env, TAG, "env");
ca_mutex_lock(g_deviceACDataListMutex);
OICFree(curData);
}
ca_mutex_unlock(g_deviceACDataListMutex);
- OIC_LOG(DEBUG, TAG, "OUT-CAManagerRemoveAllData");
+ OIC_LOG(DEBUG, TAG, "OUT - CAManagerRemoveAllACData");
return CA_STATUS_OK;
}
-bool CAManagerGetAutoConnectionFlag(JNIEnv *env, jstring jaddress)
+CAResult_t CAManagerGetAutoConnectingFlag(JNIEnv *env, jstring jaddress, bool *flag)
{
- OIC_LOG(DEBUG, TAG, "IN-CAManagerGetAutoConnectionFlag");
- VERIFY_NON_NULL_RET(env, TAG, "env", NULL);
- VERIFY_NON_NULL_RET(jaddress, TAG, "jaddress", NULL);
+ OIC_LOG(DEBUG, TAG, "CAManagerGetAutoConnectingFlag");
+ VERIFY_NON_NULL(env, TAG, "env");
+ VERIFY_NON_NULL(jaddress, TAG, "jaddress");
ca_mutex_lock(g_deviceACDataListMutex);
if (!strcmp(setAddress, address))
{
+ OIC_LOG_V(DEBUG, TAG, "address : [%s], isAutoConnecting : %d", address,
+ curData->isAutoConnecting);
+ *flag = curData->isAutoConnecting;
(*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
(*env)->ReleaseStringUTFChars(env, jaddress, address);
ca_mutex_unlock(g_deviceACDataListMutex);
- OIC_LOG_V(DEBUG, TAG, "flag is %d", curData->isAutoConnect);
- return curData->isAutoConnect;
+ return CA_STATUS_OK;
}
(*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
}
+
+ OIC_LOG_V(DEBUG, TAG, "[%s] doesn't exist in list", address);
(*env)->ReleaseStringUTFChars(env, jaddress, address);
ca_mutex_unlock(g_deviceACDataListMutex);
- OIC_LOG(DEBUG, TAG, "OUT-CAManagerGetAutoConnectionFlag");
- return false;
+ return CA_STATUS_FAILED;
}
-void CAManagerSetAutoConnectionFlag(JNIEnv *env, jstring jaddress, bool flag)
+bool CAManagerSetAutoConnectingFlag(JNIEnv *env, jstring jaddress, bool flag)
{
- OIC_LOG(DEBUG, TAG, "IN-CAManagerSetAutoConnectionFlag");
- VERIFY_NON_NULL_VOID(env, TAG, "env");
- VERIFY_NON_NULL_VOID(jaddress, TAG, "jaddress");
+ OIC_LOG(DEBUG, TAG, "CAManagerSetAutoConnectingFlag");
+ VERIFY_NON_NULL_RET(env, TAG, "env", false);
+ VERIFY_NON_NULL_RET(jaddress, TAG, "jaddress", false);
ca_mutex_lock(g_deviceACDataListMutex);
{
OIC_LOG(ERROR, TAG, "address is null");
ca_mutex_unlock(g_deviceACDataListMutex);
- return;
+ return false;
}
size_t length = u_arraylist_length(g_deviceACDataList);
OIC_LOG(ERROR, TAG, "curData is null");
(*env)->ReleaseStringUTFChars(env, jaddress, address);
ca_mutex_unlock(g_deviceACDataListMutex);
- return;
+ return false;
}
const char* setAddress = (*env)->GetStringUTFChars(env, curData->address, NULL);
OIC_LOG(ERROR, TAG, "address is null");
(*env)->ReleaseStringUTFChars(env, jaddress, address);
ca_mutex_unlock(g_deviceACDataListMutex);
- return;
+ return false;
}
if (!strcmp(setAddress, address))
{
- OIC_LOG_V(DEBUG, TAG, "flag is set to %d", flag);
- curData->isAutoConnect = flag;
+ OIC_LOG_V(DEBUG, TAG, "isAutoConnecting flag of [%s] is set to %d", address,
+ curData->isAutoConnecting);
+ curData->isAutoConnecting = flag;
(*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
(*env)->ReleaseStringUTFChars(env, jaddress, address);
ca_mutex_unlock(g_deviceACDataListMutex);
- return;
+ return true;
}
(*env)->ReleaseStringUTFChars(env, curData->address, setAddress);
}
+
+ OIC_LOG_V(DEBUG, TAG, "[%s] doesn't exist in list", address);
(*env)->ReleaseStringUTFChars(env, jaddress, address);
ca_mutex_unlock(g_deviceACDataListMutex);
- OIC_LOG(DEBUG, TAG, "OUT-CAManagerSetAutoConnectionFlag");
+ return false;
}
size_t CAManagerGetACDataLength()
void CAManagerSetBTRecovery(bool flag)
{
g_isBTRecovery = flag;
- OIC_LOG_V(DEBUG, TAG, "BT recovery flag : %d", g_isBTRecovery);
+ OIC_LOG_V(DEBUG, TAG, "BT recovery flag is set to %d", g_isBTRecovery);
}
bool CAManagerIsRecoveryFlagSet()
*/
typedef struct
{
- jstring address; /**< remote address */
- bool isAutoConnect; /**< auto connection flag */
+ jstring address; /**< remote address */
+ bool isAutoConnecting; /**< whether GATT connection has been in progress */
} CAManagerACData_t;
/**
/**
* create auto connection list.
- * @param[in] env JNI interface pointer.
*/
-void CAManagerCreateACDataList(JNIEnv *env);
+void CAManagerCreateACDataList();
+
+/**
+ * Destroy auto connection list.
+ */
+void CAManagerDestroyACDataList();
/**
* initialize mutex.
void CAManagerTerminateMutexVariables();
/**
- * check whether target address is already contained in list or not.
+ * check whether target address is already contained in ACData list or not.
* @param[in] env JNI interface pointer.
* @param[in] jaddress ble address.
*/
-bool CAManagerIsMatchedACData(JNIEnv *env, jstring jaddress);
+bool CAManagerIsInACDataList(JNIEnv *env, jstring jaddress);
/**
* add auto connection data into list.
void CAManagerAddACData(JNIEnv *env, jstring jaddress);
/**
- * remove auto connection data for selected ble address.
+ * remove auto connection data from ACData list for selected ble address.
* @param[in] env JNI interface pointer.
* @param[in] jaddress ble address.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
-CAResult_t CAManagerRemoveData(JNIEnv *env, jstring jaddress);
+CAResult_t CAManagerRemoveACData(JNIEnv *env, jstring jaddress);
/**
- * remove auto connection data for all devices.
+ * remove auto connection data from ACData list for all devices.
* @param[in] env JNI interface pointer.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
-CAResult_t CAManagerRemoveAllData(JNIEnv *env);
+CAResult_t CAManagerRemoveAllACData(JNIEnv *env);
/**
- * get current auto connection flag.
+ * get isAutoConnecting flag for the address.
* @param[in] env JNI interface pointer.
* @param[in] jaddress ble address.
- * @return true or false
+ * @param[out] flag isAutoConnecting flag
+ * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
*/
-bool CAManagerGetAutoConnectionFlag(JNIEnv *env, jstring jaddress);
+CAResult_t CAManagerGetAutoConnectingFlag(JNIEnv *env, jstring jaddress, bool *flag);
/**
- * set auto connection flag.
+ * set isAutoConnecting flag for the address.
* @param[in] env JNI interface pointer.
* @param[in] jaddress ble address.
- * @param[in] flag auto connection flag.
+ * @param[in] flag isAutoConnecting flag.
+ * @return true or false
*/
-void CAManagerSetAutoConnectionFlag(JNIEnv *env, jstring jaddress, bool flag);
+bool CAManagerSetAutoConnectingFlag(JNIEnv *env, jstring jaddress, bool flag);
/**
* get length of auto connection list.
return jni_obj_device;
}
-jstring CAManagerGetAddressFromGatt(JNIEnv *env, jobject gatt)
-{
- OIC_LOG(DEBUG, TAG, "IN - CAManagerGetAddressFromGatt");
-
- VERIFY_NON_NULL_RET(env, TAG, "env is null", NULL);
- VERIFY_NON_NULL_RET(gatt, TAG, "gatt is null", NULL);
-
- jclass jni_cid_gattdevice_list = (*env)->FindClass(env, CLASSPATH_BT_GATT);
- if (!jni_cid_gattdevice_list)
- {
- OIC_LOG(ERROR, TAG, "jni_cid_gattdevice_list is null");
- return NULL;
- }
-
- jmethodID jni_mid_getDevice = (*env)->GetMethodID(env, jni_cid_gattdevice_list, "getDevice",
- METHODID_BT_DEVICE);
- if (!jni_mid_getDevice)
- {
- OIC_LOG(ERROR, TAG, "jni_mid_getDevice is null");
- return NULL;
- }
-
- jobject jni_obj_device = (*env)->CallObjectMethod(env, gatt, jni_mid_getDevice);
- if (!jni_obj_device)
- {
- OIC_LOG(ERROR, TAG, "jni_obj_device is null");
- return NULL;
- }
-
- jstring jni_address = CALEGetAddressFromBTDevice(env, jni_obj_device);
- if (!jni_address)
- {
- OIC_LOG(ERROR, TAG, "jni_address is null");
- return NULL;
- }
-
- OIC_LOG(DEBUG, TAG, "OUT - CAManagerGetAddressFromGatt");
- return jni_address;
-}
-
bool CAManagerIsDeviceBonded(JNIEnv *env, jobject btDevice)
{
OIC_LOG(DEBUG, TAG, "IN - CAManagerIsDeviceBonded");
bool CAManagerRemoveConnectedDeviceAddress(JNIEnv *env, jobject context,
jstring address, jobject set)
{
- OIC_LOG(DEBUG, TAG, "IN-CAManagerRemoveConnectedDeviceAddress");
+ OIC_LOG(DEBUG, TAG, "CAManagerRemoveConnectedDeviceAddress");
VERIFY_NON_NULL_RET(env, TAG, "env", false);
VERIFY_NON_NULL_RET(context, TAG, "context", false);
jobject CAManagerGetRemoteDevice(JNIEnv *env, jstring address);
/**
- * get address from gatt profile object.
- * @param[in] env JNI interface pointer.
- * @param[in] gatt gatt profile object.
- * @return LE address.
- */
-jstring CAManagerGetAddressFromGatt(JNIEnv *env, jobject gatt);
-
-/**
* check whether the devie is bonded or not.
* @param[in] env JNI interface pointer.
* @param[in] btDevice bluetooth device object.
+++ /dev/null
-/* ****************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * 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.
- *
- ******************************************************************/
-
-#include "camanagerleinterface.h"
-#include "cacommon.h"
-#include "logger.h"
-
-#define TAG "OIC_CA_MANAGER_AR_LE"
-
-static CAAdapterStateChangedCB g_adapterStateCB = NULL;
-static CAConnectionStateChangedCB g_connStateCB = NULL;
-
-void CASetLENetworkMonitorCallbacks(CAAdapterStateChangedCB adapterStateCB,
- CAConnectionStateChangedCB connStateCB)
-{
- OIC_LOG(DEBUG, TAG, "CASetLENetworkMonitorCallbacks");
-
- g_adapterStateCB = adapterStateCB;
- g_connStateCB = connStateCB;
-}
-
-CAResult_t CASetLEClientAutoConnectionDeviceInfo(const char * address)
-{
- OIC_LOG(DEBUG, TAG, "CASetClientAutoConnectionDeviceInfo");
- (void)address;
- return CA_NOT_SUPPORTED;
-}
-
-CAResult_t CAUnsetLEClientAutoConnectionDeviceInfo(const char * address)
-{
- OIC_LOG(DEBUG, TAG, "CAUnsetClientAutoConnectionDeviceInfo");
- (void)address;
- return CA_NOT_SUPPORTED;
-}
-
-void CAStartServerLEAdvertising()
-{
- OIC_LOG(DEBUG, TAG, "CAStartServerLEAdvertising");
-}
-
-void CAStopServerLEAdvertising()
-{
- OIC_LOG(DEBUG, TAG, "CAStopServerLEAdvertising");
-}
+++ /dev/null
-/* ****************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * 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.
- *
- ******************************************************************/
-
-#include "camanagerleinterface.h"
-#include "cacommon.h"
-#include "logger.h"
-
-#define TAG "OIC_CA_MANAGER_LI_LE"
-
-static CAAdapterStateChangedCB g_adapterStateCB = NULL;
-static CAConnectionStateChangedCB g_connStateCB = NULL;
-
-void CASetLENetworkMonitorCallbacks(CAAdapterStateChangedCB adapterStateCB,
- CAConnectionStateChangedCB connStateCB)
-{
- OIC_LOG(DEBUG, TAG, "CASetLENetworkMonitorCallbacks");
-
- g_adapterStateCB = adapterStateCB;
- g_connStateCB = connStateCB;
-}
-
-CAResult_t CASetLEClientAutoConnectionDeviceInfo(const char * address)
-{
- OIC_LOG(DEBUG, TAG, "CASetLEClientAutoConnectionDeviceInfo");
- (void)address;
- return CA_NOT_SUPPORTED;
-}
-
-CAResult_t CAUnsetLEClientAutoConnectionDeviceInfo(const char * address)
-{
- OIC_LOG(DEBUG, TAG, "CAUnsetLEClientAutoConnectionDeviceInfo");
- (void)address;
- return CA_NOT_SUPPORTED;
-}
-
-void CAStartServerLEAdvertising()
-{
- OIC_LOG(DEBUG, TAG, "CAStartServerLEAdvertising");
-}
-
-void CAStopServerLEAdvertising()
-{
- OIC_LOG(DEBUG, TAG, "CAStopServerLEAdvertising");
-}
#include "camanagerleinterface.h"
#include "cabtpairinginterface.h"
#include "cautilinterface.h"
-
+#include "cainterfacecontroller.h"
#include "cacommon.h"
#include "logger.h"
#define TAG "OIC_CA_COMMON_UTILS"
+static CAAdapterStateChangedCB g_adapterStateCB = NULL;
+static CAConnectionStateChangedCB g_connStateCB = NULL;
+
+static void CAManagerAdapterMonitorHandler(CATransportAdapter_t adapter,
+ CANetworkStatus_t status)
+{
+ if (CA_INTERFACE_DOWN == status)
+ {
+ if (g_adapterStateCB)
+ {
+ g_adapterStateCB(adapter, false);
+ OIC_LOG(DEBUG, TAG, "Pass the disabled adapter state to upper layer");
+ }
+ }
+ else if (CA_INTERFACE_UP == status)
+ {
+ if (g_adapterStateCB)
+ {
+ g_adapterStateCB(adapter, true);
+ OIC_LOG(DEBUG, TAG, "Pass the enabled adapter state to upper layer");
+ }
+ }
+}
+
+static void CAManagerConnectionMonitorHandler(const CAEndpoint_t *info, bool isConnected)
+{
+ if (!info || !info->addr)
+ {
+ OIC_LOG(ERROR, TAG, "remoteAddress is NULL");
+ return;
+ }
+
+ if (isConnected)
+ {
+ if (g_connStateCB)
+ {
+ g_connStateCB(info->adapter, info->addr, isConnected);
+ OIC_LOG(DEBUG, TAG, "Pass the connected device info to upper layer");
+ }
+ }
+ else
+ {
+ if (g_connStateCB)
+ {
+ g_connStateCB(info->adapter, info->addr, isConnected);
+ OIC_LOG(DEBUG, TAG, "Pass the disconnected device info to upper layer");
+ }
+ }
+}
+
CAResult_t CARegisterNetworkMonitorHandler(CAAdapterStateChangedCB adapterStateCB,
CAConnectionStateChangedCB connStateCB)
{
OIC_LOG(DEBUG, TAG, "CARegisterNetworkMonitorHandler");
-#ifdef LE_ADAPTER
- CASetLENetworkMonitorCallbacks(adapterStateCB, connStateCB);
- return CA_STATUS_OK;
-#else
- (void)adapterStateCB;
- (void)connStateCB;
- return CA_NOT_SUPPORTED;
-#endif
+ g_adapterStateCB = adapterStateCB;
+ g_connStateCB = connStateCB;
+ CASetNetworkMonitorCallbacks(CAManagerAdapterMonitorHandler,
+ CAManagerConnectionMonitorHandler);
+ return CA_STATUS_OK;
}
CAResult_t CASetAutoConnectionDeviceInfo(const char *address)
{
OIC_LOG(DEBUG, TAG, "CASetAutoConnectionDeviceInfo");
-#ifdef LE_ADAPTER
+#if defined(__ANDROID__) && defined(LE_ADAPTER)
return CASetLEClientAutoConnectionDeviceInfo(address);
#else
(void)address;
{
OIC_LOG(DEBUG, TAG, "CAUnsetAutoConnectionDeviceInfo");
-#ifdef LE_ADAPTER
+#if defined(__ANDROID__) && defined(LE_ADAPTER)
return CAUnsetLEClientAutoConnectionDeviceInfo(address);
#else
(void)address;
#endif
#ifdef __TIZEN__
-#define OCLog(level,tag,mes)
-#define OCLogv(level,tag,fmt,args...)
+/**
+ * Output the contents of the specified buffer (in hex) with the specified priority level.
+ *
+ * @param[in] level DEBUG, INFO, WARNING, ERROR, FATAL
+ * @param[in] tag Module name
+ * @param[in] buffer pointer to buffer of bytes
+ * @param[in] bufferSize max number of byte in buffer
+ */
+void OCLogBuffer(LogLevel level, const char * tag, const uint8_t * buffer, uint16_t bufferSize);
+
+#define OCLog(level,tag,mes) LOG_(LOG_ID_MAIN, (level), (tag), mes)
+#define OCLogv(level,tag,fmt,args...) LOG_(LOG_ID_MAIN, (level),tag,fmt,##args)
#elif defined(ANDROID) || defined(__linux__) || defined(__APPLE__)
/**
* Configure logger to use a context that defines a custom logger function
#define OIC_LOG(level,tag,mes) LOG_(LOG_ID_MAIN, (level), (tag), mes)
#define OIC_LOG_V(level,tag,fmt,args...) LOG_(LOG_ID_MAIN, level, tag, fmt, ##args)
-#define OIC_LOG_BUFFER(level, tag, buffer, bufferSize)
+#define OIC_LOG_BUFFER(level, tag, buffer, bufferSize)\
+ OCLogBuffer((level), (tag), (buffer), (bufferSize))
#else // These macros are defined for Linux, Android, and Arduino
#endif
#endif // __ANDROID__
-
#ifndef ARDUINO
+
+/**
+ * Output the contents of the specified buffer (in hex) with the specified priority level.
+ *
+ * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
+ * @param tag - Module name
+ * @param buffer - pointer to buffer of bytes
+ * @param bufferSize - max number of byte in buffer
+ */
+void OCLogBuffer(LogLevel level, const char * tag, const uint8_t * buffer, uint16_t bufferSize)
+{
+ if (!buffer || !tag || (bufferSize == 0))
+ {
+ return;
+ }
+
+ // No idea why the static initialization won't work here, it seems the compiler is convinced
+ // that this is a variable-sized object.
+ char lineBuffer[LINE_BUFFER_SIZE];
+ memset(lineBuffer, 0, sizeof lineBuffer);
+ int lineIndex = 0;
+ int i;
+ for (i = 0; i < bufferSize; i++)
+ {
+ // Format the buffer data into a line
+ snprintf(&lineBuffer[lineIndex*3], sizeof(lineBuffer)-lineIndex*3, "%02X ", buffer[i]);
+ lineIndex++;
+ // Output 16 values per line
+ if (((i+1)%16) == 0)
+ {
+ OCLogv(level, tag, "%s", lineBuffer);
+ memset(lineBuffer, 0, sizeof lineBuffer);
+ lineIndex = 0;
+ }
+ }
+ // Output last values in the line, if any
+ if (bufferSize % 16)
+ {
+ OCLogv(level, tag, "%s", lineBuffer);
+ }
+}
#ifndef __TIZEN__
void OCLogConfig(oc_log_ctx_t *ctx)
{
}
#endif
}
-
-/**
- * Output the contents of the specified buffer (in hex) with the specified priority level.
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param buffer - pointer to buffer of bytes
- * @param bufferSize - max number of byte in buffer
- */
-void OCLogBuffer(LogLevel level, const char * tag, const uint8_t * buffer, uint16_t bufferSize)
-{
- if (!buffer || !tag || (bufferSize == 0))
- {
- return;
- }
-
- // No idea why the static initialization won't work here, it seems the compiler is convinced
- // that this is a variable-sized object.
- char lineBuffer[LINE_BUFFER_SIZE];
- memset(lineBuffer, 0, sizeof lineBuffer);
- int lineIndex = 0;
- int i;
- for (i = 0; i < bufferSize; i++)
- {
- // Format the buffer data into a line
- snprintf(&lineBuffer[lineIndex*3], sizeof(lineBuffer)-lineIndex*3, "%02X ", buffer[i]);
- lineIndex++;
- // Output 16 values per line
- if (((i+1)%16) == 0)
- {
- OCLog(level, tag, lineBuffer);
- memset(lineBuffer, 0, sizeof lineBuffer);
- lineIndex = 0;
- }
- }
- // Output last values in the line, if any
- if (bufferSize % 16)
- {
- OCLog(level, tag, lineBuffer);
- }
-}
#endif //__TIZEN__
#endif //ARDUINO
#ifdef ARDUINO
1) Build IoTivity with security enabled:
$ cd <iotivity-base>
- $ scons resource SECURED=1
+ $ scons SECURED=1
2) Verify functionality using secure sample apps:
$ cd <iotivity-base>/out/<...>/release/resource/csdk/stack/samples/linux/secure
uint16_t securedPort);
/*
- * Cleanup CARequestInfo_t object.
- *
- * @param requestInfo is the pointer to @ref CARequestInfo_t.
- */
-void FreeCARequestInfo(CARequestInfo_t *requestInfo);
-
-/*
* This method is used by Policy engine to checks Amacl resource.
* If Amacl is found then it fills up context->amsMgrContext->amsDeviceId
* with amsID of the Amacl else leaves it empty.
1-3. Performing ownership transfer
We provided OCDoOwnershipTransfer API to perform ownership transfer.
In order to perform ownership transfer, unowned device list is required generated by OCDiscoverUnownedDevices API.
- OCDoOwnershipTransfer will require the result callback as 3rd paramter.
+ OCDoOwnershipTransfer will require the result callback as 3rd parameter.
This callback function will be invoked when ownership transfer is finished.
You can check result of ownership transfer for each devices as array of OCProvisionResult_t.
# 7. Num. of Rowner : 1
# 8. [1]Rowner : lightDeviceUUID0
#
-# After successfull sending acl provisioning_client will ask you for CRL data:
+# After successful sending acl provisioning_client will ask you for CRL data:
# 1. Enter number of revoced certificates(1..9): 1
# 2. Revoced certificate 0: Serial number (E. g.: 100): 3
-# And then you should see message about successfull sending CRL
+# And then you should see message about successful sending CRL
#
# Note: provisioning_client send ACL and CRL only to Light sever
OicSecPconf_t *pconf, OCProvisionResultCB resultCallback);
/**
+ * API to send Direct-Pairing Configuration to a device.
+ *
+ * @param[in] selectedDeviceInfo Selected target device.
+ * @param[in] pconf PCONF pointer.
+ * @param[in] resultCallback callback provided by API user, callback will be called when
+ * provisioning request recieves a response from resource server.
+ * @return OC_STACK_OK in case of success and other value otherwise.
+ */
+OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selectedDeviceInfo,
+ OicSecPconf_t *pconf, OCProvisionResultCB resultCallback);
+
+/**
* API to provision credential to devices.
*
* @param[in] type Type of credentials to be provisioned to the device.
{
OCStackResult ret = OC_STACK_ERROR;
+ if (!context->amsMgrContext)
+ {
+ goto exit;
+ }
+
//The AmsMgr context endpoint and requestInfo will be free from ,
//AmsMgrAclReqCallback function
if (context->amsMgrContext->endpoint)
{
if (NULL == requestInfo)
{
- OIC_LOG_V(ERROR, TAG, "%s: Can't free memory. Received NULL requestInfo", __func__);
+ OIC_LOG_V(DEBUG, TAG, "%s: Can't free memory. Received NULL requestInfo", __func__);
return;
}
OICFree(requestInfo->info.token);
context->amsProcessing = false;
context->retVal = ACCESS_DENIED_POLICY_ENGINE_ERROR;
- FreeCARequestInfo(context->amsMgrContext->requestInfo);
- OICFree(context->amsMgrContext->endpoint);
- memset(context->amsMgrContext, 0, sizeof(AmsMgrContext_t));
+ if (context->amsMgrContext)
+ {
+ if (context->amsMgrContext->requestInfo)
+ {
+ FreeCARequestInfo(context->amsMgrContext->requestInfo);
+ }
+ OICFree(context->amsMgrContext->endpoint);
+ memset(context->amsMgrContext, 0, sizeof(AmsMgrContext_t));
+ }
// Set state.
context->state = state;
* API to handle the connected device for KeepAlive.
* @return Current Time.
*/
-void HandleKeepAliveConnCB(const CAEndpoint_t *endpoint);
-
-/**
- * API to handle the disconnected device for KeepAlive.
- * @return Current Time.
- */
-void HandleKeepAliveDisconnCB(const CAEndpoint_t *endpoint);
+void HandleKeepAliveConnCB(const CAEndpoint_t *endpoint, bool isConnected);
#ifdef __cplusplus
} // extern "C"
void OCSecurityPayloadDestroy(OCSecurityPayload* payload);
void OCDiscoveryPayloadAddResource(OCDiscoveryPayload* payload, const OCResource* res,
- uint16_t port);
+ uint16_t securePort, uint16_t tcpPort);
void OCDiscoveryPayloadAddNewResource(OCDiscoveryPayload* payload, OCResourcePayload* res);
bool OCResourcePayloadAddStringLL(OCStringLL **payload, const char* type);
* Maximum length of the URI supported by client/server while processing
* REST requests/responses.
*/
-#define MAX_URI_LENGTH (64)
+#define MAX_URI_LENGTH (256)
/**
* Maximum length of the query supported by client/server while processing
/** Port. */
#define OC_RSRVD_HOSTING_PORT "port"
+/** TCP Port. */
+#define OC_RSRVD_TCP_PORT "tcp"
+
/** For Server instance ID.*/
#define OC_RSRVD_SERVER_INSTANCE_ID "sid"
#define OC_RSRVD_RESOURCE_TYPE_RDPUBLISH "oic.wk.rdpub"
/**
+ * Mark a parameter as unused. Used to prevent unused variable compiler warnings.
+ * Used in three cases:
+ * 1. in callbacks when one of the parameters are unused
+ * 2. when due to code changes a functions parameter is no longer
+ * used but must be left in place for backward compatibility
+ * reasons.
+ * 3. a variable is only used in the debug build variant and would
+ * give a build warning in release mode.
+ */
+#define OC_UNUSED(x) (void)(x)
+
+/**
* These enums (OCTransportAdapter and OCTransportFlags) must
* be kept synchronized with OCConnectivityType (below) as well as
* CATransportAdapter and CATransportFlags (in CACommon.h).
OC_FLAG_SECURE = (1 << 4),
/** IPv4 & IPv6 auto-selection is the default.*/
- /** IP adapter only.*/
+ /** IP & TCP adapter only.*/
OC_IP_USE_V6 = (1 << 5),
- /** IP adapter only.*/
+ /** IP & TCP adapter only.*/
OC_IP_USE_V4 = (1 << 6),
/** internal use only.*/
/** De-register observation, intended for internal use.*/
OC_REST_CANCEL_OBSERVE = (1 << 6),
- #ifdef WITH_PRESENCE
+#ifdef WITH_PRESENCE
/** Subscribe for all presence notifications of a particular resource.*/
OC_REST_PRESENCE = (1 << 7),
- #endif
+#endif
/** Allows OCDoResource caller to do discovery.*/
OC_REST_DISCOVER = (1 << 8)
} OCMethod;
OC_STACK_AUTHENTICATION_FAILURE,
/** Insert all new error codes here!.*/
- #ifdef WITH_PRESENCE
+#ifdef WITH_PRESENCE
OC_STACK_PRESENCE_STOPPED = 128,
OC_STACK_PRESENCE_TIMEOUT,
OC_STACK_PRESENCE_DO_NOT_HANDLE,
- #endif
+#endif
/** ERROR in stack.*/
OC_STACK_ERROR = 255
/** Error status code - END HERE.*/
uint8_t bitmap;
bool secure;
uint16_t port;
+#ifdef TCP_ADAPTER
+ uint16_t tcpPort;
+#endif
struct OCResourcePayload* next;
} OCResourcePayload;
//Secure Virtual Resource database for Iotivity Client application\r
//It contains Client's Identity and the PSK credentials\r
//of other devices which the client trusts\r
-static char CRED_FILE[] = "oic_svr_db_client_directpairing.dat";\r
-\r
+static char CRED_FILE[] = "oic_svr_db_client_directpairing.dat";
+
static const OCDPDev_t *discoveredDevs = NULL;\r
static const OCDPDev_t *pairedDevs = NULL;\r
\r
OIC_LOG(ERROR, TAG, "Invalid PIN");\r
continue;\r
}\r
- sscanf(input, "%8s", pinNumber);\r
- printf("\n");\r
+ sscanf(input, "%8s", pinNumber);
+ printf("\n");
\r
ret = DoDirectPairing(peer, pmSel, pinNumber);\r
if (OC_STACK_OK != ret)\r
\r
return 0;\r
}\r
-\r
-\r
-\r
-{\r
+{
"acl": {\r
"aclist": {\r
"aces": [\r
}
OCResource * collResource = (OCResource *) ehRequest->resource;
- OCChildResource *tempChildResource = NULL;
OCRepPayload* payload = OCRepPayloadCreate();
if (!payload)
if (stackRet == OC_STACK_OK)
{
- tempChildResource = collResource->rsrcChildResourcesHead;
-
+ OCChildResource *tempChildResource = (collResource) ? collResource->rsrcChildResourcesHead
+ : NULL;
while(tempChildResource)
{
OCResource* tempRsrcResource = tempChildResource->rsrcResource;
// is ehRequest->resource
ehRequest->resource = (OCResourceHandle) tempRsrcResource;
- OCEntityHandlerResult ehResult = tempRsrcResource->entityHandler(OC_REQUEST_FLAG, ehRequest,
- tempRsrcResource->entityHandlerCallbackParam);
+ OCEntityHandlerResult ehResult = tempRsrcResource->entityHandler(OC_REQUEST_FLAG,
+ ehRequest, tempRsrcResource->entityHandlerCallbackParam);
// The default collection handler is returning as OK
if (stackRet != OC_STACK_SLOW_RESOURCE)
return NULL;
}
-static OCResourcePayload* OCCopyResource(const OCResource* res, uint16_t port)
+static OCResourcePayload* OCCopyResource(const OCResource* res, uint16_t securePort,
+ uint16_t tcpPort)
{
OCResourcePayload* pl = (OCResourcePayload*)OICCalloc(1, sizeof(OCResourcePayload));
if (!pl)
pl->bitmap = res->resourceProperties & (OC_OBSERVABLE | OC_DISCOVERABLE);
pl->secure = (res->resourceProperties & OC_SECURE) != 0;
- pl->port = port;
-
+ pl->port = securePort;
+#ifdef TCP_ADAPTER
+ pl->tcpPort = tcpPort;
+#endif
return pl;
}
void OCDiscoveryPayloadAddResource(OCDiscoveryPayload* payload, const OCResource* res,
- uint16_t port)
+ uint16_t securePort, uint16_t tcpPort)
{
- OCDiscoveryPayloadAddNewResource(payload, OCCopyResource(res, port));
+ OCDiscoveryPayloadAddNewResource(payload, OCCopyResource(res, securePort, tcpPort));
}
bool OCResourcePayloadAddStringLL(OCStringLL **stringLL, const char *value)
payload->base.type = PAYLOAD_TYPE_PLATFORM;
+ payload->interfaces = (OCStringLL*)OICCalloc(1, sizeof(OCStringLL));
+ if (!payload->interfaces)
+ {
+ return NULL;
+ }
+ payload->interfaces->value = OICStrdup(OC_RSRVD_INTERFACE_READ);
+ payload->rt = OICStrdup(OC_RSRVD_RESOURCE_TYPE_PLATFORM);
payload->info = *platformInfo;
return payload;
}
payload->base.type = PAYLOAD_TYPE_PLATFORM;
+ payload->rt = OICStrdup(OC_RSRVD_RESOURCE_TYPE_PLATFORM);
OCResourcePayloadAddStringLL(&payload->interfaces, OC_RSRVD_INTERFACE_DEFAULT);
OCResourcePayloadAddStringLL(&payload->interfaces, OC_RSRVD_INTERFACE_READ);
- payload->rt = OICStrdup(OC_RSRVD_RESOURCE_TYPE_PLATFORM);
OCCopyPlatformInfo(platformInfo, payload);
return payload;
VERIFY_CBOR_SUCCESS(TAG, err, "Failed adding secure port value");
}
+#ifdef TCP_ADAPTER
+ err |= cbor_encode_text_string(&policyMap, OC_RSRVD_TCP_PORT,
+ sizeof(OC_RSRVD_TCP_PORT) - 1);
+ VERIFY_CBOR_SUCCESS(TAG, err, "Failed adding tcp port tag");
+ err |= cbor_encode_uint(&policyMap, resource->tcpPort);
+ VERIFY_CBOR_SUCCESS(TAG, err, "Failed adding tcp port value");
+#endif
+
err |= cbor_encoder_close_container(&linkMap, &policyMap);
VERIFY_CBOR_SUCCESS(TAG, err, "Failed closing policy map");
VERIFY_CBOR_SUCCESS(TAG, err, "to find port value");
}
+#ifdef TCP_ADAPTER
+ // TCP Port
+ err = cbor_value_map_find_value(&policyMap, OC_RSRVD_TCP_PORT, &curVal);
+ if (cbor_value_is_valid(&curVal))
+ {
+ err = cbor_value_get_int(&curVal, (int *)&resource->tcpPort);
+ VERIFY_CBOR_SUCCESS(TAG, err, "to find tcp port value");
+ }
+#endif
+
err = cbor_value_advance(&resourceMap);
VERIFY_CBOR_SUCCESS(TAG, err, "to advance resource map");
}
*outPayload = (OCPayload *)out;
+ OIC_LOG_PAYLOAD(DEBUG, *outPayload);
+
return OC_STACK_OK;
exit:
// Resource Type
err = cbor_value_map_find_value(rootValue, OC_RSRVD_RESOURCE_TYPE, &curVal);
VERIFY_CBOR_SUCCESS(TAG, err, "to find resource type tag");
+
if (cbor_value_is_valid(&curVal))
{
err = OCParseStringLL(rootValue, OC_RSRVD_RESOURCE_TYPE, &out->types);
// Resource type
err = cbor_value_map_find_value(rootValue, OC_RSRVD_RESOURCE_TYPE, &repVal);
VERIFY_CBOR_SUCCESS(TAG, err, "to find resource type tag");
+
if(cbor_value_is_valid(&repVal))
{
err = cbor_value_dup_text_string(&repVal, &rt, &len, NULL);
// Interface Types
err = cbor_value_map_find_value(rootValue, OC_RSRVD_INTERFACE, &repVal);
VERIFY_CBOR_SUCCESS(TAG, err, "to find interface tag");
+
if(cbor_value_is_valid(&repVal))
{
err = OCParseStringLL(rootValue, OC_RSRVD_INTERFACE, &interfaces);
static CborError OCParseArray(OCRepPayload *out, const char *name, CborValue *container)
{
void *arr = NULL;
- OCRepPayloadPropType type;
- size_t dimensions[MAX_REP_ARRAY_DEPTH];
+
+ OCRepPayloadPropType type = OCREP_PROP_NULL;
+ size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0 };
+
size_t dimTotal = 0;
size_t allocSize = 0;
bool res = true;
return OC_STACK_OK;
}
+#ifdef TCP_ADAPTER
+/* This method will retrieve the tcp port */
+static OCStackResult GetTCPPortInfo(OCDevAddr *endpoint, uint16_t *port)
+{
+ uint16_t p = 0;
+
+ if (endpoint->adapter == OC_ADAPTER_IP)
+ {
+ if (endpoint->flags & OC_IP_USE_V4)
+ {
+ p = caglobals.tcp.ipv4.port;
+ }
+ else if (endpoint->flags & OC_IP_USE_V6)
+ {
+ p = caglobals.tcp.ipv6.port;
+ }
+ }
+
+ *port = p;
+ return OC_STACK_OK;
+}
+#endif
+
/*
* Function will extract 0, 1 or 2 filters from query.
* More than 2 filters or unsupported filters will result in error.
{
return OC_STACK_INVALID_PARAM;
}
- uint16_t port = 0;
+ uint16_t securePort = 0;
if (resourcePtr->resourceProperties & OC_SECURE)
{
- if (GetSecurePortInfo(devAddr, &port) != OC_STACK_OK)
+ if (GetSecurePortInfo(devAddr, &securePort) != OC_STACK_OK)
{
- port = 0;
+ securePort = 0;
}
}
if (rdResponse)
{
- port = devAddr->port;
+ securePort = devAddr->port;
}
- OCDiscoveryPayloadAddResource(payload, resourcePtr, port);
+ uint16_t tcpPort = 0;
+#ifdef TCP_ADAPTER
+ if (GetTCPPortInfo(devAddr, &tcpPort) != OC_STACK_OK)
+ {
+ tcpPort = 0;
+ }
+#endif
+
+ OCDiscoveryPayloadAddResource(payload, resourcePtr, securePort, tcpPort);
return OC_STACK_OK;
}
OCDiscoveryPayload *discPayload = (OCDiscoveryPayload *)payload;
discPayload->sid = (char *)OICCalloc(1, UUID_STRING_SIZE);
VERIFY_NON_NULL(discPayload->sid, ERROR, OC_STACK_NO_MEMORY);
+
const char* uid = OCGetServerInstanceIDString();
- if(uid)
+ if (uid)
{
memcpy(discPayload->sid, uid, UUID_STRING_SIZE);
}
{
OIC_LOG(INFO, TAG, "Received a message without callbacks. Sending RESET");
SendDirectStackResponse(endPoint, responseInfo->info.messageId, CA_EMPTY,
- CA_MSG_RESET, 0, NULL, NULL, 0, NULL);
+ CA_MSG_RESET, 0, NULL, NULL, 0, NULL);
}
}
{
serverRequest.reqTotalSize = requestInfo->info.payloadSize;
serverRequest.payload = (uint8_t *) OICMalloc(requestInfo->info.payloadSize);
+ if (!serverRequest.payload)
+ {
+ OIC_LOG(ERROR, TAG, "Allocation for payload failed.");
+ return;
+ }
memcpy (serverRequest.payload, requestInfo->info.payload,
requestInfo->info.payloadSize);
}
VERIFY_SUCCESS(result, OC_STACK_OK);
#ifdef TCP_ADAPTER
- CARegisterKeepAliveHandler(HandleKeepAliveConnCB, HandleKeepAliveDisconnCB);
+ CARegisterKeepAliveHandler(HandleKeepAliveConnCB);
#endif
#ifdef WITH_PRESENCE
#endif
#ifdef TCP_ADAPTER
- if(result == OC_STACK_OK)
+ if (result == OC_STACK_OK)
{
result = InitializeKeepAlive(myStackMode);
}
{
colon = close + 1;
}
- adapter = (OCTransportAdapter)(adapter | OC_ADAPTER_IP);
+
+ if (istcp)
+ {
+ adapter = (OCTransportAdapter)(adapter | OC_ADAPTER_TCP);
+ }
+ else
+ {
+ adapter = (OCTransportAdapter)(adapter | OC_ADAPTER_IP);
+ }
flags = (OCTransportFlags)(flags | OC_IP_USE_V6);
}
else
end = (colon && colon < slash) ? colon : slash;
if (istcp)
- { // coap over tcp
+ {
+ // coap over tcp
adapter = (OCTransportAdapter)(adapter | OC_ADAPTER_TCP);
}
else
{
adapter = (OCTransportAdapter)(adapter | OC_ADAPTER_IP);
- flags = (OCTransportFlags)(flags | OC_IP_USE_V4);
}
+ flags = (OCTransportFlags)(flags | OC_IP_USE_V4);
}
else
{ // MAC address
case OC_REST_OBSERVE:
case OC_REST_OBSERVE_ALL:
- OIC_LOG_V(INFO, TAG, "Canceling observation for resource %s",
- clientCB->requestUri);
- if (qos != OC_HIGH_QOS)
+ OIC_LOG_V(INFO, TAG, "Canceling observation for resource %s", clientCB->requestUri);
+
+ CopyDevAddrToEndpoint(clientCB->devAddr, &endpoint);
+
+ if ((endpoint.adapter & CA_ADAPTER_IP) && qos != OC_HIGH_QOS)
{
FindAndDeleteClientCB(clientCB);
break;
requestInfo.info.numOptions = numOptions + 1;
requestInfo.info.resourceUri = OICStrdup (clientCB->requestUri);
- CopyDevAddrToEndpoint(clientCB->devAddr, &endpoint);
ret = OCSendRequest(&endpoint, &requestInfo);
OIC_LOG(ERROR, TAG, "Invalid parameters");
return OC_STACK_INVALID_PARAM;
}
- if(NULL == resultCallback)
+ if (NULL == resultCallback)
{
OIC_LOG(ERROR, TAG, "Invalid callback");
return OC_STACK_INVALID_CALLBACK;
previous = pointer;
pointer = pointer->next;
}
- previous->next = resourceType;
+
+ if (previous)
+ {
+ previous->next = resourceType;
+ }
}
resourceType->next = NULL;
return OC_STACK_OK;
}
-void HandleKeepAliveConnCB(const CAEndpoint_t *endpoint)
+void HandleKeepAliveConnCB(const CAEndpoint_t *endpoint, bool isConnected)
{
VERIFY_NON_NULL_NR(endpoint, FATAL);
- OIC_LOG(DEBUG, TAG, "Received the connected device information from CA");
-
- // Send discover message to find ping resource
- OCCallbackData pingData = { .cb = PingRequestCallback };
- OCDevAddr devAddr = { .adapter = OC_ADAPTER_TCP };
- CopyEndpointToDevAddr(endpoint, &devAddr);
-
- OCDoResource(NULL, OC_REST_DISCOVER, KEEPALIVE_RESOURCE_URI, &devAddr, NULL,
- OC_ADAPTER_TCP, OC_HIGH_QOS, &pingData, NULL, 0);
-}
-
-void HandleKeepAliveDisconnCB(const CAEndpoint_t *endpoint)
-{
- VERIFY_NON_NULL_NR(endpoint, FATAL);
+ if (isConnected)
+ {
+ OIC_LOG(DEBUG, TAG, "Received the connected device information from CA");
- OIC_LOG(DEBUG, TAG, "Received the disconnected device information from CA");
+ // Send discover message to find ping resource
+ OCCallbackData pingData = { .cb = PingRequestCallback };
+ OCDevAddr devAddr = { .adapter = OC_ADAPTER_TCP };
+ CopyEndpointToDevAddr(endpoint, &devAddr);
- OCStackResult result = RemoveKeepAliveEntry(endpoint);
- if(result != OC_STACK_OK)
+ OCDoResource(NULL, OC_REST_DISCOVER, KEEPALIVE_RESOURCE_URI, &devAddr, NULL,
+ OC_ADAPTER_TCP, OC_HIGH_QOS, &pingData, NULL, 0);
+ }
+ else
{
- OIC_LOG(ERROR, TAG, "Failed to remove entry");
- return;
+ OIC_LOG(DEBUG, TAG, "Received the disconnected device information from CA");
+
+ OCStackResult result = RemoveKeepAliveEntry(endpoint);
+ if(result != OC_STACK_OK)
+ {
+ OIC_LOG(ERROR, TAG, "Failed to remove entry");
+ return;
+ }
}
}
OIC_LOG(INFO, TAG, "Starting CreateResourceBadUri test");
InitStack(OC_SERVER);
- const char *uri65 = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL";
+ const char *uri257 = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW";
OCResourceHandle handle;
EXPECT_EQ(OC_STACK_INVALID_URI, OCCreateResource(&handle,
"core.led",
"core.rw",
- uri65, //"/a/led",
+ uri257, //"/a/led",
0,
0,
OC_DISCOVERABLE|OC_OBSERVABLE));
../../../service/easy-setup/inc \
../../../service/scene-manager/include \
-
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
# also the default input encoding. Doxygen uses libiconv (or the iconv built
# the class node. If there are many fields or methods and many nodes the
# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS
# threshold limits the number of items for each type to make the size more
-# managable. Set this to 0 for no limit. Note that the threshold may be
+# manageable. Set this to 0 for no limit. Note that the threshold may be
# exceeded by 50% before the limit is enforced.
UML_LIMIT_NUM_FIELDS = 10
examples_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
examples_env.AppendUnique(RPATH = [env.get('BUILD_DIR')])
-examples_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'coap'])
+examples_env.PrependUnique(LIBS = ['coap'])
+examples_env.AppendUnique(LIBS = ['connectivity_abstraction'])
+examples_env.AppendUnique(LIBS = ['oc_logger'])
+examples_env.AppendUnique(LIBS = ['octbstack'])
+examples_env.AppendUnique(LIBS = ['oc'])
+
if env.get('SECURED') == '1':
examples_env.AppendUnique(LIBS = ['tinydtls'])
cout << "Invalid option" << endl;
break;
}
- fflush(stdin);
}
}
catch (OCException& e)
* After creating instances of OCHeaderOptions, use setHeaderOptions API
* (in OCResource.h) to set header Options.
* NOTE: HeaderOptionID is an unsigned integer value which MUST be within
- * range of 2048 to 3000 inclusive of lower and upper bound.
+ * range of 2048 to 3000 inclusive of lower and upper bound
+ * except for If-Match with empty(num : 1), If-None-Match(num : 5),
+ * Location-Path(num : 8), Location-Query(num : 20) option.
* HeaderOptions instance creation fails if above condition is not satisfied.
*/
const uint16_t MIN_HEADER_OPTIONID = 2048;
const uint16_t MAX_HEADER_OPTIONID = 3000;
+ const uint16_t IF_MATCH_OPTION_ID = 1;
+ const uint16_t IF_NONE_MATCH_OPTION_ID = 5;
+ const uint16_t LOCATION_PATH_OPTION_ID = 8;
+ const uint16_t LOCATION_QUERY_OPTION_ID = 20;
class OCHeaderOption
{
m_optionID(optionID),
m_optionData(optionData)
{
- if(!(optionID >= MIN_HEADER_OPTIONID && optionID <= MAX_HEADER_OPTIONID))
+ if (!(optionID >= MIN_HEADER_OPTIONID && optionID <= MAX_HEADER_OPTIONID)
+ && optionID != IF_MATCH_OPTION_ID
+ && optionID != IF_NONE_MATCH_OPTION_ID
+ && optionID != LOCATION_PATH_OPTION_ID
+ && optionID != LOCATION_QUERY_OPTION_ID)
{
throw OCException(OC::Exception::OPTION_ID_RANGE_INVALID);
}
StringLLToVector(res->types),
StringLLToVector(res->interfaces)
)));
+
+#ifdef TCP_ADAPTER
+ if (res->tcpPort != 0)
+ {
+ OCDevAddr tcpDevAddr = m_devAddr;
+ tcpDevAddr.port = res->tcpPort;
+ tcpDevAddr.adapter = OC_ADAPTER_TCP;
+ m_resources.push_back(std::shared_ptr<OC::OCResource>(
+ new OC::OCResource(m_clientWrapper, tcpDevAddr,
+ std::string(res->uri),
+ std::string(payload->sid),
+ (res->bitmap & OC_OBSERVABLE) == OC_OBSERVABLE,
+ StringLLToVector(res->types),
+ StringLLToVector(res->interfaces)
+ )));
+ }
+#endif
}
res = res->next;
}
static const char GENERAL_JSON_PARSE_FAILED[] = "JSON Parser Error";
static const char RESOURCE_UNREG_FAILED[] = "Unregistering resource failed";
static const char OPTION_ID_RANGE_INVALID[] =
- "Error: OptionID valid only from 2048 to 3000 inclusive.";
+ "Error: OptionID valid only If-Match(1), If-None-Match(5),"
+ "Location-Path(8), Location-Query(20),"
+ "and from 2048 to 3000 inclusive.";
static const char NO_ERROR[] = "No Error";
static const char RESOURCE_CREATED[] = "Resource Created";
static const char RESOURCE_DELETED[] = "Resource Deleted";
if target_os == 'android':
liboc_logger_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
liboc_logger_env.AppendUnique(LIBS = ['gnustl_shared', 'log'])
+ liboc_logger_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,liboc_logger.so'])
if target_os not in ['arduino', 'windows', 'winrt']:
liboc_logger_env.AppendUnique(CFLAGS = ['-Wall', '-std=c99', '-fPIC'])
oclib_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
if target_os == 'android':
- oclib_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
- oclib_env.AppendUnique(LIBS = ['boost_thread', 'gnustl_shared', 'log'])
+ oclib_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
+ oclib_env.AppendUnique(LIBS = ['boost_thread', 'gnustl_shared', 'log'])
+ oclib_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,liboc.so'])
if target_os == 'tizen':
oclib_env.AppendUnique(CPPDEFINES = ['__TIZEN__'])
{
for(uint16_t i = 0; i < HeaderOption::MIN_HEADER_OPTIONID; ++i)
{
- ASSERT_THROW(
- HeaderOption::OCHeaderOption(i,""),
- OCException);
+ if (HeaderOption::IF_MATCH_OPTION_ID != i
+ && HeaderOption::IF_NONE_MATCH_OPTION_ID != i
+ && HeaderOption::LOCATION_PATH_OPTION_ID != i
+ && HeaderOption::LOCATION_QUERY_OPTION_ID != i)
+ {
+ ASSERT_THROW(
+ HeaderOption::OCHeaderOption(i,""),
+ OCException);
+ }
}
}
return ehResult;
}
+ char* tnn;
+ if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_TNN, &tnn))
+ {
+ OICStrcpy(gProvResource.tnn, sizeof(gProvResource.tnn), tnn);
+ OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.tnn %s", gProvResource.tnn);
+
+ gProvResource.ps = ES_PS_PROVISIONING_COMPLETED;
+ }
+
+ char* cd;
+ if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_CD, &cd))
+ {
+ OICStrcpy(gProvResource.cd, sizeof(gProvResource.cd), cd);
+ OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.cd %s", gProvResource.cd);
+ }
+
+ OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.ps %lld", gProvResource.ps);
+
int64_t tr;
if (OCRepPayloadGetPropInt(input, OC_RSRVD_ES_TR, &tr))
{
}
else
{
+ gProvResource.tr = ES_PS_TRIGGER_INIT_VALUE;
OIC_LOG(ERROR, ES_RH_TAG, "gNetworkInfoProvEventCb is NULL."
"Network handler not registered. Failed to connect to the network");
ehResult = OC_EH_ERROR;
OIC_LOG(DEBUG, ES_RH_TAG, "Provisioning the network information to the Enrollee.");
}
- OICStrcpy(gProvResource.tnn, sizeof(gProvResource.tnn), "");
- OICStrcpy(gProvResource.cd, sizeof(gProvResource.cd), "");
-
- char* tnn;
- if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_TNN, &tnn))
- {
- OICStrcpy(gProvResource.tnn, sizeof(gProvResource.tnn), tnn);
- OIC_LOG(INFO, ES_RH_TAG, "got ssid");
- }
-
- OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.tnn %s", gProvResource.tnn);
-
- char* cd;
- if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_CD, &cd))
- {
- OICStrcpy(gProvResource.cd, sizeof(gProvResource.cd), cd);
- OIC_LOG(INFO, ES_RH_TAG, "got password");
- }OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.cd %s", gProvResource.cd);
-
- gProvResource.ps = ES_PS_PROVISIONING_COMPLETED;
-
- OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.ps %lld", gProvResource.ps);
-
OCRepPayload *getResp = constructResponse(ehRequest);
if (!getResp)
{
/**
* @file
*
- * This file contains private internal callback function
+ * This file contains private internal callback function
* prototypes for Easy setup [Enrollee]
*/
return ehResult;
}
+ char* tnn;
+ if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_TNN, &tnn))
+ {
+ OICStrcpy(gProvResource.tnn, sizeof(gProvResource.tnn), tnn);
+ OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.tnn %s", gProvResource.tnn);
+
+ gProvResource.ps = ES_PS_PROVISIONING_COMPLETED;
+ }
+
+ char* cd;
+ if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_CD, &cd))
+ {
+ OICStrcpy(gProvResource.cd, sizeof(gProvResource.cd), cd);
+ OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.cd %s", gProvResource.cd);
+ }
+
+ OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.ps %lld", gProvResource.ps);
+
int64_t tr;
if (OCRepPayloadGetPropInt(input, OC_RSRVD_ES_TR, &tr))
{
}
else
{
+ gProvResource.tr = ES_PS_TRIGGER_INIT_VALUE;
OIC_LOG(ERROR, ES_RH_TAG, "gNetworkInfoProvEventCb is NULL."
"Network handler not registered. Failed to connect to the network");
ehResult = OC_EH_ERROR;
OIC_LOG(DEBUG, ES_RH_TAG, "Provisioning the network information to the Enrollee.");
}
- OICStrcpy(gProvResource.tnn, sizeof(gProvResource.tnn), "");
- OICStrcpy(gProvResource.cd, sizeof(gProvResource.cd), "");
-
- char* tnn;
- if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_TNN, &tnn))
- {
- OICStrcpy(gProvResource.tnn, sizeof(gProvResource.tnn), tnn);
- OIC_LOG(INFO, ES_RH_TAG, "got ssid");
- }
-
- OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.tnn %s", gProvResource.tnn);
-
- char* cd;
- if (OCRepPayloadGetPropString(input, OC_RSRVD_ES_CD, &cd))
- {
- OICStrcpy(gProvResource.cd, sizeof(gProvResource.cd), cd);
- OIC_LOG(INFO, ES_RH_TAG, "got password");
- }OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.cd %s", gProvResource.cd);
-
- gProvResource.ps = ES_PS_PROVISIONING_COMPLETED;
-
- OIC_LOG_V(INFO, ES_RH_TAG, "gProvResource.ps %lld", gProvResource.ps);
-
OCRepPayload *getResp = constructResponse(ehRequest);
if (!getResp)
{
/**
* It will return Device which is creating Soft AP.
* i.e.Enrollee or Mediator.
- * This decesion is based on, what is the value set for ES_SOFTAP_MODE in build command as well as
+ * This decision is based on, what is the value set for ES_SOFTAP_MODE in build command as well as
* in iotivity.spec file.
*/
DeviceRole ESSoftapHost()
};
//callbacks
-void OCProvisioningStatusCallback(EasySetupInfo *easySetupInfo)
+void OCProvisioningStatusCallback(EasySetupInfo *easySetupInfo)
{
(void) easySetupInfo;
}
easy_setup_env.AppendUnique(CXXFLAGS = ['-Wall', '-std=c++0x'])
if target_os in ['linux']:
- easy_setup_env.AppendUnique(LIBS = ['pthread', 'dl'])
+ easy_setup_env.AppendUnique(LIBS = ['pthread', 'dl', 'coap'])
if target_os in ['android']:
easy_setup_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
easy_setup_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
easy_setup_env.AppendUnique(RPATH = [env.get('BUILD_DIR')])
easy_setup_env.AppendUnique(CXXFLAGS = ['-pthread'])
- easy_setup_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'pthread', 'connectivity_abstraction'])
+ easy_setup_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger'])
if env.get('SECURED') == '1':
easy_setup_env.AppendUnique(LIBS = ['ocpmapi', 'ocprovision'])
if env.get('SECURED') == '1':
- mediator_rich_test_env.PrependUnique(LIBS = ['tinydtls','ocprovision', 'ocpmapi'])
+ mediator_rich_test_env.PrependUnique(LIBS = ['tinydtls','ocprovision', 'ocpmapi', 'timer'])
mediator_rich_test_env.PrependUnique(LIBS = [
+ 'ESMediatorRich',
'oc',
'octbstack',
'oc_logger',
- 'oc_logger_core',
- 'connectivity_abstraction',
- 'coap',
- 'ESMediatorRich',
gtest,
gtest_main])
target_os = env.get('TARGET_OS')
if target_os == 'linux':
from tools.scons.RunTest import *
- run_test(mediator_rich_test_env, '', 'service/easy-setup/mediator/richsdk/unittests/mediator_richsdk_test')
\ No newline at end of file
+ run_test(mediator_rich_test_env, '', 'service/easy-setup/mediator/richsdk/unittests/mediator_richsdk_test')
if target_os not in ['windows', 'winrt']:
mediator_env.AppendUnique(CXXFLAGS = ['-Wall', '-std=c++0x'])
-
+
mediator_env.PrependUnique(CPPPATH = [
env.get('SRC_DIR') + '/resource/include',
env.get('SRC_DIR') + '/resource/oc_logger/include',
- env.get('SRC_DIR') + '/resource/csdk/ocmalloc/include',
+ env.get('SRC_DIR') + '/resource/csdk/ocmalloc/include',
env.get('SRC_DIR') + '/resource/csdk/stack/include',
env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include',
env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include/internal',
env.get('SRC_DIR') + '/service/easy-setup/mediator/richsdk/src',
env.get('SRC_DIR') + '/service/easy-setup/inc'])
-mediator_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'pthread', 'connectivity_abstraction', 'coap', 'ESMediatorRich'])
+if env.get('SECURED') == '1':
+ mediator_env.PrependUnique(LIBS = ['tinydtls', 'timer'])
+
+mediator_env.PrependUnique(LIBS = ['ESMediatorRich', 'oc', 'octbstack', 'oc_logger'])
+
if env.get('SECURED') == '1':
mediator_env.PrependUnique(LIBS = ['ocpmapi', 'ocprovision'])
except KeyError:
print ''
-
-resource_container_env.PrependUnique(LIBS = ['rcs_client', 'rcs_server', 'rcs_common', 'oc','octbstack', 'oc_logger', 'connectivity_abstraction'])
-resource_container_env.AppendUnique(LIBS = ['dl', 'boost_system', 'boost_date_time', 'boost_thread'])
+resource_container_env.PrependUnique(LIBS = ['coap'])
+resource_container_env.AppendUnique(LIBS = ['connectivity_abstraction'])
+resource_container_env.AppendUnique(LIBS = ['oc_logger'])
+resource_container_env.AppendUnique(LIBS = ['octbstack'])
+resource_container_env.AppendUnique(LIBS = ['oc'])
+resource_container_env.AppendUnique(LIBS = ['rcs_client'])
+resource_container_env.AppendUnique(LIBS = ['rcs_server'])
+resource_container_env.AppendUnique(LIBS = ['rcs_common'])
+resource_container_env.AppendUnique(LIBS = ['dl'])
+resource_container_env.AppendUnique(LIBS = ['boost_system'])
+resource_container_env.AppendUnique(LIBS = ['boost_date_time'])
+resource_container_env.AppendUnique(LIBS = ['boost_thread'])
if int(containerJavaSupport):
try:
# Build Container Java SDK
######################################################################
if target_os == 'android':
- SConscript('android/SConscript')
\ No newline at end of file
+ SConscript('android/SConscript')
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
*/
include ':resource-container'
linux_sample_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
linux_sample_env.AppendUnique(CPPDEFINES = ['LINUX'])
linux_sample_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-linux_sample_env.AppendUnique(LIBS = ['oc'])
-linux_sample_env.AppendUnique(LIBS = ['octbstack'])
-linux_sample_env.AppendUnique(LIBS = ['libconnectivity_abstraction'])
linux_sample_env.AppendUnique(LIBS = ['libcoap'])
+linux_sample_env.AppendUnique(LIBS = ['libconnectivity_abstraction'])
linux_sample_env.AppendUnique(LIBS = ['liboc_logger'])
+linux_sample_env.AppendUnique(LIBS = ['octbstack'])
+linux_sample_env.AppendUnique(LIBS = ['oc'])
linux_sample_env.AppendUnique(LIBS = ['pthread'])
if env.get('SECURED') == '1':
######################################################################
heightsensorapp = linux_sample_env.Program('HeightSensorApp', 'src/HeightSensorApp.cpp')
Alias("heightsensorapp_sample", heightsensorapp)
-env.AppendTarget('heightsensorapp')
\ No newline at end of file
+env.AppendTarget('heightsensorapp')
linux_sample_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
linux_sample_env.AppendUnique(CPPDEFINES = ['LINUX'])
linux_sample_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-linux_sample_env.AppendUnique(LIBS = ['oc'])
+linux_sample_env.AppendUnique(LIBS = ['coap'])
+linux_sample_env.AppendUnique(LIBS = ['connectivity_abstraction'])
+linux_sample_env.AppendUnique(LIBS = ['oc_logger'])
linux_sample_env.AppendUnique(LIBS = ['octbstack'])
-linux_sample_env.AppendUnique(LIBS = ['libconnectivity_abstraction'])
-linux_sample_env.AppendUnique(LIBS = ['libcoap'])
-linux_sample_env.AppendUnique(LIBS = ['liboc_logger'])
+linux_sample_env.AppendUnique(LIBS = ['oc'])
linux_sample_env.AppendUnique(LIBS = ['pthread'])
if env.get('SECURED') == '1':
######################################################################
weightsensorapp = linux_sample_env.Program('WeightSensorApp', 'src/WeightSensorApp.cpp')
Alias("weightsensorapp_sample", weightsensorapp)
-env.AppendTarget('weightsensorapp')
\ No newline at end of file
+env.AppendTarget('weightsensorapp')
linux_sample_env.AppendUnique(CXXFLAGS = ['-Wall', '-pthread','-std=c++0x'])
linux_sample_env.AppendUnique(CPPDEFINES = ['LINUX'])
linux_sample_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-linux_sample_env.AppendUnique(LIBS = ['oc'])
+linux_sample_env.AppendUnique(LIBS = ['coap'])
+linux_sample_env.AppendUnique(LIBS = ['connectivity_abstraction'])
+linux_sample_env.AppendUnique(LIBS = ['oc_logger'])
linux_sample_env.AppendUnique(LIBS = ['octbstack'])
-linux_sample_env.AppendUnique(LIBS = ['libconnectivity_abstraction'])
-linux_sample_env.AppendUnique(LIBS = ['libcoap'])
-linux_sample_env.AppendUnique(LIBS = ['liboc_logger'])
+linux_sample_env.AppendUnique(LIBS = ['oc'])
linux_sample_env.AppendUnique(LIBS = ['pthread'])
if env.get('SECURED') == '1':
linux_sample_env.AppendUnique(CXXFLAGS = ['-Wall', '-pthread','-std=c++0x'])
linux_sample_env.AppendUnique(CPPDEFINES = ['LINUX'])
linux_sample_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-linux_sample_env.AppendUnique(LIBS = ['oc'])
+linux_sample_env.AppendUnique(LIBS = ['coap'])
+linux_sample_env.AppendUnique(LIBS = ['connectivity_abstraction'])
+linux_sample_env.AppendUnique(LIBS = ['oc_logger'])
linux_sample_env.AppendUnique(LIBS = ['octbstack'])
-linux_sample_env.AppendUnique(LIBS = ['libconnectivity_abstraction'])
-linux_sample_env.AppendUnique(LIBS = ['libcoap'])
-linux_sample_env.AppendUnique(LIBS = ['liboc_logger'])
+linux_sample_env.AppendUnique(LIBS = ['oc'])
linux_sample_env.AppendUnique(LIBS = ['pthread'])
if env.get('SECURED') == '1':
}
}
- OIC_LOG_V(INFO, CONTAINER_TAG, "Container get request for %s finished, %d attributes",strResourceUri.c_str(), attr.size());
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Container get request for %s finished, %zu attributes",strResourceUri.c_str(), attr.size());
return RCSGetResponse::create(std::move(attr), 200);
}
std::list<std::string> lstAttributes;
std::string strResourceUri = request.getResourceUri();
- OIC_LOG_V(INFO, CONTAINER_TAG, "Container set request for %s, %d attributes",strResourceUri.c_str(), attributes.size());
+ OIC_LOG_V(INFO, CONTAINER_TAG, "Container set request for %s, %zu attributes",strResourceUri.c_str(), attributes.size());
if (m_mapServers.find(strResourceUri) != m_mapServers.end()
&& m_mapResources.find(strResourceUri) != m_mapResources.end())
private OnResourceDiscoveredListener mOnResourceDiscoveredListener = new OnResourceDiscoveredListener() {
@Override
public void onResourceDiscovered(
- RcsRemoteResourceObject RcsRemoteResourceObject) {
- if (mClient != null)
+ RcsRemoteResourceObject remoteObject) {
+ if (mClient != null) {
return;
+ }
- mClient = RcsRemoteResourceObject;
+ mClient = remoteObject;
synchronized (mCond) {
mCond.notify();
}
while (mClient == null) {
try {
RcsDiscoveryManager.DiscoveryTask discoveryTask = RcsDiscoveryManager
- .getInstance().discoverResourceByType(
- RcsAddress.multicast(), "/oic/res",
+ .getInstance().discoverResourceByType(RcsAddress.multicast(),
RESOURCETYPE, mOnResourceDiscoveredListener);
synchronized (mCond) {
protected void setServerAttrbutes(RcsResourceAttributes attrs)
throws RcsException {
RcsResourceObject.AttributesLock lock = mServer.getAttributesLock();
- lock.lock().putAll(attrs);
- lock.apply();
- lock.unlock();
+
+ try {
+ lock.lock().putAll(attrs);
+ lock.apply();
+ } finally {
+ lock.unlock();
+ }
}
@Override
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
*/
include ':service'
sample_env.AppendUnique(CXXFLAGS = ['-Wall', '-std=c++0x'])
sample_env.AppendUnique(LIBS = [
- 'rcs_common',
- 'oc',
- 'octbstack',
- 'oc_logger',
- 'connectivity_abstraction',
'coap',
+ 'connectivity_abstraction',
+ 'oc_logger',
+ 'octbstack',
+ 'oc',
+ 'rcs_common',
'pthread'
])
sample_env.AppendUnique(CPPPATH = ['../../include'])
sample_env.AppendUnique(CXXFLAGS = ['-Wall', '-std=c++0x'])
sample_env.AppendUnique(LIBS = [
- 'rcs_common',
- 'oc',
- 'octbstack',
- 'oc_logger',
- 'connectivity_abstraction',
'coap',
+ 'connectivity_abstraction',
+ 'oc_logger',
+ 'octbstack',
+ 'oc',
+ 'rcs_common',
'pthread',
'tinydtls'
])
void DevicePresence::subscribeCB(OCStackResult ret,
const unsigned int seq, const std::string & hostAddress)
{
+ OC_UNUSED(seq);
+ OC_UNUSED(hostAddress);
+
OIC_LOG_V(DEBUG, BROKER_TAG, "subscribeCB()");
OIC_LOG_V(DEBUG, BROKER_TAG, "Received presence CB from: %s",hostAddress.c_str());
OIC_LOG_V(DEBUG, BROKER_TAG, "In subscribeCB: %d",ret);
broker_test_env.PrependUnique(CPPPATH = [env.get('SRC_DIR')+'/extlibs/hippomocks-master',
gtest_dir + '/include'])
broker_test_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-broker_test_env.PrependUnique(LIBS = ['rcs_client','rcs_common', 'oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'coap', gtest, gtest_main])
+
+broker_test_env.PrependUnique(LIBS = ['coap'])
+broker_test_env.AppendUnique(LIBS = ['connectivity_abstraction'])
+broker_test_env.AppendUnique(LIBS = ['oc_logger'])
+broker_test_env.AppendUnique(LIBS = ['octbstack'])
+broker_test_env.AppendUnique(LIBS = ['oc'])
+broker_test_env.AppendUnique(LIBS = ['rcs_client'])
+broker_test_env.AppendUnique(LIBS = ['rcs_common'])
+broker_test_env.AppendUnique(LIBS = [gtest])
+broker_test_env.AppendUnique(LIBS = [gtest_main])
if target_os not in ['windows', 'winrt']:
broker_test_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
TEST_F(ResourceObjectInterfaceHandlerTest, SettingDefaultInterfaceEqualsGetDefaultInterface)
{
- initServer({SENSOR_INTERFACE}, BASELINE_INTERFACE);
+ initServer({ SENSOR_INTERFACE }, BASELINE_INTERFACE);
EXPECT_EQ(BASELINE_INTERFACE, server->getDefaultInterface());
}
rcs_test_env.AppendUnique(LIBS = ['pthread'])
rcs_test_env.PrependUnique(LIBS = [
+ 'connectivity_abstraction',
+ 'oc_logger',
+ 'oc_logger_core',
+ 'octbstack',
+ 'oc',
'rcs_client',
'rcs_server',
'rcs_common',
- 'oc',
- 'octbstack',
- 'oc_logger',
- 'oc_logger_core',
- 'connectivity_abstraction',
gtest,
gtest_main])
target_os = env.get('TARGET_OS')
if target_os == 'linux':
from tools.scons.RunTest import *
- run_test(rcs_test_env, '', 'service/resource-encapsulation/unittests/rcs_client_test')
\ No newline at end of file
+ run_test(rcs_test_env, '', 'service/resource-encapsulation/unittests/rcs_client_test')
/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // 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.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * 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 com.example.sample.provider;
resourcehosting_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
resourcehosting_sample_env = resourcehosting_env.Clone()
resourcehosting_env.AppendUnique(LIBS = [
+ 'coap',
+ 'connectivity_abstraction',
+ 'oc_logger',
+ 'octbstack',
+ 'oc',
'resource_hosting',
'rcs_client',
'rcs_server',
'rcs_common',
- 'oc',
- 'octbstack',
- 'oc_logger',
- 'connectivity_abstraction',
- 'coap',
'pthread'
])
resourcehosting_sample_env.AppendUnique(LIBS = [
- 'oc',
- 'octbstack',
- 'oc_logger',
'connectivity_abstraction',
'coap',
+ 'oc_logger',
+ 'octbstack',
+ 'oc',
'pthread'
])
waitForCondition(waitForResponse);
mocks.OnCallFunc(onDiscoveryResource).Do(
- [this, &uri, &discoveryTask, &testObject, &discoveredResource]
+ [this, &uri, &discoveryTask]
(RCSRemoteResourceObject::Ptr ptr)
{
if(ptr->getUri() == testObject.getHostedServerUri())
int waitForResponse = 1000;
mocks.ExpectCallFunc(onDestroy).Do(
- [& responseCon]()
+ []()
{
responseCon.notify_all();
});
waitForCondition();
mocks.OnCallFunc(onDiscoveryResource).Do(
- [this, &uri, &testObject](RCSRemoteResourceObject::Ptr ptr)
+ [this, &uri](RCSRemoteResourceObject::Ptr ptr)
{
if(ptr->getUri() == testObject.getHostedServerUri())
{
scenemanager_env.PrependUnique(LIBS = [
+ 'coap',
+ 'connectivity_abstraction',
+ 'oc_logger',
+ 'octbstack',
+ 'oc',
'rcs_client',
'rcs_server',
- 'rcs_common',
- 'oc',
- 'octbstack',
- 'oc_logger',
- 'connectivity_abstraction',
- 'libcoap'
+ 'rcs_common'
])
if target_os not in ['windows', 'winrt']:
scenemanager_sample_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
scenemanager_sample_env.AppendUnique(LIBS = [
+ 'oc_logger',
+ 'coap',
+ 'connectivity_abstraction',
'scene_manager',
'rcs_client',
'rcs_server',
'rcs_common',
- 'oc',
'octbstack',
- 'oc_logger',
- 'connectivity_abstraction',
- 'coap',
+ 'oc',
'pthread'
])
sceneserver = scenemanager_sample_env.Program('sceneserver', 'sceneserver.cpp')
sceneclient = scenemanager_sample_env.Program('sceneclient', 'sceneclient.cpp')
fanserver = scenemanager_sample_env.Program('fanserver', 'fanserver.cpp')
-lightserver = scenemanager_sample_env.Program('lightserver', 'lightserver.cpp')
\ No newline at end of file
+lightserver = scenemanager_sample_env.Program('lightserver', 'lightserver.cpp')
}
// --- Scene Manager Remote API sample
-
void configurePlatform()
{
PlatformConfig config
void SceneUtils::getHostUriString(
const std::string address, std::string *host, std::string *uri)
{
- unsigned int nextStartIndex = 0;
+ size_t nextStartIndex = 0;
int indexOfStr = 3;
if (address.find(COAP_TAG) == std::string::npos)
From Run/Debug settings, Choose a launch configuration and press Edit -> select 'Environment' tab
-> Click on 'Select' -> check LD_LIBRARY_PATH option -> OK. Edit the LD_LIBRARY_PATH and add the
-complete path upto the libs folder of the plug-in project
+complete path up to the libs folder of the plug-in project
( ~/iotivity/service/simulator/java/eclipse-plugin/ClientControllerPlugin/libs)
-> Apply -> OK. Then Apply -> OK to close the properties window.
Resource resource = new SingleResource();
resource.setSimulatorResource(jSimulatorResource);
- // Fetch and locally store the resource name and uri.
+ // Fetch and locally store the resource name, type and uri.
String uri = jSimulatorResource.getURI();
if (null == uri || uri.trim().isEmpty()) {
+ // URI is mandatory to be present in RAML. If it is not there, then
+ // resource can't be created.
return null;
}
resource.setResourceURI(uri.trim());
- String name = jSimulatorResource.getName();
- if (null == name || name.trim().isEmpty()) {
- return null;
+ String type = jSimulatorResource.getResourceType();
+ if (null != type) {
+ type = type.trim();
}
+ resource.setResourceType(type);
- resource.setResourceName(name.trim());
+ String name = jSimulatorResource.getName();
+ if (null != name) {
+ name = name.trim();
+ }
+ resource.setResourceName(name);
return resource;
}
* notifies the UI listeners.
*/
public boolean completeSingleResourceCreationByRAML(Resource resource,
- String uri, String name, boolean multiInstance)
+ String uri, String name, String type, boolean multiInstance)
throws SimulatorException {
if (null == resource || !(resource instanceof SingleResource)) {
return false;
}
// Update resource URI and Name if they are changed.
- String newUri = uri.trim();
- String newName = name.trim();
-
- if (multiInstance) {
+ String newUri = "";
+ String newName = "";
+ String newType = "";
+
+ if (null != uri)
+ newUri = uri.trim();
+ if (null != name)
+ newName = name.trim();
+ if (null != type)
+ newType = type.trim();
+
+ if (!multiInstance && !singleRes.getResourceURI().equals(newUri)) {
+ jSimulatorSingleResource.setURI(newUri);
singleRes.setResourceURI(newUri);
+ }
+ String currentName = singleRes.getResourceName();
+ if (null == currentName || !currentName.equals(newName)) {
+ jSimulatorSingleResource.setName(newName);
singleRes.setResourceName(newName);
- } else {
- if (!singleRes.getResourceURI().equals(newUri)) {
- jSimulatorSingleResource.setURI(newUri);
- singleRes.setResourceURI(newUri);
- }
- if (!singleRes.getResourceName().equals(newName)) {
- jSimulatorSingleResource.setName(newName);
- singleRes.setResourceName(newName);
- }
+ }
+ String currentType = singleRes.getResourceType();
+ if (null == currentType || !currentType.equals(newType)) {
+ jSimulatorSingleResource.setResourceType(newType);
+ singleRes.setResourceType(newType);
}
// Set the model change listener.
singleRes.setResourceModel(jResModel);
// Fetch the basic details of the resource.
- singleRes.setResourceType(jSimulatorSingleResource
- .getResourceType());
singleRes
.setResourceInterfaces(Utility
.convertVectorToSet(jSimulatorSingleResource
}
SimulatorSingleResource jResource;
SingleResource resource;
- boolean result;
for (SimulatorResource jSimulatorResource : jSimulatorResources) {
// If the resource creation progress is canceled, then stop the
// creation and stop/delete
resource = new SingleResource();
resource.setSimulatorResource(jResource);
try {
- result = completeSingleResourceCreationByRAML(resource,
- jResource.getURI(), jResource.getName(), true);
- if (result) {
- resultSet.add(resource);
+ String uri = jSimulatorResource.getURI();
+ if (null == uri || uri.trim().isEmpty()) {
+ // URI is mandatory to be present in RAML. If it is not
+ // there, then resource will be ignored.
+ continue;
+ }
+ resource.setResourceURI(uri.trim());
+
+ String type = jSimulatorResource.getResourceType();
+ if (null != type) {
+ type = type.trim();
}
+ resource.setResourceType(type);
+
+ String name = jSimulatorResource.getName();
+ if (null != name) {
+ name = name.trim();
+ }
+ resource.setResourceName(name);
+
+ resultSet.add(resource);
} catch (SimulatorException eInner) {
Activator
.getDefault()
.getDefault()
.getLogManager()
.log(Level.ERROR.ordinal(), new Date(),
- "There is an error while creating the wizard.\n");
+ "There is an error while reading information from the UI wizard.\n");
return;
}
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Display;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.Date;
*/
public class CreateResourceWizard extends Wizard {
- private MainPage mainPage;
- private SimpleResourceBasicDetailsPage simpleResourceBasicDetailsPage;
- private SimpleResourceAddAttributePage simpleResourceAddAttributePage;
- private SimpleResourceOtherDetailsPage simpleResourceOtherDetailsPage;
- private LoadRamlPage loadRamlPage;
- private UpdatePropertiesPage updatePropPage;
+ private MainPage mainPage;
+ private SimpleResourceBasicDetailsPage simpleResourceBasicDetailsPage;
+ private SimpleResourceAddAttributePage simpleResourceAddAttributePage;
+ private SimpleResourceOtherDetailsPage simpleResourceOtherDetailsPage;
+ private LoadRamlPage loadRamlPage;
+ private UpdatePropertiesPage updatePropPage;
+ private UpdateMultiInstanceCreationPropertiesPage updateMultiInstanceCreationPropPage;
- private String status;
+ private String status;
- private WizardDialog wizDialog;
- private boolean dlgForceClosed;
+ private WizardDialog wizDialog;
+ private boolean dlgForceClosed;
- private Resource createdResource;
-
- private IProgressMonitor progressMonitor;
+ private Resource createdResource;
+ private Set<SingleResource> multiInstanceResourceSet;
public CreateResourceWizard() {
setWindowTitle("Create resources");
simpleResourceOtherDetailsPage = new SimpleResourceOtherDetailsPage();
loadRamlPage = new LoadRamlPage();
updatePropPage = new UpdatePropertiesPage();
+ updateMultiInstanceCreationPropPage = new UpdateMultiInstanceCreationPropertiesPage();
addPage(mainPage);
addPage(simpleResourceBasicDetailsPage);
addPage(simpleResourceOtherDetailsPage);
addPage(loadRamlPage);
addPage(updatePropPage);
+ addPage(updateMultiInstanceCreationPropPage);
}
public void setWizardDialog(WizardDialog dlg) {
return createdResource;
}
+ public Set<SingleResource> getCreatedMultiInstanceResourceSet() {
+ return multiInstanceResourceSet;
+ }
+
@Override
public boolean canFinish() {
IWizardPage curPage = this.getContainer().getCurrentPage();
- if ((curPage == updatePropPage && ((mainPage.getOption() == Option.SIMPLE_FROM_RAML) || !Activator
- .getDefault().getResourceManager().isAnyResourceExist()))
- || curPage == simpleResourceAddAttributePage
- || (curPage == loadRamlPage && loadRamlPage.isSelectionDone() && loadRamlPage
- .isMultiResourceCreation())) {
+ if ((curPage == updateMultiInstanceCreationPropPage || curPage == updatePropPage
+ && ((mainPage.getOption() == Option.SIMPLE_FROM_RAML) || !Activator
+ .getDefault().getResourceManager().isAnyResourceExist()))
+ || curPage == simpleResourceAddAttributePage) {
return true;
}
return false;
.log(Level.ERROR.ordinal(), new Date(), e.getMessage());
e.printStackTrace();
}
- } else if (curPage == loadRamlPage) {
- // Validate the file path.
- FileInputStream fileStream = null;
- try {
- fileStream = new FileInputStream(
- loadRamlPage.getConfigFilePath());
- } catch (FileNotFoundException e) {
- MessageDialog
- .openError(getShell(), "Invalid File",
- "File doesn't exist. Either the file path or file name is invalid.");
- return false;
- } finally {
- if (null != fileStream) {
- try {
- fileStream.close();
- } catch (IOException e) {
- Activator
- .getDefault()
- .getLogManager()
- .log(Level.ERROR.ordinal(), new Date(),
- "There is an error while closing the file stream.\n");
- }
- }
- }
-
- // Handling multiple instance creation of simple resource with RAML
- if ((loadRamlPage.getResourceCount() + Activator.getDefault()
- .getResourceManager().getResourceCount()) > Constants.MAX_RESOURCE_COUNT) {
- MessageDialog.openInformation(Display.getDefault()
- .getActiveShell(), "Resource limit exceeded",
- Constants.RESOURCE_LIMIT_EXCEEDED_MSG);
- return false;
- }
-
- final int[] resCreatedCount = new int[1];
- try {
- getContainer().run(true, true, new IRunnableWithProgress() {
-
- @Override
- public void run(final IProgressMonitor monitor)
- throws InvocationTargetException,
- InterruptedException {
- progressMonitor = monitor;
- try {
- monitor.beginTask(
- "Single Resource Creation(multi-instance) With RAML",
- loadRamlPage.getResourceCount());
- resCreatedCount[0] = createMultiInstanceSingleResourceWithoutRAML();
-
- } finally {
- monitor.done();
- }
- }
- });
- } catch (InvocationTargetException e) {
- Activator.getDefault().getLogManager()
- .log(Level.ERROR.ordinal(), new Date(), e.getMessage());
- e.printStackTrace();
- } catch (InterruptedException e) {
- Activator.getDefault().getLogManager()
- .log(Level.ERROR.ordinal(), new Date(), e.getMessage());
- e.printStackTrace();
- }
- boolean canceled = false;
- if (null != progressMonitor && progressMonitor.isCanceled()
- && 0 == resCreatedCount[0]) {
- canceled = true;
- }
- progressMonitor = null;
- if (canceled) {
- return false;
+ } else if (curPage == updatePropPage
+ || curPage == updateMultiInstanceCreationPropPage) {
+ multiInstanceResourceSet = loadRamlPage
+ .getMultiInstanceResourceSet();
+ createdResource = loadRamlPage.getResource();
+
+ String resName;
+ String resURI;
+ String resType;
+ boolean multiInstanceCreation = loadRamlPage
+ .isMultiResourceCreation();
+
+ if (curPage == updatePropPage) {
+ resName = updatePropPage.getResName();
+ resURI = updatePropPage.getResURI();
+ resType = updatePropPage.getResType();
} else {
- if (resCreatedCount[0] > 0) {
- UiListenerHandler.getInstance()
- .resourceCreatedUINotification(ResourceType.SINGLE);
- }
+ resName = updateMultiInstanceCreationPropPage.getResName();
+ resURI = "";
+ resType = updateMultiInstanceCreationPropPage.getResType();
}
- } else if (curPage == updatePropPage) {
- // Handling the single instance
- String resName = updatePropPage.getResName();
- String resURI = updatePropPage.getResURI();
+
if (null == resName || resName.trim().length() < 1) {
MessageDialog.openError(Display.getDefault().getActiveShell(),
"Invalid Resource Name.", "Resource name is invalid");
return false;
}
- if (!Utility.isUriValid(resURI)) {
+
+ if (!multiInstanceCreation && !Utility.isUriValid(resURI)) {
MessageDialog.openError(Display.getDefault().getActiveShell(),
"Invalid Resource URI.", Constants.INVALID_URI_MESSAGE);
return false;
}
+
// Creation of simple resource with RAML
// Checking whether the URI is used by any other resource.
- if (Activator.getDefault().getResourceManager()
- .isResourceExist(updatePropPage.getResURI())) {
+ if (!multiInstanceCreation
+ && Activator.getDefault().getResourceManager()
+ .isResourceExist(resURI)) {
MessageDialog
.openError(getShell(), "Resource URI in use",
"Entered resource URI is in use. Please try a different one.");
return false;
}
+ if (!Utility.isResourceTypeValid(resType)) {
+ MessageDialog.openError(Display.getDefault().getActiveShell(),
+ "Invalid Resource Type.",
+ Constants.INVALID_RESOURCE_TYPE_MESSAGE);
+ return false;
+ }
+
try {
getContainer().run(true, false, new IRunnableWithProgress() {
try {
monitor.beginTask("Completing Resource Creation", 2);
monitor.worked(1);
- completeResourceCreationWithRAML();
+ if (loadRamlPage.isMultiResourceCreation()) {
+ completeMultiInstanceResourceCreationWithRAML();
+ } else {
+ completeSingleInstanceResourceCreationWithRAML();
+ }
monitor.worked(1);
} finally {
monitor.done();
return updatePropPage;
}
+ public UpdateMultiInstanceCreationPropertiesPage getUpdateMultiInstanceCreationPropPage() {
+ return updateMultiInstanceCreationPropPage;
+ }
+
+ public void setUpdateMultiInstanceCreationPropPage(
+ UpdateMultiInstanceCreationPropertiesPage updateMultiInstanceCreationPropPage) {
+ this.updateMultiInstanceCreationPropPage = updateMultiInstanceCreationPropPage;
+ }
+
public void setStatus(String status) {
this.status = status;
}
}
}
- private void completeResourceCreationWithRAML() {
+ private void completeSingleInstanceResourceCreationWithRAML() {
+ String resName = updatePropPage.getResName();
+ String resURI = updatePropPage.getResURI();
+ String resType = updatePropPage.getResType();
+
try {
boolean result = false;
- Resource res = loadRamlPage.getResource();
- if (res instanceof SingleResource) {
+ if (createdResource instanceof SingleResource) {
result = Activator
.getDefault()
.getResourceManager()
- .completeSingleResourceCreationByRAML(res,
- updatePropPage.getResURI(),
- updatePropPage.getResName(), false);
+ .completeSingleResourceCreationByRAML(createdResource,
+ resURI, resName, resType, false);
}
if (result) {
status = "Resource created.";
- createdResource = res;
} else {
status = "Failed to create resource.";
createdResource = null;
}
}
- private int createMultiInstanceSingleResourceWithoutRAML() {
- int toCreateCount = loadRamlPage.getResourceCount();
- int resCreatedCount = 0;
- Set<SingleResource> resources;
- try {
- resources = Activator
- .getDefault()
- .getResourceManager()
- .createSingleResourceMultiInstances(
- loadRamlPage.getConfigFilePath(), toCreateCount,
- progressMonitor);
- if (null != progressMonitor && progressMonitor.isCanceled()) {
- try {
- Activator.getDefault().getResourceManager()
- .removeSingleResources(resources);
- } catch (SimulatorException e) {
- Activator
- .getDefault()
- .getLogManager()
- .log(Level.ERROR.ordinal(),
- new Date(),
- "There is an error while updating the resource model.\n"
- + Utility.getSimulatorErrorString(
- e, null));
+ private void completeMultiInstanceResourceCreationWithRAML() {
+ String resName = updateMultiInstanceCreationPropPage.getResName();
+ String resType = updateMultiInstanceCreationPropPage.getResType();
+
+ if (null == multiInstanceResourceSet)
+ return;
+
+ boolean result = false;
+ int count = loadRamlPage.getResourceCount();
+ int successCount = 0;
+ SingleResource resource;
+ Iterator<SingleResource> itr = multiInstanceResourceSet.iterator();
+ while (itr.hasNext()) {
+ resource = itr.next();
+ try {
+ result = Activator
+ .getDefault()
+ .getResourceManager()
+ .completeSingleResourceCreationByRAML(resource, null,
+ resName, resType, true);
+ if (result) {
+ successCount++;
}
- return 0;
- }
- if (null != resources)
- resCreatedCount = resources.size();
- if (resCreatedCount > 0) {
- status = "[" + resCreatedCount + " out of " + toCreateCount
- + "]";
- status += ((resCreatedCount == 1) ? "resource" : "resources")
- + " created successfully.";
- } else {
- status = "Failed to create resources.";
+
+ } catch (SimulatorException e) {
+ // Do Nothing.
}
- } catch (SimulatorException e) {
- status = "Failed to create resource.\n"
- + Utility.getSimulatorErrorString(e, null);
}
- return resCreatedCount;
+ if (successCount > 0) {
+ UiListenerHandler.getInstance().resourceCreatedUINotification(
+ ResourceType.SINGLE);
+
+ status = "[" + successCount + " out of " + count + "]";
+ status += ((successCount == 1) ? "resource" : "resources")
+ + " created successfully.";
+ } else {
+ status = "Failed to create resources.";
+ }
}
}
\ No newline at end of file
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Date;
+import java.util.Set;
import org.oic.simulator.ILogger.Level;
import org.oic.simulator.SimulatorException;
private int resourceCount;
private Resource resource;
+ private Set<SingleResource> multiInstanceResourceSet;
private SimulatorResource.Type typeOfResource;
+ private IProgressMonitor progressMonitor;
+
protected LoadRamlPage() {
super("Create Resource");
resourceCount = -1;
resourceCount = -1;
}
if (null != configFilePath && configFilePath.trim().length() > 0) {
- if (resourceCount == 1) {
+ if (resourceCount >= 1) {
done = true;
}
}
return null;
}
+ IWizardPage nextPage;
+ String resName;
+ String resURI;
+ String resType;
final CreateResourceWizard wizard = ((CreateResourceWizard) getWizard());
+ if (isMultiResourceCreation()) {
+ final int[] resCreatedCount = new int[1];
+ try {
+ getContainer().run(true, true, new IRunnableWithProgress() {
+
+ @Override
+ public void run(final IProgressMonitor monitor)
+ throws InvocationTargetException,
+ InterruptedException {
+ progressMonitor = monitor;
+ try {
+ monitor.beginTask(
+ "Single Resource Creation(multi-instance) With RAML",
+ wizard.getLoadRamlPage().getResourceCount());
+ resCreatedCount[0] = createMultiInstanceSingleResourceWithRAML();
+
+ } finally {
+ monitor.done();
+ }
+ }
+ });
+ } catch (InvocationTargetException e) {
+ Activator.getDefault().getLogManager()
+ .log(Level.ERROR.ordinal(), new Date(), e.getMessage());
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ Activator.getDefault().getLogManager()
+ .log(Level.ERROR.ordinal(), new Date(), e.getMessage());
+ e.printStackTrace();
+ }
- try {
- getContainer().run(true, false, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
- try {
- monitor.beginTask("Resource Creation With RAML", 2);
- monitor.worked(1);
- resource = Activator.getDefault().getResourceManager()
- .createResourceByRAML(configFilePath);
- monitor.worked(1);
- } catch (SimulatorException e) {
- wizard.setStatus("Failed to create resource.\n"
- + Utility.getSimulatorErrorString(e, null));
- } finally {
- monitor.done();
+ if (0 == resCreatedCount[0]) {
+ wizard.setStatus("Failed to create Resources.");
+ wizard.getWizardDialog().close();
+ return null;
+ }
+
+ boolean canceled = false;
+ if (null != progressMonitor && progressMonitor.isCanceled()) {
+ canceled = true;
+ }
+ progressMonitor = null;
+ if (canceled) {
+ return null;
+ }
+
+ // It is guaranteed that will be at least one resource at this
+ // point.
+ SingleResource resourceInstance = (SingleResource) multiInstanceResourceSet
+ .toArray()[0];
+ resName = resourceInstance.getResourceName();
+ resType = resourceInstance.getResourceType();
+ resURI = resourceInstance.getResourceURI();
+ UpdateMultiInstanceCreationPropertiesPage updatePageRef = wizard
+ .getUpdateMultiInstanceCreationPropPage();
+ updatePageRef.setResName(resName);
+ updatePageRef.setResType(resType);
+ nextPage = updatePageRef;
+ } else {
+ try {
+ getContainer().run(true, false, new IRunnableWithProgress() {
+ @Override
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException,
+ InterruptedException {
+ try {
+ monitor.beginTask("Resource Creation With RAML", 2);
+ monitor.worked(1);
+ resource = Activator.getDefault()
+ .getResourceManager()
+ .createResourceByRAML(configFilePath);
+ monitor.worked(1);
+ } catch (SimulatorException e) {
+ wizard.setStatus("Failed to create resource.\n"
+ + Utility.getSimulatorErrorString(e, null));
+ } finally {
+ monitor.done();
+ }
}
+ });
+ } catch (InvocationTargetException e) {
+ Activator.getDefault().getLogManager()
+ .log(Level.ERROR.ordinal(), new Date(), e.getMessage());
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ Activator.getDefault().getLogManager()
+ .log(Level.ERROR.ordinal(), new Date(), e.getMessage());
+ e.printStackTrace();
+ }
+ if (null == resource) {
+ wizard.setStatus("Failed to create Resource.");
+ wizard.getWizardDialog().close();
+ return null;
+ } else {
+ // Checking whether the resource is of type single.
+ Option intendedResource = wizard.getMainPage().getOption();
+ if ((intendedResource == Option.SIMPLE_FROM_RAML && !(resource instanceof SingleResource))) {
+ MessageDialog
+ .openError(
+ getShell(),
+ "Invalid RAML",
+ "Uploaded RAML is not of simple type. "
+ + "Please upload the proper RAML of simple type.");
+ return null;
}
- });
- } catch (InvocationTargetException e) {
- Activator.getDefault().getLogManager()
- .log(Level.ERROR.ordinal(), new Date(), e.getMessage());
- e.printStackTrace();
- } catch (InterruptedException e) {
- Activator.getDefault().getLogManager()
- .log(Level.ERROR.ordinal(), new Date(), e.getMessage());
- e.printStackTrace();
+ }
+ resName = resource.getResourceName();
+ resURI = resource.getResourceURI();
+ resType = resource.getResourceType();
+ UpdatePropertiesPage updatePageRef = wizard.getUpdatePropPage();
+ updatePageRef.setResName(resName);
+ updatePageRef.setResURI(resURI);
+ updatePageRef.setResType(resType);
+ nextPage = updatePageRef;
}
- if (null == resource) {
- wizard.setStatus("Failed to create Resource.");
- wizard.getWizardDialog().close();
- return null;
- } else {
- // Checking whether the resource is of type single.
- Option intendedResource = wizard.getMainPage().getOption();
- if ((intendedResource == Option.SIMPLE_FROM_RAML && !(resource instanceof SingleResource))) {
- MessageDialog
- .openError(
- getShell(),
- "Invalid RAML",
- "Uploaded RAML is not of simple type. "
- + "Please upload the proper RAML of simple type.");
- return null;
+ return nextPage;
+ }
+
+ public int createMultiInstanceSingleResourceWithRAML() {
+ int resCreatedCount = 0;
+ try {
+ multiInstanceResourceSet = Activator
+ .getDefault()
+ .getResourceManager()
+ .createSingleResourceMultiInstances(configFilePath,
+ resourceCount, progressMonitor);
+ if (null != progressMonitor && progressMonitor.isCanceled()) {
+ try {
+ Activator.getDefault().getResourceManager()
+ .removeSingleResources(multiInstanceResourceSet);
+ } catch (SimulatorException e) {
+ Activator
+ .getDefault()
+ .getLogManager()
+ .log(Level.ERROR.ordinal(),
+ new Date(),
+ "There is an error while handling the cancellation request.\n"
+ + Utility.getSimulatorErrorString(
+ e, null));
+ }
+ return 0;
}
+ if (null != multiInstanceResourceSet)
+ resCreatedCount = multiInstanceResourceSet.size();
+ } catch (SimulatorException e) {
+ Activator
+ .getDefault()
+ .getLogManager()
+ .log(Level.ERROR.ordinal(),
+ new Date(),
+ "Failed to create resource(s).\n"
+ + Utility.getSimulatorErrorString(e, null));
}
- UpdatePropertiesPage updatePageRef = wizard.getUpdatePropPage();
- updatePageRef.setResName(resource.getResourceName());
- updatePageRef.setResURI(resource.getResourceURI());
- return updatePageRef;
+ return resCreatedCount;
}
public String getConfigFilePath() {
public void setResource(Resource resource) {
this.resource = resource;
}
+
+ public Set<SingleResource> getMultiInstanceResourceSet() {
+ return multiInstanceResourceSet;
+ }
+
+ public void setMultiInstanceResourceSet(Set<SingleResource> resource) {
+ multiInstanceResourceSet = resource;
+ }
}
\ No newline at end of file
LoadRamlPage loadRamlPage = createWizard.getLoadRamlPage();
UpdatePropertiesPage updatePropPage = createWizard
.getUpdatePropPage();
+ UpdateMultiInstanceCreationPropertiesPage updateMultiInstanceCreationPropPage = createWizard
+ .getUpdateMultiInstanceCreationPropPage();
IWizardPage curPage = wizard.getContainer().getCurrentPage();
IWizardPage prevPage = null;
if (curPage == loadRamlPage
|| curPage == simpleResourceBasicDetailsPage) {
prevPage = mainPage;
- } else if (curPage == updatePropPage) {
+ } else if (curPage == updatePropPage
+ || curPage == updateMultiInstanceCreationPropPage) {
loadRamlPage.setResource(null);
+ loadRamlPage.setMultiInstanceResourceSet(null);
prevPage = loadRamlPage;
} else if (curPage == simpleResourceAddAttributesPage) {
prevPage = simpleResourceBasicDetailsPage;
--- /dev/null
+/*
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ * 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 oic.simulator.serviceprovider.view.dialogs;
+
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import oic.simulator.serviceprovider.utils.Constants;
+
+public class UpdateMultiInstanceCreationPropertiesPage extends WizardPage {
+
+ private Text resNameTxt;
+ private Text resTypeTxt;
+
+ private String resName;
+ private String resType;
+
+ protected UpdateMultiInstanceCreationPropertiesPage() {
+ super("Update Properties");
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ setPageComplete(true);
+ setTitle(Constants.UPDATE_PROP_PAGE_TITLE);
+ setMessage(Constants.UPDATE_PROP_PAGE_MESSAGE);
+
+ Composite comp = new Composite(parent, SWT.NONE);
+ GridLayout gridLayout = new GridLayout();
+ comp.setLayout(gridLayout);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ comp.setLayoutData(gd);
+
+ Group grp = new Group(comp, SWT.NONE);
+ gridLayout = new GridLayout(2, false);
+ grp.setLayout(gridLayout);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ grp.setLayoutData(gd);
+
+ Label resNameLbl = new Label(grp, SWT.NULL);
+ resNameLbl.setText("Resource Name");
+ gd = new GridData();
+ gd.verticalIndent = 20;
+ resNameLbl.setLayoutData(gd);
+
+ resNameTxt = new Text(grp, SWT.BORDER);
+ resNameTxt.setFocus();
+ gd = new GridData();
+ gd.widthHint = 300;
+ gd.verticalIndent = 20;
+ resNameTxt.setLayoutData(gd);
+
+ Label resTypeLbl = new Label(grp, SWT.NULL);
+ resTypeLbl.setText("Resource Type");
+ gd = new GridData();
+ gd.verticalIndent = 10;
+ resTypeLbl.setLayoutData(gd);
+
+ resTypeTxt = new Text(grp, SWT.BORDER);
+ gd = new GridData();
+ gd.widthHint = 300;
+ gd.verticalIndent = 10;
+ resTypeTxt.setLayoutData(gd);
+
+ Label descLbl = new Label(comp, SWT.NONE);
+ descLbl.setText("Description:");
+ gd = new GridData();
+ descLbl.setLayoutData(gd);
+
+ final Text text = new Text(comp, SWT.MULTI | SWT.READ_ONLY | SWT.BORDER
+ | SWT.WRAP | SWT.V_SCROLL);
+ text.setText("All resource instances will be configured with the same resource name and type.\n"
+ + "These properties can be changed later from properties view.");
+ gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ text.setLayoutData(gd);
+
+ addUIListeners();
+
+ // Initialize data
+ if (resNameTxt.getText().length() < 1 && null != resName) {
+ resNameTxt.setText(resName);
+ }
+ if (resTypeTxt.getText().length() < 1 && null != resType) {
+ resTypeTxt.setText(resType);
+ }
+
+ setControl(comp);
+ }
+
+ private void addUIListeners() {
+ resNameTxt.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ resName = resNameTxt.getText();
+ setPageComplete(isSelectionDone());
+ }
+ });
+
+ resTypeTxt.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ resType = resTypeTxt.getText();
+ if (null == resType) {
+ return;
+ }
+
+ setPageComplete(isSelectionDone());
+ }
+ });
+ }
+
+ @Override
+ public boolean canFlipToNextPage() {
+ return false;
+ }
+
+ public boolean isSelectionDone() {
+ boolean done = false;
+ if (null != resName && resName.trim().length() > 0 && null != resType
+ && resType.trim().length() > 0) {
+ done = true;
+ }
+ return done;
+ }
+
+ @Override
+ public IWizardPage getNextPage() {
+ return null;
+ }
+
+ public void setResName(String resName) {
+ if (null == resName) {
+ resName = "";
+ }
+
+ this.resName = resName;
+ if (null != resName && !resNameTxt.isDisposed())
+ resNameTxt.setText(resName);
+ }
+
+ public void setResType(String resType) {
+ if (null == resType) {
+ resType = "";
+ }
+
+ this.resType = resType;
+ if (null != resType && !resTypeTxt.isDisposed())
+ resTypeTxt.setText(resType);
+ }
+
+ public String getResName() {
+ return resName;
+ }
+
+ public String getResType() {
+ return resType;
+ }
+}
private Text resNameTxt;
private Text resUriTxt;
+ private Text resTypeTxt;
private String resName;
private String resURI;
+ private String resType;
protected UpdatePropertiesPage() {
super("Update Properties");
gd.verticalIndent = 10;
resUriTxt.setLayoutData(gd);
+ Label resTypeLbl = new Label(grp, SWT.NULL);
+ resTypeLbl.setText("Resource Type");
+ gd = new GridData();
+ gd.verticalIndent = 10;
+ resTypeLbl.setLayoutData(gd);
+
+ resTypeTxt = new Text(grp, SWT.BORDER);
+ gd = new GridData();
+ gd.widthHint = 300;
+ gd.verticalIndent = 10;
+ resTypeTxt.setLayoutData(gd);
+
Label descLbl = new Label(comp, SWT.NONE);
descLbl.setText("Description:");
gd = new GridData();
if (resNameTxt.getText().length() < 1 && null != resName) {
resNameTxt.setText(resName);
}
+ if (resTypeTxt.getText().length() < 1 && null != resType) {
+ resTypeTxt.setText(resType);
+ }
setControl(comp);
}
setPageComplete(isSelectionDone());
}
});
+
+ resTypeTxt.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ resType = resTypeTxt.getText();
+ if (null == resType) {
+ return;
+ }
+
+ setPageComplete(isSelectionDone());
+ }
+ });
}
@Override
public boolean isSelectionDone() {
boolean done = false;
if (null != resName && resName.trim().length() > 0 && null != resURI
- && resURI.trim().length() > 0) {
+ && resURI.trim().length() > 0 && null != resType
+ && resType.trim().length() > 0) {
done = true;
}
return done;
}
public void setResName(String resName) {
+ if (null == resName) {
+ resName = "";
+ }
+
this.resName = resName;
- if (!resNameTxt.isDisposed())
+ if (null != resName && !resNameTxt.isDisposed())
resNameTxt.setText(resName);
}
public void setResURI(String resURI) {
+ if (null == resURI) {
+ resURI = "";
+ }
+
this.resURI = resURI;
- if (!resUriTxt.isDisposed())
+ if (null != resUriTxt && !resUriTxt.isDisposed())
resUriTxt.setText(resURI);
}
+ public void setResType(String resType) {
+ if (null == resType) {
+ resType = "";
+ }
+
+ this.resType = resType;
+ if (null != resType && !resTypeTxt.isDisposed())
+ resTypeTxt.setText(resType);
+ }
+
public String getResName() {
return resName;
}
public String getResURI() {
return resURI;
}
+
+ public String getResType() {
+ return resType;
+ }
}
resourceModel.remove("resourceType");\r
}\r
\r
- // Construct resource type from uri\r
- if(resourceType.empty())\r
- {\r
- std::ostringstream rtString;\r
- rtString << "oic.r.";\r
-\r
- size_t pos = resourceURI.rfind("/");\r
- if (pos == std::string::npos)\r
- pos = -1;\r
-\r
- std::string rtName = resourceURI.substr(pos+1);\r
- std::transform(rtName.begin(), rtName.end(), rtName.begin(), ::tolower);\r
- rtString << rtName;\r
- resourceType = rtString.str();\r
- }\r
-\r
// Extracting interface type.\r
std::vector<std::string> interfaceTypes;\r
if (resourceModel.contains("if"))\r
new SimulatorCollectionResourceImpl());\r
\r
collectionRes->setName(resourceName);\r
- collectionRes->setResourceType(resourceType);\r
+ if(!resourceType.empty())\r
+ collectionRes->setResourceType(resourceType);\r
if (interfaceTypes.size() > 0)\r
collectionRes->setInterface(interfaceTypes);\r
collectionRes->setURI(ResourceURIFactory::getInstance()->makeUniqueURI(resourceURI));\r
new SimulatorSingleResourceImpl());\r
\r
singleRes->setName(resourceName);\r
- singleRes->setResourceType(resourceType);\r
+ if(!resourceType.empty())\r
+ singleRes->setResourceType(resourceType);\r
if (interfaceTypes.size() > 0)\r
singleRes->setInterface(interfaceTypes);\r
singleRes->setURI(ResourceURIFactory::getInstance()->makeUniqueURI(resourceURI));\r
linux_sample_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
linux_sample_env.AppendUnique(CPPDEFINES = ['LINUX'])
linux_sample_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
-linux_sample_env.AppendUnique(LIBS = ['libTGMSDKLibrary', 'oc', 'octbstack',
- 'connectivity_abstraction',
- 'libcoap', 'liboc_logger', 'dl', 'pthread'])
+linux_sample_env.PrependUnique(LIBS = ['coap'])
+linux_sample_env.AppendUnique(LIBS = ['connectivity_abstraction'])
+linux_sample_env.AppendUnique(LIBS = ['oc_logger'])
+linux_sample_env.AppendUnique(LIBS = ['octbstack'])
+linux_sample_env.AppendUnique(LIBS = ['oc'])
+linux_sample_env.AppendUnique(LIBS = ['libTGMSDKLibrary'])
+linux_sample_env.AppendUnique(LIBS = ['dl'])
+linux_sample_env.AppendUnique(LIBS = ['pthread'])
+
if env.get('SECURED') == '1':
linux_sample_env.AppendUnique(LIBS = ['tinydtls'])
ThingsManager_gtest_env.PrependUnique(LIBS = [
'libTGMSDKLibrary',
- 'oc',
- 'octbstack',
+ 'coap',
+ 'connectivity_abstraction',
'oc_logger',
'oc_logger_core',
- 'connectivity_abstraction',
+ 'oc',
+ 'octbstack',
gtest,
gtest_main])
if target_os == 'linux':
from tools.scons.RunTest import *
run_test(ThingsManager_gtest_env, '',
- 'service/things-manager/unittests/ThingsManagerTest')
\ No newline at end of file
+ 'service/things-manager/unittests/ThingsManagerTest')