libfota - libfota fota Upgrade#

Adaptation status unknown

Note

This page document is automatically generated by this file. If there is any error, please submit issue or help modify pr, thank you!

Tip

This library has its own demo,click this link to view libfota demo examples

Example

--Note: due to the use of sys.wait() all apis need to be used in the coroutine
--Usage Examples
local libfota = require("libfota")

-- function: get the callback function of fota
-- Parameters:
-- result:number Type
--   0 Indicates success
--   1 Indicates a connection failure
--   2 Indicates that the url is wrong
--   3 Indicates that the server is disconnected
--   4 Indicates an error in receiving a message.
--   5 Indicates that the use of the iot platform VERSION requires the use of the form xxx.yyy.zzz
function libfota_cb(result)
    log.info("fota", "result", result)
    -- fota Success
    if result == 0 then
        rtos.reboot()   --If there's something else to do, don't do it right away.reboot
    end
end

--Attention!!!: if you use the hozhou iot platform, you must use the. binfile generated by luatools mass production!!! Self-built servers can use. ota files!!!
--Attention!!!: if you use the hozhou iot platform, you must use the. binfile generated by luatools mass production!!! Self-built servers can use. ota files!!!
--Attention!!!: if you use the hozhou iot platform, you must use the. binfile generated by luatools mass production!!! Self-built servers can use. ota files!!!

--the following example shows the joint iot platform, address :http://iot.openluat.com
libfota.request(libfota_cb)

--If you use a self-built server, replace it yourself.url
-- The requirement for a custom server is:
-- If you need to upgrade, respond to http 200, body is the content of the upgrade file.
-- If you do not need to upgrade, you must pay attention to the code 300 or above.
libfota.request(libfota_cb,"http://xxxxxx.com/xxx/upgrade?version=" .. _G.VERSION)

-- If a scheduled upgrade is required
-- co-platform iot
sys.timerLoopStart(libfota.request, 4*3600*1000, libfota_cb)
-- Self-built platform
sys.timerLoopStart(libfota.request, 4*3600*1000, libfota_cb, "http://xxxxxx.com/xxx/upgrade?version=" .. _G.VERSION)

libfota.request(cbFnc,ota_url,storge_location, len, param1,ota_port,libfota_timeout,server_cert, client_cert, client_key, client_password)#

fota Upgrade

Parameters

Incoming Value Type

Explanation

function

cbFnc User callback function. The callback function is called in the form of cbFnc(result) and must be passed

string

ota_url upgrade the url. if you do not fill it in, you will automatically use the aliot platform.

number/string

storge_location optional, the starting position of fota data storage
if it is int, it is determined by the chip platform specifically
if it is string, it is stored in the file system
if it is nil, the storage position is determined by the bottom layer

number

len Optional, maximum space for data storage

userdata

param1,Optional, if the data is stored in the spiflash spi_device

number

ota_port Optional, request port, default 80

number

libfota_timeout Optional. The request timeout time, in milliseconds. The default value is 30000 milliseconds.

string

server_cert optional, server ca certificate data

string

client_cert optional, client ca certificate data

string

client_key Optional, the client private key encrypts data

string

client_password Optional, client private key password data

Return Value

return value type

explanation

nil

No return value

Examples

None