2 * ******************************************************************
4 * Copyright 2016 Samsung Electronics All Rights Reserved.
6 * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
20 * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
23 package org.iotivity.base.examples;
25 import android.content.Context;
26 import android.widget.Toast;
27 import android.util.Log;
29 import org.iotivity.base.OcPlatform;
30 import org.iotivity.base.ResourceProperty;
32 import java.text.DateFormat;
33 import java.util.Calendar;
34 import java.util.Date;
35 import java.util.EnumSet;
36 import java.util.Locale;
39 * This class charge of common part.
43 private static final String TAG = "OIC_SIMPLE_COMMON";
44 public static final int DATA_SIZE = 3000;
45 public static String HOST = "coap+tcp://192.168.0.1:5683";
46 public static final String COAP_TCP = "coap+tcp://";
47 public static final String COAPS_TCP = "coaps+tcp://";
48 public static String TCP_ADDRESS = "192.168.0.1";
49 public static String TCP_PORT = "5683";
50 public static final String PORT_SEPARATOR = ":";
51 public static final String IP_ADDRESS = "0.0.0.0";
52 public static final int IP_PORT = 0;
53 public static final String GET_COMMAND = "get_command";
54 public static final String STATE_KEY = "state_key";
55 public static final String STATE_GET = "state_get";
56 public static final String LARGE_KEY = "large_key";
57 public static final String LARGE_GET = "large_get";
58 public static final String RESOURCE_URI = "/a/light";
59 public static final String RESOURCE_TYPE = "core.light";
60 public static final String RESOURCE_INTERFACE = OcPlatform.DEFAULT_INTERFACE;
61 public static final EnumSet<ResourceProperty> RESOURCE_PROPERTIES =
62 EnumSet.of(ResourceProperty.DISCOVERABLE, ResourceProperty.OBSERVABLE);
65 public final static String MQ_DEFAULT_TOPIC_URI = "/oic/ps/cleanroom";
66 public final static String MQ_BROKER_URI = "/oic/ps";
68 private static String mLeAddress = null;
70 public static String getDateCurrentTimeZone() {
71 StringBuilder sb = new StringBuilder();
73 Calendar calendar = Calendar.getInstance();
74 calendar.setTimeInMillis(System.currentTimeMillis());
75 DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT,
78 Date currentTimeZone = calendar.getTime();
79 sb.append(dateFormat.format(currentTimeZone));
80 } catch (Exception e) {
86 public static void showToast(Context context, String msg) {
87 Toast.makeText(context, msg, Toast.LENGTH_SHORT).show();
90 public static void setLeAddress(String address)
92 Log.i(TAG, "setLeAddress : " + address.toString());
96 public static String getLeAddress()
98 Log.i(TAG, "getLeAddress : " + mLeAddress);