Mobillyo IOS APP

Mobillyo IOS App Main Screen

Introduction

The Mobillyo IOS app is an application that enables a user to remotely control a Mobillyo Arduino compatible board or any other device with the Nordic nrf51 or nrf52 and the Nordic UART characteristics.

Mobillyo App Features

LEDs

There are 4 LEDs that can be red, green or off depending on the message received from the Mobillyo Arduino compatible board. The LED’s title can also be changed dynamically.

Push Buttons

The 4 push buttons send messages to the Mobillyo Arduino compatible board when a user touches them.

Switches

The 4 switches  send messages to the Mobillyo Arduino compatible board when a user toggles them.

Sliders

The 4 sliders  send messages to the Mobillyo Arduino compatible board while a user moves them. The last value received is the stop value.

Text Box

The text box receives text data from the Mobillyo Arduino compatible board.

Mobillyo IOS App Select Device Screen

Connecting to the Mobillyo Board

Make sure that Bluetooth is on in the iPhone or iPad settings screen.

When you enter the app touch the bottom left connect button. You will be transfered to the Bluetooth scan results screen. Select the Mobillyo device. You will automatically return to the main screen and the Mobillyo name will be at the bottom right. The Connect button now becomes a disconnect button.

Mobillyo IOS App Log screen

Log Screen

The log screen is only used to debug an application you are developping on the Mobillyo Arduino compatible board. It is not used in normal operations.

Tap the left menu icon on the main navigation bar to access the log screen. This screen shows all the Bluetooth events when you are connected to a Mobillyo Arduino compatible board or any other device with the Nordic nrf51 or nrf52 and the UART characteristics. This includes messages received from and sent to the Mobillyo Arduino compatible board.

There is a text box at the top of the screen to send messages to the Mobillyo for testing. The messages must be in the format specified in the Protocol definition document. Messages that do not conform to the protocol may have unpredictable results.  

Tap the same navigation icon a second time to return to the main screen.

Managing Objects

The default objects are created when the app first loads.

If an object (LED, Switch, Push Button, Slider or text box) is not needed it can de deleted by a type 3 message from the Mobillyo Arduino compatible board.

Deleted objects can be re-created. Objects are saved in the app when the app enters the background and re-created when the app launches. The state of the objects is saved in the iPhone or iPad using core-data. Type 1 messages create objects and defines their positions on the screen.

Creating Objects

The steps are:

  1. Enter the app.
  2. Connect to the Mobillyo.
  3. Send object type 3 and type 1 messages to create, delete or move objects.
  4. Quit the app.
  5. Re-enter the app.

Updating Object Properties

Object properties can be set as part of the object creation as described above. Some properties can be changed by type 1 and type 2 messages. Type 1 messages are usually longer and should be uses less often. Type 2 messages are designed to be shorter and faster.

Object Properties:

Object properties are updated dynamically without having to quit the app or send it to the background.

LEDs:  off, Red or green,  changed by type 2 message. The LED labels can be changed with type 1 messages if needed.

Pushbutton Switches: Pushbutton text can be changed with type 2 messages. For example if a button has 2 (or more) states start and stop, the Mobillyo board can send a type 2 message in response to a pushbutton message received from the app (button 32 tapped). The message would have the new information to update the pushbutton text.

Sliders:  Only a Slider label text can be updated dynamically with a type 1 message.

Toggle Switches: A switch label can be updated dynamically with a type 1 message.

Important note: All messages sent must contain all elements. For example a type 1 message updating a slide switch label must also contain the switch x and y positions.

Each screen object has a distinct number shown on the image to the left.

License

Copyright (C) 2017 Seenov inc.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”.

This document is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Free Documentation License for more details.

Introduction

The ATMega32u4 communicates with the nrf52 over I2C. The AtMega32U4 is the master and the nrf52 is the slave. Messages from the ATmega32U4 are passed unchanged over Bluetooth to the iPhone. Maximum block length is 20 bytes but a whole message can be made up of up to 5 blocks. Messages from the iPhone are stored in the nrf52 while the nrf52 interrupts the ATmega32U4 requesting a I2C read. The ATmega32U4 must read a message before a second one arrives to avoid the message being lost. The ATmega32U4 can send and receive messages to the nrf52 only for local LEDs and read back of battery/solar power voltages. nrf52 I2C address is 86 decimal or 0x56.

Message Structure

A message is composed of a start character, a number of components separated by a ; delimiter and a stop character. Each message is sent in blocks of 20 bytes or less. A short message can have 1 block of less than 20 bytes while a long message can have multiples blocks of 20 bytes or less.

Message structure :

Start ; length ; control ; Type of variable ; variable number ; value ; title ; desc ; window ; xpos ; ypos ; endofmsg

bytes 1 1-3 1 1 1 -2 1- 4 1-7 0-24 1 1- 4 1-4 1

Message length = max length = 100 1,2 or 3 ASCII characters. The length is not implemented nil can be used = > start;;control; etc

Start and end only on the first and last blocks for messages greater than 20 bytes

Start “{” = start of msg,

End OF Msg = ” }”

; = delimiter

control = 1==> variable creation and initialization use full message decoding in this order:

Type of variable

Variable number

Value

Title

Description not implemented except for text

Window; not implemented = 0

Xpos; x position on screen

Ypos; y position on screen

All parts/components of msg must be included if nil = ;;

Control = 2 ==> variable update

Start ; length ; control ; Type of variable ; variable number  ; value ; endofmsg

control =3 ==> delete variable same structure and components as type 2 even if the value =”0″ only the control and variable number are decoded

control =4 ==> I/O local to nrf52 is not passed to BLE only between Arduino and nrf52

Type Description Xcode implementation Variable number Number of bytes
10 Virtual LED display state sent by ATmega32U4 UIImageView 1 to 8 empty circle or red,green circle

value =0 off,

1 = green

2 = red

0,1,2,3

4,5,6,7

not implemented

1
1
1 Virtual Slide Switch can be displayed and changed on UI on or off UISwitch 1 to 8 8-11,

12-15 not implemented

1
2 Analog input, can be displayed not changed on UI UILabel 1 to 8 16… 23

Not implemented

ASCII up to 6 bytes
3 slider is displayed and changed on UI as slider with max value UISlider 1 to 8 24-27

28-31Not implemented

ASCII up to 6 bytes
5 Virtual Push Button displayed and changed on UI UIButton 1 to 8 32-35

36-39 Not implemented

1 byte value is 3 indicting a touch
6 Text Box Display can be displayed not changed on UI 24 characters 4 lines UITextView qty 2 40,

41 not implemented

96 bytes displayed txt = value
7 Text Box Input can be displayed and changed on UI UITextView qty 4 42,43,44,45

not implemented

7 bytes
8 Line Graph Display can be displayed not changed on UI scaled and auto autoscroll values should be short if possible tbd qty 1 0 Not implemented tbd
9 RGB 32 x 32 Display tbd tbd qty 1 0 Not implemented tbd
11 nrf52 local variables solar bat volts must be requested to read 1 80 1 to 4 ;1; to ;9999;
11 nrf52 local variables solar panel volts must be requested to read 1 81 1 to 4
11 nrf52 local variables solar panel current must be requested to read 1 82 1 to 4
12 nrf52 local led 2 txled90, rxled 91 0= off, 1 = on,

Note max number of windows = Only window 0 implemented

x,y may change depending on phone or pad                 0—————————–> x

  Y from top left to bottom

Message Examples

Create a switch transmit message in 2 blocks of less than 20 bytes with 100 msec delays

{;;1;1;8;1;Turbo;; 0;55;205;} create switch 8

{;;1;1;9;1;Switch2;; 0;135;205;} create switch 9

{;;1;1;10;1;Switch3;; 0;215;205;} create switch 10

{;;1;1;11;1;Switch 4 ;;0;195;205;} create switch 11

for example create switch 8 with label Turbo at x = 55, y = 205

Wire.beginTransmission(86); // nrf52 address is 0x56 = 86 dec.

Wire.write(“{;;1;1;8;1;Turbo;;”); // create switch 8 with label Turbo first block

Wire.endTransmission(); // stop transmitting

delay(100);

Wire.beginTransmission(86);

Wire.write(“0;55;205;}”); // second block

Wire.endTransmission(); // stop transmitting

delay(100);

Remove switch 8

Wire.beginTransmission(86); // nrf52 address is 0x56 = 86 dec.

Wire.write(“{;;3;1;8;0;}”);

Wire.endTransmission(); // stop transmitting

Send text display in 3 blocks of 20 bytes or less

{;;1;6;40;0;;text se nt from Mobillyo;0;2 0;90;}

Wire.beginTransmission(86); // part address is 0x56

Wire.write(“{;;1;6;40;0;;Text se”); // first block

Wire.endTransmission(); // stop transmitting

delay(100);

Wire.beginTransmission(86); // part address is 0x56

Wire.write(“nt from Mobillyo;0;2”); // second block

Wire.endTransmission(); // stop transmitting

delay(100);

Wire.beginTransmission(86); // part address is 0x56

Wire.write(“0;90;}”); // trird block

Wire.endTransmission(); // stop transmitting

Turn on LED connected to nrf52 one block message

Wire.beginTransmission(86); // part address is 0x56

Wire.write(“{;16;4;12;90;1;}”); // or Wire.write(“{;;4;12;90;1;}”);

Wire.endTransmission(); // stop transmitting

Notes

I2C messages maximum length is 20 bytes

BLE requires max data to be 20 bytes.

nrf52 serial port

baud rate 115200 8 bits, no parity, 1 stop, no flow control