Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
D_Sensei
Created March 20, 2020 © GPL3+

Hazard Zone Awareness

A beacon is placed in a hazardous area for a mobile device to discover and alert its operator of the local hazard.

IntermediateFull instructions provided8 hours67

Things used in this project

Hardware components

RSL10-SENSE-GEVK
onsemi RSL10-SENSE-GEVK
This kit includes the Segger J-Link LITE Cortex-M debugger for flashing firmware and a battery.
×1
Android device
Android device
×1

Software apps and online services

Android Studio
Android Studio
onsemi ON Semiconductor IDE
Drupal CMS
XAMPP
Windows 10
Microsoft Windows 10

Story

Read more

Code

ble_broadcaster_eddystone\include\app_config.h

C/C++
The example code in the CMSIS Pack Manager for ble_broadcaster_eddystone is configured for the RSL10-COIN board. This app_config.h file updates the PIN assignments and tells the compiler to use a custom board instead of the COIN board.
//-----------------------------------------------------------------------------
// Copyright (c) 2019 Semiconductor Components Industries LLC
// (d/b/a "ON Semiconductor").  All rights reserved.
// This software and/or documentation is licensed by ON Semiconductor under
// limited terms and conditions.  The terms and conditions pertaining to the
// software and/or documentation are available at
// http://www.onsemi.com/site/pdf/ONSEMI_T&C.pdf ("ON Semiconductor Standard
// Terms and Conditions of Sale, Section 8 Software") and if applicable the
// software license agreement.  Do not use this software and/or documentation
// unless you have carefully read and you agree to the limited terms and
// conditions.  By using this software and/or documentation, you agree to the
// limited terms and conditions.
//-----------------------------------------------------------------------------
//!
//! \file app_config.h
//!
//! Header containing configurable parameters of the application.
//!
//! This file uses the CMSIS Configuration Wizard Annotations.
//! It can be opened by right clicking it in Project Explorer and selecting:
//!     Open With -> CMSIS COnfiguration Wizard
//!
//-----------------------------------------------------------------------------

#ifndef APP_EDDYSTONE_CONFIG_H
#define APP_EDDYSTONE_CONFIG_H

// <<< Use Configuration Wizard in Context Menu >>>

// <h> Eddystone Beacon Configuration
// <i> Configures what types of Eddystone packets should be used.

// <e> Eddystone UID [on/off]
#define CFG_EDDY_UID_ENABLE  1

// <o> Tx Power [dBm]
// <i> TX power level to use for this type of advertising packet.
// <i> Allowed range is from -17 dBm up to 6 dBm.
// <i> Default: 0 dBm
#define CFG_EDDY_UID_TX_POWER  0

// <o> Advertising Interval [ms] <100-999999>
// <i> Eddystone specification declares allowed adv. interval range as 100 ms up to 5000 ms.
// <i> Default: 1000 ms
#define CFG_EDDY_UID_ADV_INT  1000

// <s> Namespace
#define CFG_EDDY_UID_NAMESPACE  "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A"

// <s.14> Instance
#define CFG_EDDY_UID_INSTANCE  "\x01\x02\x03\x04\x05\x06"

// </e>

// <e> Eddystone URL [on/off]
#define CFG_EDDY_URL_ENABLE  0

// <o> Tx Power [dBm]
// <i> TX power level to use for this type of advertising packet.
// <i> Allowed range is from -17 dBm up to 6 dBm.
// <i> Default: 0 dBm
#define CFG_EDDY_URL_TX_POWER  0

// <o> Advertising Interval [ms] <100-999999>
// <i> Eddystone specification declares allowed adv. interval range as 100 ms up to 5000 ms.
// <i> Default: 1000 ms
#define CFG_EDDY_URL_ADV_INT  1000

// <o> URL Sheme Prefix
// <0=> http://www.
// <1=> https://www.
// <2=> http://
// <3=> https://
#define CFG_EDDY_URL_PREFIX  1

// <s> Encoded URL
// <i> Encoded part of URL that follows the URL Prefix
// <i> Text expansion codes can be inserted as escaped octal digit into the string.
// <i> Default: "onsemi\000b-idk" (12 bytes) which expands into "onsemi.com/b-idk" (16 bytes)
#define CFG_EDDY_URL_ENCODED_URL  "onsemi\000b-idk"

// </e>

// <e> Eddystone TLM [on/off]
#define CFG_EDDY_TLM_ENABLE  1

// <o> Tx Power [dBm]
// <i> TX power level to use for this type of advertising packet.
// <i> Allowed range is from -17 dBm up to 6 dBm.
// <i> Default: 0 dBm
#define CFG_EDDY_TLM_TX_POWER  -17

// <o> Advertising Interval [ms] <100-999999>
// <i> Eddystone specification declares allowed adv. interval range as 100 ms up to 5000 ms.
// <i> Default: 5000 ms
#define CFG_EDDY_TLM_ADV_INT  5000

// </e>

// <e> Device Name [on/off]
#define CFG_EDDY_NAME_ENABLE  1

// <o> Tx Power [dBm]
// <i> TX power level to use for this type of advertising packet.
// <i> Allowed range is from -17 dBm up to 6 dBm.
// <i> Default: 0 dBm
#define CFG_EDDY_NAME_TX_POWER  -17

// <o> Advertising Interval [ms] <100-999999>
// <i> Eddystone specification declares allowed adv. interval range as 100 ms up to 5000 ms.
// <i> Default: 5000 ms
#define CFG_EDDY_NAME_ADV_INT  5000

// <s.25> Complete Local Name
#define CFG_EDDY_NAME_VALUE  "ble_broadcaster_eddystone"

// </e>

// </h>


// <h> Hardware Configuration

// <o> Board selection
// <i> Switch to Source Editor to set pin map if Custom board is used.
// <0=> RSL10-COIN-GEVB r0.1
// <1=> TWHBC giveaway rev0.1
// <2=> RSL10 Evaluation Board
// <3=> Custom
#define CFG_HW_BOARD_SELECTION  3  //For the RSL10-SENSE-GEVB

// <h> Temperature sensor configuration

// <o> Operation mode
// <i> On demand - Sensor is initialized and enabled on request when Eddystone TLM is used.
// <i> Disabled - Sensor is initialized but no measurements will be done.
// <i> Not present - No communication with sensor. Can be used on boards without temperature sensor.
// <0=> On demand
// <1=> Disabled
// <2=> Not present
#define CFG_HW_TEMP_SENSOR_MODE  0

// <o> Sample Rate [s] <1-86400>
// <i> Select temperature sensor sample rate that is independent of TLM advertising.
// <i> Default: 10s
#define CFG_HW_TEMP_SENSOR_SAMPLE_RATE  10

// </h>

// <h> LED Indication Configuration
// <i> Configure which events are to be indicated by on-board LEDs.

// <e> Startup Indication [on/off]
// <i> Turn on LED during start-up or when waking up from power down mode.
#define CFG_HW_LED_STARTUP_IND  1

// <o> PWM Duty Cycle <0-255>
// <i> Range: 0 - 255
#define CFG_HW_LED_STARTUP_IND_DUTY  32

// </e>

// <e> BLE Advertising Indication [on/off]
// <i> Turn on LED while advertising is in progress.
#define CFG_HW_LED_ADV_IND  1

// <o> PWM Duty Cycle <0-255>
// <i> Range: 0 - 255
#define CFG_HW_LED_ADV_IND_DUTY  64

// </e>

// <e> Power Down mode enter indication [on/off]
// <i> Turn on LED for a moment when entering Power Down mode
#define CFG_HW_LED_PDOWN_IND  1

// <o> PWM Duty Cycle <0-255>
// <i> Range: 0 - 255
#define CFG_HW_LED_PDOWN_IND_DUTY  255

// <o> Indication Time [ms] <1-5000><#*32>
// <i> For how long to keep the LED on before entering power down mode.
#define CFG_HW_LED_PDOWN_IND_DELAY 32000

// </e>

// <e> DFU mode enter indication [on/off]
// <i> Turn on LED for a moment when entering Power Down mode
#define CFG_HW_LED_DFU_IND  1

// <o> PWM Duty Cycle <0-255>
// <i> Range: 0 - 255
#define CFG_HW_LED_DFU_IND_DUTY  255

// <o> Indication Time [ms] <1-5000><#*32>
// <i> For how long to keep the LED on before entering DFU mode.
#define CFG_HW_LED_DFU_IND_DELAY 16000

// </e>

// </h>

// </h>


// <h> Debug Trace Configuration
// <i> Controls whether tracing message are used.

// <o> Trace Method
// <i> Disable or enable trace messages over selected channel.
// <i> Note: RTT trace is not retained during deep sleep.
// <0=> Disabled
// <1=> UART
// <2=> RTT
#define CFG_TRACE_TYPE  1

// <h> UART Configuration

// <o> Baud Rate
// <230400=> 230400
// <115200=> 115200
// <9600=> 9600
#define CFG_TRACE_UART_BAUD_RATE  230400

// <o> Maximum message size [bytes]
// <i> Maximum string size that can be transmitted over UART.
// <i> Buffer of this size will be allocated in memory.
// <i> Default: 100
#define CFG_TRACE_UAR_MAX_SIZE_STR  100

// </h>

// </h>


// <h> FOTA Application Information

// <h> Application Identifier
// <i> Short identification string for this application.
// <i> Must be 6 characters long.

// <s.6> Debug build
// <i> Short identification string for this application.
// <i> Must be 6 characters long.
#define CFG_FOTA_VER_ID_DEBUG  "BREDCd"

// <s.6> Release build
// <i> Short identification string for this application.
// <i> Must be 6 characters long.
#define CFG_FOTA_VER_ID_RELEASE  "BREDCr"

// </h>

// <h> Version

// <o> Major <0-255>
// <i> Range: 0 - 255
#define CFG_FOTA_VER_MAJOR  1

// <o> Minor <0-255>
// <i> Range: 0 - 255
#define CFG_FOTA_VER_MINOR  1

// <o> Revision <0-255>
// <i> Range: 0 - 255
#define CFG_FOTA_VER_REVISION  2

// </h>
// </h>


// <<< end of configuration section >>>


// ---------------------------------------------------------------
// Select proper Pin Map based on selected board.
// ---------------------------------------------------------------

#define BOARD_RSL10_COIN_GEVB  0
#define BOARD_TWHBV_GIVEAWAY   1
#define BOARD_RSL10_EVK        2
#define BOARD_CUSTOM           3

#define TEMP_ON_DEMAND         0
#define TEMP_DISABLED          1
#define TEMP_NOT_PRESENT       2

#if (CFG_HW_BOARD_SELECTION == BOARD_RSL10_COIN_GEVB)
#define PIN_SCL         1
#define PIN_SDA         9
#define PIN_UART_TX     3 /* GIO_SPARE - routed to interface header. */
#define PIN_UART_RX     5 /* TP1 - test point. */
#define PIN_BUTTON      0
#define PIN_LED_GREEN   11
//#define PIN_LED_RED     -1 /* Not available on this board. */
#elif (CFG_HW_BOARD_SELECTION == BOARD_TWHBV_GIVEAWAY)
#define PIN_SCL         6
#define PIN_SDA         7
#define PIN_UART_TX     4
#define PIN_UART_RX     5
#define PIN_BUTTON      2
#define PIN_LED_GREEN   9
#define PIN_LED_RED     11
#elif (CFG_HW_BOARD_SELECTION == BOARD_RSL10_EVK)
#define PIN_SCL         7
#define PIN_SDA         8
#define PIN_UART_TX     5
#define PIN_UART_RX     4
#define PIN_BUTTON      0
#define PIN_LED_GREEN   6
#elif (CFG_HW_BOARD_SELECTION == BOARD_CUSTOM) //For the RSL10-SENSE-GEVB
#define PIN_SCL         5
#define PIN_SDA         4
#define PIN_UART_TX     3
#define PIN_UART_RX     7
#define PIN_BUTTON      15
#define PIN_LED_GREEN   1
#define PIN_LED_RED     2
#else
#error Invalid value of CFG_HW_BOARD_SELECTION.
#endif /* CFG_HW_BOARD_SELECTION */

// Override I2C pin map from RTE_Device.h for the CMSIS-Driver
#define RTE_I2C0_SDA_PIN_DEFAULT PIN_SDA
#define RTE_I2C0_SCL_PIN_DEFAULT PIN_SCL

// ---------------------------------------------------------------
// Select proper FOTA application ID
// ---------------------------------------------------------------

#ifdef NDEBUG
#define CFG_FOTA_VER_ID CFG_FOTA_VER_ID_RELEASE
#else
#define CFG_FOTA_VER_ID CFG_FOTA_VER_ID_DEBUG
#endif /* NDEBUG */

// ---------------------------------------------------------------
// Check configuration
// ---------------------------------------------------------------

#if (CFG_EDDY_UID_TX_POWER < -17 || CFG_EDDY_UID_TX_POWER > 6)
#warning Value of CFG_EDDY_UID_TX_POWER is out of allowed range.
#endif /* CFG_EDDY_UID_TX_POWER < -17 || CFG_EDDY_NAME_TX_POWER > 6 */

#if (CFG_EDDY_URL_TX_POWER < -17 || CFG_EDDY_URL_TX_POWER > 6)
#warning Value of CFG_EDDY_URL_TX_POWER is out of allowed range.
#endif /* CFG_EDDY_URL_TX_POWER < -17 || CFG_EDDY_URL_TX_POWER > 6 */

#if (CFG_EDDY_TLM_TX_POWER < -17 || CFG_EDDY_TLM_TX_POWER > 6)
#warning Value of CFG_EDDY_TLM_TX_POWER is out of allowed range.
#endif /* CFG_EDDY_TLM_TX_POWER < -17 || CFG_EDDY_TLM_TX_POWER > 6 */

#if (CFG_EDDY_NAME_TX_POWER < -17 || CFG_EDDY_NAME_TX_POWER > 6)
#warning Value of CFG_EDDY_NAME_TX_POWER is out of allowed range.
#endif /* CFG_EDDY_NAME_TX_POWER < -17 || CFG_EDDY_NAME_TX_POWER > 6 */

//#if (PIN_BUTTON > 3)
//#warning DIO pad assigned to PIN_BUTTON must be in range 0 - 3.
// DIO Pads 0 - 3 needed for deep sleep wake-up functionality.
//#endif /* (PIN_BUTTON > 3) */


#endif    /* APP_EDDYSTONE_CONFIG_H */

Hazard Zone Awareness Android App

Activates beacon detection on an Bluetooth Low Energy Android device.

Credits

D_Sensei

D_Sensei

1 project • 0 followers

Comments