Torna indietro   Hardware Upgrade Forum > Software > Programmazione

NVIDIA RTX Spark, arrivano i desktop compatti per l'IA: fino a 128 GB di memoria unificata
NVIDIA RTX Spark, arrivano i desktop compatti per l'IA: fino a 128 GB di memoria unificata
NVIDIA amplia la famiglia RTX Spark con desktop compatti basati sul chip N1X, dotati di 20 core CPU, 6.144 core GPU e fino a 128 GB di memoria unificata. I primi modelli ASUS e MSI sono disponibili da oggi, con prezzi a partire da 4.399 dollari. L'obiettivo è offrire una piattaforma Windows sempre attiva per gaming, creazione di contenuti e soprattutto intelligenza artificiale locale.
HP OmniBook 3 con Snapdragon X: autonomia da record nella fascia d'ingresso
HP OmniBook 3 con Snapdragon X: autonomia da record nella fascia d'ingresso
Lo Snapdragon X arriva nella fascia d’ingresso con HP OmniBook 3: oltre 17 ore di autonomia, una tastiera comoda e porte ben distribuite, ma anche 8 GB di RAM saldata, una GPU modesta e i compromessi di Windows su ARM. Vediamo a chi si rivolge questo notebook da 14 pollici e se il prezzo è giustificato
Nuova Dacia Spring, del modello precedente resta solo il nome: più grande, più efficiente e ora prodotta in Europa
Nuova Dacia Spring, del modello precedente resta solo il nome: più grande, più efficiente e ora prodotta in Europa
La seconda generazione della citycar elettrica di Dacia passa alla piattaforma RGEV small di Renault Group, cresce di 15 cm in lunghezza e 18 cm in larghezza, adotta un motore da 80 CV e una batteria LFP da 27,5 kWh per 250 km WLTP. Prezzi da 17.900 euro, produzione a Novo Mesto in Slovenia.
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 25-02-2011, 14:33   #1
mr.money.in.the.bank
Junior Member
 
Iscritto dal: Nov 2006
Messaggi: 17
[JAVA] Bluetooth Discovery Device

Salve ragazzi/e,

in parole povere ho questo problema.
Ho trovato in Rete un programma che mi fa la "scoperta" di tutte le periferiche bluetooth.
Ora, questo programma l'ho provato utilizzando due IDE: Netbeans e Eclipse.

Per il progetto che devo fare, mi è più intuitivo e semplice utilizzare Netbeans, quindi posterò l'esperienza fatta su Netbeans.

Il codice è il seguente:

Codice:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package test2;

import java.io.IOException;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.bluetooth.DiscoveryListener;
import javax.bluetooth.LocalDevice;
import javax.bluetooth.RemoteDevice;
import javax.bluetooth.DeviceClass;
import javax.bluetooth.ServiceRecord;
import javax.bluetooth.BluetoothStateException;
import javax.bluetooth.DiscoveryAgent;

public class BluetoothDiscoveryDevice extends MIDlet implements CommandListener,
        DiscoveryListener {
    private Display display;
    /**
     * For displaying found devices.
     */
    private List listDev;
    private Command cmdExit;
    private Command cmdDiscover;
    private Command cmdStopDiscover;

    private LocalDevice devLocal;
    private DiscoveryAgent discoverAgent;


    /**
     * Constructor. Constructs the object and initializes displayables.
     */
    public BluetoothDiscoveryDevice() {
        InitializeComponents();
    }
    /**
     * Initializes a ListBox object and adds softkeys.
     */
    protected void InitializeComponents() {
        display = Display.getDisplay( this );
        //initializing device list
        listDev = new List( "Device list", List.IMPLICIT );

        cmdExit = new Command( "Exit", Command.EXIT, 1 );
        cmdDiscover = new Command( "Start", Command.SCREEN, 1);
        cmdStopDiscover = new Command( "Stop", Command.SCREEN, 1);

        listDev.addCommand( cmdExit );
        listDev.addCommand( cmdDiscover );
        listDev.setCommandListener( this );
    }

    /**
     * From MIDlet.
     * Called when MIDlet is started.
     * @throws javax.microedition.midlet.MIDletStateChangeException
     */
    public void startApp() throws MIDletStateChangeException {
        display.setCurrent( listDev );
    }
    /**
     * From MIDlet.
     * Called to signal the MIDlet to enter the Paused state.
     */
    public void pauseApp() {
        //No implementation required
    }
    /**
     * From MIDlet.
     * Called to signal the MIDlet to terminate.
     * @param unconditional whether the MIDlet has to be unconditionally
     * terminated
     * @throws javax.microedition.midlet.MIDletStateChangeException
     */
    public void destroyApp(boolean unconditional)
        throws MIDletStateChangeException {
        exitMIDlet();
    }
    /**
     * From CommandListener.
     * Called by the system to indicate that a command has been invoked on a
     * particular displayable.
     * @param command the command that was invoked
     * @param displayable the displayable where the command was invoked
     */
    public void commandAction( Command command, Displayable displayable ) {

        if( command == cmdExit ) {
            exitMIDlet();
        }
        if( command == cmdDiscover ) {
            int err = 0;
            err = initLocalDevice();
            if( err != 0 ){
                return;
            }
            err = startDeviceSearch();
            if( err != 0) {
                return;
            }
            //we do not need a start soft key when in descovery mode
            listDev.removeCommand( cmdDiscover );
            //now we add stop soft key
            listDev.addCommand( cmdStopDiscover );
        }
        if( command == cmdStopDiscover ) {
            stopDiscover();
            //we remove stop softkey
            listDev.removeCommand( cmdStopDiscover );
            //adding start soft key
            listDev.addCommand( cmdDiscover );
        }
    }
    /**
     * Method calls stopDiscover method and notifyDestroyed after that.
     */
    protected void exitMIDlet() {
        stopDiscover();
        notifyDestroyed();
    }
    /**
     * Gets a reference to LocalDevice and saves it to devLocal variable.
     * @return '0' if local device reference getting succeded. '-1' on exception.
     */
    protected int initLocalDevice() {
        try {
            devLocal = LocalDevice.getLocalDevice();
        } catch (BluetoothStateException e) {
            showErrAlert( "Error getting local device!" );
            return -1;
        }
        return 0;
    }
    /**
     * Clears device listbox, retreves DiscoveryAgent instance and saves it to
     * discoveryAgent variable. Starts device inquiry mode with access code
     * General/Unlimited Inquiry Access Code (GIAC).
     * @return '0' function execution was successfull.
     * '-1' if startInquiry threw an exception.
     * @see JSR82 for more info.
     */
    protected int startDeviceSearch() {
        discoverAgent = devLocal.getDiscoveryAgent();
        try {
            listDev.deleteAll();
            discoverAgent.startInquiry( DiscoveryAgent.GIAC,
                    this );
        } catch( BluetoothStateException e ) {
            showErrAlert( "Error starting device enquiry!" );
            return -1;
        }
        return 0;
    }

    /**
     * From DiscoveryListener.
     * Called when new bluetooth device discovered.
     * @param remoteDev reference to RemoteDevice object instance of
     * discovered device
     * @param devClass the service classes, major device class,
     * and minor device class of the remote device
     */
    public void deviceDiscovered(RemoteDevice remoteDev, DeviceClass devClass) {
        try {
            //add device "Friendly name" to a listbox
            listDev.append( "Device: " + remoteDev.getFriendlyName( false ),
                    null);
        } catch ( IOException e ) {
            //TODO: Handle error
        }
    }

    /**
     * From DiscoveryListener.
     * Called when service(s) are found during a service search.
     * @param transID the transaction ID of the service search that is
     * posting the result
     * @param servRecord a list of services found during the search request
     */
    public void servicesDiscovered(int transID, ServiceRecord[] servRecord) {
        //No implementation required
    }

    /**
     * From DiscoveryListener.
     * Called when a service search is completed or was terminated
     * because of an error
     * @param transID the transaction ID identifying the request which
     * initiated the service search
     * @param respCode the response code that indicates the status
     * of the transaction
     */
    public void serviceSearchCompleted(int transID, int respCode) {
        //No implementation required
    }

    /**
     * From DiscoveryListener.
     * Called when an inquiry is completed.
     * @param discType the type of request that was completed
     */
    public void inquiryCompleted(int discType) {
        // No implementation required
    }
    /**
     * Show error alert with a string specified in strError.
     * @param strError Error message show.
     */
    protected void showErrAlert( String strError ) {
        Alert alertErr = new Alert("Error", strError, null, AlertType.ERROR );
        display.setCurrent( alertErr );
    }

    /**
     * Stops device discovery mode.
     */
    protected void stopDiscover() {
       //we turning of the device discovery mode
        Alert alert = new Alert("Finish", null, null, AlertType.INFO);
        display.setCurrent(alert);
       discoverAgent.cancelInquiry( this );
    }
}
Il problema è dato dal fatto che, quando lo mando in esecuzione, non trova nessuna periferica, nonostante io ne abbia almeno tre attive a non più di 2 metri da me.
All'inizio ho pensato che fosse un problema di driver bluetooth (ho un ACER 5920G, e sono sicuro che abbia il modulo bluetooh) e ho comprato un modulo esterno in modo da essere sicuro che sia funzionante.

Quello che succede quando il programma è in esecuzione è il fatto che l'emulatore (uso il JAVA ME SDK 3.0 Device Manager) sembra andare alla ricerca dei dispositivi, ma poi ad un certo punto mi esce il messaggio di ricerca finita, e non ha trovato nessun dispositivo.

La cosa strana di questa situazione quale è...quello che se io installo il file JAR creato dall'applicazione sul mio cellulare, questo funziona a meraviglia. Quindi a questo punto mi viene da pensare che sia un problema di configurazione o all'interno di Netbeans oppure nell'emulatore stesso.
Quindi ho deciso di utilizzare anche Eclipse per verificare la cosa precedente, ho creato una nuova Midlet Suite all'interno di Eclipse (dopo aver fatto e rifatto le installazioni del plugin EclipseMe per essere sicuro), e ho incollato lo stesso codice che si vede sopra. La differenza è che utilzzo il Sun Wireless Toolkit 5.2.1.
Ora non credo sinceramente che ci siano problemi agli emulatori, ma piuttosto che ci sia qualche problema di configurazione all'interno dei due IDE.

C'è qualcuno che mi può aiutare o che mi può dare qualche dritta...oramai è un pezzo che sono su questa cosa e non so più dove la testa!!
__________________
...sbalordito il Diavolo rimase, quando comprese quanto osceno fosse il bene... e vide la virtù nello splendore delle sue forme sinuose...
mr.money.in.the.bank è offline   Rispondi citando il messaggio o parte di esso
 Rispondi


NVIDIA RTX Spark, arrivano i desktop compatti per l'IA: fino a 128 GB di memoria unificata NVIDIA RTX Spark, arrivano i desktop compatti pe...
HP OmniBook 3 con Snapdragon X: autonomia da record nella fascia d'ingresso HP OmniBook 3 con Snapdragon X: autonomia da rec...
Nuova Dacia Spring, del modello precedente resta solo il nome: più grande, più efficiente e ora prodotta in Europa Nuova Dacia Spring, del modello precedente resta...
BOOX Picco: l'ebook reader minuscolo è una genialata, e si può attaccare allo smartphone BOOX Picco: l'ebook reader minuscolo è un...
AMD EPYC Venice: dentro Zen 6, i SoC a 256 core e la sfida al costo della memoria AMD EPYC Venice: dentro Zen 6, i SoC a 256 core ...
Il meglio del Black Friday Amazon, pesan...
AliExpress Black Friday 2026: nuovi coup...
Novità per la missione LV-01 di U...
Microsoft Ignite 2026: controllo degli a...
Thales Alenia Space: accordo con ASI per...
Il produttore di satelliti ICEYE annunci...
Cloud ibrido più sicuro per PA e ...
Niente volante, niente pedali: Tesla spe...
Costa un ventesimo di Claude Opus 5.5 e ...
NAS e ransomware: come proteggere i dati...
HPE annuncia storage ibrido per il super...
NVIDIA DGX Spark HPC Developer Kit fa gi...
Microsoft apre l'anteprima di Windows Se...
Robot con mani da umano: Genesis AI inca...
Black Friday Yale: la tua casa diventa s...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 00:31.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Served by www3v