com.gizwits.gizwifisdk.api.GizWifiSDK Java Examples

The following examples show how to use com.gizwits.gizwifisdk.api.GizWifiSDK. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GosPushManager.java    From GOpenSource_AppKit_Android_AS with MIT License 6 votes vote down vote up
public static void pushUnBindService(String token) {

		if (token.isEmpty()) {
			return;
		}

		if (GizPushType.GizPushJiGuang == gizPushType) {
			// 获取JPush的RegistrationID,即Channel_ID
			Channel_ID = JPushInterface.getRegistrationID(context);
		} else if (GizPushType.GizPushBaiDu == gizPushType) {
			// 获取BDPush的Channel_ID
			Channel_ID = BaiDuPushReceiver.BaiDuPush_Channel_ID;
		} else {
			return;
		}
		// TODO 绑定推送
		Log.i("Apptest", Channel_ID + "\n" + gizPushType.toString() + "\n" + token);
		GizWifiSDK.sharedInstance().channelIDUnBind(token, Channel_ID);
	}
 
Example #2
Source File: GosDeviceListActivity.java    From Gizwits-SmartBuld_Android with MIT License 6 votes vote down vote up
@Override
protected void onResume() {
	super.onResume();
	// TODO GosMessageHandler.getSingleInstance().SetHandler(handler);
	if (boundMessage.size() != 0) {
		progressDialog.show();
		if (boundMessage.size() == 2) {
			GizWifiSDK.sharedInstance().bindDevice(uid, token, boundMessage.get(0), boundMessage.get(1), null);
		} else if (boundMessage.size() == 1) {
			GizWifiSDK.sharedInstance().bindDeviceByQRCode(uid, token, boundMessage.get(0));
		} else {
			Log.i("Apptest", "ListSize:" + boundMessage.size());
		}
	}else {
		GosDeviceModuleBaseActivity.deviceslist = GizWifiSDK.sharedInstance().getDeviceList();
		UpdateUI();
	}

}
 
Example #3
Source File: GosDeviceListActivity.java    From gokit-android with MIT License 6 votes vote down vote up
@Override
protected void onResume() {
	super.onResume();
	
	GosDeviceModuleBaseActivity.deviceslist=GizWifiSDK.sharedInstance().getDeviceList();
	UpdateUI();
	// TODO GosMessageHandler.getSingleInstance().SetHandler(handler);
	if (boundMessage.size() != 0) {
		progressDialog.show();
		if (boundMessage.size() == 2) {
			GizWifiSDK.sharedInstance().bindDevice(uid, token, boundMessage.get(0), boundMessage.get(1), null);
		} else if (boundMessage.size() == 1) {
			GizWifiSDK.sharedInstance().bindDeviceByQRCode(uid, token, boundMessage.get(0));
		} else {
			Log.i("Apptest", "ListSize:" + boundMessage.size());
		}
	}

}
 
Example #4
Source File: GosApplication.java    From Gizwits-SmartBuld_Android with MIT License 6 votes vote down vote up
public void onCreate() {
	super.onCreate();

	// 读取配置文件
	gosDeploy = new GosDeploy(this);
	String AppID = GosDeploy.setAppID();
	String AppSecret = GosDeploy.setAppSecret();

	if (TextUtils.isEmpty(AppID) || AppID.contains("your_app_id") || TextUtils.isEmpty(AppSecret)
			|| AppSecret.contains("your_app_secret")) {
		if (flag == 0) {
		
		}
		flag++;
	} else {

		// 启动SDK
		GizWifiSDK.sharedInstance().startWithAppID(getApplicationContext(), AppID, null, null);

		// 设置日志等级和云端服务
		handler.sendEmptyMessageDelayed(0, 3000);

	}
}
 
Example #5
Source File: GosPushManager.java    From Gizwits-SmartBuld_Android with MIT License 6 votes vote down vote up
public static void pushUnBindService(String token) {

		if (token.isEmpty()) {
			return;
		}

		if (GizPushType.GizPushJiGuang == gizPushType) {
			// 获取JPush的RegistrationID,即Channel_ID
			Channel_ID = JPushInterface.getRegistrationID(context);
		} else if (GizPushType.GizPushBaiDu == gizPushType) {
			// 获取BDPush的Channel_ID
			Channel_ID = BaiDuPushReceiver.BaiDuPush_Channel_ID;
		} else {
			return;
		}
		// TODO 绑定推送
		Log.i("Apptest", Channel_ID + "\n" + gizPushType.toString() + "\n" + token);
		GizWifiSDK.sharedInstance().channelIDUnBind(token, Channel_ID);
	}
 
Example #6
Source File: GosPushManager.java    From gokit-android with MIT License 6 votes vote down vote up
public static void pushUnBindService(String token) {

		if (token.isEmpty()) {
			return;
		}

		if (GizPushType.GizPushJiGuang == gizPushType) {
			// 获取JPush的RegistrationID,即Channel_ID
			Channel_ID = JPushInterface.getRegistrationID(context);
		} else if (GizPushType.GizPushBaiDu == gizPushType) {
			// 获取BDPush的Channel_ID
			Channel_ID = BaiDuPushReceiver.BaiDuPush_Channel_ID;
		} else {
			return;
		}
		// TODO 绑定推送
		Log.i("Apptest", Channel_ID + "\n" + gizPushType.toString() + "\n" + token);
		GizWifiSDK.sharedInstance().channelIDUnBind(token, Channel_ID);
	}
 
Example #7
Source File: MessageCenter.java    From gokit-android with MIT License 6 votes vote down vote up
private void init(Context c) {
	gosDeploy = new GosDeploy(c);
	String AppID = GosDeploy.setAppID();
	String AppSecret = GosDeploy.setAppSecret();
	if (TextUtils.isEmpty(AppID) || AppID.contains("your_app_id") || TextUtils.isEmpty(AppSecret)
			|| AppSecret.contains("your_app_secret")) {
		String AppID_Toast = c.getString(R.string.AppID_Toast);
		if (flag == 0) {
			Toast.makeText(c, AppID_Toast, Toast.LENGTH_LONG).show();
		}
		flag++;
	} else {
		// 启动SDK
		ConcurrentHashMap<String, String> serverMap = new ConcurrentHashMap<String, String>();

		serverMap.put("openAPIInfo", TextUtils.isEmpty((String) GosDeploy.infoMap.get("openAPIDomain"))
				? "api.gizwits.com" : (String) GosDeploy.infoMap.get("openAPIDomain"));
		serverMap.put("siteInfo", TextUtils.isEmpty((String) GosDeploy.infoMap.get("siteDomain"))
				? "site.gizwits.com" : (String) GosDeploy.infoMap.get("siteDomain"));
		serverMap.put("pushInfo", (String) GosDeploy.infoMap.get("pushDomain"));
		GizWifiSDK.sharedInstance().startWithAppID(c, AppID, GosDeploy.setProductKeyList(), serverMap, false);
	}
	hand.sendEmptyMessageDelayed(SETCLOUD, 3000);

}
 
Example #8
Source File: GosPushManager.java    From gokit-android with MIT License 5 votes vote down vote up
/**
 * 向云端绑定推送
 * 
 * @param Token
 * @param Channel_ID
 * @param gizPushType
 */
public static void pushBindService(String token) {

	if (GizPushType.GizPushJiGuang == gizPushType) {
		// 获取JPush的RegistrationID,即Channel_ID
		Channel_ID = JPushInterface.getRegistrationID(context);

		// 设定JPush类型
		JPushInterface.setAlias(context, Channel_ID, new TagAliasCallback() {
			@Override
			public void gotResult(int arg0, String arg1, Set<String> arg2) {
				if (arg0 == 0) {
					Log.i("Apptest", "Alias: " + arg1);
				} else {
					Log.e("Apptest", "Result: " + arg0);
				}
			}
		});

	} else if (GizPushType.GizPushBaiDu == gizPushType) {
		// 获取BDPush的Channel_ID
		Channel_ID = BaiDuPushReceiver.BaiDuPush_Channel_ID;
	} else {
		return;
	}

	// TODO 绑定推送
	Log.i("Apptest", Channel_ID + "\n" + gizPushType.toString() + "\n" + token);
	GizWifiSDK.sharedInstance().channelIDBind(token, Channel_ID, gizPushType);
}
 
Example #9
Source File: GosPushManager.java    From GOpenSource_AppKit_Android_AS with MIT License 5 votes vote down vote up
/**
 * 向云端绑定推送
 * 
 * @param Token
 * @param Channel_ID
 * @param gizPushType
 */
public static void pushBindService(String token) {

	if (GizPushType.GizPushJiGuang == gizPushType) {
		// 获取JPush的RegistrationID,即Channel_ID
		Channel_ID = JPushInterface.getRegistrationID(context);

		// 设定JPush类型
		JPushInterface.setAlias(context, Channel_ID, new TagAliasCallback() {
			@Override
			public void gotResult(int arg0, String arg1, Set<String> arg2) {
				if (arg0 == 0) {
					Log.i("Apptest", "Alias: " + arg1);
				} else {
					Log.e("Apptest", "Result: " + arg0);
				}
			}
		});

	} else if (GizPushType.GizPushBaiDu == gizPushType) {
		// 获取BDPush的Channel_ID
		Channel_ID = BaiDuPushReceiver.BaiDuPush_Channel_ID;
	} else {
		return;
	}

	// TODO 绑定推送
	Log.i("Apptest", Channel_ID + "\n" + gizPushType.toString() + "\n" + token);
	GizWifiSDK.sharedInstance().channelIDBind(token, Channel_ID, gizPushType);
}
 
Example #10
Source File: MessageCenter.java    From GOpenSource_AppKit_Android_AS with MIT License 5 votes vote down vote up
private void init(Context c) {
	gosDeploy = new GosDeploy(c);
	String AppID = GosDeploy.setAppID();
	String AppSecret = GosDeploy.setAppSecret();
	if (TextUtils.isEmpty(AppID) || AppID.contains("your_app_id") || TextUtils.isEmpty(AppSecret)
			|| AppSecret.contains("your_app_secret")) {
		String AppID_Toast = c.getString(R.string.AppID_Toast);
		if (flag == 0) {
			Toast.makeText(c, AppID_Toast, Toast.LENGTH_LONG).show();
		}
		flag++;
	} else {
		// 启动SDK
		ConcurrentHashMap<String, String> serverMap = new ConcurrentHashMap<String, String>();

		serverMap.put("openAPIInfo", TextUtils.isEmpty((String) GosDeploy.infoMap.get("openAPI_URL"))
				? "api.gizwits.com" : (String) GosDeploy.infoMap.get("openAPI_URL"));
		serverMap.put("siteInfo", TextUtils.isEmpty((String) GosDeploy.infoMap.get("site_URL")) ? "site.gizwits.com"
				: (String) GosDeploy.infoMap.get("site_URL"));
		serverMap.put("pushInfo", (String) GosDeploy.infoMap.get("push_URL"));
		//GizWifiSDK.sharedInstance().startWithAppID(c, AppID, GosDeploy.setProductKeyList(), serverMap);

		GizWifiSDK.sharedInstance().startWithAppID(c, AppID, AppSecret, GosDeploy.setProductKeyList(), serverMap,
				false);

	}
	hand.sendEmptyMessageDelayed(SETCLOUD, 3000);

}
 
Example #11
Source File: GosAboutActivity.java    From Gizwits-SmartBuld_Android with MIT License 5 votes vote down vote up
@Override
	public void onResume() {
		super.onResume();
//		tv_SDKVersion.setText("V" + GizWifiSDK.sharedInstance().getVersion().toString());
		tv_SDKVersion.setText(GizWifiSDK.sharedInstance().getVersion().toString());
		tv_AppVersion.setText(getAppVersionName(this));
	}
 
Example #12
Source File: GosChangeUserPasswordActivity.java    From GOpenSource_AppKit_Android_AS with MIT License 5 votes vote down vote up
@Override
protected void onResume() {
	// TODO Auto-generated method stub
	super.onResume();

	GizWifiSDK.sharedInstance().setListener(listener);
}
 
Example #13
Source File: GosDeviceControlModuleBaseActivity.java    From Gizwits-SmartBuld_Android with MIT License 5 votes vote down vote up
@Override
protected void onResume() {
	super.onResume();
	// 每次返回activity都要注册一次sdk监听器,保证sdk状态能正确回调
	GizWifiSDK.sharedInstance().setListener(gizWifiSDKListener);
	// 每次打开页面都注册一次device监听器,保证能收到设备数据
	if (device != null) {
		device.setListener(gizWifiDeviceListener);
	}
}
 
Example #14
Source File: GosDeviceMoreActivity.java    From Gizwits-SmartBuld_Android with MIT License 5 votes vote down vote up
private void unboundAtion() {
	setProgressDialog(getResources().getString(R.string.unbounding_device), true, true);
	// 显示等待栏
	progressDialog.show();
	GizWifiSDK.sharedInstance().unbindDevice(spf.getString("Uid", ""), spf.getString("Token", ""), device.getDid());

}
 
Example #15
Source File: GosPushManager.java    From Gizwits-SmartBuld_Android with MIT License 5 votes vote down vote up
/**
 * 向云端绑定推送
 * 
 * @param Token
 * @param Channel_ID
 * @param gizPushType
 */
public static void pushBindService(String token) {

	if (GizPushType.GizPushJiGuang == gizPushType) {
		// 获取JPush的RegistrationID,即Channel_ID
		Channel_ID = JPushInterface.getRegistrationID(context);

		// 设定JPush类型
		JPushInterface.setAlias(context, Channel_ID, new TagAliasCallback() {
			@Override
			public void gotResult(int arg0, String arg1, Set<String> arg2) {
				if (arg0 == 0) {
					Log.i("Apptest", "Alias: " + arg1);
				} else {
					Log.e("Apptest", "Result: " + arg0);
				}
			}
		});

	} else if (GizPushType.GizPushBaiDu == gizPushType) {
		// 获取BDPush的Channel_ID
		Channel_ID = BaiDuPushReceiver.BaiDuPush_Channel_ID;
	} else {
		return;
	}

	// TODO 绑定推送
	Log.i("Apptest", Channel_ID + "\n" + gizPushType.toString() + "\n" + token);
	GizWifiSDK.sharedInstance().channelIDBind(token, Channel_ID, gizPushType);
}
 
Example #16
Source File: GosAboutActivity.java    From gokit-android with MIT License 4 votes vote down vote up
@Override
public void onResume() {
	super.onResume();
	tv_SDKVersion.setText(GizWifiSDK.sharedInstance().getVersion().toString());
	tv_AppVersion.setText(getAppVersionName(this));
}
 
Example #17
Source File: GosUserModuleBaseActivity.java    From Gizwits-SmartBuld_Android with MIT License 4 votes vote down vote up
@Override
protected void onResume() {
	super.onResume();
	// 每次返回activity都要注册一次sdk监听器,保证sdk状态能正确回调
	GizWifiSDK.sharedInstance().setListener(gizWifiSDKListener);
}
 
Example #18
Source File: GosDeviceModuleBaseActivity.java    From gokit-android with MIT License 4 votes vote down vote up
@Override
protected void onResume() {
	super.onResume();
	// 每次返回activity都要注册一次sdk监听器,保证sdk状态能正确回调
	GizWifiSDK.sharedInstance().setListener(gizWifiSDKListener);
}
 
Example #19
Source File: GosConfigCountdownActivity.java    From Gizwits-SmartBuld_Android with MIT License 4 votes vote down vote up
private void readyToSoftAP() {

		// 切换至设备热点
		WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
		WifiAutoConnectManager manager = new WifiAutoConnectManager(wifiManager);
		WifiCipherType cipherType = WifiAutoConnectManager.getCipherType(GosConfigCountdownActivity.this, softSSID);
		manager.connect(softSSID, SoftAP_PSW, cipherType);
		IntentFilter filter = new IntentFilter();
		filter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);

		workSSID = spf.getString("workSSID", "");
		workSSIDPsw = spf.getString("workSSIDPsw", "");
		final Timer mtimer = new Timer();
		mtimer.schedule(new TimerTask() {

			@Override
			public void run() {
				if (progressDialog.isShowing()) {
					progressDialog.cancel();
					mtimer.cancel();
					handler.sendEmptyMessage(handler_key.FAILED.ordinal());
				} else {
					mtimer.cancel();
				}
			}
		}, 10 * 1000);
		isChecked = true;
		while (isChecked) {
			String presentSSID = NetUtils.getCurentWifiSSID(GosConfigCountdownActivity.this);
			if (!TextUtils.isEmpty(presentSSID) && presentSSID.contains(SoftAP_Start)) {
				if (checkNetwork(GosConfigCountdownActivity.this)) {
					GizWifiSDK.sharedInstance().setDeviceOnboarding(workSSID, workSSIDPsw,
							GizWifiConfigureMode.GizWifiSoftAP, presentSSID, 60, null);
					progressDialog.cancel();
					isChecked = false;
					handler.sendEmptyMessage(handler_key.START_TIMER.ordinal());
				}
				registerReceiver(broadcase, filter);
			}
		}
	}
 
Example #20
Source File: GosConfigCountdownActivity.java    From gokit-android with MIT License 4 votes vote down vote up
private void readyToSoftAP() {

		// 切换至设备热点
		WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
		WifiCipherType cipherType = WifiAutoConnectManager.getCipherType(GosConfigCountdownActivity.this, softSSID);
		WifiAutoConnectManager manager = new WifiAutoConnectManager(wifiManager);
		manager.connect(softSSID, SoftAP_PSW, cipherType);
		IntentFilter filter = new IntentFilter();
		filter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);

		workSSID = spf.getString("workSSID", "");
		workSSIDPsw = spf.getString("workSSIDPsw", "");
		final Timer mtimer = new Timer();
		mtimer.schedule(new TimerTask() {

			@Override	
			public void run() {
				if (progressDialog.isShowing()) {
					progressDialog.cancel();
					mtimer.cancel();
					String failText=(String) getText(R.string.configuration_failed);
					Message msg=new Message();
					msg.what=handler_key.FAILED.ordinal();
					msg.obj=failText;
					handler.sendMessage(msg);
				} else {
					mtimer.cancel();
				}
			}
		}, 10 * 1000);
		isChecked = true;
		while (isChecked) {
			String presentSSID = NetUtils.getCurentWifiSSID(GosConfigCountdownActivity.this);
			if (!TextUtils.isEmpty(presentSSID) && presentSSID.contains(SoftAP_Start)) {
				if (checkNetwork(GosConfigCountdownActivity.this)) {
					GizWifiSDK.sharedInstance().setDeviceOnboarding(workSSID, workSSIDPsw,
							GizWifiConfigureMode.GizWifiSoftAP, presentSSID, 60, null);
					progressDialog.cancel();
					isChecked = false;
					handler.sendEmptyMessage(handler_key.START_TIMER.ordinal());
				}
				if(broadcase==null){
					broadcase = new GosWifiChangeReciver();
					registerReceiver(broadcase, filter);
				}
				
			}
		}
	}
 
Example #21
Source File: GosConfigModuleBaseActivity.java    From gokit-android with MIT License 4 votes vote down vote up
@Override
protected void onResume() {
	super.onResume();
	// 每次返回activity都要注册一次sdk监听器,保证sdk状态能正确回调
	GizWifiSDK.sharedInstance().setListener(gizWifiSDKListener);
}
 
Example #22
Source File: GosAirlinkConfigCountdownActivity.java    From gokit-android with MIT License 4 votes vote down vote up
private void startAirlink() {
	GizWifiSDK.sharedInstance().setDeviceOnboarding(workSSID, workSSIDPsw,
			GizWifiConfigureMode.GizWifiAirLink, null, 60, modeList);
	handler.sendEmptyMessage(handler_key.START_TIMER.ordinal());

}
 
Example #23
Source File: GosUserModuleBaseActivity.java    From gokit-android with MIT License 4 votes vote down vote up
@Override
protected void onResume() {
	super.onResume();
	// 每次返回activity都要注册一次sdk监听器,保证sdk状态能正确回调
	GizWifiSDK.sharedInstance().setListener(gizWifiSDKListener);
}
 
Example #24
Source File: GosAirlinkConfigCountdownActivity.java    From Gizwits-SmartBuld_Android with MIT License 4 votes vote down vote up
private void startAirlink() {
	GizWifiSDK.sharedInstance().setDeviceOnboarding(workSSID, workSSIDPsw, GizWifiConfigureMode.GizWifiAirLink,
			null, 60, modeList);
	handler.sendEmptyMessage(handler_key.START_TIMER.ordinal());

}
 
Example #25
Source File: GosConfigModuleBaseActivity.java    From Gizwits-SmartBuld_Android with MIT License 4 votes vote down vote up
@Override
protected void onResume() {
	super.onResume();
	// 每次返回activity都要注册一次sdk监听器,保证sdk状态能正确回调
	GizWifiSDK.sharedInstance().setListener(gizWifiSDKListener);
}
 
Example #26
Source File: GosDeviceModuleBaseActivity.java    From GOpenSource_AppKit_Android_AS with MIT License 4 votes vote down vote up
@Override
protected void onResume() {
	super.onResume();
	// 每次返回activity都要注册一次sdk监听器,保证sdk状态能正确回调
	GizWifiSDK.sharedInstance().setListener(gizWifiSDKListener);
}
 
Example #27
Source File: GosDeviceModuleBaseActivity.java    From Gizwits-SmartBuld_Android with MIT License 4 votes vote down vote up
@Override
protected void onResume() {
	super.onResume();
	// 每次返回activity都要注册一次sdk监听器,保证sdk状态能正确回调
	GizWifiSDK.sharedInstance().setListener(gizWifiSDKListener);
}
 
Example #28
Source File: GosChangeUserPasswordActivity.java    From GOpenSource_AppKit_Android_AS with MIT License 4 votes vote down vote up
public void confirm(View v) {

		if (TextUtils.isEmpty(oldpass.getText().toString())
				|| TextUtils.isEmpty(newpass.getText().toString())
				|| TextUtils.isEmpty(confrimpass.getText().toString())) {

			if (TextUtils.isEmpty(oldpass.getText().toString())) {

				Toast.makeText(
						this,
						getResources().getString(
								R.string.enter_current_password), 2000).show();

				return;
			}

			if (TextUtils.isEmpty(newpass.getText().toString())) {
				Toast.makeText(this,
						getResources().getString(R.string.enter_new_password),
						2000).show();

				return;
			}

			if (TextUtils.isEmpty(confrimpass.getText().toString())) {
				Toast.makeText(
						this,
						getResources()
								.getString(R.string.re_enter_new_password),
						2000).show();
				return;
			}

		} else {
			String npass = newpass.getText().toString();
			String cpass = confrimpass.getText().toString();
			if (npass.equals(cpass)) {
				GizWifiSDK.sharedInstance().changeUserPassword(
						spf.getString("Token", ""),
						oldpass.getText().toString(), npass);
			} else {
				Toast.makeText(this,
						getResources().getString(R.string.nosamepass), 2000)
						.show();
			}
		}
	}
 
Example #29
Source File: GosUserModuleBaseActivity.java    From GOpenSource_AppKit_Android_AS with MIT License 4 votes vote down vote up
@Override
protected void onResume() {
	super.onResume();
	// 每次返回activity都要注册一次sdk监听器,保证sdk状态能正确回调
	GizWifiSDK.sharedInstance().setListener(gizWifiSDKListener);
}
 
Example #30
Source File: GosAirlinkConfigCountdownActivity.java    From GOpenSource_AppKit_Android_AS with MIT License 4 votes vote down vote up
private void startAirlink() {
	GizWifiSDK.sharedInstance().setDeviceOnboarding(workSSID, workSSIDPsw,
			GizWifiConfigureMode.GizWifiAirLink, null, 60, modeList);
	handler.sendEmptyMessage(handler_key.START_TIMER.ordinal());

}