QR Code & mobile devices & the desktop

John Craig john at splash21.com
Tue Feb 7 09:16:52 EST 2012


Just noticed that tType should be 'text' or 'text/html', etc... in 
socketRespond

put "Content-Type: " & tType & CRLF after tHeaders



On 07/02/2012 14:07, John Craig wrote:
> Hi, Nicolas.  I had thought the exact same thing - there's no need for 
> additional hardware if you already have a capable phone / tablet.
> I put a simple demo together - just paste the following code into a 
> card and add a button that calls 'serverReset' and a field called 
> 'Data' to show incoming data. I've used port 10310 for the connections 
> and my local ip address is 192.168.0.100 - just replace with your own 
> details.
>
> On your scanner app, after scanning a code, you can just;
> put URL("http://192.168.0.100:10310/?" & urlEncode("QR code data 
> 12345...")) into tResponse
>
> You can also just use a browser to test quickly.  Don't you just love 
> all this modern mobile technology?!  :D
>
> John.
>
>
>
> on serverReset
>    # reset and listen on a custom port
>    resetAll
>    set the socketTimeoutInterval to 30
>    accept connections on port 10310 with message "socketConnect"
>    put the millisecs
> end serverReset
>
>
> on socketConnect pSocket
>    # just read the first line of the request
>   read from socket pSocket until CRLF with message "socketReceive"
> end socketConnect
>
>
> on socketReceive pSocket, pData
>    # word 2 is the requested URL
>    put word 2 of pData into tURL
>    set itemDel to "?"
>    if the num of items in tURL > 1 then
>       # data received
>       put urlDecode(item 2 of tURL) into tData
>       put the long date && the long time & LF & \
>             "Received: " &  tData & LF \
>             into fld "Data"
>       # process data, store in database, etc...
>       # ..........
>       # ..........
>       # mirror the data back to signal success - you could send an md5 
> hash, etc. instead
>       put tData into tResponse
>    else
>       # no data received, response will be an error message
>       put "Error: No data!" into tResponse
>    end if
>    # send the response and disconnect
>    socketRespond pSocket, tResponse
>    socketDisconnect pSocket
> end socketReceive
>
>
> on socketRespond pSocket, pData
>    # send an HTTP response
>   put "HTTP/1.1 200 OK" & CRLF into tHeaders
>   put "Content-Type: " & tType & CRLF after tHeaders
>   put "Cache-Control: no-cache" & CRLF after tHeaders
>   put "Connection: Close" & CRLF after tHeaders
>   put "Date: " & the internet date & CRLF after tHeaders
>   put "Content-Length: " & length(pData) & CRLF after tHeaders
>   put CRLF after tHeaders
>   write tHeaders & pData to socket pSocket
> end socketRespond
>
>
> on socketDisconnect pSocket
>   close socket pSocket
> end socketDisconnect
>
>
> on socketError pSocket
>   socketDisconnect pSocket
> end socketError
>
>
> on socketTimeout pSocket
>   socketDisconnect pSocket
> end socketTimeout
>
>
> on socketClosed pSocket
>   socketDisconnect pSocket
> end socketClosed
>
>
>
> On 07/02/2012 10:56, Nicolas Cueto wrote:
>> Hello All,
>>
>> Given the relatively high price of USB 2D code readers, those recent
>> and tempting announcements about QR Code libraries aimed for LC users
>> have got me wondering.
>>
>> What LC components (add-ons?) and LC commands ought I consider for
>> somehow relaying (internet? WIFI?) to a desktop computer some QR Code
>> scanned by a mobile device (iPhone or Android tablet)?
>>
>> A general idea about the steps involved would be great. And much 
>> appreaciated.
>>
>> Cheers.
>>
>> -- 
>> Nicolas Cueto
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your 
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>




More information about the use-livecode mailing list