This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

how to know HTTP server is connected by mobile device ?

Other Parts Discussed in Thread: EK-TM4C1294XL

Hi All, 

I am developing HTTP server with EK-TM4C1294XL board.

There is one question.

Is it possbile to show different HTML page for mobile browser and normal PC browser ?

If possible, please let me know how to do.

Best Regards,

Hea Ryong

  • This is a more general topic that you may need to study and understand while parsing headers, specifically the User-Agent header.

    For example you may refer to the following link which has some info:
    delib.zendesk.com/.../203431259-Browser-device-identification-how-to-find-out-which-browser-and-device-have-been-used-to-submit-a-response
    which recommends: "looking for the string “Mobi” anywhere in the User Agent to detect a mobile device."

    Following link also has some good tips:
    stackoverflow.com/.../auto-detect-mobile-browser-via-user-agent

    Murat
  • Hello Murat, 

    Thanks for your response.

    It could be helpful for normal solution.

    please let me describe my problem more detail.

    I think HTTP message is delivered to HTTP server in RTOS, so I cannot identify what HTTP parameters are in the HTTP message, since message is parsed inside of HTTP server.

    Is there a way to know the parsed parameters outside of HTTP server ?

    How to add my code in the HTTP server ?

     

    Expecting your feedback.

    Thanks a lot.

    Best Regards,
    Hae Ryong

  • Can you tell me what tools and APIs you are using along with some code snippets?
  • Thanks for prompt response.

    I'm using tirtos_tivac_2_16_01_14, and EK-TM4C1294XL board.
  • Hi,

    Can you tell me which HTTP server you are using, and how you are interfacing with it? (actual code snippets)

    Murat
  • Hi Murat, 

    Sorry for late responding.

    please refer to following simple test project.

    it requires login info to connect HTTP server, id:user, password:0000   <- number zero, not character 'O', you can see at net_utils.c

    3603.TM4C_http.zip

    if you need anything, please let me know.

    Thanks in advance,

    Best Regards,

    Hae Ryong

  • Hi Hae,

    I am not sure what stage your current project that you shipped is in, but I couldn't import the project file into CCS and instead looked at the sources in the zip file, I don't see any http server related code or API calls. I suspect relavant parts are omitted, and I don't have anything to go by.

    It is not clear what http server code you are running, you said you use TI-RTOS, but I need more specific and useful information in order to be able to help,

    Best regards,
    Murat

  • Hi Murat,

    I don't understand that situation.

    As I have tried, it worked fine. although it is simplfied snippet from actual project.

    My test environment, PC - personal  router - EK-TM4C1294XL

    You can see HTTP server is enabled by looking at base.cfg

    var Tcp = xdc.useModule('ti.ndk.config.Tcp');
    var Ip = xdc.module('ti.ndk.config.Ip');
    Ip.hostName = "ACU1";
    Ip.autoIp = false;
    Ip.address = "192.168.0.14";
    Ip.mask = "255.255.255.0";
    Ip.gatewayIpAddr = "192.168.0.1";
    Ip.domainName = "ACU1.net";
    
    var Http = xdc.useModule('ti.ndk.config.Http');
    var http0Params = new Http.Params();
    http0Params.CallByIP = true;
    http0Params.mode = 4;
    var http0 = Http.create(http0Params);

    and authentication info is in netOpenHook() of net_utils.c

    when I run the code, console log showed as follows

    Using MAC address in flash
    Network Added: If-1:192.168.0.14
    Service Status: HTTP : Enabled : : 000

    I have attached zip with build files including execution file.

    please check again. I'm sure it works.

    5123.TM4C_http_build.zip

    Best Regards,

    Hae Ryong

  • Hi Hae,

    Ok, I see you are using the NDK http. I looked at the documentation in:

    and I don't see any APIs exposing you to the http payload received by the server directly.
    Looking at the example in section E.4.2. the closest thing I can see is if you could experiment with supplying a similar cgi function for HTTP GET requests and see what you can access in the htmlSock connection. This example is using a provided cgiParse() function to parse contents of the socket, but you might want to just inspect and see if any HTTP header content is available. If so, then you can use the "User-Agent" info as I mentioned above. If not, I don't see any published API that lets you process the HTTP header data, but I will consult with the developers to see if we can get more insights.

    Best regards,
    Murat

  • There was a suggested answer and since there has been no active on this thread for more than a week, the suggested answer was marked as verify. Please feel free to select the "Reject Answer" button and reply with more details.
  • The development team came back with an aswer confirming my earlier comment, stating that  there is no public API for parsing HTTP headers in NDK.
    You can add the required abiliy to parse these headers on your own until a public feature is released, you would have to modify httpClientProcess() in ti\ndk\nettools\http\httpclie.c. This is where the parsing of the header occurs.

     I will file an enhancement request for that, and in the meanwhile we can close this thread.

    Best regards,
    Murat

  • Hi,
    Just a follow-up, the development team confirmed my earlier comment, that there is no public API for parsing HTTP headers.
    Until this feature is added to NDK you can add this on your own by modifing httpClientProcess() in ti\ndk\nettools\http\httpclie.c. This is where the parsing of the header occurs.

    I will file an enhancement request for the feature for future development plans,
    Murat
  • Hi Murat,

    OK, thanks for your feedback.
    Happy New Year!

    Best Regards,
    Hae Ryong