AirVantage asset not registered

Hi,

I’m attempting to send data to AirVantage using this code:

assert(airvantage.init())
	M.asset = airvantage.newasset(M.pr.items.asset_name)
	M.asset.tree.actuator = M.write_actuator
	M.asset.tree.settings = M.pr.items
	M.asset :start()
	-- Start polling

It did work but something has changed. The asset_name and items table have entries. When debugging this and the working “HelloAirVantage” example I noticed that the M.asset.registered variable is false for the above code, whereas in the working example it is true after executing start(). What does the registered status depend on?

Thanks,
Steve

Hi,

“asset.registered” variable is kind of an internal variable, used to store binary result of asset registration.
The registration is going from the asset instance in one AAF application to AAF agent which responsible to route, organize data and services to all running AAF applications and underlying assets instance(s).

There are several possible issues with the registration process, most of them are related to the asset_name being used.

The registration error is not stored in the object, anyway the appropriate way for the user to get it is to store the result from the :start() call.
So please try something like that, post the error you have:

local asset_name="asset_id_test"
local log = require "log"

assert(airvantage.init())
local asset = airvantage.newasset(asset_name)
local res, err = asset :start()

log("AAF-APP", "ERROR", "start() res=[%s], err=[%s]", tostring(res), tostring(err))
-- you can use assert() here instead of log/print APIs, it's up to you

Also please give full example with asset_name (and pr.items etc) contents: if you are not willing to share the whole code, please put minimal example with concrete values/code displaying the issue.

Regards,

Laurent.

Hi Laurent,

I never solved my problem so I chose a new name “cbmP” and that worked without issue:

assert(airvantage.init())
	M.asset = airvantage.newasset("cbmP")
	local res, err = M.asset:start()

This app has been working without issue or change & now I’ve tried to provide you with some diagnostics I get this error.

If I debug this err is:
“BAD_PARAMETER:asset name already registered”
res is nil.

What does this mean?

Regards, Steve

Hi,

It means that there is already another asset instance created with that name.
The asset ID / name must be unique on the device, so that’s why the error is happening.

How is it possible?
It depends how you run the code on device, but here are some clues:

  • several instance of the same code is running at the same time (e.g. one instance is installed on the device, the other one being run using run/debug targets of the Developer Studio)
  • a previous instance stopped without cleaning resources: it is always a good habit to end up the application code with resources releasing, in this case “asset:close()”.

Let me know if those could explain your issue.

Regards,

Hi,

Thanks for that the app must have been running in the device although it said it was stopped in the local web interface and it appeared stopped from the “Remote System Explorer” in the IDE & I’d commanded it to stop several times in AirVantage. A reboot fixed it.

Thank you for your assistance.

Regards, Steve