elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado:


  Mostrar Temas
Páginas: 1 [2] 3 4
11  Informática / Electrónica / libreria LTV704 eagle en: 21 Septiembre 2015, 17:04 pm
Hola,

Estoy buscando la libreria ltv704 eagle para un diseño d un pcb pero no la encuentro. EL componente lo podeis encontrar en el siguiente enlace.

Si conoces alguna página donde pueda encontrarlo estaría muy agradecido.

http://www.ti.com/product/TLV704/technicaldocuments --> ltv70433

salu2.
12  Programación / Java / [Android] Conexión BD externa. [Solucionado] en: 14 Septiembre 2015, 08:26 am
Hola,

Estoy intentando que se conecte el Android directamente a la BD Mysql de mi ordenador y cuando llega a la línea

Código
  1. Class.forName("com.mysql.jdbc.Driver").newInstance();
  2.  

me salta la excepción ClassNotFoundException a que se debe???

Código
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3. import java.sql.ResultSet;
  4. import java.sql.SQLException;
  5. import java.sql.Statement;
  6.  
  7. /**
  8.  * Created by alarcon on 27/7/15.
  9.  */
  10. public class BBDDMySQL
  11. {
  12.  
  13.    public Connection mConnection;
  14.  
  15.    boolean debug = true;
  16.    public BBDDMySQL()
  17.    {
  18.        super();
  19.    }
  20.  
  21.    public boolean Connect2BDMySQL (String user, String pass, String ip, String port, String catalog)
  22.    {
  23.        if (mConnection == null)
  24.        {
  25.            String urlMySQL = "";
  26.            if (catalog != "")
  27.            {
  28.                urlMySQL = "jdbc:mysql://" + ip + ":" + port + "/" + catalog;
  29.            }else
  30.            {
  31.                urlMySQL = "jdbc:mysql://" + ip + ":" + port;
  32.            }
  33.  
  34.            if (!user.isEmpty() && !ip.isEmpty() && !port.isEmpty())
  35.            {
  36.                try
  37.                {
  38.                    Class.forName("com.mysql.jdbc.Driver").newInstance();
  39.                    mConnection = DriverManager.getConnection(urlMySQL, user, pass);
  40.                }
  41.                catch (ClassNotFoundException e)
  42.                {
  43.                    if(debug)
  44.                        System.out.println("Connect2BDMySQL --" +
  45.                                " Connect2BDMySQL -> Error: " + e.getMessage());
  46.  
  47.                    return false;
  48.                }
  49.                catch (SQLException e)
  50.                {
  51.                    if(debug)
  52.                     System.out.println("Connect2BDMySQL --" +
  53.                                " Connect2BDMySQL -> Error: " + e.getMessage());
  54.  
  55.                    return false;
  56.                } catch (InstantiationException e) {
  57.                    e.printStackTrace();
  58.                } catch (IllegalAccessException e) {
  59.                    e.printStackTrace();
  60.                }
  61.            }
  62.        }
  63.        return true;
  64.    }
  65. }
  66.  

Solución: vaya fallo no me había cogido la librería de sql, no estaba linkada.
--------------------------------------
Pero sigo sin poder conectarme a la BD ahora el problema es que no me puedo conectar.

Connect2BDMySQL -- Connect2BDMySQL -> Error: Could not create connection to database server.
SQLState: 08001
VendorError: 0

Parece que es un problema de red, pero tengo ambos dispositivos conectados en la misma red.

Solución.

El problema no era del código si no de la configuración del MySQL para solucionarlo había que proporcionale permisos al usuario y habilitar en mysql las conexiones externeas. Ojito si teneis ferial activo.

aquí un enlace con los pasos a seguir.

http://www.trey.es/blog/base-de-datos/mysql/permitir-conexiones-externas-mysql/
13  Programación / Programación C/C++ / Conversión tipos float a U_int8 en: 23 Agosto 2015, 22:57 pm
Hola gente,

Estoy aquí porque ando un poco perdido con los tipos y los diferentes lenguajes, les comento.

tengo un numero en float(32 bits) y necesito pasarlo a u_int8. Mi idea, y creo que no voy a perder representación es el numero tipo float multiplicarlo por 1000, es decir, 25.890 float seria 25890.0 hacerle un cast a entero.

y luego esto dividirlo en en 4 bytes que se enviaría y en java recoger los 4byte y montar el número entero.

Mi pregunta es ¿Perderé representación al multiplicar x1000?

¿Hay alguna otra manera? He visto que con memcpy pero después de probarlo no lo he conseguido.



14  Programación / Java / conversion de tipos. en: 5 Agosto 2015, 21:12 pm
Hola tengo una dudilla a ver si me pueden echar una mano.

tengo un array de bytes que me llega de un dispositivo Bluetooth
Código
  1. byte[] scandRecord ={9,9,65,114,113,117,101,116,97,0,3,3,-1,-1,5,-1,15,60,112
  2. ,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  3. 0,0,0,0,0,0,0,0,0,0,0,0,0};
  4.  

yo se que la información que me tiene que llegar va a ser unsigned y de 8 bites por eso no entiendo porque aparece el -1, debería aparecer f = 255 2^7-1 que es lo que ha sido enviado en el dispositivo.

Como podría yo comparar estos valores si estoy haciendo una comparación en hex.
es decir 0xf con -1.

hasta ahora comparaba cogiendo el tipo?

switch(byte)
     case 0xff:

pero no me funciona?

PD: creo que son las horas delante de la pantalla las que demuestran mi idiotez.

15  Programación / Java / [Android] Por qué funciona y salta excepcion del error. en: 27 Julio 2015, 11:58 am
Hola,
les comento gente estoy haciendo un controlador BLE (Bluetooth low energy). Estoy montando una arquitectura separando el controlador BLE de la GUI y demás pero tengo un error que aunque el programa funciona me gustaría corregirlo.

Os explico:
Tengo una clase para manejar los dispositivos BLE:
Código
  1. package pfc.teleco.upct.es.iot_ble.BLE;
  2.  
  3. import android.bluetooth.BluetoothAdapter;
  4. import android.bluetooth.BluetoothAdapter.LeScanCallback;
  5. import android.bluetooth.BluetoothDevice;
  6. import android.bluetooth.BluetoothGatt;
  7. import android.bluetooth.BluetoothGattCallback;
  8. import android.bluetooth.BluetoothGattCharacteristic;
  9. import android.bluetooth.BluetoothGattDescriptor;
  10. import android.bluetooth.BluetoothGattService;
  11. import android.bluetooth.BluetoothManager;
  12. import android.bluetooth.BluetoothProfile;
  13. import android.content.Context;
  14. import android.content.Intent;
  15. import android.util.Log;
  16.  
  17. import java.util.ArrayList;
  18. import java.util.List;
  19. import java.util.UUID;
  20.  
  21. import pfc.teleco.upct.es.iot_ble.BEAN.BeanBluetoothDevice;
  22. import pfc.teleco.upct.es.iot_ble.Constant;
  23. import pfc.teleco.upct.es.iot_ble.DEVICES.Device;
  24.  
  25. public class HandlerBLE implements LeScanCallback
  26. {
  27.    public static final String ACTION_DEVICE_CONNECTED = "pfc.teleco.upct.es.iot_ble.DEVICE_FOUND";
  28.  
  29.    private static HandlerBLE mHandlerBLE;
  30.    private static Context mContext;
  31.    private static BluetoothDevice mDevice;
  32.    private static String mDeviceAddress;
  33.    private static BluetoothGatt mGatt;
  34.    private static BluetoothAdapter mBlueAdapter = null;
  35.  
  36.    public static boolean isScanning = false;
  37.  
  38.    //###################################################################
  39.    /****************** Constructor                **********************/
  40.    //###################################################################
  41.    public HandlerBLE(Context context)
  42.    {
  43.        mContext = context;
  44.        mDeviceAddress= null;
  45.    }
  46.  
  47.    //###################################################################
  48.    /*********************  statics methods   **************************/
  49.    //###################################################################
  50.    public static HandlerBLE getInstance(Context context) {
  51.        if(mHandlerBLE==null){
  52.            mHandlerBLE = new HandlerBLE(context);
  53.            setup();
  54.        }
  55.        return mHandlerBLE;
  56.    }
  57.  
  58.    public static void  resetHandlerBLE()
  59.    {
  60.        mDeviceAddress=null;
  61.        disconnect();
  62.        mGatt=null;
  63.    }
  64.  
  65.    public static void setup()
  66.    {
  67.        BluetoothManager manager = (BluetoothManager) mContext.getSystemService(Context.BLUETOOTH_SERVICE);
  68.        mBlueAdapter = manager.getAdapter();
  69.    }
  70.  
  71.    //###################################################################
  72.    /********************* methods bluetooth                *************/
  73.    //###################################################################
  74.  
  75.    public void setDeviceAddress(String address) {
  76.        mDeviceAddress=address;
  77.    }
  78.  
  79.    public String getDeviceAddress() {
  80.        return mDeviceAddress;
  81.    }
  82.  
  83.    public void startLeScan()
  84.    {
  85.        try
  86.        {
  87.            mBlueAdapter.startLeScan(this);//deprecated
  88.            isScanning = true;
  89.            //mBlueAdapter.startDiscovery();
  90.        }
  91.        catch (Exception e)
  92.        {
  93.            Log.i(Constant.TAG,"(HandlerBLE)[Error]:"+e.getStackTrace()+" "+e.getCause()+" "+e.getMessage()+
  94.                    " "+e.getLocalizedMessage());
  95.        }
  96.  
  97.    }
  98.  
  99.    public void stopLeScan()
  100.    {
  101.        try
  102.        {
  103.            mBlueAdapter.stopLeScan(this); //deprecated
  104.            //mBlueAdapter.startDiscovery();
  105.            isScanning = false;
  106.        }
  107.        catch(Exception e)
  108.        {
  109.            Log.i(Constant.TAG,"(HandlerBLE)[Error]:"+e.getStackTrace()+" "+e.getCause()+" "+e.getMessage()+
  110.                    " "+e.getLocalizedMessage());
  111.        }
  112.    }
  113. /*
  114.     public void connect() {
  115.         mDevice   = mBlueAdapter.getRemoteDevice(mDeviceAddress);
  116.         mServices.clear();
  117.         if(mGatt!=null){
  118.             mGatt.connect();
  119.         }else{
  120.             mDevice.connectGatt(mContext, false, mCallBack);
  121.         }
  122.     }
  123. */
  124.    public void discoverServices() {
  125.        if (Constant.DEBUG)
  126.            Log.i(Constant.TAG, "(HandlerBLE)Scanning services and caracteristics");
  127.        mGatt.discoverServices();
  128.    }
  129.  
  130.    public static void disconnect(){
  131.        if (mGatt!=null) {
  132.            try{
  133.                mGatt.disconnect();
  134.                mGatt.close();
  135.                if (Constant.DEBUG)
  136.                    Log.i(Constant.TAG, "(HandlerBLE)Disconnecting GATT");
  137.            } catch(Exception ex){};
  138.        }
  139.        mGatt = null;
  140.    }
  141.  
  142.    public boolean isConnected(){
  143.        return (mGatt!=null);
  144.    }
  145.  
  146.    //###################################################################
  147.    /********************* methods Scan bluetooth          *************/
  148.    //###################################################################
  149.    /*
  150.     * this method is used to receive devices which were found durind a scan*/
  151.    @Override
  152.    public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord)
  153.    {
  154.        if(Constant.DEBUG)
  155.            Log.i(Constant.TAG,"(HandlerBLE) -- onLeScan -> throwing information to the listener.");
  156.  
  157.        //create the packet wich will be sent to listener.
  158.        Intent intent = new Intent();
  159.        intent.setAction(HandlerBLE.ACTION_DEVICE_CONNECTED);
  160.  
  161.        BeanBluetoothDevice beanBlue = new BeanBluetoothDevice();
  162.        beanBlue.setBluetoothDevice(device);
  163.        beanBlue.setmRssi(rssi);
  164.        beanBlue.setmScanRecord(scanRecord);
  165.  
  166.        intent.putExtra(Constant.EXTRA_BEAN_BLUETOOTHDEVICE,beanBlue);
  167.        mContext.sendBroadcast(intent);
  168.    }
  169. }
  170.  

Esta clase se encargará de controlar el BLE sanea, conexión y comunicación con otros dispositivos. Y a su vez se comunicará con el resto de la aplicación con Broadcastreceiver , es decir en el método implementado en la interfaz onLeScan, me avisa cuando se ha encontrado un dispositivo y envia la señal broadcast.

Como se puede ver tengo un objeto llamado BeanBluetoothDevice este simplemente es una encapsulación de la información que necesito y serializado.

Código
  1. public class BeanBluetoothDevice implements Parcelable
  2. {
  3.    private BluetoothDevice mdevice;
  4.    private int mRssi;
  5.    private byte[] mScanRecord;
  6.  
  7.    public BeanBluetoothDevice() {
  8.        super();
  9.    }
  10.  
  11.    //###################################################################
  12.  
  13.    protected BeanBluetoothDevice(Parcel in) {
  14.        mdevice     = in.readParcelable(BluetoothDevice.class.getClassLoader());
  15.        mRssi       = in.readInt();
  16.        mScanRecord = in.createByteArray();
  17.    }
  18.  
  19.    public static final Creator<BeanBluetoothDevice> CREATOR = new Creator<BeanBluetoothDevice>() {
  20.        @Override
  21.        public BeanBluetoothDevice createFromParcel(Parcel in) {
  22.            return new BeanBluetoothDevice(in);
  23.        }
  24.  
  25.        @Override
  26.        public BeanBluetoothDevice[] newArray(int size) {
  27.            return new BeanBluetoothDevice[size];
  28.        }
  29.    };
  30.  
  31.    //###################################################################
  32.    /****************** gets and sets methods     **********************/
  33.    //###################################################################
  34.  
  35.    public void setBluetoothDevice(BluetoothDevice device)
  36.    {mdevice = device;}
  37.  
  38.    public BluetoothDevice getBluetoothDevice()
  39.    {return mdevice;}
  40.  
  41.    public int getmRssi() {
  42.        return mRssi;
  43.    }
  44.  
  45.    public void setmRssi(int mRssi) {
  46.        this.mRssi = mRssi;
  47.    }
  48.  
  49.    public byte[] getmScanRecord() {
  50.        return mScanRecord;
  51.    }
  52.  
  53.    public void setmScanRecord(byte[] mScanRecord) {
  54.        this.mScanRecord = mScanRecord;
  55.    }
  56.  
  57.  
  58.    @Override
  59.    public int describeContents() {
  60.        return 0;
  61.    }
  62.  
  63.    @Override
  64.    public void writeToParcel(Parcel dest, int flags) {
  65.        dest.writeParcelable(mdevice, flags);
  66.        dest.writeInt(mRssi);
  67.        dest.writeByteArray(mScanRecord);
  68.    }
  69. }
  70.  


una vez e envia la señal yo la recojo en la activity que me interesa, en mi casa es la principal para mostrar los dispositivos.
Código
  1. public class ScanActivity extends ListActivity implements OnItemClickListener{ //}, LeScanCallback {
  2.  
  3.    private static final int SCAN_ITEM = 1;
  4.    private static ListView mListView;
  5.    private static Context mContext;
  6.    private static HandlerBLE mHandlerBLE;
  7.    private Handler mHandler;
  8.    private static MySimpleArrayAdapter mAdapter;
  9.    private static List<BluetoothDevice> mDeviceList;
  10.    private Menu mMenu;
  11.    private Activity mActivity;
  12.    private BLEBroadcastReceiver mScanBroadcastReceiver;
  13.  
  14.  
  15.    //###################################################################
  16.    /****************** metodos del flujo Android. **********************/
  17.    //###################################################################
  18.    @Override
  19.    protected void onCreate(Bundle savedInstanceState) {
  20.        super.onCreate(savedInstanceState);
  21.        setContentView(R.layout.activity_scan);
  22.  
  23.        mActivity   = this;
  24.        mContext    = this;
  25.        mHandler    = new Handler() ;
  26.        mDeviceList = new ArrayList<BluetoothDevice>();
  27.        mAdapter    = new MySimpleArrayAdapter(mContext, mDeviceList);
  28.        mScanBroadcastReceiver = new BLEBroadcastReceiver(this,mAdapter);
  29.  
  30.        IntentFilter i = new IntentFilter(HandlerBLE.ACTION_DEVICE_CONNECTED);
  31.        registerReceiver(mScanBroadcastReceiver,i);
  32.  
  33.        if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
  34.            Toast.makeText(this, "BLE TECHNOLOGY NOT SUPPORTED ON THIS DEVICE", Toast.LENGTH_SHORT).show();
  35.            finish();
  36.        }
  37.  
  38.  
  39.  
  40.  
  41.        //run service
  42.        Intent service = new Intent(this, ServiceDetectionTag.class);
  43.        startService(service);
  44.  
  45.        //manejador BLE
  46.        mHandlerBLE = ((BLE_Application) getApplication()).getmHandlerBLEInstance(this);
  47.        ((BLE_Application) getApplication()).resetHandlerBLE();
  48.  
  49.        mListView = getListView();
  50.        mListView.setVisibility(View.VISIBLE);
  51.  
  52.        mListView.setAdapter(mAdapter);
  53.        mListView.setOnItemClickListener(this);
  54.  
  55.    }
  56.  
  57.    @Override
  58.    public boolean onCreateOptionsMenu(Menu menu)
  59.    {
  60.        super.onCreateOptionsMenu(menu);
  61.        mMenu = menu;
  62.        String menuTitle= getResources().getString(R.string.scan);
  63.        menu.add(0,SCAN_ITEM,0,menuTitle);
  64.  
  65.       /*
  66.         // Inflate the menu; this adds items to the action bar if it is present.
  67.         getMenuInflater().inflate(R.menu.menu_scan, menu);*/
  68.        return true;
  69.    }
  70.  
  71.    @Override
  72.    public boolean onOptionsItemSelected(MenuItem item)
  73.    {
  74.        switch (item.getItemId()){
  75.            case SCAN_ITEM:
  76.                scan();
  77.                break;
  78.        }
  79.        return true;
  80.        /*
  81.         // Handle action bar item clicks here. The action bar will
  82.         // automatically handle clicks on the Home/Up button, so long
  83.         // as you specify a parent activity in AndroidManifest.xml.
  84.         int id = item.getItemId();
  85.  
  86.         //noinspection SimplifiableIfStatement
  87.         if (id == R.id.action_settings) {
  88.             return true;
  89.         }
  90.  
  91.         return super.onOptionsItemSelected(item);*/
  92.    }
  93.  
  94.  
  95.    @Override
  96.    protected void onResume()
  97.    {
  98.        super.onResume();
  99.        //mAdapter.clear();
  100.        HandlerBLE.setup();
  101.    }
  102.  
  103.    @Override
  104.    protected void onPause() {
  105.        super.onStop();
  106.        //Make sure that there is no pending Callback
  107.        mHandler.removeCallbacks(mStopRunnable);
  108.  
  109.        //stop service
  110.        Intent service = new Intent(this, ServiceDetectionTag.class);
  111.        stopService(service);
  112.  
  113.        //mAdapter.clear();
  114.  
  115.        if (mHandlerBLE.isScanning)
  116.        {
  117.            mHandlerBLE.stopLeScan();
  118.            unregisterReceiver(mScanBroadcastReceiver);
  119.        }
  120.    }
  121.  
  122.    @Override
  123.    protected void onStop()
  124.    {
  125.        super.onStop();
  126.    }
  127.  
  128.    //###################################################################
  129.    /****************** metodos manejo Tag        **********************/
  130.    //###################################################################
  131.    @Override
  132.    //recogemos los metodos del tag seleccionado y recogemos los datos.
  133.    public void onItemClick(AdapterView<?> parent, View view, int position, long id)
  134.    {
  135.        if (Constant.DEBUG)
  136.            Log.i(Constant.TAG, "Selected device " + mDeviceList.get(position).getAddress());
  137.  
  138.        if (mHandlerBLE.isScanning)
  139.        { //stop scanning
  140.            configureScan(false);
  141.            mHandlerBLE.stopLeScan();
  142.            if (Constant.DEBUG)
  143.                Log.i(Constant.TAG, "Stop scanning");
  144.        }
  145.  
  146.        String address  = mDeviceList.get(position).getAddress();
  147.        String name     = mDeviceList.get(position).getName();
  148.  
  149.        if (name==null)
  150.            name="unknown";
  151.  
  152.        Intent intentActivity= new Intent(this, DeviceActivity.class);
  153.        intentActivity.putExtra(Constant.EXTRA_ADDRESS, address);
  154.        intentActivity.putExtra(Constant.EXTRA_NAME, name);
  155.        this.startActivity(intentActivity);
  156.  
  157.        if (Constant.DEBUG)
  158.            Log.i(Constant.TAG, "Trying to connect");
  159.        //mConnectionManager.connect(address,true);
  160.        Toast.makeText(this, "Wait for connection to selected device", Toast.LENGTH_LONG).show();
  161.    }
  162.  
  163.    //Handle automatic stop of LEScan
  164.    private Runnable mStopRunnable = new Runnable() {
  165.        @Override
  166.        public void run() {
  167.            mHandlerBLE.stopLeScan();
  168.            configureScan(false);
  169.            if (Constant.DEBUG)
  170.                Log.i(Constant.TAG, "Stop scanning");
  171.        }
  172.    };
  173.  
  174.    public void configureScan(boolean flag)
  175.    {
  176.        //isScanning      = flag;
  177.        String itemText = null;
  178.  
  179.        if (mHandlerBLE.isScanning)
  180.        {
  181.            itemText = getResources().getString(R.string.stopScan);
  182.            mHandlerBLE.stopLeScan();
  183.            if (Constant.DEBUG)
  184.                Log.i(Constant.TAG, "ScanActivity -- StopScan");
  185.        }
  186.        else
  187.        {
  188.            itemText= getResources().getString(R.string.scan);
  189.            mHandlerBLE.startLeScan();
  190.  
  191.            if (Constant.DEBUG)
  192.                Log.i(Constant.TAG, "ScanActivity -- StartScan");
  193.        }
  194.  
  195.        mMenu.findItem(SCAN_ITEM).setTitle(itemText);
  196.  
  197.        if (Constant.DEBUG)
  198.            Log.i(Constant.TAG, "Updated Menu Item. New value: " + itemText);
  199.    }
  200.  
  201.    // Metodo para iniciar el scaneo cuando te llaman manualmente.
  202.    private void scan() {
  203.        if (mHandlerBLE.isScanning) { //stop scanning
  204.            configureScan(false);
  205.            mHandlerBLE.stopLeScan();
  206.  
  207.            if (Constant.DEBUG)
  208.                Log.i(Constant.TAG, "Stop scanning");
  209.  
  210.            return;
  211.        } else {
  212.            mAdapter.clear();
  213.            mAdapter.notifyDataSetChanged();
  214.            configureScan(true);
  215.  
  216.            if (Constant.DEBUG)
  217.                Log.i(Constant.TAG, "Start scanning for BLE devices...");
  218.  
  219.            mHandlerBLE.startLeScan();
  220.            //automatically stop LE scan after 5 seconds
  221.            mHandler.postDelayed(mStopRunnable, 30000);
  222.        }
  223.    }
  224.  
  225.  
  226.    /*
  227.     Clase para crear el adaptador de dispositos Bluetooh
  228.      */
  229.    public class MySimpleArrayAdapter extends ArrayAdapter<BluetoothDevice> {
  230.        private final Context context;
  231.  
  232.        public MySimpleArrayAdapter(Context context, List<BluetoothDevice> deviceList)
  233.        {
  234.            super(context, R.layout.activity_scan_item,R.id.deviceName, deviceList);
  235.            this.context = context;
  236.        }
  237.    }
  238.  
  239.    /*
  240.     @Override
  241.     public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord)
  242.     {
  243.         String name="unknown";
  244.  
  245.         if (device.getName()!=null)
  246.             name=device.getName();
  247.  
  248.         final String finalName = name;
  249.         final String  finalAddress = device.getAddress();
  250.  
  251.         if (Constant.DEBUG)
  252.             Log.i(Constant.TAG, "Found new device "+ finalAddress + " --- Name: " + finalName);
  253.  
  254.         final BluetoothDevice finalDevice= device;
  255.         // This callback from Bluetooth LEScan can arrive at any moment not necessarily on UI thread.
  256.         // Use this mechanism to update list View
  257.         mActivity.runOnUiThread(new Runnable() {
  258.                                     @Override
  259.                                     public void run() {
  260.                                         mAdapter.add(finalDevice);
  261.                                         mAdapter.notifyDataSetChanged();
  262.  
  263.                                         if (Constant.DEBUG)
  264.                                             Log.i(Constant.TAG, "Added new device "+ finalAddress + " --- Name: " + finalName);
  265.                                     }
  266.                                 }
  267.         );
  268.     }*/
  269.  
  270. }
  271.  

Como se puede ver en el método onCreate doy de alta la señal que espero recibir.
Código
  1. mScanBroadcastReceiver = new BLEBroadcastReceiver(this,mAdapter);
  2.  
  3. IntentFilter i = new IntentFilter(HandlerBLE.ACTION_DEVICE_CONNECTED);
  4. registerReceiver(mScanBroadcastReceiver,i);
  5.  

Ahora nos dirigimos en la clase donde creo que está el problema, es la clase donde se recibe la señal Broadcast y se procesa.
Código
  1. public class BLEBroadcastReceiver extends BroadcastReceiver
  2. {
  3.    private Activity mActivity;
  4.    private ScanActivity.MySimpleArrayAdapter mAdapter;
  5.    public BLEBroadcastReceiver(Activity activity, ScanActivity.MySimpleArrayAdapter adapter)
  6.    {
  7.        super();
  8.        mAdapter  = adapter;
  9.        mActivity = activity;
  10.    }
  11.    public BLEBroadcastReceiver()
  12.    {
  13.        super();
  14.    }
  15.    @Override
  16.    public void onReceive(Context context, Intent intent)
  17.    {
  18.        if(Constant.DEBUG)
  19.            Log.i(Constant.TAG, "ScanActivity -- OnReceive() -> BroadcastReceiver new device found.");
  20.  
  21.        //get signal and add new device into MyarrayAdapter
  22.        if(intent.getAction().equals(HandlerBLE.ACTION_DEVICE_CONNECTED))
  23.        {
  24.            try
  25.            {
  26.                BeanBluetoothDevice beanDeviceFound = intent.getExtras().getParcelable(Constant.EXTRA_BEAN_BLUETOOTHDEVICE);
  27.                final BluetoothDevice deviceFound   = beanDeviceFound.getBluetoothDevice();
  28.  
  29.                mActivity.runOnUiThread(new Runnable() {
  30.                    @Override
  31.                    public void run() {
  32.                        mAdapter.add(deviceFound);
  33.                        mAdapter.notifyDataSetChanged();
  34.  
  35.                        if (Constant.DEBUG)
  36.                            Log.i(Constant.TAG, "Added new device " + deviceFound.getAddress() + " --- Name: " + deviceFound.getName());
  37.                    }
  38.                });
  39.            }catch(Exception e)
  40.            {
  41.                Log.i(Constant.TAG,"[Error(BLEBroadcastReceiver)]: "+e.getCause()+"\n"+e.getStackTrace()+"\n"+e.getLocalizedMessage());
  42.            }
  43.        }
  44.    }
  45. }
  46.  

aquí el problema me aparice cuando quito el constructor vacío, es decir, al que no se le pasan parámetros. Si lo eliminamos en tiempo de ejecución el programa peta y cuando se lo pongo todo corre normalmente, es decir, si me introduce el dispositivo en el arrayList pero a su vez me da una excepción de los objetos mAdapter y mActivity.

¿A qué puede deberse esto? Si al final lo introduce correctamente.

PD: soy un patata programando, no ser muy duros conmigo.
16  Seguridad Informática / Bugs y Exploits / snnifer bluetooth para mac en: 3 Julio 2015, 16:45 pm
Hola,

Estoy desarrollando una app entre un terminal y un micro con bluetooth 4.0 BLE y me gustaría saber si existe un snnifer para capturar el trafico desde mac. Es necesario para hacer la depuración.

un saludo
17  Programación / .NET (C#, VB.NET, ASP) / [C#] DataGridView congelación de app en: 10 Junio 2015, 10:15 am
Hola,

El problema es el siguiente: inserto filas en un datagridview y cuando llega a un determinado número de filas se queda la app congelada y el scroll vertical no aparece si no que hace algo raro. Además tengo la propiedad ScrollBar en Vertical.

Personalmente no sé que puede estar pasando quizas un problema de la interfaz .... ni idea. He estado buscando por internet y a la gente este componente no suele darle muchos problemas.

¿Se os ocurre que puede estar pasando?

#########################
Ya aparece el scroll era simplemente que tenia la propiedad AutoSize = true; y claro había que ponerla a false. Pero el problema sigue existiendo cuando aparece el scroollBar la app se queda congelada.
18  Foros Generales / Foro Libre / Serie Mr Robot en: 5 Junio 2015, 16:20 pm
Se anuncia una nueva sería de hackers para este mes ¿Qué creéis molará?

http://www.xataka.com/cine-y-tv/mr-robot-la-serie-antisistema-con-hackers-de-verdad-mas-prometedora-en-anos
19  Programación / .NET (C#, VB.NET, ASP) / Visual Studio Code en: 6 Mayo 2015, 19:40 pm
Hola,

Alguien ha utilizado Visual Studio Code en una maquina con Linux o Mac. Que les ha parecido? Se puede hacer un desarrollo en C# en linux con este IDE/Editor de texto
20  Programación / Programación General / [Estimación]Controlar tiempo de desarrollo. en: 29 Abril 2015, 16:45 pm
Hola,

Me gustaría que me comentaseis como hacéis para calcular los tiempos de desarrollo dado que actualmente estoy de freelance y me como algunos marrones porque no estimo convenientemente.

¿Qué metodología utilizais?¿Los que desarrollas solos os marcáis plazos?

PD: en mi caso son proyectos semi profesionales (java, android, .Net y C).
Páginas: 1 [2] 3 4
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines