Ejemplo n.º 1
0
/*!
    \reimp
 */
void QBluetoothDefaultPasskeyAgent::requestPasskey(QBluetoothPasskeyRequest &req)
{
    QBluetoothLocalDevice device(req.localDevice());
    QBluetoothRemoteDevice remote(req.remoteDevice());
    device.updateRemoteDevice(remote);

    if (m_passDialog->isVisible()) {
        qLog(Bluetooth) << "Got new pairing request for"
            << remote.address().toString()
            << "but another pairing already in progress, rejecting new pair request";
        req.setRejected();
        return;
    }

    QString msg = "<P>";
    msg += tr("You are trying to pair with %1 [%2]. Please enter a PIN. You will need to enter the same PIN on the other device.", "%1=name, %2=address")
            .arg(remote.name()).arg(remote.address().toString());

    // brighten the screen
    QtopiaServiceRequest e1("QtopiaPowerManager", "setBacklight(int)");
    e1 << -1; // read brightness setting from config
    e1.send();

    // vibrate the phone if profile allows
    QPhoneProfileManager manager;
    QPhoneProfile profile = manager.activeProfile();
    if (profile.vibrate()) {
        QVibrateAccessory acc;
        acc.setVibrateNow(true);
        QTimer::singleShot(1000, this, SLOT(stopVibration()));
    }

    m_passDialog->reset();
    m_passDialog->setPrompt(msg);
    m_passDialog->setWindowModality(Qt::WindowModal);
    QtopiaApplication::execDialog(m_passDialog);

    QString pairPin = m_passDialog->password();
    if (!pairPin.isEmpty())
        req.setPasskey(pairPin);
    else
        req.setRejected();
}
Ejemplo n.º 2
0
int main() {
    
    initialize();
    uint8_t receivedValidNumber = false;
    uint16_t nbMilliseconds = 0;
    
/*    
    startVibration();
    while(true);*/
    
    while(true) {
        nbMilliseconds = numberMillisecondsFromPC(&receivedValidNumber);
        if (receivedValidNumber) {
            startVibration();
            attendre_ms(nbMilliseconds);
            stopVibration();
        }
    }
    
    // cette section ne devrait jamais être atteinte
    while(true); // ne jamais quitter le main
    return 0; 
}
Ejemplo n.º 3
0
int main() {
    
    can amplifierOnCan;
    
    initialize(amplifierOnCan);
    uint8_t receivedValidNumber = false;
    uint16_t nbMilliseconds = 0;
    
    while(true) {
        nbMilliseconds = numberMillisecondsFromPC(&receivedValidNumber);
        if (receivedValidNumber) {
            startVibration();
            attendre_ms(nbMilliseconds);
            stopVibration();
        }
        else {
            updateAmplifierStatus(amplifierOnCan);
        }
    }
    
    // cette section ne devrait jamais être atteinte
    while(true); // ne jamais quitter le main
    return 0; 
}