package com.vispec.sdkdemo;

import android.app.Application;
import android.content.Context;
import android.hardware.usb.UsbManager;
import android.os.Looper;
import android.os.MessageQueue;

import com.vispec.sdklibrary.DriverUtil;
import com.vispec.sdklibrary.bluetooth.BluetoothClient;

import cn.wch.ch34xuartdriver.CH34xUARTDriver;

public class MyApplication extends Application {
    public static Context applicationContext;
    public static BluetoothClient mClient;
    private CH34xUARTDriver driver;

    @Override
    public void onCreate() {
        super.onCreate();
        applicationContext = getApplicationContext();
        initClient(getApplicationContext());
    }

    public  BluetoothClient initClient(Context context) {
        if (mClient == null) {
            mClient = new BluetoothClient(context);
        }
        return mClient;
    }
    public CH34xUARTDriver getDriver(Context context){
        if (driver == null) {
            driver = new CH34xUARTDriver((UsbManager) getSystemService(Context.USB_SERVICE),context, DriverUtil.ACTION_USB_PERMISSION);
        }
        return driver;
    }


}
