Author Topic: ScriptBasic for Android  (Read 75045 times)

kryton9

  • Guest
Re: ScriptBasic for Android
« Reply #15 on: May 14, 2012, 02:20:09 PM »
John, I got it working now, thanks.  I also got the
Quote
OPEN "localhost:56098" FOR SOCKET AS #1
PRINT #1,"{id:1,method:makeToast,params:[\"ScriptBasic\"]}"
working with the port assigned from my emulator.

kryton9

  • Guest
Re: ScriptBasic for Android
« Reply #16 on: May 14, 2012, 02:35:23 PM »
John, I am just trying to wrap my mind around the overview of how things are working.
scriba is native code that bring scriptbasic to android, but it doesn't interface to the android api and that is what you are trying to do with Facades?

Here is a point of confusion for me: http://code.google.com/p/android-scripting/wiki/InterpreterDeveloperGuide
Lists 3 ways of bringing a language in, I don't see where Facades fit in?

Thanks in advance for any clarification.



The following Facade's are available for ownership. Please let us know which Facade you will be working on. I will be doing random functions to help with areas that aren't well documented.

Android SL4A API

  • ActivityResultFacade
  • AndroidFacade
  • ApplicationManagerFacade
  • BatteryManagerFacade
  • BluetoothFacade
  • CameraFacade
  • CommonIntentsFacade
  • ContactsFacade
  • EventFacade
  • LocationFacade
  • MediaPlayerFacade
  • MediaRecorderFacade
  • PhoneFacade
  • PreferencesFacade
  • SensorManagerFacade
  • SettingsFacade
  • SignalStrengthFacade
  • SmsFacade
  • SpeechRecognitionFacade
  • TextToSpeechFacade
  • ToneGeneratorFacade
  • UiFacade
  • WakeLockFacade
  • WebCamFacade
  • WifiFacade



kryton9

  • Guest
rpc server test for the notify method
« Reply #17 on: May 14, 2012, 03:16:26 PM »
Here is another little test. This sends a notification to the android device.
The "localhost:xxxxx" needs the x'es replaced with your RPC server port number.
Code: [Select]
OPEN "localhost:xxxxx" FOR SOCKET AS #1
PRINT #1,"{id:1,method:notify,params:[\"ScriptBasic\",\"The message for the notification\"]}"

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ScriptBasic for Android
« Reply #18 on: May 14, 2012, 03:27:39 PM »
Glad to see you talking to the Droid.  :D

It might be easier and more readable if you change this code ...
Code: [Select]
PRINT #1,"{id:1,method:notify,params:[\"ScriptBasic\",\"The message for the notification\"]}"

to something like this. This follows the JSON string declaration more closely. (even though it doesn't seem to matter)
Code: [Select]
PRINT #1,"""{"id":1,"method":"notify","params":["ScriptBasic","The message for the notification"]}\n"""

Hint: Don't forget the \n at the end of your JSON messages to the server. The response contains a linefeed so you will want to use CHOMP() to remove it before passing it to JSON2SB().
« Last Edit: May 14, 2012, 03:34:13 PM by support »

kryton9

  • Guest
Re: ScriptBasic for Android
« Reply #19 on: May 14, 2012, 04:35:38 PM »
John, are we going to develop these facades and then you will put them into 1 module?

I will try the webcam facade tonight and send you what I come up with based on your user functions code.

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ScriptBasic for Android
« Reply #20 on: May 14, 2012, 05:24:35 PM »
You are going to have to do your testing in a top/down script at the moment. (no functions or subs)

I'm going ahead with building the DVM module on Ubuntu and running it from there. (until SB Android is fixed)


kryton9

  • Guest
PC to Tablet Test Fail
« Reply #21 on: May 14, 2012, 06:20:57 PM »
I tried what you wrote about earlier John, going from pc to android device(tablet).
I installed sl4a release 5 as that has the fixed port setting option that the release I had didn't have.

In my server list it shows the public server as: 1%1:42241
It doesn't show the actual public ip. But I know from my router and from the ping result that it is
192.168.1.101

My stuff I send or run for the android device is in a subfolder I named 4d(short hand for droid) in my root ScriptBasic folder.
The open command gives an error. It is the same error I had before in testing when the port was not correct. In this case, I wonder if that %1 that is assigned instead of an ip is the problem?

On another note in the SB help, I can't find anything for SOCKET or MODULE, are these new commands?
« Last Edit: May 14, 2012, 06:24:12 PM by kryton9 »

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ScriptBasic for Android
« Reply #22 on: May 14, 2012, 06:35:45 PM »
I haven't tried the remote SL4A option yet and will do so tonight.

SOCKET

MODULE


kryton9

  • Guest
Re: ScriptBasic for Android
« Reply #23 on: May 14, 2012, 08:00:27 PM »
Thanks I was using the users guide that came with the download, the web one is bookmarked for future use, thanks.

I tried doing the android example with my pc to tablet with a public server and it gave an error too:
http://code.google.com/p/android-scripting/wiki/RemoteControl

You can see the results and how I followed the tutorial in the screenshot.




kryton9

  • Guest
python to tablet private server, worked!
« Reply #24 on: May 14, 2012, 08:20:42 PM »
python to tablet private server, worked!

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ScriptBasic for Android
« Reply #25 on: May 14, 2012, 08:44:47 PM »
The million dollar question is what is the IP to use in scriba?


Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ScriptBasic for Android
« Reply #26 on: May 14, 2012, 09:17:50 PM »
Get the latest development release, 5x18.

http://code.google.com/p/android-scripting/wiki/Unofficial

This will show the IP and not ::1%1.

The server hangs on the OPEN from scriba on Ubuntu using the IP:PORT given. (public server)


kryton9

  • Guest
without recent updates, but a working structure:WORKING!!! with update
« Reply #27 on: May 14, 2012, 09:30:51 PM »
John, I will get the updates, but I know my ip is correct from my router.
After having success with the python tutorial, I tried to mimic it with sb.

I have my tablet hooked via usb and setup a private server just as in python.
I wrote a cmd file(running in windows7) to make it easier to make changes.
It is in the attachment. You can make changes as needed for your system.

The sb2d.cmd I put in my E:\android-sdk-windows\platform-tools

The 2 sb scripts are in my E:\ScriptBasic\4d  
this is also where my sciba is located.
UPDATE:
WOOHOO! after getting the latest sl4a you linked too, it is all working now. I made no changes to the attached files. Just make sure you are on the home screen so you can see the output. When you are looking at the server info, the message doesn't show up.



Update2: it now works also without the usb cable attached :)

Update 3: I did a restart on my pc and skipped all the adb stuff (usb cable not used), I didn't do any of the set AP_ commands and just ran scriba hello2v2.sb  and it worked over the internet and wireless!!

Update 4:  Did a full shutdown of the public server and my tablet. Did a full shutdown on my PC. After powering both up and starting a new public server via sl4a it worked just fine with scriba hello2v2.sb command line issued!
« Last Edit: May 14, 2012, 09:56:55 PM by kryton9 »

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ScriptBasic for Android
« Reply #28 on: May 14, 2012, 10:23:40 PM »
Under Ubuntu Linux running the Android emulator provided with the SDK, it just hangs on the OPEN for both private (with port forwarding) and public connections.

I have a message out on the Android Scripting list asking Robbie what's up.

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ScriptBasic for Android
« Reply #29 on: May 14, 2012, 11:14:59 PM »
Finally!

I ran into a post on some forum and it said that the RPC server only listens on the loopback (127.0.0.1) port under Linux. That was the hint that got me pointed in the right direction. I still had to do the adb port forwarding. I have the default sever port set to be 9999. (pref.) I issue the following adb command in my Ubuntu terminal.

jrs@laptop:~$ adb forward tcp:9999 tcp:9999

This way I don't have to touch a thing if I'm running remote or on the sdcard.

Code: [Select]
OPEN "localhost:9999" FOR SOCKET AS #1
PRINT #1,"""{"id":1,"method":"getPhoneType","params":[]}\n"""
LINE INPUT #1, r
PRINT r

jrs@laptop:~/sb/test$ scriba phonetype.sb
{"error":null,"id":1,"result":"gsm"}
jrs@laptop:~/sb/test$


I can see an advantage of running a SB script on a desktop that accesses a MySQL or ODBC database and updates an Android phone or pad with new contacts or even SQLite DBs on the device. The concept of write once, run anywhere is leaning toward using scripting language solutions. Python is in the lead but has a size and dependency downside. I hope the simplistic nature of traditional Basic and the versatility to run anywhere will give ScriptBasic a purpose on a mass scale.
« Last Edit: May 15, 2012, 12:55:19 AM by support »