У меня тоже по началу телефон сеть терял пока я не подпаял резисторов и диодов. Что то сомневаюсь что у вас длинна 26, воспользуйтесь лучше программой конвертером http://www.avrdevices.ru/Soft/Pdu.exe
Вот нарыл в гугле интересный пример. Я так понял он как раз конвертрует текст в скетче в формат пду, но у меня не заработало(
PHP код:
#include <NewSoftSerial.h>
NewSoftSerial mySerial(2, 3);
#define num_to_char(number) ((number) < 10 ? \
('0' + (number)) : \
(('A' - 10) + (number)) )
/* To select the 4 bits we do this */
#define first_four(byte) (0x0F & (byte))
/* Last four: Shift left to get to a number < 16 */
#define last_four(byte) ((0xF0 & (byte)) >> 4)
/* The MSB goes first. */
#define hexdump_a(byte) num_to_char( last_four(byte))
#define hexdump_b(byte) num_to_char(first_four(byte))
int timesToSend = 1; // Numbers of SMS to send
int count = 0;
void setup()
{
Serial.begin(9600);
Serial.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
//mySerial.println("Hello, world?");
}
void loop() // run over and over
{
send_sms("Hello World");
/*
if (Serial.available() > 0) {
// number_in = Serial.read();
mySerial.println("AT+CMGF=0"); // Set PDU mode
delay(3000);
mySerial.println("AT+CMGS=30"); // Number of octets
delay(3000);
mySerial.print("0011000B919731630470F20008FF10043F0440043E043204350440043A0430"); // Sends "Hello" to "00 46707112233"
delay(3000);
mySerial.write(26);
delay(3000);
}*/
}
void hexdump_byte(unsigned char byte)
{
mySerial.print(hexdump_a(byte), BYTE);
mySerial.print(hexdump_b(byte), BYTE);
}
void send_sms(char *data)
{
size_t data_length, x;
char c, l;
long i;
long n;
data_length = strlen(data);
i = data_length * 7;
/* Round i up to a multiple of 8 */
if (i & 0x07) i = (i & ~0x07) + 0x08;
/* Calculate the number of message octets */
i = i / 8;
//Select operating mode for sms: PDU, since it doesnt understand anything else
mySerial.println("AT+CMGF=0");
delay(1500);
mySerial.print("AT+CMGS=");
//Now we say "AT+CMGS=..." that gives it the cellphone number.
//This is also in weirdass PDU format, so i am sending a message to myself at "0031-653587738"
// which was the destination phone nr. Serial.print("AT+CMGS=");
delay(1500);
mySerial.println(i + 14);
delay(1500);
//This is actually the number. If you want to use your own number you just have to figure out where to put your digits.
//Mine was "31653587738" Because this is an uneven amount of numbers, there is an F included before the last 8.
//If you check it out you probably figure it out: you have to make your phonenumber so that they're
//switched in pairs of two, so like if your number is "123456789" it will become "21436587F9"
//And if its "123456" it will be "214365". I know, it's weird and ancient.
//that's why im posting this code.
mySerial.print("0011000B919731630470F20000AA"); //1356537837F8 is the phonenr
hexdump_byte(data_length & 0xFF);
l = 0;
n = 0;
//The rest of the code then is just about changing our serial info "Hello World" into neat PDU HEX format.
for (x = 0; x < data_length; x++)
{
if (data[x] == '$') data[x] = 0x02;
n |= (data[x] & 0x7F) << l;
l += 7;
if (l >= 8)
{
hexdump_byte(n & 0xFF);
l -= 8;
n >>= 8;
}
}
if (l != 0)
{
hexdump_byte(n & 0xFF);
}
mySerial.println(0x1A, BYTE);
//mySerial.write(26);
}
Ссылка на оригинал.