Back to project page gokit-android.
The source code is released under:
Copyright (c) 2014~2015 Xtreme Programming Group, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software...
If you think the Android project gokit-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/** * Project Name:Gokit//from w w w.ja v a 2 s . c o m * File Name:MessageCenter.java * Package Name:com.xpg.gokit.sdk * Date:2014-11-18 10:06:04 * Copyright (c) 2014~2015 Xtreme Programming Group, Inc. * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package com.xpg.gokit.sdk; import org.json.JSONException; import org.json.JSONObject; import android.content.Context; import com.xpg.gokit.setting.SettingManager; import com.xtremeprog.xpgconnect.XPGWifiDevice; import com.xtremeprog.xpgconnect.XPGWifiSDK; import com.xtremeprog.xpgconnect.XPGWifiSDK.XPGWifiConfigureMode; /** * ???????. * * @author Lien Li */ public class MessageCenter { /** The xpg wifi gcc. */ private static XPGWifiSDK xpgWifiGCC; /** The m center. */ private static MessageCenter mCenter; /** The m setting manager. */ private SettingManager mSettingManager; /** * Instantiates a new message center. * * @param c the c */ private MessageCenter(Context c) { if (mCenter == null) { init(c); } } /** * Gets the single instance of MessageCenter. * * @param c the c * @return single instance of MessageCenter */ public static MessageCenter getInstance(Context c) { if (mCenter == null) { mCenter = new MessageCenter(c); } return mCenter; } /** * Inits the. * * @param c the c */ private void init(Context c) { mSettingManager = new SettingManager(c); xpgWifiGCC = XPGWifiSDK.sharedInstance(); } /** * Gets the XPG wifi sdk. * * @return the XPG wifi sdk */ public XPGWifiSDK getXPGWifiSDK() { return xpgWifiGCC; } // ================================================================= // // ????????? // // ================================================================= /** * ??????. * * @param phone ??????? * @param code ????? * @param password ????? */ public void cRegisterPhoneUser(String phone, String code, String password) { xpgWifiGCC.registerUserByPhoneAndCode(phone, password, code); } /** * ??????<P> * ???????????????????????????????. */ public void cUserLoginAnonymous() { xpgWifiGCC.userLoginAnonymous(); } /** * ??????. */ public void cLogout() { xpgWifiGCC.userLogout(mSettingManager.getUid()); xpgWifiGCC.userLogout(mSettingManager.getHideUid()); mSettingManager.clean(); } /** * ??????. * * @param name ????? * @param psw ??? */ public void cLogin(String name, String psw) { xpgWifiGCC.userLoginWithUserName(name, psw); } /** * ?????. * * @param phone ????? * @param code ????? * @param password ??? */ public void cChangeUserPasswordWithCode(String phone, String code, String password) { xpgWifiGCC.changeUserPasswordByCode(phone, code, password); } /** * ?????????????????. * * @param phone ????? */ public void cRequestSendVerifyCode(String phone) { xpgWifiGCC.requestSendVerifyCode(phone); } /** * ?????airlink??????????wifi?ssid?password?????????. * * @param wifi wifi???? * @param password wifi??? */ public void cSetAirLink(String wifi, String password) { xpgWifiGCC.setDeviceWifi(wifi, password, XPGWifiConfigureMode.XPGWifiConfigureModeAirLink, 60); } /** * ??SSID. * * @param ssid the ssid * @param psw the psw */ public void cSetSSID(String ssid, String psw) { xpgWifiGCC.setDeviceWifi(ssid, psw, XPGWifiConfigureMode.XPGWifiConfigureModeSoftAP, 60); } /** * ?????????????????????????????????????? * ???Demo????????????productKey?6f3074fe43894547a4f1314bd7e3ae0b?????? * ????????????? * * @param uid ????? * @param token ??? */ public void cGetBoundDevices(String uid, String token) { xpgWifiGCC.getBoundDevices(uid, token, "6f3074fe43894547a4f1314bd7e3ae0b"); } /** * ????. * * @param uid ????? * @param token ??? * @param did did * @param passcode passcode */ public void cBindDevice(String uid, String token, String did, String passcode) { xpgWifiGCC.bindDevice(uid, token, did, passcode, null); } // ================================================================= // // ????????? // // ================================================================= /** * ???????. * * @param xpgWifiDevice the xpg wifi device * @param jsonsend the jsonsend */ public void cWrite(XPGWifiDevice xpgWifiDevice, JSONObject jsonsend) { xpgWifiDevice.write(jsonsend.toString()); } /** * ?????????. * * @param xpgWifiDevice the xpg wifi device * @throws JSONException the JSON exception */ public void cGetStatus(XPGWifiDevice xpgWifiDevice) throws JSONException { JSONObject json = new JSONObject(); json.put("cmd", 2); xpgWifiDevice.write(json.toString()); } /** * ????. * * @param xpgWifiDevice the xpg wifi device */ public void cDisconnect(XPGWifiDevice xpgWifiDevice) { xpgWifiDevice.disconnect(); } /** * ????Passcode. * * @param xpgWifiDevice the xpg wifi device * @return the string */ public String cGetPasscode(XPGWifiDevice xpgWifiDevice) { return xpgWifiDevice.getPasscode(); } /** * ????. * * @param xpgWifiDevice the xpg wifi device * @param uid the uid * @param token the token */ public void cUnbindDevice(XPGWifiDevice xpgWifiDevice, String uid, String token) { xpgWifiGCC.unbindDevice(uid, token, xpgWifiDevice.getDid(), xpgWifiDevice.getPasscode()); } }