## @file  Eddystone_Beacon_naviaglonass_ru.py
##
## <!-- Copyright 2016 by NAVIA.  All rights reserved. -->
##

# Reset BlueNRG/BlueNRG-MS 
RESET()
# Set Public Address
SET_PUBLIC_ADDRESS(0x123456789AAA)
# Init GATT 
if  ACI_GATT_INIT()!=0x00:
    ERROR('ACI_GATT_INIT FAILED')

# Init GAP as peripheral device
status,_,_,_=  ACI_GAP_INIT(Role=PERIPHERAL)
if status !=0x00:
    ERROR('ACI_GAP_INIT CALL FAILED')

#Set TX power level
ACI_HAL_SET_TX_POWER_LEVEL(En_High_Power=1,PA_Level = 4) 

# Put device in non-connectable mode
status = ACI_GAP_SET_DISCOVERABLE(Advertising_Type=0x03, Advertising_Interval_Min=160, Advertising_Interval_Max=160, Local_Name_Length = 0x0, Local_Name = 0x0)
if status !=0x00:
    ERROR('ACI_GAP_SET_DISCOVERABLE CALL FAILED')

#Remove this AD type otherwise  beaconPayload exceed the maximum size
#status = ACI_GAP_DELETE_AD_TYPE (ADType=0x0A)
#if status !=0x00:
#    ERROR('ACI_GAP_DELETE_AD_TYPE CALL FAILED')

# Define the beacon payload to be used within the advertising data
beaconPayload = [
	0xAA, 0xfE,					# 16-bit Eddystone UUID
	0x10,						# Frame Type: 0x10 URL
	0xF1,						# TX Power
	0x02,						# URL Scheme: http://
	0x6E,						# naviaglonass
	0x61,
	0x76,
	0x69,
	0x61,
	0x67,
	0x6C,
	0x6F,
	0x6E,
	0x61,
	0x73,
	0x73,
	0x2E,						# .ru/
	0x72,
	0x75,
    ]	

lenData= len(beaconPayload)+1

        
#AD type 0xFF = Manufacturer Specific Data ->  2 or more octets
#Description = The first 2 octets contain the company Identifier Code followed by additional manufactures specific data 
data = [lenData , 0x16 ] + beaconPayload

# Update advertising data 
status = ACI_GAP_UPDATE_ADV_DATA( AdvDataLen=len(data), AdvData= data)
if status !=0x00:
    ERROR('ACI_GAP_UPDATE_ADV_DATA CALL FAILED')
## @endcond






