×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    8

    Send UID to a webserver

    Hi,

    I want to send the UID of the RFID tag to a web server through php. Once I do this php scripts run on the webpage and sends me updated information. Basically whenever I read a tag, it goes to the this php webpage that updates the status of the tag and displays the updated info on the phone.

    Now the problem is when I run my midlet on the emulator it works perfectly fine. But when I try to connect to the php page through my actual phone, it doesn't go to the page... it just redirects and gives me response code 302, instead of HTTP_OK (response code :200) which I get when I run it on the emulator.

    It's making me mad... please help me out!!

    Thanks in advance

  2. #2
    Registered User
    Join Date
    Feb 2009
    Location
    Hagenberg, Austria
    Posts
    121

    Re: Send UID to a webserver

    Hallo Rashida,

    this seems to be a server side problem. Have you tried to trace the communication between the emulator/phone and the webserver? Are there any differences in the request headers?

    br,
    Michael

  3. #3
    Registered User
    Join Date
    Mar 2010
    Posts
    8

    Re: Send UID to a webserver

    Hi Michael,

    Thank you for your response. You mentioned something about request headers. I don't know what you exactly mean by it.

    Below is a code snippet to make the connection

    connection = (HttpConnection) Connector.open(url);
    //HTTP Request
    System.out.println("connected");
    connection.setRequestMethod(HttpConnection.GET);
    connection.setRequestProperty("IF-Modified-Since","20 Jan 2001 16:19:14 GMT");
    connection.setRequestProperty("User-Agent","Profile/MIDP-2.0 Confirguration/CLDC-1.0");
    connection.setRequestProperty("Content-Language", "en-CA");
    connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

    When I output the following as an alert - on the emulator it gives me 200 and and on the phone it gives me 302

    error = connection.getResponseCode();

    Is it because of WAP issue? Because it's not just my php page... it gives me this error when I try connecting to any webpage that is not a .html. Even asp webpages don't work.

    I have a series 40, 3rd Edition phone i.e Nokia 6131. Is it a browser issue with the phone? If so... is there any other way to send data to a webserver?

    Many thanks =)

  4. #4
    Registered User
    Join Date
    Feb 2009
    Location
    Hagenberg, Austria
    Posts
    121

    Re: Send UID to a webserver

    Hallo Rashida,

    Quote Originally Posted by rashida.fd View Post
    You mentioned something about request headers. I don't know what you exactly mean by it.
    The HTTP protocol consists of a HTTP request sent from the client (e.g. web browser) to the server and a HTTP response that the server replies in return for the request. The request consists of
    * a request method (e.g. GET),
    * a request target (i.e. a web site URI),
    * request headers (these further descibe what the client actually wants, among others the "request properties" you set) and
    * a request body (that contains further data that can be processed by the server, i.e. your URL-encoded form data)

    Based on all the information from such a request, the server decides what you receive in return.

    Therefore, to debug what is going on, you would need a program on the server (or before the webserver), that shows you how the received request looks like and what might have gone wrong with it.

    Quote Originally Posted by rashida.fd View Post
    Is it because of WAP issue? Because it's not just my php page... it gives me this error when I try connecting to any webpage that is not a .html. Even asp webpages don't work.
    This might be the case. Many service providers place proxy servers in between the connection. Therefore, the proxy server might modify the request before it is passed on to the actual webserver.

    Have you tried if the request ever reaches the PHP script? E.g. you could write something (or better all server variables) to a log file on the server whenever a client accesses the script.

    br,
    Michael

  5. #5
    Registered User
    Join Date
    Mar 2010
    Posts
    8

    Re: Send UID to a webserver

    Hi Michael,

    Thank You for your reply. I am going to try debugging what the problem with the web server is.

    My main aim to connect to a web server is to store information related to each tag.

    For instance, I read a tag id say 1234... and with the tag id - I send a name and status of the tag (which alternates between 'in' and 'out' every time the tag is touched) to the web server and similarly I get information about the tag from the web server using the tag id again.

    I was wondering if it is possible for me to store the tag information i.e the name and status on the tag itself. I read one of your post on another thread for reading text from RFID tag but I want to know how to do I write text to RFID tag.

    http://wiki.forum.nokia.com/index.ph...ge_to_NDEF_tag

    The above code writes Image... would changing image/png to text/plain work?

    I don't have a lot of knowledge. I would really really appreciate if you help me.

    Many many thanks,
    Rashida

  6. #6
    Registered User
    Join Date
    Feb 2009
    Location
    Hagenberg, Austria
    Posts
    121

    Re: Send UID to a webserver

    Hallo Rashida,

    you could try something like the following:
    Code:
    public void targetDetected(TargetProperties[] prop) {
    
        [...]
    
        String url = prop[0].getUrl();
        conn = (NDEFTagConnection) Connector.open(url);
    
        NDEFRecordType t = new NDEFRecordType(NDEFRecordType.EXTERNAL_RTD, "urn:nfc:ext:nfc-research.at:mydata");
    
        NDEFMessage message = conn.readNDEF();
        NDEFRecord[] records = message.getRecords();
    
        if (records != null) {
            for (int i = 0; i < records.length; ++i) {
                if (records[i].getRecordType().equals(t)) {
                    [read data (i.e. tag name and tag status) from record]
                }
            }
        }
    
        byte[] payload = null;
        [create payload from data (i.e. from tag name and tag status)]
    
        NDEFRecord record = new NDEFRecord(t, null, payload);
        message = new NDEFMessage(new NDEFRecord[] { record });
        conn.writeNDEF(msg);
    
        conn.close();
    
        [...]
        
    }
    The code first reads an existing NDEF message from the tag and parses it for a certain record type (urn:nfc:ext:nfc-research.at:mydata). Then it creates a new message containing this record type with some payload and writes it back to the tag.

    br,
    Michael

  7. #7
    Registered User
    Join Date
    Mar 2010
    Posts
    8

    Re: Send UID to a webserver

    Thanks a ton Michael,

    Regards,
    Rashida

Similar Threads

  1. Replies: 9
    Last Post: 2010-02-15, 17:37
  2. send automatically sms from webserver(apache2,mysql,php) to mobile
    By gudivada213 in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2009-06-17, 10:58
  3. Send pictures from memory to webserver
    By cyliax in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2005-05-08, 14:53

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×