Categories
Android devices News Source Code

WebBroker on Android and Raspberry Pi 3

I covered this previously in a few webinars and presentations, but never published the source code for WebBroker on Android. To be honest I hadn’t tested it with C++Builder before, but I completely expected it to work, and it did. I also updated the tests on Emteria.OS (FKA RTAndroid) and it also works there.

The process of porting a Delphi or C++Builder WebBroker project to Android is pretty straight forward, but I’m publishing the code anyway. You create a Windows FMX WebBroker project, then copy all the code into a regular FireMonkey project. You will need to copy a few files from the RTL folder locally so you can reference them since they aren’t included in the Android package.

  • Web.WebReq.pas
  • Web.WebBroker.pas
  • Web.WebConst.pas
  • IdHTTPWebBrokerBridge.pas
  • IdCompilerDefines.inc
  • For C++Builder you also need
    • Web.WebReq.hpp
    • Web.WebBroker.hpp
    • Web.WebConst.hpp
    • IdHTTPWebBrokerBridge.hpp

Here are the links for the Delphi and C++Builder projects. They were built and tested in with 10.3.1 Rio. I also compiled some updated details on how to build the project and how to install and test on Emteria.OS.

I mention this in the slide deck, but officially WebBroker isn’t supported on Android. I tested it, and it seems to work, but if you run into an instance where it doesn’t work as expected, then you are on your own. Please don’t contact support and tell them I said it should work. Thanks!

Previous webinars:

Delphi and C++Builder on Raspberry Pi and SBC

Slides

Revisiting Raspberry Pi, Android and the SBC

Slides

See also: Targeting Chrome OS with Delphi via Android and Linux

Categories
Audio podCast devices podcast

The Craig Chapman IoT Episode

Talking with Craig Chapman about Internet of Things, high altitude balloons, Linux server configuration, enumerating data sets and 4K displays.

Links from today’s episode . . .

Microsoft’s Tweet about RAD Studio first IDE with Desktop Bridge support

[Soundcloud]

Categories
Android devices Internet of Things

Google’s Project Brillo, Weave, and Delphi

If you followed Google I/O then you no doubt heard about Google’s announcements in the Internet of Things space: Project Brillo and Weave. Brillo is Google’s new operating system for Internet of Things devices, and Weave is the language for how the devices will communicate. Right now Brillo and Weave are just product announcements. You can sign up for more information, but there is no preview release or developer build available. A lot may change before they are released, so it is tough to talk about them, but you sill may wonder how they will play with Delphi and RAD Studio XE8.

Disclaimer: This is based on public information released by Embarcadero and Google as interpreted by me. I’m not announcing anything, nor sharing any internal secrets. Just connecting the dots. If you connect the dots and get a different picture then let me know.

Neither Brillo or Weave are on our official roadmap because they were just announced. But we do have a good record lately of supporting new platforms quickly with new releases when those platforms are in our area of focus: iOS, Android, Windows and OS X. Just with XE8 we added iOS 64-bit to meet Apple’s new requirement, and it was added in such a way that most projects just need a recompile (which is much better option than the other native tools out there)

Besides wishful thinking, lets look at what they are and what we already support with XE8.

Project Brillo is a modified (or scrubbed down) version of Android. There have already been a few new devices come out that are powered by Android beyond the traditional tablet and phone. This is because Android is an open platform that comes with a rich development and app ecosystem. Brillo is Google’s attempt to make Android more flexible for more new devices in the future. It is a great idea.

Project Brillo may be in response to Microsoft’s announcement of Windows 10 for Devices, specifically targeting Raspberry Pi 2. These devices are going to be huge in the Internet of Things (IoT). That is why Microsoft is targeting the Raspberry Pi 2, and why Google is releasing Project Brillo. They all want to be the operating system of the Internet of Things. This is one place in the IoT where Apple is behind the pack, since they are a hardware company, they don’t want to sell an OS without hardware.

What about Delphi support for Brillo? We can look at the last 3 big modified versions of Android: Amazon’s Fire OS, Google Glass and Android Wear. All three of these we supported “out of the box” with our current release at the time, and some of them we added features in future releases to enhance that support. This is because we have great support of the Android OS directly. So I would suspect we will support Brillo when it is released.

That being said, one of the goals of Brillo is to run on “broad silicon” beyond the common ARVv7 processors that most Android devices run on.  We only currently support ARMv7 and ARMv8 (with NEON being part of the ARM standard going forward, so isn’t hardly worth mentioning). We’ve seen some recent success with Intel ATOM processor support thanks to libHoudini updates in KitKat. Now if a Brillo device is running a processors meeting these specs, it is likely to be supported “out of the box.” But if Brillo is running on an ARMv5 or “Bill and Ted’s Excellent CPU” then support is less likely.

Now it is possible that Brillo will be scrubbed down so much that it is no longer compatible with an Android app. Remember that Android is based on Linux, and Linux console apps are on our official roadmap for a future release, so support is still possible.

That brings us to Google Weave: a common library of terms for how devices will communicate. Its objective is to expose the developer API in a cross-platform way. It is based on JSON and REST from what I can tell. So it will be an agreed standard within REST and JSON. We already have great JSON and REST support, and there are 3rd party libraries that extend that as well. Combine the REST client library and the EMS server REST support and I suspect we will be in a good place to support Weave.

Weave is the protocol, but the channel will most likely be WiFi via HTTPS or Bluetooth LE. Also already covered great in XE8.

Naturally once Brillo and Weave are more than just vague product announcements we may have specific support for them that would make them easier to work with and unlock more features of those platforms beyond the stuff you already get with XE8. The moral of the story is to start developing your IoT solutions with XE8 today and make sure you have Update Subscription so you are ready for the future.

Categories
Android devices

Developing on the Samsung Gear Live Smart Watch

Previously I created a blog post about using Delphi and RAD Studio XE7 to develop for the Moto 360. The new FireUI Multi Device Designer (MDD) makes is a breeze to design for the new smaller UI. I’ve since updated the FireUI Devices project on GitHub to cover the Samsung Gear Live & LG-G watches in addition to the Moto 360.

I thought I would walk through the steps for developing with the Samsung Gear Live. One advantage it has over the Moto 360 is that it has a physical USB cable connection, so you don’t need to deploy via BlueTooth. This makes for a much faster deploy cycles. With a USB cable though, you need to install the ADB USB Drivers.

  1. Put the device in USB Debugging Mode
    1. Hold the home / side button until the settings menu appears (couple seconds)
    2. Select About and tap Build Number until it notifies you that developer options are enabled.
    3. Swipe left to right to go back
    4. Select Developer Options and enable USB Debugging.
  2. You still need to have the watch paired with a phone via the Android Wear app since the confirmation dialog is displayed there.
  3. Run the SDK Manager / Android Tools and Make sure you have Android SDK Tools, Platform-tools and Build tools updated (this moves the ZipAlign.exe, so you need to tell the IDE where to find it.)
  4. Install the Samsung Android USB Driver for Windows
  5. Gear Live should appear as an Other Device in device manager once you connect it to windows via USB.
  6. Select Update Driver Software
  7. Browse my computer for Driver software
  8. Let me pick from a list of device drivers on my computer
  9. Then select ADB Interface
  10. Select SAMSUNG Android ADB Interface
  11. On your phone you will see a dialog “Allow Wear Debugging” Check “Always allow .. . ” and then select OK.

Gear Live - Device Manager Driver Update

 

Once you have done all of that, it will show up in your IDE as a target, and when you load the FireUI custom device for it, then you will have a great design surface for it too.

GearLive in XE7 IDE

 

And you are ready to build your Gear Live app with Delphi XE7.

Delphi XE7 on the Samsung Gear Live

I’m sure I’ll have more coverage on Android Wear in the coming months too.

Categories
Android devices iOS Mobile

The FireUI: Multi-Device Designer in RAD Studio XE7

Here is the video replay, slides and resources from my Developer Skill Sprint on the new Multi-Device Designer in RAD Studio XE7. This is one part of the new FireUI, the evolution of FireMonkey.

The Multi-Device Designer is a new feature in Appmethod, RAD Studio, Delphi and C++Builder XE7 that makes it easy to maximize the reuse of your visually designed forms across devices, while also getting the most flexibility and customization as possible.

Design your UI once for Windows, OS X, iOS and Android, then customize it for different screen sizes: iPad, iPhone, Tablet, Google Glass, Surface Pro, etc.

You can view the slides on Google Docs.

Check out the Guided Tour on the Welcome Page and the following DocWiki pages:

Check out the other skill sprints too. . .

Categories
devices

Delphi Sensors on Windows 8 Tablet

New in XE6 is support for VCL Sensors. What better way to show these off then on the 8″ Dell Venue 8 Pro Windows 8.1 Tablet. The VCLSensors sample ships with RAD Studio XE6. I simply deployed it to the Dell Venue 8 Pro and it runs great.

VCL Sensors on Dell Venue 8 Pro

 

I added one of the VCL Styles to it as well. You can see it running here with my favorite wallpaper. It shows the Latitude & Longitude from the GPS via the TLocationSensor, the motion from the accelerometer via the TMotionSensor and the compass heading + tilt from the compass and gyroscope via the TOrientationSensor.

These sensors behave exactly the same way as the FireMonkey mobile ones do on Android and iOS, but now you can take advantage of them with your desktop applications.

You can also use the Metropolis UI and the tablet optimized styles for a full screen tablet experience on the Dell tablet. Both with VCL and FireMonkey.

 

Categories
Brain Computer Interface devices gadgets webinar

Connecting Delphi to my Brain with the Emotiv EPOC

Emotiv EPOC NeuroheadsetThe Emotiv EPOC might seem more Sci-Fi than practical technology. It is designed to pick up on brain waves through its 14 brain wave sensors (plus 2 reference receivers) and convert them into a usable signal for your computer. For head tracking it also includes a head mounted gyroscope.

The sensor input comes in 4 different categories:

  • Head rotation: The gyroscope returns acceleration information about the movement of your head.
  • Facial Expressions: Referred to as the Expressiv Suite, it processes the signals to detect facial expressions in real time. This includes winks, smiles, and eye movement.
  • Emotions: The Affectiv Suite provides real time emotional feedback including frustration, distraction, etc.
  • Direct Thought Control: The Cognitiv Suite lets you define trained brain patterns that you associate with different outcomes. When you repeat the brain pattern the system responds appropriately.

If you want to play with the Emotiv EPOC it is $500 for the developer set. The normal consumer set only works with official licensed software. It comes with a nice control panel that lets you play with the different inputs.

Thanks to the work of Simon J. Stuart (aka LaKraven) the SDK has a full Delphi translation. I have a short demo using the gyroscope. The brain access systems were giving me a handshake error, but that may be a commentary on my brain power.

My next objective is to unlock the brain interface and combine that with the Parrot AR.Drone api so I can fly the quadricopter with my mind.

That was part of the 11 demos in our Devices and Gadgets webinar. You can access the full replay on demand, which includes access to most all the drivers, wrappers, apis and source code. The only missing source code is to Allen Bauer‘s bluetooth infrared velocity screen system. He’ll have a blog post about that one.

Categories
Android Brain Computer Interface devices gadgets iOS Mobile

Connecting to the Parrot AR.Drone 2.0 from Delphi XE5

My first thought when I see cool technology is to figure out how to connect to it with Delphi. So the day I got the Parrot AR.Drone 2.0 quadricopter I started working on Delphi interface. By the time evening rolled around the batteries were dead (after a couple recharges), but I had a basic interface working. The official developer guide seemed to be a little out of date, or I was reading it wrong, but once I got my facts staight, connecting was really easy. http://www.youtube.com/watch?v=aaGe2aERwgI The Parrot AR.Drone has it’s own access point. Once you’ve connected to it, then it is simply a matter of sending UDP packets for the basic controls. To accomplish that I simply used the Indy UDP Client: TIdUDPClient. Each command is sent with an increasing sequence number, so I initialize my interface as follows:

  udp := TIdUDPClient.Create(nil);
  udp.Host := '192.168.1.1';
  udp.Port := 5556;
  seq := 1;

The AR.Drone is always at 192.168.1.1 since it is the access point, and the port for communication is 5556 (one of a few ports, but the one we need for now.) It is worth pointing out that if you’ve previously flown your AR.Drone with the FreeFlight mobile app then you may need to reset your drone to unpair it. Otherwise it is paired to only that device. The commands are formatted with an AT* prefix, and a series of arguments. For example, to take off, the command is AT*REF=1,290718208 where AT*REF is the command, 1 is the sequence number (always the first argument) and 290718208 is a bitmask that means take off. I created a SendCommand routine that looks like:

procedure TARDrone.SendCommand(cmd, arg: string);
var
  full: string;
begin
  if not udp.Active then Connect;

  full := Format('%s=%d,%s' + Chr(13), [Cmd, Seq, arg]);
  Seq := Seq + 1;
  udp.Send(full);
end;

Notice the command is terminated with a carriage return (#13). The documentation says line-feed (#10), it is wrong. Supposedly you can send multiple commands in the same message, if they are separated by the carriage return. I haven’t tested that. Then I can send the some common commands like this:

  SendCommand('AT*REF','290718208'); // Takeoff
  SendCommand('AT*REF','290717696'); // Land
  SendCommand('AT*CONFIG', '"control:altitude_max","10000"'); // unlimited altitude
  SendCommand('AT*CONFIG', '"control:altitude_max","5000"'); // restrituded altitude - unsure what units 500-5000.
  SendCommand('AT*PCMD','1,0,0,0,0'); // Hover (stop movement)

PCMD is the move command. It takes 5 arguments (after the sequence number.) The first is the controller type, which we are leaving 1 for now. The next 4 are phi, theta, gaz, yaw and they are floating point numbers in an integer representation. This is where it gets interesting. The documentation says:

The number –0.8 is stored in memory as a 32-bit word whose value is BF4CCCCD(base 16), according to the IEEE-754 format. This 32-bit word can be considered as holding the 32-bit integer value –1085485875(base 10).

The first way I thought of to access the same memory as two different types is a variant record. So I came up with the following helper routine:

function IEEEFloat(const aFloat: Single): Integer;
type
  TIEEEFloat = record
    case Boolean of
      True: (Float: Single);
      False: (Int: Integer);
  end;
var
  Convert: TIEEEFloat;
begin
  Convert.Float := aFloat;
  Result := Convert.Int;
end;

Using that I built a move routine that takes 4 singles (32-bit floats) and sends them as integers:

procedure TARDrone.Move(const phi, theta, gaz, yaw: Single);
begin
  SendCommand('AT*PCMD',Format('1,%d,%d,%d,%d',
    [IEEEFloat(phi), IEEEFloat(theta), IEEEFloat(gaz), IEEEFloat(yaw)]));
end;

Now if I want the drone to go up I can call:

  Move(0,0,5.6,0); // positive gaz is upward acceleration

Now it is just a matter of figuring out how to the rest of the movements map to the physical worked and building a user interface on Android, iOS, Windows or Mac. Maybe all 4! Once I build up the API a little bit more I’ll share some full working apps and libraries. Let me know if you are interested in collaborating on such.