Carbider | 26 September, 2007 12:44
To build a system's skeleton we decided to construct all the
GUIs which will be presented at final BluSPAN program. But after 20 days have passed, my Carbide License was expired and I could not use the UI designer. While the license gets outlined (via
https://pro.forum.nokia.com/)
I decided to look at the existing PAN and BNEP sources. The first I found was “BlueZ” linux bluetooth protocol stack (
http://www.bluez.org/).
It is written on C language, so I supposed it will be a good attempt to port it into Carbide C++ as Symbian application.
I’ve downloaded two archives.
“bluez-libs-3.18.tar.gz” and “bluez-utils-3.18.tar.gz”
As Carbide C++ project base I chose Bluetooth Chat example that still available with expired license. I took Chat example, because I thought it has all headers and libraries included to work with BT.
To do that, I created new directory for future workspace, and copied “S60ExChat” folder there.
Then opened Carbide, switched workspace to which I recently made.
Next step was importing example.
Choose File->Import->Symbian OS Bld.inf -> Browse to “workspaceChatgroupbld.inf”.
So Chat example is imported.
Then I created new files: pand.h, bnep.h, bnep.c .... which are copy-pasted from BlueZ.
Now there was a time to see how Unix C code would be compatible with Symbian one. Of course, they were not so alike. I started porting, that means to make Unix source code and algorithms functioning. For that time my idea was to achieve just out of error compilation.
The first problem I saw were type definitions undefined for carbide. So I wrote “myPortedTypes.h” header file which typedefs some Bluetooth types known in Symbian. Some types were available from <systypes.h> library.
I made some type definitions out of “myPortedTypes.h” also.
At bnep.c I defined
#define AF_BLUETOOTH 31
#define PF_BLUETOOTH AF_BLUETOOTH
#define BTPROTO_BNEP 4
This types were expected at <syssocket.h> library but were absent there. So I had to determine them.
At bnep.h I defined
#define ETH_ALEN 6 // That was expected at <netethernet.h> lib
One more pain was connected with lib <sys/ioctl.h>.
Carbide has a little different implementation of <sys/ioctl.h> than BlueZ expected.
<ioctl.h> has the macroses _IOR and _IOW which are used by bnep.h.
But Carbide’s ones have 2 arguments , but BlueZ expects 3 arguments…
I passed through 3 ways before solve this problem.
»The first.
I thought I have to use other source code of <ioctl.h> (and <ioctl.c>) library. I’ve found some sources in the web, and used them in my project. Everything seems to be ok. But there are 2 disadvantages:
1. The Symbian’s one ioctl should be much more effective, because it’s native to their phones.
2. I’m not sure that new trouble will not appear because of possible conflicts with hardware.
»The Second.
Due to _IOR is a macros declared with #define directive, The #undef directive is applicable to it. In this case I can apply new definition to that macros using other source libraries.
By this manipulations I reached redefinition just of the part of <ioctl.h> library. So it was more effective way.
»The Third.
The third way was to examine, how Bnep.h uses those macros, and to transform the Bnep.h code to use 2 arguments instead of 3.
During the code examination, I found out that the third argument of _IOR macrosis not used. It was just drowned by useless int type. So the only thing I had to do is to cut every third parameter from _IOR macros call. This was a best way to leave standard <ioctl.h> macros definition.
The current problems that brake porting are signal operations.
I created new file “mySysSignal.h” which includes <sys/signal.h> header and determines some definitions from <signal.h>. Yes, they are different.
Furthermore, <sys/signal.h> doesn’t want to declare “sigaction” struct, because _STRICT_ANSI was defined. So I had to #undef it and then #define back.
But I could not find the sigaction() function implementation at this headers!
I tried to adopt other sources where sigaction()is implemented, but no result. Those codes want more and more implementations. Does anyone know which sigaction()implementation would be the best for Symbian? Please, write your comments if you do.
I downloaded some sigaction sources from:
I started CVS project at Sourceforge.net. You can download my sources and examine them here:
You can checkout this source codes directly to Carbide C++. To do this look for my post: Get project from CVS to Carbide C++. The source files I worked with are:
Bluetooth.h Bnep.h Getopt.h Hci_lib.h Hci.h L2cap.h myPortedTypes.h | mySysLog.h mySysSignal.h pand.h poll.h sigaction.h sigvec.h |
and their *.cpp implemenation at "src/".
The written code is pretty chaotic because of Porting process. So don’t be wonder for that : -)
Thanks
Carbider | 05 October, 2007 15:50
there was a period while all features were enabled. I used Carbide professional edition.
Then the test period was over, and Carbide came to Express(free, test) edition automatically.
For now I could not use UI Designer tool.
As a
S2F blogs author, I was linked up with
https://pro.forum.nokia.com/ launchpad program. We ordered there license of Carbide
Developer edition.
It took some time to understand, why the license is not still available for me though it was ordered. The reason was that there are different statuses of launchpad members. They are: the account owner and the account users. After purchasing Carbide, the account owner directs the license to account user. At this step user can activate the license.
There are “Node-locked” and “Floating” licenses models. The first means, that the license will be tied to concrete user’s computer by mac-address. The floating license allows to use several carbide products on several computers inside one development team’s network.
My license was node-locked. I clicked “Activate” link in front of license in my account.
The activation page has appeared. There I putted in my mac-address. I have Windows XP machine, so I used “IP CONFIG /ALL” command in prompt to retrieve those address. The license’s text appeared on screen, I copied it to Carbide’s “Help->Carbide Licenses->Install License”.
That was it. After IDE restarted I have had already enabled UI Designer feature.
The S60v3 SDK wants to be registered after 14 days too. It is simple free registration. The code would be send to your e-mail.
The license installation is described step-by-step while you’re ordering and retrieving it at
http://www.forum.nokia.com/main/e-store/.
The most full description is in pfd:
http://wiki.forum.nokia.com/images/1/1b/EStore-UM-v3.0.pdf
Carbider | 16 October, 2007 15:01
After unsatisfactory attempt to port BlueZ system to Symbian due to <sys/signal.h> differences, David advised me to look at P.I.P.S libraries. P.I.P.S. are Symbian libraries that are compatible with POSIX standard.
That could mean reducing efforts while migrating the project to mobile device.
That was true on several positions. But there still was a trouble with <sys/system.h>.
It has sigaction{} structure inside. But BlueZ needs sigaction() function too.
I don’t know, if the trouble is that BlueZ doesn’t support POSIX. Or it is a Symbian’s trait.
[PIPS_Essential_Booklet.pdf]
Which says: “The P.I.P.S. environment does not support signals”.
Other functions that are not supported:
sigfillset()
sigdelset()
I had to examine what Signals are used for. I came to conclusion that they are used to halt child processes.
Sigaction()function was used to specify the action to be associated with a specific signal. After that the process generates his child instance (with fork and exec) which can be killed by sending “halt” signal with this statement:
kill(pid, SIGHUP)
So, I did not still find the replacement to this function to kill child processes. I’m thinking about Symbian’s RProcess class. Any ideas?
I found that Carbide C++ is very strict to data types. Even more strict than unix c.
I had to replace statements like:
struct bnep_setup_conn_req *req;
req = (void *) pkt;
to
req = (struct bnep_setup_conn_req *) pkt;
At this 2 documents:
I found recommendations how to substitute ther “fork”, “exec” operations with other posix functions. The main is posix_spawn().
I tried to follow this idea, outflanking the forks and execs with posix_spawn().It worked well.
At run_script() function there is instruction:
execv(script, argv);
Before run_script()is used, the fork()function is called to create the instance of program itself.
This “execv+fork”pair is replaced by one
posix_spawn(&Childpid,script,NULL,NULL,argv,NULL);
call.
There are still lots of goals to reach. I don’t know how to pass command line arguments to Carbide’s console application.
The sdp.c is not implemented in this version of port because it still makes too much errors and it will take time to solve.
I think there will be resulting GUI application which will run main PAND console instances. After that they should get into single signed SIS installation file.