Greetings ,
Thank you so much for the reply.
By using following java class My NETWPIN is 4940205060072800 .
The message got deliver to handset but again authentication fails .
Following is the java class i am using to send OTA message using NETWPIN.
In main function i m calling
sendOMASettings(“8146256126”,” 4940205060072800 ”);
public String sendOMASettings(String to, String pin) {
String result = "";
try {
StringBuffer buffer = new StringBuffer();
if (pin == null) {
pin = "0000";
}
buffer.append("<?xml version=\"1.0\"?>\r\n").
append("<!DOCTYPE wap-provisioningdoc PUBLIC
\"-//WAPFORUM//DTD PROV 1.0//EN\" \"http://www.wapforum.org/DTD/prov.dtd\
<http://www.wapforum.org/DTD/prov.dtd/> ">\r\n").
append("<wap-provisioningdoc >\r\n").
append("<characteristic type=\"NAPDEF\">\r\n").
append("<parm name=\"NAPID\" value=\"inet\"/>\r\n").
append("<parm name=\"NAME\" value=\"Idea Internet\"/>\r\n").
append("<parm name=\"BEARER\" value=\"GSM-GPRS\"/>\r\n").
append("<parm name=\"NAP-ADDRESS\"
value=\"internet\"/>\r\n").
append("<parm name=\"NAP-ADDRTYPE\"
value=\"internet\"/>\r\n").
append("<parm name=\"INTERNET\"/>\r\n").
append("</characteristic>\r\n").
append("<characteristic type=\"APPLICATION\">\r\n").
append("<parm name=\"APPID\" value=\"w2\"/>\r\n").
append("<parm name=\"TO-NAPID\" value=\"inet\"/>\r\n").
append("<characteristic type=\"RESOURCE\">\r\n").
append("<parm name=\"URI\"
value=\"http://google.com\"/>\r\n").
append("<parm name=\"STARTPAGE\"/>\r\n").
append("</characteristic>\r\n").
append("</characteristic>\r\n").
append("</wap-provisioningdoc>\r\n");
String data = java.net.URLEncoder.encode(buffer.toString(), "UTF8");
String toInURL = java.net.URLEncoder.encode(to, "UTF8");
String sendURL = "http://" + "kannelServerIP" + ":" +
"serverSendPort" + "/cgi-bin/sendota?username=" + "user"
+ "&password=" + "password" + "&coding=2&to=" + toInURL + "&text="
+ data + "&from="
+ "yourShortNumber" + "&type=oma-settings" + "&sec=netwpin" +
"&pin=" + pin ;
java.net.URL url = new java.net.URL(sendURL);
java.io.InputStream in = url.openStream();
java.io.BufferedInputStream bufIn = new
java.io.BufferedInputStream(in);
for (;;) {
int car = bufIn.read();
if (car == -1) {
break;
} else {
result = result + (char) car;
}
}
bufIn.close();
in.close();
} catch (Exception e) {
e.printStackTrace();
result = "failed";
}
return result;
} //END
The mobile number and imsi no are verified and tested using nowsms trial
version.
Please help in using sendota method with netwpin.
Regards
Harmeet Singh
From: Benaiad [mailto:[email protected]]
Sent: 21 October 2010 11:14
To: Harmeet Singh
Cc: kannel users
Subject: Re: Regarding IMSI No
Try this java class:
------------------------
public class NETWPIN {
public static void main(String[] args) {
String IMSI = "404020506708200";
byte[] key = getKeyFromIMSI(IMSI);
String NETWPIN = bytesToHex(key);
System.out.println("NETWPIN from imsi: " + NETWPIN);
}
private static byte[] getKeyFromIMSI(String imsi) {
imsi = imsi.trim();
if ((imsi.length() % 2) == 1) {
imsi = "9" + imsi;
} else {
imsi = "1" + imsi;
imsi = imsi + "F";
}
int numDigit = imsi.length();
String temp = null;
char c1 = 0;
char c2 = 0;
byte b = 0;
byte[] key = new byte[numDigit / 2]; // always even
int t = 0;
for (int i = 0; i < numDigit; i++) {
c1 = imsi.charAt(i);
c2 = imsi.charAt(++i);
temp = "" + c2 + c1;
try {
key[t] = (byte) (Integer.parseInt(temp, 16));
} catch (Exception ex) {
ex.printStackTrace();
}
t++;
}
return key;
}
private static String bytesToHex(byte[] b) {
StringBuffer buf = new StringBuffer("");
for (int i = 0; i < b.length; i++) {
buf.append(byteToHex(b[i]));
}
return buf.toString();
}
private static String byteToHex(byte b) {
// Returns hex String representation of byte b
char hexDigit[] = {
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
};
char[] array = {hexDigit[(b >> 4) & 0x0f], hexDigit[b & 0x0f]};
return new String(array);
}
}
Regards
--
Abdulmnem Benaiad
Almontaha CTO
Tripoli-Libya
<http://www.almontaha.ly/> www.almontaha.ly
about.me <http://about.me/benaiad/bio>
On Wed, Oct 13, 2010 at 6:22 PM, Harmeet Singh <[email protected]>
wrote:
Hi,
Please help me in understanding how to use NETWPIN with kannel to send OTA
settings.
I think i am missing how to calculate HMAC code.
Will be grateful for any kind of hint .
Regards
Harmeet Singh
From: Harmeet Singh [mailto:[email protected]]
Sent: 12 October 2010 15:29
To: 'Benaiad'
Cc: 'kannel users'
Subject: RE: Regarding IMSI No
Greetings ,
Thanks for the reply.
According to the document i had calculate the NETWPIN but again same message
is there i.e Authentication failed .
My IMSI no is 404020506708200 as per the document i had calculated as 49 40 20
50 60 07 28 00 .
9 is used to pair.
It is not working , Please help me in calculating above IMSI no to NETWPIN for
Kannel.
Regards
Harmeet Singh
From: Benaiad [mailto:[email protected]]
Sent: 12 October 2010 11:36
To: Harmeet Singh
Cc: kannel users
Subject: Re: Regarding IMSI No
Hi,
This document may help to explain the process of calculating the NETWPIN:
http://www.nowsms.com/discus/messages/1/OTA_Motorola-3137.pdf
Regards
--
Abdulmnem Benaiad
Almontaha CTO
<http://www.almontaha.ly/> www.almontaha.ly
Tripoli-Libyan
On Tue, Oct 12, 2010 at 7:17 AM, Harmeet Singh <[email protected]>
wrote:
Greetings,
I am able to send the OTA Settings Message by using Kannel and UserPin has been
used , But i want to use Netwpin (Imsi No) .
I had already verified my IMSI no and it is ok . It has 15 digit .
After reading and searching i came to know that we should provide Netwpin as
semi-octets .
Please help me to know how can i use Netwpin to send the OTA settings.
Regards
Harmeet Singh