Ëae¼¼Êo½ø²½£¬¶ÌÐÅÊÕ¢ÁiÓo°´Ê±¼aÏȺo²uÉuÁËÈýÖÖģʽ£ºBLOCK MODE£¬»uÓÚATÖ¸ÁiµÄTEXT MODE£¬»uÓÚATÖ¸ÁiµÄPDU MODE¡£ÆaÖУ¬TEXT MODE±È½Ï¼oµ¥£¬¶a¿iŵ»uÑÇÊÖ»u¾uÖ§³Ö´Ë¿iģʽ¡£Î÷ÃÅ×ÓµÄÊÖ»u´o¶aÊýÖ»Ö§³ÖPDU MODE¡£PDU ģʽÊÇÊÕ¢¶ÌÐŵÄÒ»ÖÖ½¨£¬¶ÌÐÅÕýÎľ¹ýÊ®Áu½øÖƱaÂeºo±»´«ËÍ¡£Ä¿Ç°£¬PDUÒÑÈ¡´uBLOCK MODE¡£
SMSÊÇÓÉEtsiËuÖƶ¨µÄÒ»¸o¹ae¶£¨GSM 03.40 ºÍGSM 03.38£(C)¡£µ±Ê¹ÓÃ7-bits±aÂeʱ£¬Ëu¿ÉÒÔ¢ËÍ×i¶a160¸o×Öu;µ«ÓÃ8-bit±aÂe£¬×i¶a¿ÉÒÔ¢ËÍ140¸o×Öu£¬Í¨³£ÎÞ¨Ö±½Óͨ¹ýÊÖ»uÏÔʾ;»¹ÓÐÓÃ16-bit±aÂeʱ£¬×i¶a70¸o×Ö*u£¬±»ÓÃÀ´ÏÔʾUnicode(UCS2)Îı¾ÐÅÏ¢£¬¿ÉÒÔ±»´o¶aÊýµÄÊÖ»uËuÏÔʾ¡£
½ñÌiÌÖÂÛµÄÊÇPDU MODE£¬UCS2±aÂe,Ò²¾ÍÊÇ˵£¬×i¶aÖ»ÄÜ*¢ËÍ70¸o×Ö*u£¬²»¹ÜÓ¢ÎÄ»¹ÊÇÖÐÎÄ¡£
¼ÙÉeÏÖÔÚÒª*¢ËÍÈçÏÂÐÅÏ¢£º¡°ÄaºÃ¡±¡£ÔÚûÓÐ*¢ËÍ֮ǰ£¬ÒªÖªµÀÊÖ»uSIM¿¨ËuÔڵصĶÌÐÅÖÐÐĺţ¬ÀýÈçÒƶ¯µÄ¶ÌÐÅÖÐÐĺţº
½ÓÊÕµÄÊÖ»uºÅ£º13638197275
º¼ÖݶÌÐÅÖÐÐĺţº13800571500
¶ÌÐÅÄÚÈÝ£º ÄaºÃ
*¢ËÍÕaÌo¶ÌÐÅ£¬Òª½øÐбaÂeºoÊÖ»u²Å»aÖ´ÐУ¬±aÂeºo»a±a³ÉÒÔÏÂÒ»´®×Ö*u£º
0891683180501705F011000D91683136187972F5000800044F60597D
¿´²»¶®°É£¬´Ó͵½Î²°ÑÕa´®±aÂe½aÊÍһϣº
08 ¨C Ö¸µÄÊǶÌÐÅÖÐÐĺŵij¤¶È£¬Ò²¾ÍÊÇÖ¸(91)+(683180501705F0)µÄ³¤¶È³ýÒÔ2£¬¼´ 08 =£¨2+14£(C)/ 2
91 ¨C Ö¸µÄÊǶÌÐÅÏ¢ÖÐÐĺÅÂeÀaÐÍ¡£91ÊÇTON/NPI×ñÊØInternational/E.164±e×¼£¬Ö¸ÔÚºÅÂeÇ°Ðe¼Ó¡®+'ºÅ£»´ËÍa»¹ÓÐÆaËuÊýÖµ£¬µ«91×i³£Óá£
683180501705F0 - ¶ÌÐÅÏ¢ÖÐÐĺÅÂe¡£ÓÉÓÚλÖÃÉÏÂÔÓд¦Ài£¬Êµ¼ÊºÅÂeӦΪ£º8613800571500£¨×ÖĸFÊDz¹×ażÊý³¤¶ÈÌi¼ÓµÄ×Öu£(C)¡£
11 - ÎļþÍ*×Ö½Ú
00 - ÐÅÏ¢ÀaÐÍ£¨TP-Message-Reference£(C)
0D - ±»½ÐºÅÂe³¤¶È
91 - ±»½ÐºÅÂeÀaÐÍ
ÆaʵÔÚʵ¼Ê´¦ÀiÖУ¬ÎÒÃÇͨ³£°Ñ11000D91дËÀÔÚ³ÌÐoÖУ¬ÒoΪÔÚ¹uÄÚ£¬ÕaÐ(C)Êý¾Ý¶¼ÊDz»»a¸Ä±aµÄ¡£
683136187972F5 - ±»½ÐºÅÂe£¬¾¹ýÁËλÒÆ´¦Ài£¬Êµ¼ÊºÅÂeΪ¡°8613638197275¡±¡£
ÉÏÃaeµÄ£¨00 £(C)+£¨0D £(C)+£¨91 £(C)+(683136187972F5 ),¹¹³ÉÁËÕu¸o¶ÌÐŵĵڶþ²¿*ÝÄ¿µÄµØÖ*£¨TP-Destination-Address£(C)¡£
¼ÌÐø...
00 - ÐÒe±eʶTP-PID,ÕaÀiÒ»°aΪ00
08 - Êý¾Ý±aÂe*½°¸TP-DCS£¨TP-Data-Coding-Scheme£(C),²ÉÓÃÇ°Ãae˵µÄUSC2(16bit)Êý¾Ý±aÂe
00 - ÓÐЧÆÚTP-VP£¨TP-Valid-Period£(C)
04 \- ³¤¶ÈTP-UDL£¨TP-User-Data-Length£(C)£¬Ò²¾ÍÊÇÐÅÏ¢³¤¶È/2µÄÊ®Áu½ø04
4F60597D ÕaÀi¾ÍÊǶÌÐÅÄÚÈÝÁË£¬Êµ¼ÊÄÚÈÝΪ:¡°ÄaºÃ¡±
¸u¾ÝÒÔÉÏÇe¿o£¬¾Í¿ÉÒÔд³o¶ÌÐűaÂeµÄ³ÌÐo½Å±¾ÁË¡£
Ò»¡¢¶ÌÐÅÖÐÐĺÅÂe´¦Ài£º
1¡¢½«¶ÌÐÅÏ¢ÖÐÐĺÅÂe¡°+8613800571500¡±È¥µo+ºÅ£¬¿´³¤¶ÈÊÇñΪżÊý£¬Èç¹u²»ÊÇ£¬×iºoÌi¼ÓF
=> ¡°8613800571500F¡±
2¡¢½«ÆaeÊýλºÍżÊýλ½»»»¡£
=> ¡°683108501705F0¡a
3¡¢½«¶ÌÐÅÏ¢ÖÐÐĺÅÂeÇ°Ãae¼ÓÉÏ×Öu91£¬91Êǹu¼Ê»¯µÄÒa˼
=> ¡°91683108501705F0¡a
4¡¢Ëa³o³¤¶È£¬½a¹u³ý2£¬¸ñʽ»¯³É2λµÄ16½øÖÆ×Ö*u´®£¬16 / 2 = 8 => ¡°08¡a
=> ¡°0891683108501705F0¡a
¶þ¡¢ÊÖ»uºÅÂe´¦Ài£º
1¡¢½«ÊÖ»uºÅÂe+8613638197275È¥µo+ºÅ£¬¿´¿´³¤¶ÈÊÇ*ñΪżÊý£¬Èç¹u²»ÊÇ£¬×iºoÌi¼ÓF
=> ¡°8613638197275F¡±
2¡¢½«ÊÖ»uºÅÂeÆaeÊýλºÍżÊýλ½»»»¡£
=> ¡°683136187972F5¡a
*Èý¡¢¶ÌÐÅÏ¢²¿Ö´¦Ài£º**
1¡¢×ª×Ö*u´®×ª»»ÎªUnicode´uÂe£¬
¡°ÄaºÃ¡±µÄunicode´uÂe Ϊ4F60597D
2¡¢½«³¤¶È³ý2£¬±£ÁoÁ½Î»16½øÖÆÊý£¬¼´ 4F60597D = 8 / 2 => ¡°04¡a£¬
=> ¡°044F60597D¡a
ËÄ¡¢×eºÏ
1¡¢ÊÖ»uºÅÂeÇ°¼ÓÉÏ×Öu´® 11000D91£¨1100£º¹Ì¶¨£¬0D£ºÊÖ»uºÅÂeµÄ³¤¶È£¬²»Ëa£«ºÅ£¬Ê®Áu½øÖƱiʾ£¬91£º¢ËÍ
µ½ÊÖ»uΪ91£¬*¢Ë͵½Ð¡ÁeͨΪ81£(C)£¬
¼´ 11000D91 + 683136187972F5
=> 11000D91683136187972F5
2¡¢ÊÖ»uºÅÂeºo¼ÓÉÏ 000800 ºÍ¸Õ²ÅµÄ¶ÌÐÅÏ¢ÄÚÈÝ£¬000800ҲдËÀ¾Í¿ÉÒÔÁË
¼´ 11000D91683136187972F5 + 000800 + 044F60597D
=> 11000D91683136187972F5000800044F60597D
3¡¢ÕuÌoÐÅÏ¢³¤¶È³ýÒÔ2£¬¸ñʽ»¯³É2λµÄÊ®½øÖÆÊý
¼´ 11000D91683136187972F5000800044F60597D => 38λ / 2 => 19
*Îa¡¢ËuÒÔÒª¢Ë͵ÄÄÚÈÝΪ**
AT+CMGF=0 <»Ø³µ> #´Ë´¦ÎªÉe¶¨¶ÌÐÅ*¢ËÍģʽPDU
OK
AT+CMGS=19<»Ø³µ>
ÊaÈe¶ÌÐÅÄÚÈݱaÂe
¸½¼Ó×iÖÕPHP´uÂe£º
<?php
// Requirement dio£¬ use cmd install: pecl install dio
set_time_limit(0);
// Windows use COM1:
$fd=dio_open('/dev/ttyS0', O_RDWR);
if(!$fd)
{
die("´o¿ª´®¿ÚttyS0ʧ°Ü");
}
// dio_tcsetattr() only Linux
// Windows ʹÓà exec('mode COM1: baud=9600 data=8 stop=1 parity=n xon=on');
dio_tcsetattr($fd, array(
'baud' => 9600,
'bits' => 8,
'stop' => 1,
'parity' => 0
));
//$ff=dio_stat($fd);
//print_r($ff);
//echo "GSM AT is start on ttyS0\n";
//¶ÌÐÅÖÐÐĺÅÂe
$smsc = "8613800571500";
$invert_smsc = invertNumbers($smsc); // ת»»¶ÌÐÅÖÐÐĺÅÂe
$inter = chr(13); // »Ø³µ×Ö*u
$ctrlz = chr(26); // ctrl+z
// *¢ËÍÐÅÏ¢
$text
= 'ÄaºÃ';
$send_to = '8613638197275';
$pdu_phone = hex2str(utf82unicode($text));
$pdu_phone = sprintf("%02X", strlen($pdu_phone)/2) . $pdu_phone;
$pdu_phone = '11000D91' . invertNumbers($send_to) . '000800' . $pdu_phone;
$atcmd = 'AT+CMGF=0' . $inter;
@dio_write($fd, $atcmd);
$atcmd = 'AT+CMGS=' . sprintf("%d", strlen($pdu_phone)/2) . $inter;
@dio_write($fd, $atcmd);
$pdu_addr = '0891' . invertNumbers($smsc);
$pdu_all = $pdu_addr . $pdu_phone . $ctrlz . $inter;
@dio_write($fd, $pdu_all);
dio_close($fd);
// ÎÒµÄÊÇutf-8±aÂe
function utf82unicode($str)
{
return iconv("utf-8", "UCS-2BE", $str);
}
function hex2str($hexstring)
{
$str = '';
for($i = 0, $len = strlen($hexstring); $i < $len; $i++)
{
$str .= sprintf("%02X", ord(substr($hexstring, $i, 1)));
}
return $str;
}
function invertNumbers($msisdn)
{
$len = strlen($msisdn);
if ( 0 != fmod($len, 2) )
{
$msisdn .= "F";
$len = $len + 1;
}
for ($i=0; $i<$len; $i+=2)
{
$t = $msisdn[$i];
$msisdn[$i] = $msisdn[$i+1];
$msisdn[$i+1] = $t;
}
return $msisdn;
}
?>
ÒÔÉÏËuÊo¾ÍÊDZ¾ÎĵÄÈ«²¿ÄÚÈÝÁË£¬Ï£Íu´o¼ÒÄܹ»Ï²»¶¡£