# An Architecture for Reliable Transportation of Delicate Goods
## 4 The Main Scenario
### Bluetooth Low Energy--Services, Characteristics and Access Modes  
A brief reference to BLE is provided on this section. BLE has been a privileged technology within the scope of IoT and widely present on mobile phones. It is easy and cheap to implement an application that communicates with BLE devices, to monitor or control them. The mobile phone can even be used as a gateway between BLE and the internet, putting the devices on the net according to the concept of IoT. BLE is also present on tablets, laptops or desktops, which is also relevant for the present work. Additionally, it can be made available as an external module to the chip or embedded in it (SoC--System on a Chip), as is the case of the chip used to validate the architecture (Nordic SemiConductors nRF52832 [40]).  
BLE defines two roles: the central and the peripheral. The peripheral defines services for aggregating characteristics. Each characteristic can be available with one or more access modes, such as reading, writing or notification. The central device behaves like a client that connects to a server (peripheral device) and access the characteristics, being the effective communication done by reading and writing in the characteristics. Depending on the processor and of the stack that implements BLE, the write and, eventually, read of a characteristic can trigger an event on the peripheral side. For characteristics available in notification mode, whenever its value changes, there is a notification that triggers an event on the central device. The characteristics are defined within the scope of a service, which can have one or more characteristics. When enabling/disabling a service, the respective characteristics are enabled/disabled.  
The devices must include components to signaling their status, allowing users to check whether they are in advertise or connected mode--an LED (Light Emitting Diode) can be used for this purpose. Moreover, Type B devices must also include a button to initiate the advertise mode. In brief, the BLE communication procedure goes through the following steps:  
1. The peripheral device is placed in advertise mode that transmits the indication that the device is available, possibly with information about the available services (each service has its own identifier).
2. The central device is placed in scan mode looking for advertise signals. It can be pre-configured to only search for peripherals that advertise certain services.
3. If the peripheral device is found, the central can then request the connection.
4. The connection then takes place, which may involve security procedures, with different levels of implementation--some of which are used in the proposed architecture.
5. The central can read/write in the characteristics available with these types of access or enable the characteristics that can be used on the notification mode.  
The peripheral device can notify the central device via characteristics of this type (already enabled).
7. The connection between devices can be closed by any of the devices.  
The central role is performed by the mobile device (smartphone). It can also be performed by a device operating in (c) mode, as explained at Section 5.3.