Plugshare decompilation error

Issue #278 resolved
Simon Walters created an issue

Getting this when I click on File then Open

Comments (9)

  1. Simon Walters reporter

    edit - actually after I click the Microblocks tab in the File Open dialog

    Also, doesn't seem to be fatal - I can just click on X and carry on

  2. John Maloney repo owner

    It looks like you clicked on "open from board", which attempts to read and decompile a MicroBlocks project from the board. Do you happen to remember the project you had on that board? If you still have the project or can recreate it, that would be helpful in trying debug this issue.

    Let me know if you are getting this error when clicking the normal "open" command. I'm not seeing the problem in the Mac or webapp versions but I haven't tested it on Windows.

  3. Simon Walters reporter

    Yes - I have PlugShare enabled and disabling it and error goes away

    This is the project

    https://microblocks.fun/run/microblocks.html#project=projectName%20%27HTTPServerUsingPOST%27%0A%0Amodule%20main%0Aauthor%20unknown%0Aversion%201%200%20%0Adescription%20%27%27%0Avariables%20%27%20data%20key%27%20log%20%27data%20value%27%20%27parsed%20GET%27%20%27last%20HTTP%20request%27%20%27POST%20data%27%20%0A%0Ascript%2081%2063%20%7B%0AwhenStarted%0AsetUserLED%20true%0Amotor%20%27A%2BB%27%200%0AsayIt%20%27connecting...%27%0AwifiConnect%20%27CYCY%27%20%27%27%0AsayIt%20%28%27%5Bdata%3Ajoin%5D%27%20%27connected%20-%20IP%20is%3A%20%27%20%28getIPAddress%29%29%0AsetUserLED%20false%0A%27MQTT%20connect%20to%27%20%27mqtt.eclipseprojects.io%27%0A%27MQTT%20pub%27%20%28%27%5Bdata%3Ajoin%5D%27%20%27myIP%2F%27%20%27SimonWEMOS%27%29%20%28getIPAddress%29%0Aforever%20%7B%0A%20%20%27last%20HTTP%20request%27%20%3D%20%28%27%5Bnet%3AhttpServerGetRequest%5D%27%29%0A%20%20if%20%28%28%27request%20method%27%20%28v%20%27last%20HTTP%20request%27%29%29%20%3D%3D%20%27POST%27%29%20%7B%0A%20%20%20%20%27POST%20data%27%20%3D%20%28lowercase%20%28%27body%20of%20request%27%20%28v%20%27last%20HTTP%20request%27%29%29%29%0A%20%20%20%20sayIt%20%28v%20%27POST%20data%27%29%0A%20%20%20%20if%20%28%28%27%5Bmisc%3AjsonGet%5D%27%20%28v%20%27POST%20data%27%29%20%27motora%2Bb%27%29%20%21%3D%20%27%27%29%20%7B%0A%20%20%20%20%20%20motor%20%27A%2BB%27%20%28%27%5Bmisc%3AjsonGet%5D%27%20%28v%20%27POST%20data%27%29%20%27motora%2Bb%27%29%0A%20%20%20%20%7D%0A%20%20%20%20if%20%28%28%27%5Bmisc%3AjsonGet%5D%27%20%28v%20%27POST%20data%27%29%20%27motora%27%29%20%21%3D%20%27%27%29%20%7B%0A%20%20%20%20%20%20motor%20%27A%27%20%28%27%5Bmisc%3AjsonGet%5D%27%20%28v%20%27POST%20data%27%29%20%27motora%27%29%0A%20%20%20%20%7D%0A%20%20%20%20if%20%28%28%27%5Bmisc%3AjsonGet%5D%27%20%28v%20%27POST%20data%27%29%20%27motor%27%29%20%21%3D%20%27%27%29%20%7B%0A%20%20%20%20%20%20motor%20%27A%27%20%28%27%5Bmisc%3AjsonGet%5D%27%20%28v%20%27POST%20data%27%29%20%27motor%27%29%0A%20%20%20%20%7D%0A%20%20%20%20if%20%28%28%27%5Bmisc%3AjsonGet%5D%27%20%28v%20%27POST%20data%27%29%20%27motorb%27%29%20%21%3D%20%27%27%29%20%7B%0A%20%20%20%20%20%20motor%20%27B%27%20%28%27%5Bmisc%3AjsonGet%5D%27%20%28v%20%27POST%20data%27%29%20%27motorb%27%29%0A%20%20%20%20%7D%0A%20%20%20%20%27%5Bnet%3ArespondToHttpRequest%5D%27%20%27200%20OK%27%20%27Ok%27%0A%20%20%7D%20else%20%7B%0A%20%20%20%20%27%5Bnet%3ArespondToHttpRequest%5D%27%20%27200%20OK%27%20%27%27%0A%20%20%7D%0A%20%20waitMillis%20100%0A%7D%0A%7D%0A%0Ascript%20400%20181%20%28%27%5Bnet%3AmyMAC%5D%27%29%0A%0Ascript%20664%20186%20%7B%0AwaitMillis%20500%0AsayIt%20%27%27%0Arepeat%2010%20nil%0A%7D%0A%0Ascript%20147%201186%20%7B%0Ato%20%27path%20of%20request%27%20%7B%7D%0A%7D%0A%0A%0Amodule%20%27HTTP%20client%27%20Comm%0Aauthor%20MicroBlocks%0Aversion%201%204%20%0Adepends%20WiFi%20%0Atags%20http%20network%20get%20post%20put%20delete%20%0Achoices%20requestTypes%20GET%20POST%20PUT%20DELETE%20%0Adescription%20%27Send%20HTTP%20requests%20and%20get%20responses%20back.%20You%20can%20use%20this%20library%20to%20fetch%20or%20store%20data%20in%20online%20servers%2C%20or%20to%20control%20other%20Wifi-enabled%20boards.%0A%27%0A%0A%20%20spec%20%27r%27%20%27_http_body_start%27%20%27_http_body_start%20_%27%20%27auto%27%20%27%27%0A%20%20spec%20%27r%27%20%27_http_header_text%27%20%27_http_header_text%20_%27%20%27auto%27%20%27%27%0A%20%20spec%20%27r%27%20%27_http_status_text%27%20%27_http_status_text%20_%27%20%27auto%27%20%27%27%0A%20%20spec%20%27r%27%20%27_http_header%27%20%27_header%20_%20of%20response%20_%27%20%27auto%20auto%27%20%27content-length%27%20%27%27%0A%20%20spec%20%27r%27%20%27_http_status%27%20%27_status%20of%20response%20_%27%20%27auto%27%20%27%27%0A%20%20spec%20%27r%27%20%27_line_end%27%20%27_line_end%27%0A%20%20spec%20%27r%27%20%27_lowercase%27%20%27_lowercase%20_%27%20%27auto%27%20%27ABC%20Def%20gH%27%0A%20%20spec%20%27r%27%20%27_request_url%27%20%27_request_url%20_%20method%20_%20body%20_%20%3A%20port%20_%27%20%27str%20menu.requestTypes%20str%20num%27%20%27%27%20%27GET%27%20%27%27%2080%0A%20%20spec%20%27r%27%20%27_readHTTPResponse%27%20%27_readHTTPResponse%27%0A%20%20spec%20%27r%27%20%27http%DC%83%2F%2F%27%20%27http%DC%83%2F%2F%20_%20%20%3A%20port%20_%27%20%27auto%20num%27%20%27microblocks.fun%2Fexample.txt%27%2080%0A%20%20spec%20%27%20%27%20%27request%27%20%27_%20data%20_%20to%20http%DC%83%2F%2F%20_%20%20%3A%20port%20_%27%20%27menu.requestTypes%20str%20str%20num%27%20%27POST%27%20%27MicroBlocks%20is%20fun%27%20%27microblocks.fun%27%2080%0A%0Ato%20%27_http_body_start%27%20response%20%7B%0A%20%20return%20%28%28%27%5Bdata%3Afind%5D%27%20%28%27%5Bdata%3AunicodeString%5D%27%20%28%27%5Bdata%3AmakeList%5D%27%2013%2010%2013%2010%29%29%20response%29%20%2B%204%29%0A%7D%0A%0Ato%20%27_http_header%27%20header%20response%20%7B%0A%20%20local%20%27header%20text%27%20%28%27_http_header_text%27%20response%29%0A%20%20header%20%3D%20%28%27_lowercase%27%20header%29%0A%20%20repeatUntil%20%28%28size%20%28v%20%27header%20text%27%29%29%20%3C%203%29%20%7B%0A%20%20%20%20local%20%27key%27%20%28%27%5Bdata%3AcopyFromTo%5D%27%20%28v%20%27header%20text%27%29%201%20%28%28%27%5Bdata%3Afind%5D%27%20%27%3A%27%20%28v%20%27header%20text%27%29%29%20-%201%29%29%0A%20%20%20%20if%20%28%28%27_lowercase%27%20key%29%20%3D%3D%20header%29%20%7B%0A%20%20%20%20%20%20return%20%28%27%5Bdata%3AcopyFromTo%5D%27%20%28v%20%27header%20text%27%29%20%28%28%27%5Bdata%3Afind%5D%27%20%27%3A%27%20%28v%20%27header%20text%27%29%29%20%2B%202%29%20%28%28%27%5Bdata%3Afind%5D%27%20%28%27_line_end%27%29%20%28v%20%27header%20text%27%29%29%20-%201%29%29%0A%20%20%20%20%7D%0A%20%20%20%20%27header%20text%27%20%3D%20%28%27%5Bdata%3AcopyFromTo%5D%27%20%28v%20%27header%20text%27%29%20%28%28%27%5Bdata%3Afind%5D%27%20%28%27_line_end%27%29%20%28v%20%27header%20text%27%29%29%20%2B%202%29%29%0A%20%20%7D%0A%20%20return%20%28booleanConstant%20false%29%0A%7D%0A%0Ato%20%27_http_header_text%27%20response%20%7B%0A%20%20local%20%27headersStart%27%20%28%28%27%5Bdata%3Afind%5D%27%20%28%27_line_end%27%29%20response%29%20%2B%202%29%0A%20%20return%20%28%27%5Bdata%3AcopyFromTo%5D%27%20response%20headersStart%20%28%28%27_http_body_start%27%20response%29%20%2B%202%29%29%0A%7D%0A%0Ato%20%27_http_status%27%20response%20%7B%0A%20%20return%20%28%28%27%5Bdata%3AcopyFromTo%5D%27%20%28%27_http_status_text%27%20response%29%201%204%29%20%2B%200%29%0A%7D%0A%0Ato%20%27_http_status_text%27%20response%20%7B%0A%20%20return%20%28%27%5Bdata%3AcopyFromTo%5D%27%20response%20%28%27%5Bdata%3Afind%5D%27%20%27%20%27%20response%29%20%28%27%5Bdata%3Afind%5D%27%20%28%27_line_end%27%29%20response%29%29%0A%7D%0A%0Ato%20%27_line_end%27%20%7B%0A%20%20return%20%28%27%5Bdata%3AunicodeString%5D%27%20%28%27%5Bdata%3AmakeList%5D%27%2013%2010%29%29%0A%7D%0A%0Ato%20%27_lowercase%27%20string%20%7B%0A%20%20local%20%27lowercased%27%20%27%27%0A%20%20local%20%27char%20code%27%20%27%27%0A%20%20for%20c%20%28size%20string%29%20%7B%0A%20%20%20%20%27char%20code%27%20%3D%20%28%27%5Bdata%3AunicodeAt%5D%27%20c%20string%29%0A%20%20%20%20if%20%28and%20%28%28v%20%27char%20code%27%29%20%3E%3D%2065%29%20%28%28v%20%27char%20code%27%29%20%3C%3D%2090%29%29%20%7B%0A%20%20%20%20%20%20%27char%20code%27%20%3D%20%28%28v%20%27char%20code%27%29%20%2B%2032%29%0A%20%20%20%20%7D%0A%20%20%20%20lowercased%20%3D%20%28%27%5Bdata%3Ajoin%5D%27%20lowercased%20%28%27%5Bdata%3AunicodeString%5D%27%20%28v%20%27char%20code%27%29%29%29%0A%20%20%7D%0A%20%20return%20lowercased%0A%7D%0A%0Ato%20%27_readHTTPResponse%27%20%7B%0A%20%20local%20%27response%27%20%27%27%0A%20%20local%20%27lastChunkTime%27%20%28millisOp%29%0A%20%20repeatUntil%20%28not%20%28%27%5Bnet%3AhttpIsConnected%5D%27%29%29%20%7B%0A%20%20%20%20local%20%27chunk%27%20%28%27%5Bnet%3AhttpResponse%5D%27%29%0A%20%20%20%20if%20%28%28size%20chunk%29%20%3E%200%29%20%7B%0A%20%20%20%20%20%20response%20%3D%20%28%27%5Bdata%3Ajoin%5D%27%20response%20chunk%29%0A%20%20%20%20%20%20lastChunkTime%20%3D%20%28millisOp%29%0A%20%20%20%20%7D%20%28%28%28millisOp%29%20-%20lastChunkTime%29%20%3E%2010000%29%20%7B%0A%20%20%20%20%20%20return%20response%0A%20%20%20%20%7D%0A%20%20%20%20waitMillis%2020%0A%20%20%7D%0A%20%20response%20%3D%20%28%27%5Bdata%3Ajoin%5D%27%20response%20%28%27%5Bnet%3AhttpResponse%5D%27%29%29%0A%20%20return%20response%0A%7D%0A%0Ato%20%27_request_url%27%20url%20method%20body%20optionalPort%20%7B%0A%20%20local%20%27port%27%2080%0A%20%20if%20%28%28pushArgCount%29%20%3E%203%29%20%7B%0A%20%20%20%20port%20%3D%20optionalPort%0A%20%20%7D%0A%20%20local%20%27host%27%20%27%27%0A%20%20local%20%27path%27%20%27%27%0A%20%20local%20%27slashPosition%27%20%28%27%5Bdata%3Afind%5D%27%20%27%2F%27%20url%29%0A%20%20if%20%28slashPosition%20%3E%200%29%20%7B%0A%20%20%20%20host%20%3D%20%28%27%5Bdata%3AcopyFromTo%5D%27%20url%201%20%28slashPosition%20-%201%29%29%0A%20%20%20%20path%20%3D%20%28%27%5Bdata%3AcopyFromTo%5D%27%20url%20%28slashPosition%20%2B%201%29%29%0A%20%20%7D%20else%20%7B%0A%20%20%20%20host%20%3D%20url%0A%20%20%7D%0A%20%20if%20%28%28%27%5Bnet%3AwifiStatus%5D%27%29%20%21%3D%20%27Connected%27%29%20%7B%0A%20%20%20%20return%20%28%27%5Bdata%3Ajoin%5D%27%20%270%20Not%20Connected%27%20%28%27_line_end%27%29%29%0A%20%20%7D%0A%20%20%27%5Bnet%3AhttpConnect%5D%27%20host%20port%0A%20%20if%20%28not%20%28%27%5Bnet%3AhttpIsConnected%5D%27%29%29%20%7B%0A%20%20%20%20return%20%28%27%5Bdata%3Ajoin%5D%27%20%270%20Could%20not%20connect%20to%20server%27%20%28%27_line_end%27%29%29%0A%20%20%7D%0A%20%20%27%5Bnet%3AhttpRequest%5D%27%20method%20host%20path%0A%20%20return%20%28%27_readHTTPResponse%27%29%0A%7D%0A%0Ato%20%27http%DC%83%2F%2F%27%20url%20optionalPort%20%7B%0A%20%20local%20%27port%27%2080%0A%20%20if%20%28%28pushArgCount%29%20%3E%201%29%20%7B%0A%20%20%20%20port%20%3D%20optionalPort%0A%20%20%7D%0A%20%20local%20%27response%27%20%28%27_request_url%27%20url%20%27GET%27%20%27%27%20port%29%0A%20%20if%20%28response%20%21%3D%20%27%27%29%20%7B%0A%20%20%20%20if%20%28%28%27_http_status%27%20response%29%20%3D%3D%20200%29%20%7B%0A%20%20%20%20%20%20return%20%28%27%5Bdata%3AcopyFromTo%5D%27%20response%20%28%27_http_body_start%27%20response%29%29%0A%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20return%20%28%27_http_status_text%27%20response%29%0A%20%20%20%20%7D%0A%20%20%7D%20else%20%7B%0A%20%20%20%20return%20%27Failed%20to%20get%20response%27%0A%20%20%7D%0A%7D%0A%0Ato%20request%20method%20data%20url%20optionalPort%20%7B%0A%20%20local%20%27port%27%2080%0A%20%20if%20%28%28pushArgCount%29%20%3E%203%29%20%7B%0A%20%20%20%20port%20%3D%20optionalPort%0A%20%20%7D%0A%20%20local%20%27response%27%20%28%27_request_url%27%20url%20method%20data%20port%29%0A%20%20if%20%28response%20%21%3D%20%27%27%29%20%7B%0A%20%20%20%20local%20%27status%27%20%28%27_http_status%27%20response%29%0A%20%20%20%20local%20%27body%20start%27%20%28%27_http_body_start%27%20response%29%0A%20%20%20%20if%20%28and%20%28200%20%3D%3D%20status%29%20%28%28v%20%27body%20start%27%29%20%3E%200%29%29%20%7B%0A%20%20%20%20%20%20sayIt%20%28%27%5Bdata%3AcopyFromTo%5D%27%20response%20%28v%20%27body%20start%27%29%29%0A%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20sayIt%20%28%27_http_status_text%27%20response%29%0A%20%20%20%20%7D%0A%20%20%7D%20else%20%7B%0A%20%20%20%20sayIt%20%27Failed%20to%20get%20response%27%0A%20%20%7D%0A%7D%0A%0A%0Amodule%20%27HTTP%20server%27%20Comm%0Aauthor%20MicroBlocks%0Aversion%201%203%20%0Adepends%20WiFi%20%0Atags%20http%20network%20%0Adescription%20%27Create%20an%20HTTP%20server%20in%20MicroBlocks.%20You%20can%20use%20this%20library%20to%20allow%20remote%20control%20for%20your%20Wifi-enabled%20board.%27%0A%0A%20%20spec%20%27r%27%20%27%5Bnet%3AhttpServerGetRequest%5D%27%20%27HTTP%20server%20request%20%3A%20binary%20data%20_%20%3A%20port%20_%27%20%27bool%20num%27%20false%208080%0A%20%20spec%20%27r%27%20%27request%20method%27%20%27method%20of%20request%20_%27%20%27str%27%20%27%27%0A%20%20spec%20%27r%27%20%27path%20of%20request%27%20%27path%20of%20request%20_%27%20%27str%27%20%27%27%0A%20%20spec%20%27r%27%20%27headers%20of%20request%27%20%27headers%20of%20request%20_%27%20%27str%27%20%27%27%0A%20%20spec%20%27r%27%20%27body%20of%20request%27%20%27body%20of%20request%20_%27%20%27str%27%20%27%27%0A%20%20spec%20%27r%27%20%27content%20length%20of%20request%27%20%27content%20length%20of%20request%20_%27%20%27str%27%20%27%27%0A%20%20spec%20%27%20%27%20%27%5Bnet%3ArespondToHttpRequest%5D%27%20%27respond%20_%20to%20HTTP%20request%20%3A%20with%20body%20_%20%3A%20and%20headers%20_%20%3A%20keepAlive%20_%27%20%27str%20str%20str%20bool%27%20%27200%20OK%27%20%27Welcome%20to%20the%20MicroBlocks%20HTTP%20server%27%20%27Content-Type%3A%20text%2Fplain%27%20false%0A%20%20spec%20%27r%27%20%27_endOfHeaders%27%20%27_end%20of%20headers%20_%27%20%27str%27%0A%20%20spec%20%27r%27%20%27_toString%27%20%27_toString%20_%27%20%27auto%27%20%27abc%27%0A%0Ato%20%27_endOfHeaders%27%20request%20%7B%0A%20%20return%20%28%27%5Bdata%3Afind%5D%27%20%28%27%5Bdata%3AunicodeString%5D%27%20%28%27%5Bdata%3AmakeList%5D%27%2013%2010%2013%2010%29%29%20request%29%0A%7D%0A%0Ato%20%27_toString%27%20aStringOrByteArray%20%7B%0A%20%20comment%20%27If%20argument%20is%20a%20byte%20array%2C%20convert%20it%20to%20a%20string.%20%27%0A%20%20if%20%28not%20%28isType%20aStringOrByteArray%20%27string%27%29%29%20%7B%0A%20%20%20%20aStringOrByteArray%20%3D%20%28%27%5Bdata%3Ajoin%5D%27%20%27%27%20aStringOrByteArray%29%0A%20%20%7D%0A%20%20return%20aStringOrByteArray%0A%7D%0A%0Ato%20%27body%20of%20request%27%20request%20%7B%0A%20%20i%20%3D%20%28%27_endOfHeaders%27%20request%29%0A%20%20if%20%28i%20%3C%200%29%20%7B%0A%20%20%20%20return%20%27%27%0A%20%20%7D%0A%20%20return%20%28%27%5Bdata%3AcopyFromTo%5D%27%20request%20%28i%20%2B%204%29%29%0A%7D%0A%0Ato%20%27content%20length%20of%20request%27%20request%20%7B%0A%20%20local%20%27i%27%20%28%27_endOfHeaders%27%20request%29%0A%20%20if%20%28i%20%3C%200%29%20%7B%0A%20%20%20%20return%200%0A%20%20%7D%0A%20%20local%20%27j%27%20%28%27%5Bdata%3Afind%5D%27%20%27Content-Length%3A%20%27%20request%29%0A%20%20if%20%28j%20%3C%200%29%20%7B%0A%20%20%20%20comment%20%27Try%20alternate%20capitalization%27%0A%20%20%20%20j%20%3D%20%28%27%5Bdata%3Afind%5D%27%20%27Content-length%3A%20%27%20request%29%0A%20%20%7D%0A%20%20if%20%28or%20%28j%20%3C%200%29%20%28j%20%3E%20i%29%29%20%7B%0A%20%20%20%20return%200%0A%20%20%7D%0A%20%20j%20%2B%3D%2016%0A%20%20local%20%27k%27%20%28%27%5Bdata%3Afind%5D%27%20%28%27%5Bdata%3AunicodeString%5D%27%2013%29%20request%20j%29%0A%20%20return%20%28%28%27%5Bdata%3AcopyFromTo%5D%27%20request%20j%20%28k%20-%201%29%29%20%2B%200%29%0A%7D%0A%0Ato%20%27headers%20of%20request%27%20request%20%7B%0A%20%20i%20%3D%20%28%27_endOfHeaders%27%20request%29%0A%20%20if%20%28i%20%3C%200%29%20%7B%0A%20%20%20%20return%20%27%27%0A%20%20%7D%0A%20%20return%20%28%27_toString%27%20%28%27%5Bdata%3AcopyFromTo%5D%27%20request%201%20%28i%20-%201%29%29%29%0A%7D%0A%0Ato%20%27path%20of%20request%27%20request%20%7B%0A%20%20return%20%28%27_toString%27%20%28%27%5Bdata%3AcopyFromTo%5D%27%20request%20%28%28%27%5Bdata%3Afind%5D%27%20%27%20%27%20request%29%20%2B%201%29%20%28%28%27%5Bdata%3Afind%5D%27%20%27%20HTTP%27%20request%29%20-%201%29%29%29%0A%7D%0A%0Ato%20%27request%20method%27%20request%20%7B%0A%20%20return%20%28%27_toString%27%20%28%27%5Bdata%3AcopyFromTo%5D%27%20request%201%20%28%28%27%5Bdata%3Afind%5D%27%20%27%20%27%20request%29%20-%201%29%29%29%0A%7D%0A%0A%0Amodule%20%27JSON%20Primitives%27%20Data%0Aauthor%20MicroBlocks%0Aversion%201%200%20%0Atags%20data%20json%20network%20%0Adescription%20%27Very%20fast%20and%20efficient%20primitives%20to%20parse%20JSON%20strings.%27%0A%0A%20%20spec%20%27r%27%20%27%5Bmisc%3AjsonGet%5D%27%20%27json%20_%20.%20_%27%20%27str%20str%27%20%27%7B%20%22x%22%3A%201%2C%20%20%22y%22%3A%20%5B41%2C%2042%2C%2043%5D%20%7D%27%20%27y.2%27%0A%20%20spec%20%27r%27%20%27%5Bmisc%3AjsonCount%5D%27%20%27json%20count%20_%20.%20_%27%20%27str%20str%27%20%27%5B1%2C%20%5B4%2C%205%2C%206%2C%207%5D%2C%203%5D%27%20%27%27%0A%20%20spec%20%27r%27%20%27%5Bmisc%3AjsonValueAt%5D%27%20%27json%20value%20_%20.%20_%20at%20_%27%20%27str%20str%20num%27%20%27%7B%20%22x%22%3A%201%2C%20%20%22y%22%3A%2042%20%7D%27%20%27%27%202%0A%20%20spec%20%27r%27%20%27%5Bmisc%3AjsonKeyAt%5D%27%20%27json%20key%20_%20.%20_%20at%20_%27%20%27str%20str%20num%27%20%27%7B%20%22x%22%3A%201%2C%20%20%22y%22%3A%2042%20%7D%27%20%27%27%202%0A%0Amodule%20MQTT%20Comm%0Aauthor%20wwj718%0Aversion%201%204%20%0Adepends%20WiFi%20%0Atags%20mqtt%20network%20%0Adescription%20%27A%20simple%20MQTT%20client.%27%0A%0A%20%20spec%20%27%20%27%20%27MQTT%20connect%20to%27%20%27MQTT%20connect%20to%20broker%20_%20%3A%20buffer%20sizes%20_%20client%20id%20_%20%3A%20username%20_%20password%20_%27%20%27str%20num%20str%20str%20str%27%20%27%27%20128%20%27%27%20%27%27%20%27%27%0A%20%20spec%20%27r%27%20%27MQTT%20connected%27%20%27MQTT%20connected%27%0A%20%20spec%20%27%20%27%20%27MQTT%20disconnect%27%20%27MQTT%20disconnect%27%0A%20%20spec%20%27%20%27%20%27MQTT%20sub%27%20%27MQTT%20sub%20_%20%3A%20QoS%20_%27%20%27str%20num%27%20%27testTopic%27%200%0A%20%20spec%20%27%20%27%20%27MQTT%20unsub%27%20%27MQTT%20unsub%20_%27%20%27str%27%20%27testTopic%27%0A%20%20spec%20%27%20%27%20%27MQTT%20pub%27%20%27MQTT%20pub%20topic%20_%20payload%20_%20%3A%20retain%20_%20QoS%20_%27%20%27str%20auto%20bool%20num%27%20%27testTopic%27%20%27Hello%21%27%20false%200%0A%20%20spec%20%27r%27%20%27%5Bnet%3AMQTTLastEvent%5D%27%20%27MQTT%20event%20%3A%20binary%20_%27%20%27bool%27%20false%0A%20%20spec%20%27r%27%20%27MQTT%20event%20topic%27%20%27topic%20for%20MQTT%20event%20_%27%20%27str%27%20%27%27%0A%20%20spec%20%27r%27%20%27MQTT%20event%20payload%27%20%27payload%20for%20MQTT%20event%20_%27%20%27str%27%20%27%27%0A%0Ato%20%27MQTT%20connect%20to%27%20broker%20buffer_sizes%20client_id%20username%20password%20%7B%0A%20%20if%20%28%28getIPAddress%29%20%21%3D%20%270.0.0.0%27%29%20%7B%0A%20%20%20%20if%20%28%28pushArgCount%29%20%3D%3D%201%29%20%7B%0A%20%20%20%20%20%20callCustomCommand%20%27%5Bnet%3AMQTTConnect%5D%27%20%28%27%5Bdata%3AmakeList%5D%27%20broker%20128%20%27MicroBlocks_client%27%29%0A%20%20%20%20%7D%20%28%28pushArgCount%29%20%3D%3D%203%29%20%7B%0A%20%20%20%20%20%20callCustomCommand%20%27%5Bnet%3AMQTTConnect%5D%27%20%28%27%5Bdata%3AmakeList%5D%27%20broker%20buffer_sizes%20client_id%29%0A%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20callCustomCommand%20%27%5Bnet%3AMQTTConnect%5D%27%20%28%27%5Bdata%3AmakeList%5D%27%20broker%20buffer_sizes%20client_id%20username%20password%29%0A%20%20%20%20%7D%0A%20%20%20%20if%20%28%27MQTT%20connected%27%29%20%7B%0A%20%20%20%20%20%20sayIt%20%27Connected%21%27%0A%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20sayIt%20%27Not%20Connected%27%0A%20%20%20%20%7D%0A%20%20%7D%20else%20%7B%0A%20%20%20%20sayIt%20%27Not%20Connected%27%0A%20%20%7D%0A%7D%0A%0Ato%20%27MQTT%20connected%27%20%7B%0A%20%20return%20%28callCustomReporter%20%27%5Bnet%3AMQTTIsConnected%5D%27%29%0A%7D%0A%0Ato%20%27MQTT%20disconnect%27%20%7B%0A%20%20callCustomCommand%20%27%5Bnet%3AMQTTdisconnect%5D%27%0A%7D%0A%0Ato%20%27MQTT%20event%20payload%27%20event%20%7B%0A%20%20if%20%28and%20%28isType%20event%20%27list%27%29%20%28%28size%20event%29%20%3E%201%29%29%20%7B%0A%20%20%20%20comment%20%27Join%20to%20empty%20string%20converts%20byte%20array%20to%20string%27%0A%20%20%20%20return%20%28%27%5Bdata%3Ajoin%5D%27%20%27%27%20%28at%202%20event%29%29%0A%20%20%7D%20else%20%7B%0A%20%20%20%20return%20%27%27%0A%20%20%7D%0A%7D%0A%0Ato%20%27MQTT%20event%20topic%27%20event%20%7B%0A%20%20if%20%28and%20%28isType%20event%20%27list%27%29%20%28%28size%20event%29%20%3E%201%29%29%20%7B%0A%20%20%20%20return%20%28at%201%20event%29%0A%20%20%7D%20else%20%7B%0A%20%20%20%20return%20%27%27%0A%20%20%7D%0A%7D%0A%0Ato%20%27MQTT%20pub%27%20topic%20payload%20retain%20qos%20%7B%0A%20%20if%20%28%28pushArgCount%29%20%3C%204%29%20%7B%0A%20%20%20%20okay%20%3D%20%28callCustomReporter%20%27%5Bnet%3AMQTTPub%5D%27%20%28%27%5Bdata%3AmakeList%5D%27%20topic%20payload%29%29%0A%20%20%7D%20else%20%7B%0A%20%20%20%20okay%20%3D%20%28callCustomReporter%20%27%5Bnet%3AMQTTPub%5D%27%20%28%27%5Bdata%3AmakeList%5D%27%20topic%20payload%20retain%20qos%29%29%0A%20%20%7D%0A%20%20if%20%28not%20okay%29%20%7B%0A%20%20%20%20sayIt%20%27pub%20failure%21%27%0A%20%20%7D%0A%7D%0A%0Ato%20%27MQTT%20sub%27%20topic%20qos%20%7B%0A%20%20if%20%28%28pushArgCount%29%20%3C%202%29%20%7B%0A%20%20%20%20okay%20%3D%20%28callCustomReporter%20%27%5Bnet%3AMQTTSub%5D%27%20%28%27%5Bdata%3AmakeList%5D%27%20topic%29%29%0A%20%20%7D%20else%20%7B%0A%20%20%20%20okay%20%3D%20%28callCustomReporter%20%27%5Bnet%3AMQTTSub%5D%27%20%28%27%5Bdata%3AmakeList%5D%27%20topic%20qos%29%29%0A%20%20%7D%0A%20%20if%20%28not%20okay%29%20%7B%0A%20%20%20%20sayIt%20%27sub%20failure%21%27%0A%20%20%7D%0A%7D%0A%0Ato%20%27MQTT%20unsub%27%20topic%20%7B%0A%20%20if%20%28%28callCustomReporter%20%27%5Bnet%3AMQTTUnsub%5D%27%20%28%27%5Bdata%3AmakeList%5D%27%20topic%29%29%20%21%3D%20%28booleanConstant%20true%29%29%20%7BsayIt%20%27unsub%20failure%21%27%7D%0A%7D%0A%0A%0Amodule%20Strings%20Data%0Aauthor%20MicroBlocks%0Aversion%201%205%20%0Adescription%20%27String%20operations.%27%0A%0A%20%20spec%20%27r%27%20%27isDigit%27%20%27_%20is%20a%20digit%27%20%27str%27%20%275%27%0A%20%20spec%20%27r%27%20%27isLowercase%27%20%27_%20is%20lowercase%27%20%27str%27%20%27A%27%0A%20%20spec%20%27r%27%20%27isUppercase%27%20%27_%20is%20uppercase%27%20%27str%27%20%27E%27%0A%20%20spec%20%27r%27%20%27beginsWith%27%20%27_%20begins%20with%20_%27%20%27str%20str%27%20%27prefix%27%20%27pre%27%0A%20%20spec%20%27r%27%20%27endsWith%27%20%27_%20ends%20with%20_%27%20%27str%20str%27%20%27suffix%27%20%27fix%27%0A%20%20spec%20%27r%27%20%27contains%27%20%27_%20contains%20_%27%20%27str%20str%27%20%27smiles%27%20%27mile%27%0A%20%20spec%20%27r%27%20%27lowercase%27%20%27lowercase%20_%27%20%27str%27%20%27THIS%20is%20a%20String%21%20%3A%29%27%0A%20%20spec%20%27r%27%20%27uppercase%27%20%27uppercase%20_%27%20%27str%27%20%27Hello%2C%20world%21%27%0A%20%20spec%20%27r%27%20%27withoutWhiteSpace%27%20%27_%20without%20white%20space%27%20%27str%27%20%271%2C%202%2C%093%2C%0A4%27%0A%20%20spec%20%27r%27%20%27joinWith%27%20%27join%20string%20list%20_%20separator%20_%27%20%27auto%20str%27%20%27%20%27%20%27%20%27%0A%20%20spec%20%27r%27%20%27stringToUnicodes%27%20%27unicodes%20_%27%20%27auto%27%20%27aString%27%0A%20%20spec%20%27r%27%20%27unicodesToString%27%20%27string%20from%20unicodes%20_%27%20%27auto%27%20%27aList%27%0A%20%20spec%20%27r%27%20%27num2str%27%20%27num2str%20_%27%20%27auto%27%2042%0A%20%20spec%20%27r%27%20%27str2num%27%20%27str2num%20_%27%20%27str%27%20%27123%27%0A%0Ato%20beginsWith%20string%20substring%20%7B%0A%20%20return%20%28%28%27%5Bdata%3Afind%5D%27%20substring%20string%29%20%3D%3D%201%29%0A%7D%0A%0Ato%20contains%20string%20substring%20%7B%0A%20%20return%20%28%28%27%5Bdata%3Afind%5D%27%20substring%20string%29%20%3E%200%29%0A%7D%0A%0Ato%20endsWith%20string%20substring%20%7B%0A%20%20return%20%28%28%27%5Bdata%3Afind%5D%27%20substring%20string%29%20%3E%20%28%28size%20string%29%20-%20%28size%20substring%29%29%29%0A%7D%0A%0Ato%20isDigit%20char%20%7B%0A%20%20local%20%27unicode%27%20%28%27%5Bdata%3AunicodeAt%5D%27%201%20char%29%0A%20%20return%20%28and%20%28unicode%20%3E%3D%2048%29%20%28unicode%20%3C%3D%2057%29%29%0A%7D%0A%0Ato%20isLowercase%20char%20%7B%0A%20%20local%20%27unicode%27%20%28%27%5Bdata%3AunicodeAt%5D%27%201%20char%29%0A%20%20return%20%28and%20%28unicode%20%3E%3D%2097%29%20%28unicode%20%3C%3D%20122%29%29%0A%7D%0A%0Ato%20isUppercase%20char%20%7B%0A%20%20local%20%27unicode%27%20%28%27%5Bdata%3AunicodeAt%5D%27%201%20char%29%0A%20%20return%20%28and%20%28unicode%20%3E%3D%2065%29%20%28unicode%20%3C%3D%2090%29%29%0A%7D%0A%0Ato%20joinWith%20stringList%20separator%20%7B%0A%20%20if%20%28not%20%28isType%20stringList%20%27list%27%29%29%20%7Breturn%20%28%27%5Bdata%3Ajoin%5D%27%20%27%27%20stringList%29%7D%0A%20%20if%20%28or%20%28%28pushArgCount%29%20%3D%3D%201%29%20%28separator%20%3D%3D%20%27%27%29%29%20%7Breturn%20%28%27%5Bdata%3AjoinStrings%5D%27%20stringList%29%7D%0A%20%20local%20%27result%27%20%28newList%20%282%20%2A%20%28size%20stringList%29%29%29%0A%20%20%27%5Bdata%3Adelete%5D%27%20%27all%27%20result%0A%20%20for%20s%20stringList%20%7B%0A%20%20%20%20%27%5Bdata%3AaddLast%5D%27%20s%20result%0A%20%20%20%20%27%5Bdata%3AaddLast%5D%27%20separator%20result%0A%20%20%7D%0A%20%20%27%5Bdata%3Adelete%5D%27%20%27last%27%20result%0A%20%20return%20%28%27%5Bdata%3AjoinStrings%5D%27%20result%29%0A%7D%0A%0Ato%20lowercase%20string%20%7B%0A%20%20local%20%27new%20string%27%20%27%27%0A%20%20for%20i%20%28size%20string%29%20%7B%0A%20%20%20%20if%20%28isUppercase%20%28at%20i%20string%29%29%20%7B%0A%20%20%20%20%20%20%27new%20string%27%20%3D%20%28%27%5Bdata%3Ajoin%5D%27%20%28v%20%27new%20string%27%29%20%28%27%5Bdata%3AunicodeString%5D%27%20%28%28%27%5Bdata%3AunicodeAt%5D%27%20i%20string%29%20%2B%2032%29%29%29%0A%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%27new%20string%27%20%3D%20%28%27%5Bdata%3Ajoin%5D%27%20%28v%20%27new%20string%27%29%20%28at%20i%20string%29%29%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20return%20%28v%20%27new%20string%27%29%0A%7D%0A%0Ato%20num2str%20n%20%7B%0A%20%20return%20%28%27%5Bdata%3Ajoin%5D%27%20%27%27%20n%29%0A%7D%0A%0Ato%20str2num%20s%20%7B%0A%20%20return%20%280%20%2B%20s%29%0A%7D%0A%0Ato%20stringToUnicodes%20s%20%7B%0A%20%20local%20%27result%27%20%28newList%20%28size%20s%29%29%0A%20%20for%20i%20%28size%20s%29%20%7B%0A%20%20%20%20atPut%20i%20result%20%28%27%5Bdata%3AunicodeAt%5D%27%20i%20s%29%0A%20%20%7D%0A%20%20return%20result%0A%7D%0A%0Ato%20unicodesToString%20aList%20%7B%0A%20%20return%20%28%27%5Bdata%3AunicodeString%5D%27%20aList%29%0A%7D%0A%0Ato%20uppercase%20string%20%7B%0A%20%20local%20%27new%20string%27%20%27%27%0A%20%20for%20i%20%28size%20string%29%20%7B%0A%20%20%20%20if%20%28isLowercase%20%28at%20i%20string%29%29%20%7B%0A%20%20%20%20%20%20%27new%20string%27%20%3D%20%28%27%5Bdata%3Ajoin%5D%27%20%28v%20%27new%20string%27%29%20%28%27%5Bdata%3AunicodeString%5D%27%20%28%28%27%5Bdata%3AunicodeAt%5D%27%20i%20string%29%20-%2032%29%29%29%0A%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%27new%20string%27%20%3D%20%28%27%5Bdata%3Ajoin%5D%27%20%28v%20%27new%20string%27%29%20%28at%20i%20string%29%29%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20return%20%28v%20%27new%20string%27%29%0A%7D%0A%0Ato%20withoutWhiteSpace%20aString%20%7B%0A%20%20local%20%27result%27%20%28newList%20%28size%20aString%29%29%0A%20%20%27%5Bdata%3Adelete%5D%27%20%27all%27%20result%0A%20%20for%20i%20%28size%20aString%29%20%7B%0A%20%20%20%20local%20%27ch%27%20%28%27%5Bdata%3AunicodeAt%5D%27%20i%20aString%29%0A%20%20%20%20if%20%28ch%20%3E%2032%29%20%7B%0A%20%20%20%20%20%20%27%5Bdata%3AaddLast%5D%27%20ch%20result%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20return%20%28%27%5Bdata%3AunicodeString%5D%27%20result%29%0A%7D%0A%0A%0Amodule%20WEMOS%20D1%0Aauthor%20%27Simon%20Walters%27%0Aversion%201%200%20%0Achoices%20motors%20A%20B%20%27A%2BB%27%20%0Adescription%20%27Control%20the%20speed%20of%20motors%20using%20a%20WEMOS%20D1%20mini%20I2C%20V1.0%20Motor%20Shield%20%27%0A%0A%20%20spec%20%27%20%27%20%27motor%27%20%27WEMOS%20D1%20I2C%20motor%20_%20speed%20_%20%3A%20PWM%20freq%20_%27%20%27menu.motors%20num%20num%27%20%27A%27%200%20100%0A%0Ato%20motor%20motor%20speed%20optionalFreq%20%7B%0A%20%20local%20%27freq%27%20100%0A%20%20if%20%28%28pushArgCount%29%20%3E%202%29%20%7B%0A%20%20%20%20freq%20%3D%20optionalFreq%0A%20%20%7D%0A%20%20%27%5Bsensors%3Ai2cWrite%5D%27%2048%20%28%27%5Bdata%3AmakeList%5D%27%200%200%20%28%28freq%20%3E%3E%208%29%20%26%20255%29%20%28freq%20%26%20255%29%29%0A%20%20local%20%27direction%27%201%0A%20%20if%20%28speed%20%3C%200%29%20%7B%0A%20%20%20%20direction%20%3D%202%0A%20%20%7D%0A%20%20speed%20%3D%20%28absoluteValue%20%28speed%20%2A%20100%29%29%0A%20%20local%20%27motor%20data%27%20%28%27%5Bdata%3AmakeList%5D%27%200%20direction%20%28%28speed%20%3E%3E%208%29%20%26%20255%29%20%28speed%20%26%20255%29%29%0A%20%20if%20%28%28%27%5Bdata%3Afind%5D%27%20%27A%27%20motor%29%20%3E%200%29%20%7B%0A%20%20%20%20atPut%201%20%28v%20%27motor%20data%27%29%2016%0A%20%20%20%20%27%5Bsensors%3Ai2cWrite%5D%27%2048%20%28v%20%27motor%20data%27%29%0A%20%20%7D%0A%20%20if%20%28%28%27%5Bdata%3Afind%5D%27%20%27B%27%20motor%29%20%3E%200%29%20%7B%0A%20%20%20%20atPut%201%20%28v%20%27motor%20data%27%29%2017%0A%20%20%20%20%27%5Bsensors%3Ai2cWrite%5D%27%2048%20%28v%20%27motor%20data%27%29%0A%20%20%7D%0A%7D%0A%0A%0Amodule%20WiFi%20Comm%0Aauthor%20MicroBlocks%0Aversion%201%205%20%0Atags%20communication%20network%20%0Adescription%20%27Connect%20to%20a%20WiFi%20network.%20Used%20in%20conjunction%20with%20other%20network%20libraries%2C%20such%20as%20HTTP%20client%2C%20HTTP%20server%20or%20Web%20Thing.%0A%27%0A%0A%20%20spec%20%27%20%27%20%27wifiConnect%27%20%27wifi%20connect%20to%20_%20password%20_%20%3A%20IP%20_%20gateway%20_%20subnet%20_%27%20%27str%20str%20auto%20auto%20auto%27%20%27Network_Name%27%20%27%27%20%27192.168.1.42%27%20%27192.168.1.1%27%20%27255.255.255.0%27%0A%20%20spec%20%27%20%27%20%27wifiCreateHotspot%27%20%27wifi%20create%20hotspot%20_%20password%20_%27%20%27str%20str%27%20%27Network_Name%27%20%27Network_Password%27%0A%20%20spec%20%27r%27%20%27getIPAddress%27%20%27IP%20address%27%0A%20%20spec%20%27r%27%20%27%5Bnet%3AmyMAC%5D%27%20%27MAC%20address%27%0A%0Ato%20getIPAddress%20%7B%0A%20%20return%20%28%27%5Bnet%3AmyIPAddress%5D%27%29%0A%7D%0A%0Ato%20wifiConnect%20ssid%20password%20fixedIP%20gatewayIP%20subnetIP%20%7B%0A%20%20if%20%28not%20%28%27%5Bnet%3AhasWiFi%5D%27%29%29%20%7Breturn%7D%0A%20%20%27%5Bnet%3AstopWiFi%5D%27%0A%20%20if%20%28%28pushArgCount%29%20%3C%205%29%20%7B%0A%20%20%20%20%27%5Bnet%3AstartWiFi%5D%27%20ssid%20password%0A%20%20%7D%20else%20%7B%0A%20%20%20%20%27%5Bnet%3AstartWiFi%5D%27%20ssid%20password%20false%20fixedIP%20gatewayIP%20subnetIP%0A%20%20%7D%0A%20%20local%20%27startMSecs%27%20%28millisOp%29%0A%20%20repeatUntil%20%28%28%27%5Bnet%3AmyIPAddress%5D%27%29%20%21%3D%20%270.0.0.0%27%29%20%7B%0A%20%20%20%20comment%20%27Timeout%20after%20N%20seconds%27%0A%20%20%20%20if%20%28%28%28millisOp%29%20-%20startMSecs%29%20%3E%2010000%29%20%7B%0A%20%20%20%20%20%20sayIt%20%27Could%20not%20connect%27%0A%20%20%20%20%20%20return%200%0A%20%20%20%20%7D%0A%20%20%20%20comment%20%27Slow%20blink%20while%20trying%20to%20connect%27%0A%20%20%20%20setUserLED%20true%0A%20%20%20%20waitMillis%20300%0A%20%20%20%20setUserLED%20false%0A%20%20%20%20waitMillis%20300%0A%20%20%7D%0A%20%20repeat%206%20%7B%0A%20%20%20%20comment%20%27Quick%20blinks%20when%20connected%27%0A%20%20%20%20setUserLED%20true%0A%20%20%20%20waitMillis%2050%0A%20%20%20%20setUserLED%20false%0A%20%20%20%20waitMillis%2050%0A%20%20%7D%0A%20%20sayIt%20%27My%20IP%20address%20is%3A%27%20%28%27%5Bnet%3AmyIPAddress%5D%27%29%0A%7D%0A%0Ato%20wifiCreateHotspot%20ssid%20password%20%7B%0A%20%20if%20%28not%20%28%27%5Bnet%3AhasWiFi%5D%27%29%29%20%7Breturn%7D%0A%20%20%27%5Bnet%3AstartWiFi%5D%27%20ssid%20password%20true%0A%20%20if%20%28%27Connected%27%20%21%3D%20%28%27%5Bnet%3AwifiStatus%5D%27%29%29%20%7B%0A%20%20%20%20sayIt%20%27Could%20not%20create%20hotspot%27%0A%20%20%20%20return%200%0A%20%20%7D%0A%20%20repeat%206%20%7B%0A%20%20%20%20comment%20%27Quick%20blinks%20when%20connected%27%0A%20%20%20%20setUserLED%20true%0A%20%20%20%20waitMillis%2050%0A%20%20%20%20setUserLED%20false%0A%20%20%20%20waitMillis%2050%0A%20%20%7D%0A%20%20sayIt%20%27My%20IP%20address%20is%3A%27%20%28%27%5Bnet%3AmyIPAddress%5D%27%29%0A%7D%0A%0A

  4. John Maloney repo owner

    Thanks! I can reproduce this but I don't have time to debug it right now. Best to save your work in a file since the decompiler isn't 100% reliable (especially for large projects).

  5. John Maloney repo owner

    I found and fixed the problem, thanks to your excellent test case. Just pushed a new Pilot version (v1.1.59) with the fix.

  6. John Maloney repo owner

    Good to know that the fix works for you.

    Also, great that you were able to get the Wemos motor shield working in MicroBlocks!

    I2C opens many doors to external hardware. Some I2C data sheets are easy to read, others not so much. However, if you can find an Arduino library for the hardware in question you can usually get the key features working in MicroBlocks fairly quickly.

  7. Log in to comment