Shop OBEX P1 Docs P2 Docs Learn Events
Converting RN Wifly code to Spinneret — Parallax Forums

Converting RN Wifly code to Spinneret

T ChapT Chap Posts: 4,217
edited 2014-02-07 17:57 in Accessories
I have various code that uses the Prop connected to the RN134 Wifly module, which is a wifi interface that accepts serial commands from the Prop. I have some needs that require a wired version to upload data to a database periodically. Can someone point me in the right direction to figure out how to set up the Spinneret to do the following;


Wait for another Prop to send a byte value that represents an opcode.

Connect to a php webpage hosted on a remote server using a Get or Post with approximately 5 to 10 values included in the get.

Receive any echo's

Parse any echo's and respond or do something locally

Close the socket.

I have read over the httpserver but nothing jumps out as simple straight forward solutions as it is all over my head.

Comments

  • Mike GMike G Posts: 2,702
    edited 2014-02-03 04:01
    T Chap, did you try loading any of the client example code? The TcpSocketClientDemoDhcpDns.spin covers a client GET or POST.
  • T ChapT Chap Posts: 4,217
    edited 2014-02-03 05:39
    Thanks Mike. I will explore where you guys are parking this code, I haven't checked google repository yet.


    On a side note. I was initially searching for this forum on my iphone and it isn't there, which is why I posted my other Spinneret question in the Propeller forum thinking this section was merged and deleted. On a PC browser I can see this forum,
  • Mike GMike G Posts: 2,702
    edited 2014-02-03 09:59
    On a side note. I was initially searching for this forum on my iphone and it isn't there, which is why I posted my other Spinneret question in the Propeller forum thinking this section was merged and deleted. On a PC browser I can see this forum,
    Make sure to select the forum root and not General Forums.
  • T ChapT Chap Posts: 4,217
    edited 2014-02-03 12:15
    Ok I see what you mean.
  • T ChapT Chap Posts: 4,217
    edited 2014-02-03 14:44
    Mike. That looks like preconfigured gets in Dat. Does this allow some method to add parameters on the fly after the initial get? I don't see any examples.
  • Mike GMike G Posts: 2,702
    edited 2014-02-03 15:41
    Mike. That looks like preconfigured gets in Dat. Does this allow some method to add parameters on the fly after the initial get? I don't see any examples.
    You'll need to add the parameters you'd like to pass. Parameters can be in the URL (GET) or body (POST). The general format is name1=value1&name2=value2, where name and value are text (ASCII). Adding parameters is simple string manipulation. The easiest method is to implement fixed width names and values. If fixed width is not possible, you're looking at concatenation and byte moves.
    DAT
     google        byte  "GET /finance/historical?q="
     q             byte  "FB", "&output="
     csv           byte  "csv", "HTTP/1.1", CR, LF,
    
  • T ChapT Chap Posts: 4,217
    edited 2014-02-03 19:59
    Thanks Mike, I am studying that idea now. I will post what I find out to be a solution.
  • T ChapT Chap Posts: 4,217
    edited 2014-02-04 09:59
    OT Has anyone experienced a slow clock? As in 10 minutes behind over a month? In this case, with no power applied for a month, is it possible to see a slower than normal clock? To be honest, I never tested the clock before, but it was set in the past month and put on a shelf. Powered up today, and it is slow.
  • T ChapT Chap Posts: 4,217
    edited 2014-02-04 10:44
    I got the file you linked and just got started. Making progress, at least I see what the demo is showing. Now to try to create a GET with parameters on the fly. Cool stuff Mike!

    For about 25 bucks, the Spinneret is wifi'd with this device:

    http://www.netgear.com/home/products/connected-entertainment/gaming-home-theater/WNCE2001.aspx

    --------------------------------------------------
    Requesting IP.....192.168.1.25
    Lease Time........604800
    DNS...............192.168.1.254
    DHCP Server.......192.168.1.254
    Router............192.168.1.1
    Gateway...........192.168.1.1
    
    DNS Init (bool)...True
    Resolved IP(0)....74.125.137.113
    Resolved IPs......6
    
    Initialize Socket
    Begin Client Web Request
    Status(open)......13
    Status(conn)......01
    Connecting to.....74.125.137.113
    
    Sending HTTP Request
    Bytes Sent........99
    Bytes received....11734
    
    Disconnect
    
    
  • Mike GMike G Posts: 2,702
    edited 2014-02-04 15:44
    Has anyone experienced a slow clock?
    Yes, the RTC is not 100% accurate over time. IIRC, The datasheet has configuration information to better handle accuracy. I generally update the time via SNTP when renewing a DHCP lease. You can find an example in WebServer_W5100_RTC. BTW, all W5200 libraries work with the Spinneret. The difference being 4 more sockets with the W5200 and the SPI driver.

    I'll be picking up a Netgear Universal WiFi Adapter - Thanks
  • T ChapT Chap Posts: 4,217
    edited 2014-02-07 05:49
    If you wanted to update the time over LAN, what would be the simplest way to do this? I was thinking to have an html page on the SD card called settime.html, open it from any local computer browser and view the current time on the RTC. If a change is needed, type in the new time(year, mo, date, day, hour min sec) and press update. The only question is that if the Spinneret is the server, what method will send the time change info back for parsing and update? Echo on button press and have the Spinneret watching for an reply?

    Another idea is to have a page that displays the time, but then do a GET with the updated time in the parameters, where the time is entered in data fields and the button press creates the GET with the values added. BTW if someone is interested in offering some consulting services to help me out on accomplishing a few little goals like this, let me know.
  • Mike GMike G Posts: 2,702
    edited 2014-02-07 17:57
    If you wanted to update the time over LAN, what would be the simplest way to do this?
    If the LAN has internet access, SNTP is the easiest. There's a library for that...
    I was thinking to have an html page on the SD card called settime.html, open it from any local computer browser and view the current time on the RTC. If a change is needed, type in the new time(year, mo, date, day, hour min sec) and press update. The only question is that if the Spinneret is the server, what method will send the time change info back for parsing and update?
    A page is not required. A simple GET with URL parameters is all you need.
    http://<some ip:port>/settime/?hh=05&mm=30&ss=10
    
Sign In or Register to comment.