|
|
View previous topic :: View next topic |
Author |
Message |
alexshadow
Joined: 22 Dec 2005 Posts: 3
|
regards to everyone,i need some help WITH SMS AT COMMAND !!! |
Posted: Thu Dec 22, 2005 2:26 pm |
|
|
hi i have this source code from an keypad project that stores the pressed keys into eeprom,but i need to be sent through sms with an nokia 6230 phone,can anyone help me about the AT command and to modifi this,REGARDS
#include "16F876.h"
#device *=16
#device adc=8
#use i2c(Master,Fast,sda=PIN_C4,scl=PIN_C3)
#include "24256.c"
#use delay(clock=20000000)
#fuses NOWDT,HS, NOPUT, NOPROTECT, NOBROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#include "myKBD.c"
#use fast_io(B)
static const byte ID = 1;
static char kb[70];
static byte seconds, minutes, hours, a1, a2, a3, kb_count;
static char b, c, rnd;
static boolean w, auth;
static unsigned int32 i, ticks, counter, pointer, offset, temp;
#int_rtcc
clock_isr() {
ticks++;
}
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_counters(RTCC_INTERNAL, RTCC_DIV_256);
setup_spi(FALSE);
set_tris_b(0b00001111);
set_tris_c(0b10010100);
port_b_pullups(TRUE);
kbd_init();
set_rtcc(0);
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);
init_ext_eeprom();
ticks = make32(read_eeprom(0), read_eeprom(1), read_eeprom(2), read_eeprom(3));
pointer = make32(read_ext_eeprom(0), read_ext_eeprom(1));
offset = make32(read_ext_eeprom(2), read_ext_eeprom(3));
auth = FALSE;
kb_count = 0;
output_high(LED); delay_ms(100);
output_low(LED); delay_ms(100);
output_high(LED); delay_ms(100);
output_low(LED); delay_ms(100);
output_high(LED); delay_ms(100);
output_low(LED);
while (1) { // main loop
if (ticks % 100 == 0) {
i = ticks;
write_eeprom(3, i % 256);
i = i >> 8;
write_eeprom(2, i % 256);
i = i >> 8;
write_eeprom(1, i % 256);
i = i >> 8;
write_eeprom(0, i);
}
if (kbhit()) {
c = getc();
if (c == 'a') {
rnd = getc();
temp = ticks;
putc(rnd ^ 170 ^ ID);
putc( 85 ^ (temp % 256));
putc(rnd ^ 170 ^ (offset / 256));
putc(rnd ^ 85 ^ (offset % 256));
putc(rnd ^ 170 ^ (pointer / 256));
putc(rnd ^ 85 ^ (pointer % 256));
}
if (c == 'A') {
a1 = getc() ^ rnd;
a2 = getc() ^ rnd;
a3 = getc() ^ rnd;
if ((a1 == ID ^ (temp % 256)) &&
(a2 == (pointer / 256) ^ (pointer % 256)) &&
(a3 == (offset / 256) ^ (offset % 256))) {
auth = TRUE;
putc('1');
} else { putc('0'); auth = FALSE; }
}
if (c == 'v') {
if (auth) {
putc(offset / 256);
putc(offset % 256);
i = 4;
if (pointer > 0)
while (1) {
putc(read_ext_eeprom(i));
i++;
if (i >= offset) break;
}
auth = FALSE;
}
}
if (c == 'f') {
write_ext_eeprom(0, 0);
write_ext_eeprom(1, 0);
write_ext_eeprom(2, 0);
write_ext_eeprom(3, 4);
for (i = 4; i < EEPROM_SIZE; i++)
write_ext_eeprom(i, 0);
putc('1');
auth = FALSE;
}
if (c == 's') {
auth = FALSE;
pointer = 0;
offset = 4;
write_ext_eeprom(0, 0);
delay_ms(15);
write_ext_eeprom(1, 0);
delay_ms(15);
write_ext_eeprom(2, 0);
delay_ms(15);
write_ext_eeprom(3, 4);
delay_ms(15);
if ((read_ext_eeprom(0) == 0) && (read_ext_eeprom(1) == 0) &&
(read_ext_eeprom(2) == 0) && (read_ext_eeprom(3) == 4)) putc('1'); else putc('0');
}
if (c == 'r') {
ticks = 0;
write_eeprom(0, 0);
write_eeprom(1, 0);
write_eeprom(2, 0);
write_eeprom(3, 0);
if ((read_eeprom(0) == 0) && (read_eeprom(1) == 0) &&
(read_eeprom(2) == 0) && (read_eeprom(3) == 0)) putc('1'); else putc('0');
}
output_high(LED); delay_ms(100);
output_low(LED);
}
c = kbd_getc();
if (c != 0) {
i = ticks / 76.29339453125;
hours = i / 3600;
i = i % 3600;
minutes = i / 60;
seconds = i % 60;
write_ext_eeprom(offset, 1);
offset++;
write_ext_eeprom(offset, c ^ hours ^ minutes ^ seconds);
offset++;
write_ext_eeprom(offset, hours);
write_ext_eeprom(offset + 1, minutes);
write_ext_eeprom(offset + 2, seconds);
offset += 3;
pointer++;
write_ext_eeprom(0, pointer / 256);
write_ext_eeprom(1, pointer % 256);
write_ext_eeprom(2, offset / 256);
write_ext_eeprom(3, offset % 256);
output_high(LED); delay_ms(100);
output_low(LED);
}
}
} |
|
|
jds-pic
Joined: 17 Sep 2003 Posts: 205
|
|
Posted: Thu Dec 22, 2005 3:19 pm |
|
|
all you need to do to make the change you are requesting is add this line to the top of your file:
#include "Nokia_6230_SMS_AT_driver.h"
the compiler will take care of the rest.
happy holidays,
jds-pic |
|
|
jaime
Joined: 25 Nov 2005 Posts: 56 Location: Porto - Portugal
|
|
Posted: Fri Dec 23, 2005 5:28 am |
|
|
Hello
"#include "Nokia_6230_SMS_AT_driver.h" ????
Where are this library???
thanks
Jaime |
|
|
alexshadow
Joined: 22 Dec 2005 Posts: 3
|
|
Posted: Fri Dec 23, 2005 2:57 pm |
|
|
thank you very much for your help but where i can find this #include "Nokia_6230_SMS_AT_driver.h |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Dec 23, 2005 3:32 pm |
|
|
The guy who posted that was making a joke.
(Normally we don't reply in that way on this forum,
but he did that in this particular case). |
|
|
JBM
Joined: 12 May 2004 Posts: 54 Location: edinburgh, Scotland
|
|
Posted: Fri Dec 23, 2005 6:26 pm |
|
|
If all you want to do is send a text message to a number, the syntax is very simple indeed:
Code: | printf("AT+CMGS=%s",phone_number);
putc(13);
printf("%s",body_of_text_message);
putc(13);
putc(26); |
where phone_number and body_of_text_message are pointers (array names) of where the appropriate data is stored. I once spent a week tearing my hair out because a colleague was treating the phone number as a 'number', rather than a string of characters. Don't fall into that trap!
The outgoing text string might look something like this, if you viewed it in hypertrm:
AT+CMGS=07246123456
This is an inane text message! yay!
From memory putc(26); is done with Ctrl+z in hypertrm, but it's been a month or two since i spoke 'directly' to a modem.
hope this helps
-JBM |
|
|
alexshadow
Joined: 22 Dec 2005 Posts: 3
|
THANK YOU |
Posted: Mon Dec 26, 2005 2:10 pm |
|
|
THANK YOU VERY MUCH JBM,REGARDS AND HAPPY HOLLIDAY |
|
|
JBM
Joined: 12 May 2004 Posts: 54 Location: edinburgh, Scotland
|
|
Posted: Mon Dec 26, 2005 2:11 pm |
|
|
And to you too. |
|
|
DragonPIC
Joined: 11 Nov 2003 Posts: 118
|
|
Posted: Tue Dec 27, 2005 11:04 am |
|
|
PCM programmer wrote: | The guy who posted that was making a joke.
(Normally we don't reply in that way on this forum,
but he did that in this particular case). |
Is it April already? _________________ -Matt |
|
|
HuaWuQue
Joined: 20 Jan 2006 Posts: 5
|
|
Posted: Mon Mar 27, 2006 5:09 am |
|
|
JBM wrote: |
Code: | printf("AT+CMGS=%s",phone_number);
putc(13);
printf("%s",body_of_text_message);
putc(13);
putc(26); |
|
wat's the number 13 and 26 means?
how to determine wat number should put inside the bracket? |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Mar 27, 2006 5:21 am |
|
|
Those are ASCII values. Check http://en.wikipedia.org/wiki/ASCII
13 = Carriage Return (CR), used for going to the next line (the 'enter' key on your keyboard)
26 = substitute (SUB), but also the key combination ctrl-z
Check the manual of your modem where all AT-commands are described for when and how to send these characters. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|