|
@@ -6,20 +6,20 @@ function yo(yo_user, api_token)
|
|
|
assert(yo_user ~= '', 'yo_user must not be empty string')
|
|
assert(yo_user ~= '', 'yo_user must not be empty string')
|
|
|
assert(api_token ~= '', 'api_token must not be empty string')
|
|
assert(api_token ~= '', 'api_token must not be empty string')
|
|
|
|
|
|
|
|
- local contentString = "api_token=" .. api_token .. "&username="..string.upper(yo_user)
|
|
|
|
|
- local contentLength = string.len(contentString)
|
|
|
|
|
|
|
+ local content_string = "api_token=" .. api_token .. "&username=" .. string.upper(yo_user)
|
|
|
|
|
+ local content_length = string.len(content_string)
|
|
|
|
|
|
|
|
debug('yo.yo: sending Yo')
|
|
debug('yo.yo: sending Yo')
|
|
|
wifi.sleeptype(wifi.NONE_SLEEP)
|
|
wifi.sleeptype(wifi.NONE_SLEEP)
|
|
|
http.post(
|
|
http.post(
|
|
|
'https://api.justyo.co/yo/',
|
|
'https://api.justyo.co/yo/',
|
|
|
'Content-Type: application/x-www-form-urlencoded\r\n' ..
|
|
'Content-Type: application/x-www-form-urlencoded\r\n' ..
|
|
|
- 'Content-length: ' .. contentLength .. '\r\n',
|
|
|
|
|
- contentString,
|
|
|
|
|
|
|
+ 'Content-length: ' .. content_length .. '\r\n',
|
|
|
|
|
+ content_string,
|
|
|
function(status_code, response_data)
|
|
function(status_code, response_data)
|
|
|
wifi.sleeptype(wifi.LIGHT_SLEEP)
|
|
wifi.sleeptype(wifi.LIGHT_SLEEP)
|
|
|
- debug('yo.yo: status code ' .. status_code)
|
|
|
|
|
- debug('yo.yo: response data ' .. response_data)
|
|
|
|
|
|
|
+ debug('yo.yo: status code: ' .. status_code)
|
|
|
|
|
+ debug('yo.yo: response data: ' .. (response_data or 'nil'))
|
|
|
end
|
|
end
|
|
|
)
|
|
)
|
|
|
end
|
|
end
|