PDA

View Full Version : Connecting to Flash Lite with BREW for location based services application


punchkick
11-01-2006, 09:59 AM
I am trying to build an application in Flash Lite (compiled as a MOD) that will communicate with another file to determine the GPS location of the phone. Flash has excellent support for reading data via GET method or by using an XML socket. If this were a PHP issue, it would look like this:

<?php
$send_gps_longitude = "-80.62361";
$send_gps_latitude = "28.60970";
$send_variables = "&var_gps_longitude=";
$send_variables .= rawurlencode($send_gps_longitude);
$send_variables .= "&var_gps_latitude =";
$send_variables .= rawurlencode($send_gps_latitude);
echo "$send_variables";
?>

I am having two main problems with BREW.

1) Can someone please tell me how I would send ANY variable from a compiled C++ or python file to a Flash Lite 2.1 (ActionScript 7) file?

2) Can someone offer assistance with the location based service file that I am trying to create. As you can see, all it needs to do is return two variables so that they can be read by Flash.

Thanks!

ruben
11-01-2006, 10:50 PM
Let me try to understand, you are trying to send the lat, long value from an external applicaiton to Flashlite content, so that from actionscript you can perform network communication, is that correct?
And I also assume that, your external application would read/detect the lat/long information and write to a file.

Currently external application can't send any variable value to actionscript (not allowed as of now). As an work around, you can do the following:
1. Wite data to a regular text file or XML file and then from action script you can read the file by using "loadvariables" and then do the necessary processing (like communicating the information to the server.

punchkick
11-01-2006, 11:18 PM
You have no idea how happy I am to hear about this (mainly becuase you know what you are talking about).

If that is the case, then I think three issues arise. First, can a novice user download a single, finished application that would run both the Flash file (as a .MOD) and the external gps application (perhaps written in C++)?

Second, suppose the user could start up the Flash application and the C++ application at the same time, how would the external application be executed so that the latitude and longitude file was updated with accurate information?

Third, is it difficult to write an application that will create a text file with the following data:
&var_gps_longitude=[some value]&var_gps_latitude=[some value]&var_status=complete

Where the only dynamic data is var_gps_longitude and var_gps_latitude.


Potentially, the GPS application could be written to run in the background of the phone and always be updating the location (perhaps once per min.) as long as the phone is turned on.


If you have any more insight I would greatly appreciate the help.

Best,

ruben
11-02-2006, 08:08 AM
Please see the response below:
First, can a novice user download a single, finished application that would run both the Flash file (as a .MOD) and the external gps application (perhaps written in C++)?

>>> Yes, certainly that can be done easily. :)

Second, suppose the user could start up the Flash application and the C++ application at the same time, how would the external application be executed so that the latitude and longitude file was updated with accurate information?

>>> It depends how you would like to architect your application depending upon your business requirement. For example,
1. One approach would be, if you want to create a catalog type application, get the Flashlite brew extension header file (it doesn't cost you anything extra), create a top level C++ application which would load the flashlite extension and pass the swf file. This application can download swf file from your server and save to the disk and send the file to the player to playback swf file.
This application doesn't need to handle UI at all, Flash does all of your user interface. It does few things: downloads swf file optionally saves to the disk, and provides the swf file to the player, this application also writes GPS data to a file for Flashlite actionscript to consume.
In this way, you can keep changing swf file in your server, without submitting any more NSTL certification (need your application to be certified only once).

User downloads your application only one time.

2. Second approach: Use flash authoring tool to create FlashLite content mod file, and then you create a background services which probes GPS data and writes to file and communicates to the player. You hook up this background application with phone boot event, so that it can periodically probes and writes GPS information to a file.
When user starts your flashLite application, you can consume that GPS data file from actionscript.


Third, is it difficult to write an application that will create a text file with the following data:
&var_gps_longitude=[some value]&var_gps_latitude=[some value]&var_status=complete
Where the only dynamic data is var_gps_longitude and var_gps_latitude.

>>> You can create a text file manually to your content developer/designer so that he/she can keep developing swf file.
Meanwhile your C++ engineer write a straightforward application which probes GPS data and writes to a text file. This thing can be done in a week (if your engineer has basic knowledge of BREW)

This way, your Flash developer doesn't need to wait until the GPS background service is complete.

Potentially, the GPS application could be written to run in the background of the phone and always be updating the location (perhaps once per min.) as long as the phone is turned on.
>>> that is correct.

By the way, if you need to know more about the capabilities of Flashlite in BREW, you can refer this presentation done in BREW 2006 conference
http://brew.qualcomm.com/brew/en/press_room/events/brew_2006/pres_video_02.html

TECH-501 - Creating Flash Applications on BREW Handsets

punchkick
11-02-2006, 01:02 PM
Thank you for so much for your help with this so far-and thanks for the video.

1) Which of the two models that you mentioned would you recommend in terms of ease of implementation, ease of NSTL, security issues, and carrier issues?

I tend to lean towards the first suggestion-it just seems a lot cleaner. Since there is no need to have the data available unless the flash application is running, it seems like a poor use of resources to update a text file every min. Please let me know your thoughts on this.



2) Do you have any C++ BREW developers that you could recommend for this project? Just to clarify, the application would need to:

a. In order to keep this tool a single run application, the C++ app will need to load the Flash Lite MOD file and then remain active and transparent.
b. The C++ app will need to check for the GPS position and write the position to a text file once per min.


Like you said, it seems like a simple project but I have very little C++ experience.

Thanks again!

ruben
11-02-2006, 11:19 PM
1. First approach is better, however only tricky thing you need to get the header file from Adobe, it doesn't cost anything extra, but you need communicate with developer relations person. I will try to get you the right email ID for this.

If you don't get the header file, then the second approach is the only alternative. Please note that, in the second approach you don't have to run your background application all the time, there are ways you can hook up your background application with your flash applicaiton, so that from actionscript you can trigger to start the background application (this would address your efficiency concern).

In the event you need to take second approach, that can be also fairly clean way.

2. :) interesting question.

Wheather C++ loads the Flashlite mod and provides swf file or Flash content starts itself and ask the background application to start, that would depend which approach you would be taking. Flash content would do all UI display, GPS application would provide lat/long data.

Total C++ work wouldn't be significant (since in flash all UI work would be done), but the tricky thing would the communcation between action script and your GPS service dll.

punchkick
11-05-2006, 01:52 PM
Would you be interested in talking off line about working on this project as freelance?

ryan at punchkickinteractive dot com

abhilasha
04-02-2009, 12:33 AM
Hello Ruben,

In this thread you have mentioned that in 2nd approach Flash application can hook Brew code and can avoid it to run forever as background application.

Can you please elaborate it more and explain how this can be done.
It will be great if you can share the Adobe Customer contact point from where I can request for the header file you mentioned.


Regards,
Abhilasha

punchkick
04-02-2009, 01:15 AM
Hi Abhilasha,

I've setup FL as the UI layer for a BREW App without the Adobe header files by adding two lines of code to a basic BREW project. The code is illustrated below. **Note that the method shown is automatically generated for new BREW projects in MS Visual Studio, and I only added the code to launch the FL app, and exit the BREW app. Also, it should go without saying that you'll need the brewsaplayer and flashlite_2_1 extensions installed on the device. Additionally, you'll be actually *opening* the file 'flashlite_launcher' on the device, which will launch the FL UI, and presumably do some data legwork.

Happy coding :)


static boolean flashlite_launcher_HandleEvent(flashlite_launcher* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{

switch (eCode)
{
// App is told it is starting up
case EVT_APP_START:
// Add your code here...
// Launch the Flash Lite application
// I arbitrarily set the Flash Lite UI mod/mif pair with a class ID of: 0x01075be4
// From here you should set up an XML Socket or some other form of communication so that you can do data legwork in BREW, and visuals in FL.
ISHELL_StartApplet( pMe->a.m_pIShell, 0x01075be4 );
return(TRUE);


// App is told it is exiting
case EVT_APP_STOP:
// Add your code here...

return(TRUE);


// App is being suspended
case EVT_APP_SUSPEND:
// Add your code here...

return(TRUE);


// App is being resumed
case EVT_APP_RESUME:
// Add your code here...
// Close this application when the Flash Lite application exits
ISHELL_CloseApplet( pMe->a.m_pIShell, FALSE );
return(TRUE);


// An SMS message has arrived for this app. Message is in the dwParam above as (char *)
// sender simply uses this format "//BREW:ClassId:Message", example //BREW:0x00000001:Hello World
case EVT_APP_MESSAGE:
// Add your code here...
// Perhaps communicate with another application here...
return(TRUE);

// A key was pressed. Look at the wParam above to see which key was pressed. The key
// codes are in AEEVCodes.h. Example "AVK_1" means that the "1" key was pressed.
case EVT_KEY:
// Add your code here...

return(TRUE);


// If nothing fits up to this point then we'll just break out
default:
break;
}

return FALSE;
}

abhilasha
04-02-2009, 01:30 AM
Thanks Ryan.
I will implement XML socket to establish communication between flash and Brew application

punchkick
04-07-2009, 10:33 AM
abhilasha,

If it's not too much trouble, can you please post your socket connection code? The most basic form of whatever you intend to implement would be perfect. Ironically enough, I've only worked with C sockets that were compiled, and have never actually seen the guts of one :)

-Ryan

abhilasha
04-07-2009, 10:56 PM
Hello Ryan,

Here I am attaching a sample source code which I implemented to establish socket connection in C Code.

I have tried 2-3 alternatives for getting the host address but still not able to establish connection. Socket is getting successfully bind if I use AEE_INADDR_ANY.


Regards
Abhilasha