Let’s recap what we covered in the previous articles within this series:
讓我們回顧一下我們?cè)诒鞠盗械那皫灼恼轮兴婕暗膬?nèi)容:
- Requirements, installation, and setup steps for using the mobile app
- 使用移動(dòng)應(yīng)用程序的要求、安裝和設(shè)置步驟
- Overview of the different sections within the app
- 應(yīng)用程序內(nèi)不同部分的概述
- Running a few test case scenarios with different advertising data types
- 用不同的廣播數(shù)據(jù)類型運(yùn)行一些測(cè)試案例場景
- A detailed look at device filters
- 詳細(xì)了解設(shè)備過濾器
- Differences between the iOS and Android versions of the app
- 該應(yīng)用程序的iOS和Android版本之間的差異
In this particular tutorial, we will focus on one of the most unique features of our app: App Notifications (even in the background) for detecting Triggered Advertising Sets.
在這個(gè)特別的教程中,我們將專注于我們應(yīng)用程序的一個(gè)最獨(dú)特的功能:應(yīng)用通知(甚至在后臺(tái)),用于檢測(cè)觸發(fā)的廣播集。
So, how do these work? what exactly do we mean by “Triggered”? What are the limitations of app notifications in both versions of the app (Android and iOS)?
那么,這些是如何工作的?"Triggered "到底是什么意思?在兩個(gè)版本的應(yīng)用程序(安卓和iOS)中,應(yīng)用程序通知的限制是什么?
Triggered Advertising Sets觸發(fā)式廣播集
Triggered advertising sets allow the user to configure the device to send advertising packets only when certain conditions occur.
觸發(fā)式廣播集允許用戶配置設(shè)備,使其僅在某些條件發(fā)生時(shí)發(fā)送廣播包。
This can be very useful in use cases where advertising packets are only needed when one or more conditions are met, for example, the battery level going below 10% or the temperate going over 40 degrees Celsius. In this case, sending advertising data all the time regardless of these conditions (which is what is referred to as “Continuous Advertising Mode” in the NanoBeacon Config Tool) would unnecessarily increase battery consumption, so it makes sense to only send them out based on certain conditions.
這對(duì)于只有在滿足一個(gè)或多個(gè)條件時(shí)才需要廣播數(shù)據(jù)包的用例非常有用,例如,電池電量低于10%或溫度超過40攝氏度。在這種情況下,不管這些條件如何,一直發(fā)送廣播數(shù)據(jù)(這就是NanoBeacon配置工具中所說的 "連續(xù)廣播模式")會(huì)不必要地增加電池消耗,所以只根據(jù)某些條件發(fā)送廣播是有意義的。
Here’s a look at the various options available for this mode within the NanoBeacon Config Tool:
下面我們來看看NanoBeacon配置工具中該模式的各種可用選項(xiàng):
1、Triggered advertising event count: this defines the number of advertising events transmitted if a triggered condition is met.
1、觸發(fā)的廣播事件計(jì)數(shù):這定義了在滿足觸發(fā)條件時(shí)傳輸?shù)膹V播事件的數(shù)量。
2、Trigger event will reset triggered advertising event count: enabling this will reset the advertising event count set above in #1, meaning that if any of the trigger conditions are met, it will keep resetting the count and continue sending the advertising packets. Once none of the trigger conditions are met, the advertising event count will start decrementing. For example, suppose this option was enabled, and the trigger condition was a high threshold for internal temperature ≥ 25 deg C, and the temperature surpassed this threshold. In that case, it will continue sending advertising events until the temperature is below the threshold, and then it will only send the number of advertising events set in option #1.
2、觸發(fā)事件將重置被觸發(fā)的廣播事件計(jì)數(shù):啟用這個(gè)功能將重置上面#1中設(shè)置的廣播事件計(jì)數(shù),這意味著如果滿足任何一個(gè)觸發(fā)條件,它將不斷重置計(jì)數(shù)并繼續(xù)發(fā)送廣播數(shù)據(jù)包。一旦沒有一個(gè)觸發(fā)條件被滿足,廣播事件計(jì)數(shù)將開始遞減。例如,假設(shè)該選項(xiàng)被啟用,而觸發(fā)條件是內(nèi)部溫度≥25攝氏度的高閾值,并且溫度超過了這個(gè)閾值。在這種情況下,它將繼續(xù)發(fā)送廣播事件,直到溫度低于閾值,然后它將只發(fā)送選項(xiàng)#1中設(shè)置的廣播事件數(shù)量。
3、Single trigger, Recurring trigger, Advertise indefinitely after 1st trigger:
3、單次觸發(fā)、重復(fù)觸發(fā)、第1次觸發(fā)后無限期廣播:
- Single Trigger: choosing this type will set the behavior to only send the advertising events upon any of the trigger conditions being met just once. If the trigger conditions are met later (during the same power cycle), no advertising events will be transmitted.
- 單次觸發(fā):選擇這種類型將設(shè)置行為,只在任何一次觸發(fā)條件被滿足時(shí)才發(fā)送廣播事件。如果以后再滿足觸發(fā)條件(在同一電源周期內(nèi)),將不發(fā)送廣播事件。
- Recurring Trigger: choosing this type will send out advertising events every time a trigger condition is met.
- 循環(huán)觸發(fā):選擇這種類型,每次觸發(fā)條件被滿足時(shí)都會(huì)發(fā)送廣播事件。
- Advertise indefinitely after 1st trigger: as the name suggests, choosing this type will send out advertising events indefinitely after any of the trigger conditions are met.
- 第1次觸發(fā)后無限期廣播:顧名思義,選擇這種類型將在滿足任何觸發(fā)條件后無限期地發(fā)送廣播事件。
4、Sensor trigger source: this defines one or more sources for trigger conditions, which are set in the “Global Trigger Settings” section within the NanoBeacon Config Tool. Examples of trigger sources include VCC, Internal Temperature, ADC channels, 1-wire sensor readings, and I2C slave readings.4、傳感器觸發(fā)源:這定義了一個(gè)或多個(gè)觸發(fā)條件的來源,在 NanoBeacon 配置工具中的 "全局觸發(fā)設(shè)置 "部分設(shè)置。觸發(fā)源的例子包括VCC、內(nèi)部溫度、ADC通道、單線傳感器讀數(shù)和I2C從屬讀數(shù)。
5、GPIO trigger source: this defines one or more sources for trigger conditions based on GPIO status. The GPIOs available are: GPIO2, GPIO3, MGPIO4, MGPIO5, MGPIO6, and MGPIO7.
5、GPIO觸發(fā)源:這定義了一個(gè)或多個(gè)基于GPIO狀態(tài)的觸發(fā)條件源。可用的GPIO是:GPIO2, GPIO3, MGPIO4, MGPIO5, MGPIO6, 和 MGPIO7.
Keep in mind that the triggered event will occur if anyof the defined conditions are met.
請(qǐng)記住,如果滿足任何定義的條件,觸發(fā)的事件就會(huì)發(fā)生。
Triggered Advertising Sets on the Mobile App移動(dòng)應(yīng)用上的觸發(fā)式廣播集
Now that we better understand how triggered advertisements work and the different options available, we can now test them out to see what they look like and how they behave on both the Android and iOS versions of the mobile app.
現(xiàn)在我們更好地了解了觸發(fā)式廣播的工作原理和不同的選項(xiàng),我們現(xiàn)在可以測(cè)試一下,看看它們?cè)谝苿?dòng)應(yīng)用的安卓和iOS版本上是什么樣子的,表現(xiàn)如何。
Referring back to the previous article, where we covered the differences between the iOS and Android versions of the app, the following is a significant difference related to notifications:
參考之前的文章,我們介紹了iOS和Android版本的應(yīng)用程序之間的差異,以下是與通知有關(guān)的重大差異:
- Android supports background notifications for all types of Triggered advertisements.
- 安卓支持所有類型的Triggered廣播的后臺(tái)通知。
- iOS only supports background notifications for Triggered iBeacon advertisements.
- iOS只支持Triggered iBeacon廣播的后臺(tái)通知。
Due to this, we’ll use iBeacon as the primary test case in this tutorial.
由于這個(gè)原因,我們將使用iBeacon作為本教程的主要測(cè)試案例。
Test Case: Single Advertising Set: Triggered iBeacon
測(cè)試案例:單一廣播集:觸發(fā)的iBeacon
For this test case, we’ll go ahead and define one advertising set as iBeacon and configure it in Triggered mode.
在這個(gè)測(cè)試案例中,我們將繼續(xù)將一個(gè)廣播集定義為iBeacon,并將其配置為觸發(fā)模式。
We’ll also define the following configuration parameters, all in the NanoBeacon Config Tool:
我們還將在NanoBeacon配置工具中定義以下配置參數(shù):
- Advertising Interval = 100 ms (to make it easier to discover the advertising sets, in practice, you may want to increase the interval to reduce power consumption).
- 廣播間隔=100毫秒(為了使廣播集更容易被發(fā)現(xiàn),在實(shí)踐中,你可能想增加間隔以減少功耗)。
- Global Triggers: set the source for Trigger #2 to be Internal Temperature and set the High Threshold to some temperature value that’s greater than the current environment you’re in to be able to manually invoke the trigger condition. I’ve set the value to 3000 (which translates to 30 deg C). Note that the value you enter here will be multiplied by the “On-Chip Measurement Unit” defined in the “On-Chip Measurement Units” section accessible from the main screen of the Config Tool.
- 全局觸發(fā)器:將觸發(fā)器#2的來源設(shè)置為內(nèi)部溫度,并將高閾值設(shè)置為某個(gè)溫度值,該值要大于你當(dāng)前所處的環(huán)境,以便能夠手動(dòng)調(diào)用觸發(fā)條件。我把這個(gè)值設(shè)置為3000(換算成30攝氏度)。請(qǐng)注意,你在這里輸入的值將乘以 "片上測(cè)量單位",該單位定義在 "片上測(cè)量單位 "部分,可從配置工具的主屏幕上訪問。
- Set the Advertising Data Format to iBeacon and set the UUID, Major, Minor, and Tx Power values as you’d like.
- 將廣播數(shù)據(jù)格式設(shè)置為iBeacon,并根據(jù)你的需要設(shè)置UUID、Major、Minor和Tx Power值。
- Set the Advertising Mode to Triggered Advertising and enable “High Trigger 2” in the Sensor Trigger Source section.
- 將廣播模式設(shè)置為觸發(fā)式廣播,并在傳感器觸發(fā)源部分啟用 "高觸發(fā)器2"。
Once that’s all set, make sure your IN100 development board and programmer board are attached and connected to the computer running the NanoBeacon Config Tool.
一旦設(shè)置完畢,確保你的IN100開發(fā)板和編程板連接到運(yùn)行NanoBeacon配置工具的計(jì)算機(jī)上。
Now you can Probe the device, select it, and then Run in RAM to run your configuration on the IN100 tag.
現(xiàn)在你可以探測(cè)設(shè)備,選擇它,然后在RAM中運(yùn)行,在IN100標(biāo)簽上運(yùn)行你的配置。
Here are some screenshots showing the settings described above:
下面是一些顯示上述設(shè)置的屏幕截圖:
Now we’re ready to import this configuration into the mobile app. I’ll be using the iOS version for this test.
現(xiàn)在我們準(zhǔn)備把這個(gè)配置導(dǎo)入到移動(dòng)應(yīng)用中。我將使用iOS版本進(jìn)行這項(xiàng)測(cè)試。
Using the QR Code display functionality in the Config Tool and the QR Code import functionality in the mobile app, import the configuration:
使用配置工具中的QR碼顯示功能和移動(dòng)應(yīng)用程序中的QR碼導(dǎo)入功能,導(dǎo)入配置:
Now, navigate to the Scanner view within the mobile app and select “Only show project configuration matches” in the filter options. Give that the temperature is below the high threshold condition you set (30 degrees C in my case), you should not see any devices in the list:
現(xiàn)在,在移動(dòng)應(yīng)用程序中導(dǎo)航到掃描儀視圖,在過濾器選項(xiàng)中選擇 "只顯示項(xiàng)目配置匹配"。鑒于溫度低于你設(shè)置的高閾值條件(在我的例子中是30攝氏度),你應(yīng)該在列表中看不到任何設(shè)備:
As a simple way to enable the trigger condition, you can place your finger (or momentarily point a heat gun) on the IN100 chipset on the development board
作為啟用觸發(fā)條件的一個(gè)簡單方法,你可以將手指(或用熱風(fēng)槍瞬間指向)放在開發(fā)板上的IN100芯片組上
If you wait long enough for the temperature to hit the high threshold, the Scanner view in the mobile app should now show the iBeacon advertising set, along with a notification at the top of the screen:
如果你等待足夠長的時(shí)間讓溫度達(dá)到高閾值,移動(dòng)應(yīng)用程序中的掃描器視圖現(xiàn)在應(yīng)該顯示iBeacon廣播設(shè)置,同時(shí)在屏幕頂部有一個(gè)通知:
Even if you have the app running in the background and the phone locked, you should see the notifications come through for each Triggered advertising set being discovered:即使你的應(yīng)用程序在后臺(tái)運(yùn)行,并且手機(jī)被鎖定,你也應(yīng)該看到每個(gè)被發(fā)現(xiàn)的觸發(fā)式廣播集的通知都會(huì)出現(xiàn):
That’s all you need to do to get notifications for Triggered advertising sets from the mobile app!
這就是你需要做的,從移動(dòng)應(yīng)用中獲得觸發(fā)式廣播集的通知!
Keep in mind that iBeacon is the only Advertising Data Format type that can trigger notifications on iOS devices. On Android, that limitation is not present.
請(qǐng)記住,iBeacon是唯一可以在iOS設(shè)備上觸發(fā)通知的廣播數(shù)據(jù)格式類型。在安卓上,這個(gè)限制是不存在的。
Conclusion & Summary 結(jié)論與總結(jié)In this tutorial, we covered how to discover Triggered Advertising Sets and showed how app notifications work in the mobile app.
在本教程中,我們介紹了如何發(fā)現(xiàn)觸發(fā)式廣播集,并展示了應(yīng)用通知在移動(dòng)應(yīng)用中的作用。
In the next tutorial, we will go over another unique feature of our mobile app: Logs.
在下一個(gè)教程中,我們將介紹我們的移動(dòng)應(yīng)用程序的另一個(gè)獨(dú)特功能:日志。
With logs, you’ll be able to view the history of discovered advertising sets and the advertising data contained in them as well as the ability to export those logs outside of the app to your computer or any other device for later analysis!
通過日志,你將能夠查看已發(fā)現(xiàn)的廣播集的歷史和其中包含的廣播數(shù)據(jù),并能夠?qū)⑦@些日志導(dǎo)出到你的電腦或任何其他設(shè)備,以便日后分析!
-
BLE
+關(guān)注
關(guān)注
12文章
666瀏覽量
59480 -
掃描器
+關(guān)注
關(guān)注
0文章
170瀏覽量
11938
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
評(píng)論