Watch, Follow, &
Connect with Us

Stephen Ball

What to do with Beacons before you code?

A beacon is a Bluetooth Low Energy device including some information in its advertising data.

Working with beacons requires code to read the beacons and some setup to ensure you read only the right beacons, especially as more and more are appearing! This article mainly focuses on the latter and what you should be aware of before you deploy your beacons.

Programming for iBeacons & AltBeacons

While you can code to work with beacons via a number of languages, RAD Studio XE8 has introduces a new multi-platform component for working with beacons – as covered in this post from Sarina DuPont – this is very cool making it super easy to have both Android and iOS and Mac applications running from common code. However this is out of the scope of this post.

I will however point you to the sample projects shipped with RAD Studio XE8 using both Delphi and C++ in the following samples folder which can be opened directly using the shortcut to the samples in the IDE.

There is also great detail about what beacons are in DocWiki

<Samples>\<language>\Mobile Samples\Device Sensors and Services\Bluetooth\Beacons

Getting started with Beacon Hardware

So what do I need to know about beacons?

Beacon Standards

Firstly, beacons are typically following 2 standards for broadcasting over Bluetooth 4.

iBeacons from Apple (and requires a license if you want to create physical beacons yourself)
AltBeacons which is an open standard

Alt Beacon
iBeacon

Using these standards you can pick up data to identify a specific beacon and how far it is away. The 4 key bits of information to manage this are

UUID
Major ID
Minor ID
TxPower

Using the new Beacons component you can define which type of beacon(s) you want to scan for using the UUID as a filter, and optionally Major and Minor ID – and this brings us onto the importance of the UUID

Beacon Regions

Beacon UUID

By default the UUID is set based on the beacon manufacturer. If you are going to use beacons in a real world application then you will probably want to update the UUID to a unique ID that you will be scanning for. This way you can limit any other beacons that are deployed.

Beacon Major and Minor

Beacon Major and Minor ID’s are used to identify the specific location you want to indicate with the Beacon. Hence its important that you update the UUID so you read only the correct beacons to check for the location you are at.

An example would be using the major to identify a retail store and a minor to a specific area in the retail store.

Programming the Beacon

There are a number of beacon manufacturers out there, and its typically easy to re-program your beacon to have that unique UUID and then set the Major and Minor ID’s.

Once such beacon is the RadBeacon from Radius Networks

Radius Networks provide a useful Beacon config application that you can download for free (once you register)

The application is available for Android, iOS and Mac.Radius Network Beacon Configuration

 

 

The default pin for editing the beacons is 0000.

Requirements for the Config App

For the software requirements visit the Beacon config application home page. In short, Bluetooth 4 is a minimum and Mac (10.9+) or recent iOS / Android releases.

Securing your Beacons….

Before you deploy your beacons, you may want to secure your beacon from tampering.

It is suggested by Radius networks that you lock your beacon before its put into a live environment. Locking a beacon prevents any further editing over bluetooth, so you need to be sure of your config before you do this.

A little less radical is updating the pin code for editing the beacon, however this is easily cracked so really only ideal for short term setup.

More about what the different options on the config application do are available here: http://www.radiusnetworks.com/ibeacon/radbeacon/mac/2-0-0/help.html

The post What to do with Beacons before you code? appeared first on Stephen Ball's Technical Blog.

Posted by Stephen Ball on April 11th, 2015 under Uncategorized | Comment now »


Database updates in RAD Studio XE8

Database updates in RAD Studio XE8

With RAD Studio XE8 there have been a number of database updates to expand connectivity, and improve and introduce functionality for us programmers.

FireDAC & IBX support for Change Views

FireDAC has introduced new support for Change Views – enabling rapid identification of what has changed on the server side data and updating of client side stored data. See this <2min video for how these work.

Source code for the example ships in the samples directory:

<Samples><language>Database\FireDAC\Samples\DBMS Specific\InterBase\ChangeView

IBX has also introduced new components to make it easier to work with change views and subscriptions.

 New Platform – Teradata

FireDAC now includes support for Teradata, using the driver name TData.

TeraData in FireDAC

 

An example of how to set the driver properties is shown on the docwiki help for connecting to Teradata with Delphi.

DriverID=TData
Server=192.168.43.140
Database=MyDatabase
User_Name=dbc
Password=dbc

TDataSet TField speed up.

Marco Cantu mentioned on the Launch webinar Q&A a customer was claiming seen a speed up of around 25% on a TClientDataSet application due to the refactoring at the base of how TField is used at the core layer. :-) This is really cool for both VCL and also FMX developers.

64bit support for iOS

With the new platform for iOS 64bit, the database layer is also seamlessly available, just recompile and run :-)

Other updates

There are updates for EMS including push notification. EMS is a great way to access central data from mobile devices. EMS now is updated to include InterBase XE7 for both the server and ToGo side, allowing you to use Change Views on both Server and Clients.

Where FireDAC uses SQLite, it has been updated to a newer driver.

For more of whats new in RAD Studio XE8, including EMS updates, please click here Whats new in Delphi XE8 and C++ Builder XE8

 

The post Database updates in RAD Studio XE8 appeared first on Stephen Ball's Technical Blog.

Posted by Stephen Ball on April 10th, 2015 under Uncategorized | Comment now »


RAD Studio XE8 & my first Google Play app

RAD Studio XE8 has been launched today with a host of new features for both mobile and desktop applications.

Discover How RAD Studio XE8 Expands Your Business

Multi-platform FireUI
Extend Windows apps to mobile
Mobilize business with EMS
Update subscription
Get productive
Native Platform Controls
Stay informed with Analytics

For more on whats new visit RAD Studio XE8 documentation

My Google Play app built with XE8

I have been playing with a new application that combines my hobby as a Basketball referee with my geeky side and have published using RAD Studio XE8 a new Google Play store application for managing Basketball Shot Clocks.

Setting Up the Shot Clock
Shot Clock Timer - Running
Scaling Shot Clock Font

I started this app using components that was introduced in XE7 – AppTethering and Multi-View, and these have been great, but I have benefited recently from the new FireUI updates in building a version for multiple screens. I now have it running on Tablets, Phones and Android TV. (which is kind of fun).

Adding in XE8 “toys”

Analytics

Getting to XE8 was trivial from XE7, and my next step now is to add in the new Analytics features of XE8. AppAnalytics provides developers with a visual representation of how users are interacting with applications built with RAD Studio XE8

I’ve found you get some good analytics about platform and country etc from Google App Store, which is cool, but I want some in app details to know when its being used. – This is especially cool as this can be used in VCL and FireMonkey applications and there is a free version of the service with the option to purchase enhanced online analytics.

More Native Controls

I’m also going to look to increase the native controls used in the app with the new options for a number of the controls I have used (like the slider and list view). I like the way FireMonkey abstracts this as an option and even surfaces some new options in this area.

For more about the new controls and everything else that is new in XE8 please visit the online help documentation.

 

The post RAD Studio XE8 & my first Google Play app appeared first on Stephen Ball's Technical Blog.

Posted by Stephen Ball on April 8th, 2015 under Uncategorized | Comment now »


InterBase XE7 – Update 1 Released

InterBase XE7 Update 1 Overview

InterBase XE7, update 1 went live on Friday and brings with it SQL language enhancements for Change View, and some updates to IBConsole and the availability of InterBase ToGo for XE7

Full details about the update are available on the InterBase DocWiki

Change View Updates

There are 2 major additions to InterBase Change Views in Update 1

DROP SUBSCRIPTION
Change View SQL Extensions

Drop Subscription

Prior to update 1 you had to manually drop a subscription via an SQL statement. This was a temporary solution and has now been replaced with the correct SQL syntax

DROP SUBSCRIPTION <subscription name> [RESTRICT | CASCADE]

If you want to remove a subscription that has subscribers you must use the CASCADE command as RESTRICT is the default.

Change View SQL Extensions

InterBase SQL now includes additional language to support querying about the changed state of specific fields via the <FIELD> IS [NOT] {CHANGED | INSERTED | UPDATED | DELETED} clause.

Take the following example.  Lets imagine we have two employee records that have been modified.

EMP_NO 39 has their DEPT_NO changed
EMP_NO 109 has their SALARY changed.

At run time you want to select only those that have had a SALARY change prior to processing staff payments. To achieve this first, a Change View subscription is set active (making any SQL statement subsequently run only return the delta for that subscriber). Then SQL where clause then filters further where the SALARY IS UPDATED.

SET SUBSCRIPTION sub_employee_changes at ‘MyDeviceID’ ACTIVE;
SELECT EMP_NO, DEPT_NO, SALARY FROM EMPLOYEE WHERE SALARY IS UPDATED;

EMP_NO DEPT_NO SALARY
——– ———- ———-
109 600 75000

Regardless of what you select, the commit will still bring

InterBase IBConsole Updates

InterBase IBConsole has a number of new features, introduced in Update 1 designed to get you started quicker.

Getting Started with InterBase
Recent databases window
Change Views Integration

IBConsole Start HereIBConsole Start Here

Getting started with InterBase

When you open IBConsole now you find the new InterBase – Start Here page as a tab at the top of the screen. The start here page includes containing details about Community and featured posts, as well as training videos and direct links to the documentation. While an offline page ships with IBConsole, If you want to see this page now, please visit http://www.embarcadero.com/starthere/interbase/index.html

Having this page online allows us to improve our communication with our customers about critical information and appropriate news.

Recent Databases

There is also a new feature in the bottom left of the screen (see image above or below) enabling you to quickly connect back to the recent database you have been working on.

This windows shows you the database name, server and also the when you last accessed the database via IBConsole.

Change Views

Change View IBConsole

IBConsole also now includes access to work with subscriptions.

InterBase ToGo XE7

InterBase XE7 ToGo trial edition is now available for download – more details to come soon about ToGo.

The post InterBase XE7 – Update 1 Released appeared first on Stephen Ball's Technical Blog.

Posted by Stephen Ball on March 12th, 2015 under Uncategorized | Comment now »


InterBase Change Views Demo and Video

InterBase Change Views Example Demo

This week I hosted a Skill Sprints session looking at InterBase Change Views with an example set of code working around a Pharmacy needing to keep centralised drug information updated at distributed pharmacies.

The example code will ship with the next major release of the RAD Studio products – which you can get for free with the current RAD offer

This InterBase Change Views Example demo shows off this powerful way to track on the server what data is changing in a very lightweight and scalable way.

This Skill Sprint Video for InterBase Change Views follows on from the recent blog posts I have done on Change Views which are available here:

InterBase Change Views blogs

What is a Change View?
Creating a Change View
Using a Change View

InterBase Change Views in Spanish

Last week CodeRage III Brazil ran with a host of great sessions in Spanish, covering RTTI, App Tethering, DataSnap and FireDAC and also InterBase. Back in December I hosted the product Launch of InterBase XE7 at CodeRage 9, and it has been great working with Dormevilly and Fernando to get an updated Spanish version done, including some of the great capabilities we have today with Change Views. Great job guys :-)

The post InterBase Change Views Demo and Video appeared first on Stephen Ball's Technical Blog.

Posted by Stephen Ball on March 7th, 2015 under Uncategorized | Comment now »


What is an embedded database?

A common question for a developer is how to store data. While file formats like INI files. XML, CSV etc provide a simple way to store data, they are often not secure enough or provide enough features for most applications. This is when a data store is required. One such option is an embedded database.

What is an embedded database?

An Embedded database is one that can be deployed inside or along side you application. They are called embedded as they can be silently deployed / installed to provide database support without the need of a separate admin intensive process.  Embedded databases should be fast, have a small foot print, provide admin free capabilities all at the same time as providing full features SQL capabilities. Unfortunately, not all embedded databases provide complete capabilities, InterBase however is very feature rich in all editions. For more about Embedded databases and the different types they come in, watch the short video below.

Follow these links for

More about InterBase, the embedded database
Your free Developer edition or trial of InterBase

The post What is an embedded database? appeared first on Stephen Ball's Technical Blog.

Posted by Stephen Ball on February 27th, 2015 under Uncategorized | Comment now »


Connecting to InterBase from Visual Studio

I was recently asked how to connect to InterBase from Visual Studio, and while its not something I have done before, luckily I know a man who has. – Thanks to Gabe Goldfield for checking the example below with InterBase XE7 and Visual Studio 2013 Ultimate.

Connecting to InterBase from Visual Studio

InterBase currently supports an ADO.Net driver that works with InterBase XE, XE3 and XE7 providing both 32bit and 64bit support. Full details here.

Prerequisites

You will need to have .Net 2.0 SDK with update.
Microsoft Visual Studio 2005 or above.
InterBase XE or above.

Installation Instructions

Run the InterBase ADO.Net 2.0 installer.

Usage Instructions

Start Visual Studio 2005/2008
File new C# Windows application
Project – Add Reference and add the AdoDbxClient.dll, DbxCommonDriver, DBXInterBaseDriver to your project.
Add a DataGridView component to your Windows Form
The sample code below fills a DataGridView component with the contents of the employee table of the employee.gdb sample InterBase database:

Code Example

>>>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Borland.Data;
using Borland.Data.Units;
using System.Data.SqlClient;
using System.Data.Common;
namespace IBXEApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
ReadData(getConnection());
}
public DbConnection getConnection()
{
// DbProviderFactory factory = DbProviderFactories.GetFactory
// ("Borland.Data.AdoDbxClient");
DbConnection c = new TAdoDbxInterBaseConnection();
//DbConnection c = factory.CreateConnection();
c.ConnectionString = "Database=C:\\Embarcadero\\InterBase\\examples\\database\\employee.gdb;User_Name=sysdba;Password=masterkey";
return c;
}
public void ReadData(DbConnection conn)
{
string sql = "select * from employee";
DbCommand cmd = conn.CreateCommand();
cmd.CommandText = sql;
conn.Open();
DbDataReader myreader = cmd.ExecuteReader();
dataGridView1.DataSource = myreader;
DataSet ds = new DataSet();
DataTable dt = new DataTable("employee");
ds.Tables.Add(dt);
ds.Load(myreader, LoadOption.PreserveChanges, ds.Tables[0]);
dataGridView1.DataSource = ds.Tables[0];
myreader.Close();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{

}
}
}
<<<

The post Connecting to InterBase from Visual Studio appeared first on Stephen Ball's Technical Blog.

Posted by Stephen Ball on February 24th, 2015 under Uncategorized | Comment now »


InterBase Change Views – Part 1 – What is a change view

This is the first post of a series on InterBase Change Views and is intended to be a high level overview of the new powerful change view technology that is patent pending and part of InterBase. Following this post I plan to show more posts taking the concept of Change Views into the real world with some real application examples.

InterBase Change Views

InterBase XE7 introduces a new way to track data changes to the database called Change Views.

Change Views are a new “subscription based” model allowing you to “subscribe” to data; once subscribed you are able to ask the database at a later time, spanning connections, for what has changed.

This is an especially cool, low cost way to reduce network traffic, mobile data costs and development time when tasked with keeping multiple remote database caches up to date. (especially if you have large tables to keep up dated).

Change Views are simple to use and reduce the upfront planning needed for building in data tracking that history has shown to be inherently complex and error prone.

Best of all change views has zero impact on database performance regardless of the number of subscribers!

Subscription & Subscribers

A core concept to change views is that of Subscriptions and Subscribers.  InterBase Change view allows multiple subscribers to a subscription.

A subscription is defined once and then can be connected to by multiple users. Once defined, you can control who can subscribe thanks to the InterBase inbuilt user security.

Subscriptions work at field level and can be defined to track either an entire table or multiple tables. Subscriptions can also be defined to track Inserts, Updates or Deletes (or a mix of)

Multiple devices per subscriber

In addition to allowing specific users to subscribe to data, you can use a single user to have multiple destinations that are subscribing. This allows a user to subscribe for different devices such as their Phone, Tablet, Laptop or for a single user to be used programatically to distinguish multiple sites – e.g. Office 1, Office 2 etc.

This is done using the “at” verb when connecting to the subscription.

What Change Views are not!

Change Views are not an auditing system. While you can track deleted records, Change View are about identifying what has changed without keeping every value that it has been. If you want to do that, then continue to use Triggers and logging tables for the values you need to audit.

Video – Change Views

An overview of Change Views is available in the InterBase product address from CodeRage 9. I will be digging into more code based versions through this series. This covers the syntax used

Documentation – Change View

There is a great introduction to InterBase Change Views in the release notes for InterBase XE7
http://docwiki.embarcadero.com/InterBase/XE7/en/What’s_New_in_InterBase_XE7#Change_Views_Feature

 

The post InterBase Change Views – Part 1 – What is a change view appeared first on Stephen Ball's Technical Blog.

Posted by Stephen Ball on February 7th, 2015 under Uncategorized | Comment now »


InterBase Change Views – Part 2 – Creating a Change View

If you have ever spent time planning how to identify what data has changed, then change views is about to simplify the way you develop for ever!

If you haven’t already read Part 1 of InterBase Change Views this provides a high level overview of the technology.

Steps for creating a Change View

Rather than having to create and manage triggers to add records into log tables or planning additional date fields into your metadata (and hoping date & time changes don’t effect you) Change View are easily added to a project once the simplified architecture is complete.

There are two essential steps in creating a successful change view:

Defining the purpose of the Change View and the data you want to track
Defining who can subscribe to the change view

1) Creating a change view

Lets start with a simple example. We want to keep our sales fulfilment application up-to-date with the latest stock and suppliers information. This data is stored in two tables, INVENTORY and SUPPLIERS.

Example 1 – Multiple Tables

CREATE SUBSCRIPTION
sub_stock
ON
INVENTORY FOR ROW (INSERT, UPDATE, DELETE),
SUPPLIERS FOR ROW (INSERT, UPDATE, DELETE)
DESCRIPTION ‘Track stock and supplier changes’;

Subscriptions are created with the CREATE SUBSCRIPTION statement followed by a subscription name that you will need to use in SQL later on.

The simple example tracks all columns in the tables INVENTORY and SUPPLIERS for Inserts, Updates and Deletes.

The description allows easy identification of the subscriptions purpose later on.

Example 2 – Specifying Columns

We may have a requirement to track product name changes for our application. We can do this also with a change view.

CREATE SUBSCRIPTION
sub_stockname
ON
INVENTORY(ITEM_NAME) FOR
ROW (INSERT, UPDATE, DELETE)
DESCRIPTION ‘Track stock name changes’;

Example 2 is more granular than example 1 and tracks only a single column ITEM_NAME in the INVENTORY table. This is done by providing a comma separated list of field names for the table that you want to track.

Example 3 – Tracking Deletes

We may also want to track deletions from a specific table, lets say ORDERS. A Change Views just tracking DELETE activity on  a table will provide a way to recover data if it is deleted

CREATE SUBSCRIPTION
sub_orderDeletes
ON
ORDERS FOR
ROW (DELETE)
DESCRIPTION ‘Track Order Deletions’;

Using a Change View to track deletes is a powerful feature as you can completely recover the record at its state when it was deleted.

2) Defining who can use a change view / subscription

Once a subscription is created, you need to grant SUBSCRIBE access to the subscription. To do this use the standard GRANT syntax. e.g. (for user SYSDBA)

GRANT SUBSCRIBE ON SUBSCRIPTION sub_stock TO SYSDBA;

InterBase Documentation

For more on Change Views visit the InterBase DocWiki

In my next blog, I’ll look at using a change view

The post InterBase Change Views – Part 2 – Creating a Change View appeared first on Stephen Ball's Technical Blog.

Posted by Stephen Ball on February 7th, 2015 under Uncategorized | Comment now »


InterBase Change Views – Part 3 – Using a change view

In Part 1 I explored the concept of change views, before how to create a Change View ready for use in Part 2. In Part 3 we are going to explore how to use a Change View to collect data that has changed in your subscription.

Using an InterBase Change View to fetch data deltas

Once a Change View Subscription has been created and access to it has been granted (to either users or roles), then its time to start using your Change View!

The following steps are the high level overview of using a Change View.

Start a Transaction in SnapShot isolation mode.
Set the Subscription active
Run your select statement to fetch you delta
Once you have collected the delta commit your transaction to bring your Change View up to date.

SnapShot Mode

OK a bit of background as we all love to know how things work..

InterBase is powered by a multi-generational architecture which is exceptionally useful when data integrity is important. imagine you need to run multiple financial reports while the system is live;  Imagine a connection drops part way through a big data change how do you know what has changed? Multi-generational architectures and transactions makes this possible.

Using a transaction set to SnapShot mode we have a stable point in time that means even if records are updated at the same time as your transaction, they are not missed. When you start your next transaction you will locate those concurrently made changes! – imagine trying to do that with date time stamp tracking!

This means you can have multiple users updating the data at the same time safely without having to lock the tables :-)

Setting the subscription active

At this point, lets pretend we have a STOCK table and we run the following statement

Select * from STOCK

the data returned would be all the STOCK records.

How do we get from here to just getting changed data deltas? Well, first we need to activate the subscription and provide an ID that we are going to track against.

set subscription sub_stock at ‘DeviceID’ active;

With the subscription “sub_stock” active, running the initial statement will again return all records as its the first time data has been requested in the subscription.

At this point there are two possible next steps: Commit or Rollback.

Rollback of the transaction will ensure the data is provided again, Commit will bring the Subscription up to date for the start of the transaction.

Running the Select statement again in an active transaction with the subscription active will now return only delta’s

Preventing you data changes showing in your Change View delta

So we have covered selecting data, but what about updating data? How do you stop the changes to data you make appearing in your subscription yet still available to others? Well simply, make the changes while your subscription is active.

Start a Transaction in SnapShot isolation mode.
Set the Subscription active (using your ID)
Run your update statement to modify the data
Commit your transaction.

Simples!

Introduction to Change Views Video on Embarcadero website

Introduction to InterBase Change Views

 

To see a Change View code example see the InterBase XE7 FirstLook webinar

The post InterBase Change Views – Part 3 – Using a change view appeared first on Stephen Ball's Technical Blog.

Posted by Stephen Ball on February 7th, 2015 under Uncategorized | Comment now »




Server Response from: BLOGS1