Esempio n. 1
0
        //read response and check if it may continue
        $codigo_at = $serial->readPort();
        $verificar = substr($codigo_at, -4);
        if (substr($verificar, 0, 2) == 'OK') {
            $serial->sendMessage('AT+CMGS="' . $nr_tlm . '"' . chr(13));
            //send destination number
            $serial->sendMessage($sms . chr(26));
            //send SMS text
            sleep(5);
            //read response and check if the sms was sent
            $codigo_at = $serial->readSMS();
            $verificar = substr($codigo_at, -4);
            if (substr($verificar, 0, 2) == 'OK') {
                $resposta = "OK";
            } else {
                $resposta = "NOK";
            }
        } else {
            $resposta = "NOK";
        }
    } else {
        $resposta = "NOK";
    }
    $serial->deviceClose();
    //close COM port - NEVER FORGET THIS STEP!
    return $resposta;
}
$sms = "Message to send!";
$numero = 911111111;
$resposta_sms = enviarSMS($numero, $sms);
Esempio n. 2
0
     }
     // actualizo enviados
     if ($sent === TRUE) {
         $enviado = "OK";
     } else {
         $enviado = "ERR";
     }
     $insSql = " INSERT INTO {$dbName}.envios SET enviado=1, idimagen='{$id}', app='" . SMS_SC . "', celular='{$celular}', url='{$urlPush}', accion='push', status='{$enviado}', fecha_alta=CURDATE(), hora_alta=CURTIME() ";
     $rsIns = mysql_query($insSql, $dbc->db);
     // preparo query
     $sqlUpdate = " UPDATE {$dbName}.imagenes SET procesado=1, status='OK', url='{$urlPush}' WHERE id={$id} ";
 } else {
     $qrFound = FALSE;
     // send sms
     $msgSms = ERROR_MSG_DEFAULT;
     $sent = enviarSMS($celular, $msgSms);
     if ($sent === TRUE) {
         $enviado = "OK";
     } else {
         $enviado = "ERR";
     }
     $insSql = " INSERT INTO {$dbName}.envios SET enviado=1, idimagen='{$id}', app='" . SMS_SC . "', celular='{$celular}', url='', accion='sms', status='{$enviado}', fecha_alta=CURDATE(), hora_alta=CURTIME() ";
     $rsIns = mysql_query($insSql, $dbc->db);
     // preparo query
     $sqlUpdate = " UPDATE {$dbName}.imagenes SET procesado=1, status='ERR' WHERE id={$id} ";
 }
 // update db
 $rsUpdate = mysql_query($sqlUpdate, $dbc->db);
 if (!$rsUpdate) {
     die("DB ERROR");
 }