Art of Mobile
Home GeneralHardwareJavaMMSPerlPHPSMSWAP

Archive for the ‘WAP’ Category

Check Device’s User-Agent using Perl

Posted in Perl, WAP by artofmobile

There is a CPAN library that helps to parse the User-Agent. You can download the Perl library at:

http://search.cpan.org/~cmanley/Mobile-UserAgent-1.05/lib/Mobile/UserAgent.pm

After you download the library, perform the usual installation procedures:

perl Makefile.PL
make
make install

The following is the source code:

#!/usr/local/bin/perl
use strict;

use Mobile::UserAgent;
my $uaobj = new Mobile::UserAgent();

The codes above is the standard declaration so that you can call “Mobile::UserAgent” library. The following 3 lines are used for testing purposes. Uncomment the following 3 lines and comment the above 1 line to do some testing.

#my $useragent = 'Nokia6600/1.0 (4.09.1) SymbianOS/7.0s Series60/2.0 '.
#   'Profile/MIDP-2.0 Configuration/CLDC-1.0';
#my $uaobj = new Mobile::UserAgent($useragent);

The following lines check the User-Agent string and pass the output to the subroutine “printWml” if the device suppose WML or the subroutine “printHtml” if the device doesn’t.

if ($uaobj->success()) {
   my $out='Vendor: ' . $uaobj->vendor()     . "<br />\\n";
   $out.='Model:    ' . $uaobj->model()      . "<br />\\n";
   $out.='Version:  ' . $uaobj->version()    . "<br />\\n";
   $out.='Series60: ' . $uaobj->isSeries60() . "<br />\\n";
   &printWml($out);
} else {
   &printHtml("Connecting Client is not a mobile user-agent \\n");
}

Read the rest of this entry »

How to convert SI message to GSM SMS User Data

Posted in Java, SMS, WAP by artofmobile

After publishing the article on “How to send WAP Push data through SMPP”, there is a lot of requests on how to formulate the GSM SMS User Data.

Basically, the following is an example in java with remark in the code to explain how this is done:

  public String toSmsBinary() {
    /**
     GSM SMS User Data
     06: UDH Length which is 6
     05: 16 bit address
     04: Length(4)
     0B84: Destination Port(2948)
     23F0: Source Port(9200)

     Wireless Session Protocol
     90: Transaction ID
     06: PDU Type(Push)
     01: Headers Length is 1
     AE: Content-Type is application/vnd.wap.sic

     */
    StringBuilder ud = new StringBuilder().append("0605040b8423f0900601ae");
    ud.append(toWBXML());
    return ud.toString();

  }

The above function creates the GSM SMS User Data and Wireless Session Protocol (WSP) header. Read the rest of this entry »

How to send WAP Push data through SMPP

Posted in Java, SMS, WAP by artofmobile

Here we would like to show you how to send a WAP Push message through SMPP using Java. This short tutorial will use the library and example source code from OpenSMPP. You can download the file from SourceForge.

The downloadable zipped file include source code and jar file libraries, and this article will modify this file SMPPTest.java to demonstrate how to do that.

Modify SMPPTest.java and include the following 2 functions:

    private static final String HEXINDEX = "0123456789abcdef          ABCDEF";

    public static byte[] hexToByte(String s) {
        int l = s.length() / 2;
        byte data[] = new byte[l];
        int j = 0;

        for (int i = 0; i < l; i++) {
            char c = s.charAt(j++);
            int n, b;

            n = HEXINDEX.indexOf(c);
            b = (n & 0xf) << 4;
            c = s.charAt(j++);
            n = HEXINDEX.indexOf(c);
            b += (n & 0xf);
            data[i] = (byte) b;
        }
        return data;
    }

The above function is used to convert Hexadecimal to binary data.
Read the rest of this entry »

WAP 1.3 DTD Specification

Posted in WAP by artofmobile

The following are the URLs to download the DTD for WAP 1.3 Specification:

Wirleess Markup Language (WML) 1.3:
http://www.wapforum.org/DTD/wml13.dtd

Push Access Protocol (PAP):
http://www.wapforum.org/DTD/pap_1.0.dtd

Push Service Indication (SI):
http://www.wapforum.org/DTD/si.dtd

Push Service Loading (SL):
http://www.wapforum.org/DTD/sl.dtd

Detect WAP browser and redirect to different url in Perl

Posted in Perl, WAP by artofmobile

Do you want to have the same url for your Web and Wap broswer? The following is the code to do so in Perl:

#!/usr/local/bin/perl
use CGI;

my $query = new CGI;

my @list=$query->Accept();

my $htmlsite="http://www.artofmobile.com/index.html";
my $wmlsite="http://www.artofmobile.com/index.wml";

my $wml=0;
my $html=0;

foreach (@list) {
   $html=1 if /text\\\\/html/i;
   $wml=1 if  /wap/;
}

print $query->redirect($wmlsite)  if $wml==1;
print $query->redirect($htmlsite) if $html==1;
print $query->redirect($wmlsite);
Powered by WordPress. Theme created by Art Of Mobile