Jump to content

Recommended Posts

Posted

Hi,

never heard of of pdu before, but this is what I found : :)

http://www.mikrocontroller.net/topic/149989

http://www.mikrocontroller.net/attachment/91793/Delphi_PDU.zip

http://averagecoder.net/visual-basic-version-of-ascii-to-pdu-and-pdu-to-ascii-converter-functions.htm

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Posted

Thanks for your interest!

I see link and there are much good informations! But hi want simply use the functions inside this library

http://www.scampers.org/steve/sms/libraries.htm

But is difficult for me understand the method...I suppose to use dllcall() . I'm interesting in a simple example to use

Posted (edited)

Try this... Is not a 'pretty' script like Julia Roberts, but... But, the first result is functional.

Please, return a feedback if it work, have a bug, etc... I think we have the same interests in this script.

#include <Array.au3>
$Word = "hellohello"
ConsoleWrite(_Asc2PDU($Word) & @LF)
Func _Asc2PDU($Data)
; Author: Detefon
; Convert a simple text to PDU
Local $a[1], $b[1], $c[1]
$Temp = StringToASCIIArray($Data)
For $x = 0 To UBound($Temp) - 1
  $Temp[$x] = _Dec2Bin($Temp[$x])
  $q = $x - (8 * Int($x/8))
  _ArrayAdd($a,StringMid($Temp[$x],1,7-$q))
  _ArrayAdd($b,StringTrimLeft($Temp[$x],7-$q))
Next
For $x = 0 To UBound($a) - 1
  If $x <> UBound($a) - 1 Then
   $d = $b[$x + 1] & $a[$x]
  Else
   $d = $a[$x]
  EndIf
  If Not ($d == "") Then _ArrayAdd($c,_BinaryToHexString($d))
Next
Return _ArrayToString($c,"",1)
EndFunc
; http://www.dreamfabric.com/sms/hello.html
; http://www.ehow.com/how_7840569_convert-text-pdu.html
Func _Dec2Bin($Data)
; Author: Detefon
Local $a = 1, $bin = ""
While $Data > 0.5
  $a = Mod($Data,2)
  $Data = Int($Data/2)
  $bin = $a & $bin
WEnd
Return $bin
EndFunc
Func _Bin2Dec($Data)
; Author: Detefon
Local $Len = StringSplit($Data,""), $Numero
For $x = $Len[0] To 1 Step - 1
  $Numero += (2 ^ (8-$x)) * $Len[$x]
Next
Return $Numero
EndFunc
Func _BinaryToHexString($BinaryValue)
; http://www.autoitscript.com/forum/topic/70507-converter-dec-hex-bin/page__view__findpost__p__516614
Local $test, $Result = '',$numbytes,$nb
If StringRegExp($BinaryValue,'[0-1]') Then
  If $BinaryValue = '' Then
   SetError(-2)
   Return
  EndIf
  Local $bits = "0000|0001|0010|0011|0100|0101|0110|0111|1000|1001|1010|1011|1100|1101|1110|1111"
  $bits = stringsplit($bits,'|')
  $test = StringReplace($BinaryValue,'1','')
  $test = StringReplace($test,'0','')
  If $test <> '' Then
   SetError(-1)
   Return
  EndIf
  While 1
   $nb = Mod(StringLen($BinaryValue),4)
   If $nb = 0 Then ExitLoop
   $BinaryValue = '0' & $BinaryValue
  WEnd
  $numbytes = Int(StringLen($BinaryValue)/4)
  Local $bytes[$numbytes],$Deci[$numbytes]
  For $j = 0 To $numbytes - 1
   $bytes[$j] = StringMid($BinaryValue,1+4*$j,4)
   For $k = 0 To 15
    If $bytes[$j] = $bits[$k+1] Then
     $Deci[$j] = $k
     ExitLoop
    EndIf
   Next
  Next
   $Result = ''
   For $l = 0 To $numbytes - 1
    $Result &= Hex($Deci[$l],1)
   Next
   Return $Result
Else
  MsgBox(0,"Error","Wrong input, try again ...")
  Return
EndIf
EndFunc
Edited by detefon

Visit my repository

Posted (edited)

very nice! Only a thing....I change 8 line

from

$Temp = StringToASCIIArray($Word)

to

$Temp = StringToASCIIArray($Data)

so if you use the function is perfect!

DO you interest in gsm pdu format, right? because I see that the pdu string is longer, comprensive of smsc, number, time ecc...

how you resolve it?

thanks !

Edited by miky1985
Posted

Yes Mike, recently I became interested in pdu, because I could write a small script that sends sms to my friends and I am studying the ways of sending the message. You're right, the pdu is quite extensive, but one piece at a time ... I am currently doing the reverse, pdu to text.

Best regards.

Visit my repository

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...