Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
Posts: 425
Registered: ‎03-17-2011
My Device: Developer
My Carrier: Telus
Accepted Solution

Accessing BPS events in an ANE

[ Edited ]

First question: where would be the better place to post questions about ANE development? Here or in the native development forum?

 

Second question is regarding writing an ANE that aspires to process events from the Blackberry Platform Service (BPS) - sepecifically magnetometer events. When I include any bps functions, the ANE behaves as if the native ANE function does not even exist.  This is disappointing because if I can't initialize BPS in my ANE, I wont be able to process sensor events.  Here is a stripped down version of my native initializer function:

FREObject startMag(FREContext ctx, void* functionData, uint32_t argc,
		FREObject argv[]) {

	FREObject retVal;
	/*bps_initialize();
	if (sensor_is_supported(SENSOR_TYPE_AZIMUTH_PITCH_ROLL)) {
		FREDispatchStatusEventAsync(ctx, (uint8_t*)"CHANGE", (uint8_t*)"magnetometer is supported");
	}
	else {
		FREDispatchStatusEventAsync(ctx, (uint8_t*)"CHANGE", (uint8_t*)"magnetometer is not supported");
	}*/
	FREDispatchStatusEventAsync(ctx, (uint8_t*)"CHANGE", (uint8_t*)"magnetometer initialized");
	FRENewObjectFromBool(1, &retVal);

	return retVal;
}

 When the bps_initialize is commented out as above, an event is dispatched to my AS3 code and I can write the message to the console:

 

[SWF] com.example.NativeCode - 2,871 bytes after decompression
[SWF] UsingANE.swf - 498,013 bytes after decompression

message received from ane=magnetometer initialized

 

With the the BPS code uncommented, tI get the following unhelpful debug message.

 

ArgumentError: Error #3500: The extension context does not have a method with the name startMag.
at flash.external::ExtensionContext/_call()
at flash.external::ExtensionContext/call()
at com.example::NativeAS3/startMag()...

_________________________
In the dark and need a sky map?
Discover What's up at App World.
Follow What's up on Facebook

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Accessing BPS events in an ANE

Here is good, since it is an Adobe AIR thing.
There was an excellent sample of all of this shown at JAM10. We are still waiting for that to be posted.
Developer
Posts: 425
Registered: ‎03-17-2011
My Device: Developer
My Carrier: Telus

Re: Accessing BPS events in an ANE


jtegen wrote:
Here is good, since it is an Adobe AIR thing.
There was an excellent sample of all of this shown at JAM10. We are still waiting for that to be posted.

I've been trying to get this done for several weeks now and I finnally found an example of  reading magnetometer events here. I could easily adapt the code for my ANE if only I had a way to initialize BPS on the native side. My theory is that I could then call sensor_event_get_apr in a timer loop from the AS3 side. That way I could avoid the need for a tight  event loop on the native side.

 

Question the first:

Do you recall any details from the JAM10 example that will help me avoid crashing my ANE?  Does the technique involve BPS events at all? Or am i barking up the wrong tree?

 

Question the second:

Where will these  samples be posted when and if they arrive - in the developers blog perhaps? (would be good to know so that I can watch for them).

 

 

_________________________
In the dark and need a sky map?
Discover What's up at App World.
Follow What's up on Facebook

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Accessing BPS events in an ANE

They're example had it init when the AS3 was instantiated. They ran the loop in a thread and when it "changed", pushed an event to the AS3 side. I've been holding off with ANE until the event push was given. Now we just need the code provided. Julian Dolce did the presentation.
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Accessing BPS events in an ANE

Here is one link in case you did not have this.
http://deleteaso.com/
Developer
Posts: 425
Registered: ‎03-17-2011
My Device: Developer
My Carrier: Telus

Re: Accessing BPS events in an ANE

I am using the latest and greatest FB 4.6 with Air 3.1 and NDK 2.0. Support for AN's is really seamless now - much improved over the blog that you posted.

 

Current  ANE tutorial is here:

http://supportforums.blackberry.com/t5/Adobe-AIR-Development/Creating-AIR-Native-Extensions-for-BB10...

 

The problem that there is virtually no support beyond this tutorial. I have been able to write ANEs for severalk months now but can't figure out how to get the magnetometer to work in an ANE. Examples on how to use the magnetometer are now showing up for use in native applications and many apps are now appearing in App World.

 

Unfortunatle the examples break my ANE and are useless in my Air app. I am becoming somewhat frustrated about haing lost my competititive advantage. Such is life, I guess.


jtegen wrote:
Here is one link in case you did not have this.
http://deleteaso.com/

 

_________________________
In the dark and need a sky map?
Discover What's up at App World.
Follow What's up on Facebook

Developer
Posts: 425
Registered: ‎03-17-2011
My Device: Developer
My Carrier: Telus

Re: Accessing BPS events in an ANE


jtegen wrote:
They're example had it init when the AS3 was instantiated. They ran the loop in a thread and when it "changed", pushed an event to the AS3 side. I've been holding off with ANE until the event push was given. Now we just need the code provided. Julian Dolce did the presentation.

Thanks. I thought threading may be the cause of my problem. Is there a (simple and easy-to-comprehend) example of running a process in a thread. I have read tons of documentation on c threads, but its pretty much greek to me and I don't know anything about what libraries are available on the PB. I coiuld use an example that works on the PlayBook.if such an animal exists.

_________________________
In the dark and need a sky map?
Discover What's up at App World.
Follow What's up on Facebook

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Accessing BPS events in an ANE

Try to get a hold of Julian Dolce at QNX. He is the man on this. He said it is best to tweet him at @juliandolce. Ask him to post his example from JAM10 (and let me know if you hear something first). He had a threaded example, event calling, multi-sensor project that will solve all your problems (and mine too). I just have not had the time to work on this part yet. A single sensor ANE (to cover all sensors) would be great for the community (or at least one that can be easily adapted).
Developer
Posts: 425
Registered: ‎03-17-2011
My Device: Developer
My Carrier: Telus

Re: Accessing BPS events in an ANE

[ Edited ]

jtegen wrote:
Try to get a hold of Julian Dolce at QNX. He is the man on this. He said it is best to tweet him at @juliandolce. Ask him to post his example from JAM10 (and let me know if you hear something first). He had a threaded example, event calling, multi-sensor project that will solve all your problems (and mine too). I just have not had the time to work on this part yet. A single sensor ANE (to cover all sensors) would be great for the community (or at least one that can be easily adapted).

Thanks. I am not a twitter-bug so I can't use that channel. Perhaps a twitter-user could forward the request to Mr.Dolce.

 

With official APIs coming "soon" I don't know if a community ANE is required. But if there is a good reason, I would like to contribute. To this end I have made good progress today. I found out that Pthreads are the way to go and they are easy to implement. Tutorial here:

https://computing.llnl.gov/tutorials/pthreads/#PthreadsAPI

 

I also have ported a C routine to AS3 for correcting for magnetic declination depending on your LAT and LONG which should also be part of the ANE. I can post this if people might find it useful. The c version should be packaged with the community ANE.if we decide to go that route.



_________________________
In the dark and need a sky map?
Discover What's up at App World.
Follow What's up on Facebook

Developer
Posts: 425
Registered: ‎03-17-2011
My Device: Developer
My Carrier: Telus

Re: Accessing BPS events in an ANE


jtegen wrote:
They're example had it init when the AS3 was instantiated. They ran the loop in a thread and when it "changed", pushed an event to the AS3 side. I've been holding off with ANE until the event push was given. Now we just need the code provided. Julian Dolce did the presentation.

Well pthreads are really neat and I learned a lot abouit C string manipulation but it's all to no avail. As soon as I include a call to bps_initialize() in my code (even in the worker thread) , the AS3 side can't find my native sensor initializion function.  Here is the message I get from the FB debugger:

 

The extension context does not have a method with the name startMag.

 

I can use some help here and I wonder what the best way to get my hands on the sample code considering that I am not a twitter user. I also understand that Mark Sohm is a busy person but he has not responded to my PM.

 

In addition, I wonder if there is a way to get debugging messages printed to the console while trying to debug the native code -- The standard approach (printf) does not have any effect.

 

 

_________________________
In the dark and need a sky map?
Discover What's up at App World.
Follow What's up on Facebook