In the last article (No. 1), a program (with microbit JavaScript block editor) that sends Eddystone signals (either Eddystone-UID or Eddystone-URL) and a program that receives it with Android (by MIT App Inventor) were presented.
In this article, Eddystone-URL data that should be adversised by maicro:bit is updated from Android side. To do that, I use the Bluetooth UART service (serial over Bluetooth). Overview of the mechanism is as shown in the figure below.
Let's see the operation of Android. (a) is the initial state. In (b) we are sending a new URL to the micro bit in response to a request. In (c), the URL currently stored in microbit should be sent back for confirmation.
URL information updating |
Next, I will examine the source program briefly. The figure below is a micro:bit program. When you press button B, URL information should be received from Android side. Also, if you touch pin P0, it will send the current URL to Android. Press button A to advetise the URL.
The main parts of the Android program created with MIT App Inventor are shown below. We are communicating using BLE's UART, but in App Inventor we can use BLE extensions, which makes it very concise. However, in addition to this, connection settings with a standard BLE device, decoding of URL information, etc. are also necessary.
Finally, here is the result of displaying the web page of the adverrtised URL in another application. For example, in the above figure, we setup 6 characters "RwaMqL". This is the actual URL with the header "http://goo.gl/" appended. However, this is a shortened version of the original URL. That's because of the limitation of the number of characters that can be advertised.
The shortened URL "RwaMqL" denotes Dept. of Mathematics, Hokkaido Univ.
0 件のコメント:
コメントを投稿