Programa para pasar de Octetos a septetos en tramas PDU usadas en mensajes de texto SMS que viajan por la red GSM
main.cpp@0:e74448c0b740, 2014-10-16 (annotated)
- Committer:
- tony63
- Date:
- Thu Oct 16 22:16:35 2014 +0000
- Revision:
- 0:e74448c0b740
- Child:
- 1:a1fe02210bb6
Programa para pasar de Octetos a septetos en tramas PDU en mensajes de texto SMS para transmitir datos por la red GSM
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tony63 | 0:e74448c0b740 | 1 | #include "mbed.h" |
tony63 | 0:e74448c0b740 | 2 | Serial pc(USBTX, USBRX); // tx, rx |
tony63 | 0:e74448c0b740 | 3 | /* |
tony63 | 0:e74448c0b740 | 4 | ALGORITMO PARA PASAR DE OCTETOS A SEPTETOS |
tony63 | 0:e74448c0b740 | 5 | EN UN MENSAJE DE TEXTO DE CELULAR EN FORMATO PDU |
tony63 | 0:e74448c0b740 | 6 | SE APLICA AL RECIBIR UN MENSAJE QUE TRAE OCTETOS |
tony63 | 0:e74448c0b740 | 7 | SON VISIBLES EN ASCCI AL SER SEPTETOS |
tony63 | 0:e74448c0b740 | 8 | USA DOS CADENAS; UNA DE ENTRADA Y OTRA DE SALIDA |
tony63 | 0:e74448c0b740 | 9 | LENIN ES LA LONGITUD DE LA CADENA DE ENTRADA |
tony63 | 0:e74448c0b740 | 10 | LENOUT LA LONGITUD DE LA DE SALIDA |
tony63 | 0:e74448c0b740 | 11 | VERIFIQUE CON EL DECODIFICADOR DE ESTA PAGINA:: |
tony63 | 0:e74448c0b740 | 12 | http://www.twit88.com/home/utility/sms-pdu-encode-decode |
tony63 | 0:e74448c0b740 | 13 | en septetos use esta....http://www.asciitohex.com/ |
tony63 | 0:e74448c0b740 | 14 | LA ULTIMA VERSION ES PARA CUALQUIER NUMERO DE CARACTERES VER:SEP 24 DEL 2014 |
tony63 | 0:e74448c0b740 | 15 | tanto LENIN y LENOUT se deben especificar al ensamblar la trama PDU en el MODEM |
tony63 | 0:e74448c0b740 | 16 | GSM o GPRS |
tony63 | 0:e74448c0b740 | 17 | */ |
tony63 | 0:e74448c0b740 | 18 | |
tony63 | 0:e74448c0b740 | 19 | short DE[255]; |
tony63 | 0:e74448c0b740 | 20 | short DS[255]; |
tony63 | 0:e74448c0b740 | 21 | int i,K,LENOUT,LENIN,C; |
tony63 | 0:e74448c0b740 | 22 | //PROBAR CON ESTOS |
tony63 | 0:e74448c0b740 | 23 | //E7309B9D768741E3B0B90C son octetos ///.gallina cafe 67 61 6c 6c 69 6e 61 20 63 61 66 65 son septetos |
tony63 | 0:e74448c0b740 | 24 | int main(){ |
tony63 | 0:e74448c0b740 | 25 | LENIN=11; //numero de caracteres de abajo son los octetos |
tony63 | 0:e74448c0b740 | 26 | DE[0]=0xE7; |
tony63 | 0:e74448c0b740 | 27 | DE[1]=0x30; |
tony63 | 0:e74448c0b740 | 28 | DE[2]=0x9B; |
tony63 | 0:e74448c0b740 | 29 | DE[3]=0x9D; |
tony63 | 0:e74448c0b740 | 30 | DE[4]=0x76; |
tony63 | 0:e74448c0b740 | 31 | DE[5]=0x87; |
tony63 | 0:e74448c0b740 | 32 | DE[6]=0x41; |
tony63 | 0:e74448c0b740 | 33 | DE[7]=0xE3; |
tony63 | 0:e74448c0b740 | 34 | DE[8]=0xB0; |
tony63 | 0:e74448c0b740 | 35 | DE[9]=0xB9; |
tony63 | 0:e74448c0b740 | 36 | DE[10]=0x0C; |
tony63 | 0:e74448c0b740 | 37 | //----------------------------------- --------------------------- |
tony63 | 0:e74448c0b740 | 38 | LENOUT= LENIN*8/7; |
tony63 | 0:e74448c0b740 | 39 | K=7; |
tony63 | 0:e74448c0b740 | 40 | C=0; |
tony63 | 0:e74448c0b740 | 41 | DS[0]=DE[0] & 0x7F; // la primera sola |
tony63 | 0:e74448c0b740 | 42 | pc.printf("%2X,%d,%d\r\n",DS[0],i,K); |
tony63 | 0:e74448c0b740 | 43 | for (i=1;i < LENOUT;i++){ // inicia el algoritmo |
tony63 | 0:e74448c0b740 | 44 | DS[i]=(DE[i-1-C]>>K | DE[i-C]<<(8-K))& 0x7F; //valido para todos |
tony63 | 0:e74448c0b740 | 45 | pc.printf("%2X,%d,%d\r\n",DS[i],i,K); |
tony63 | 0:e74448c0b740 | 46 | if (K==0) {K=8;C++;} |
tony63 | 0:e74448c0b740 | 47 | K--; |
tony63 | 0:e74448c0b740 | 48 | } |
tony63 | 0:e74448c0b740 | 49 | for (i=0;i < LENOUT;i++){ |
tony63 | 0:e74448c0b740 | 50 | pc.printf("%c",DS[i]); |
tony63 | 0:e74448c0b740 | 51 | } |
tony63 | 0:e74448c0b740 | 52 | pc.printf(" ---"); |
tony63 | 0:e74448c0b740 | 53 | |
tony63 | 0:e74448c0b740 | 54 | } |