Let’s recap what we covered in the previous articles within this series:
讓我們回顧一下我們在本系列的前幾篇文章中所涉及的內容:
- Requirements, installation, and setup steps for using the mobile app
- 使用移動應用程序的要求、安裝和設置步驟
- Overview of the different sections within the app
- 應用程序內不同部分的概述
- Running a few test case scenarios with different advertising data types
- 用不同的廣播數據類型運行一些測試案例場景
- A detailed look at device filters
- 詳細了解設備過濾器
- Differences between the iOS and Android versions of the app
- 該應用程序的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.
在這個特別的教程中,我們將專注于我們應用程序的一個最獨特的功能:應用通知(甚至在后臺),用于檢測觸發的廣播集。
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 "到底是什么意思?在兩個版本的應用程序(安卓和iOS)中,應用程序通知的限制是什么?
Triggered Advertising Sets觸發式廣播集
Triggered advertising sets allow the user to configure the device to send advertising packets only when certain conditions occur.
觸發式廣播集允許用戶配置設備,使其僅在某些條件發生時發送廣播包。
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.
這對于只有在滿足一個或多個條件時才需要廣播數據包的用例非常有用,例如,電池電量低于10%或溫度超過40攝氏度。在這種情況下,不管這些條件如何,一直發送廣播數據(這就是NanoBeacon配置工具中所說的 "連續廣播模式")會不必要地增加電池消耗,所以只根據某些條件發送廣播是有意義的。
Here’s a look at the various options available for this mode within the NanoBeacon Config Tool:
下面我們來看看NanoBeacon配置工具中該模式的各種可用選項:
1、Triggered advertising event count: this defines the number of advertising events transmitted if a triggered condition is met.
1、觸發的廣播事件計數:這定義了在滿足觸發條件時傳輸的廣播事件的數量。
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、觸發事件將重置被觸發的廣播事件計數:啟用這個功能將重置上面#1中設置的廣播事件計數,這意味著如果滿足任何一個觸發條件,它將不斷重置計數并繼續發送廣播數據包。一旦沒有一個觸發條件被滿足,廣播事件計數將開始遞減。例如,假設該選項被啟用,而觸發條件是內部溫度≥25攝氏度的高閾值,并且溫度超過了這個閾值。在這種情況下,它將繼續發送廣播事件,直到溫度低于閾值,然后它將只發送選項#1中設置的廣播事件數量。
3、Single trigger, Recurring trigger, Advertise indefinitely after 1st trigger:
3、單次觸發、重復觸發、第1次觸發后無限期廣播:
- 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.
- 單次觸發:選擇這種類型將設置行為,只在任何一次觸發條件被滿足時才發送廣播事件。如果以后再滿足觸發條件(在同一電源周期內),將不發送廣播事件。
- Recurring Trigger: choosing this type will send out advertising events every time a trigger condition is met.
- 循環觸發:選擇這種類型,每次觸發條件被滿足時都會發送廣播事件。
- 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次觸發后無限期廣播:顧名思義,選擇這種類型將在滿足任何觸發條件后無限期地發送廣播事件。
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、傳感器觸發源:這定義了一個或多個觸發條件的來源,在 NanoBeacon 配置工具中的 "全局觸發設置 "部分設置。觸發源的例子包括VCC、內部溫度、ADC通道、單線傳感器讀數和I2C從屬讀數。
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觸發源:這定義了一個或多個基于GPIO狀態的觸發條件源。可用的GPIO是:GPIO2, GPIO3, MGPIO4, MGPIO5, MGPIO6, 和 MGPIO7.
Keep in mind that the triggered event will occur if anyof the defined conditions are met.
請記住,如果滿足任何定義的條件,觸發的事件就會發生。
Triggered Advertising Sets on the Mobile App移動應用上的觸發式廣播集
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.
現在我們更好地了解了觸發式廣播的工作原理和不同的選項,我們現在可以測試一下,看看它們在移動應用的安卓和iOS版本上是什么樣子的,表現如何。
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版本的應用程序之間的差異,以下是與通知有關的重大差異:
- Android supports background notifications for all types of Triggered advertisements.
- 安卓支持所有類型的Triggered廣播的后臺通知。
- iOS only supports background notifications for Triggered iBeacon advertisements.
- iOS只支持Triggered iBeacon廣播的后臺通知。
Due to this, we’ll use iBeacon as the primary test case in this tutorial.
由于這個原因,我們將使用iBeacon作為本教程的主要測試案例。
Test Case: Single Advertising Set: Triggered iBeacon
測試案例:單一廣播集:觸發的iBeacon
For this test case, we’ll go ahead and define one advertising set as iBeacon and configure it in Triggered mode.
在這個測試案例中,我們將繼續將一個廣播集定義為iBeacon,并將其配置為觸發模式。
We’ll also define the following configuration parameters, all in the NanoBeacon Config Tool:
我們還將在NanoBeacon配置工具中定義以下配置參數:
- 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毫秒(為了使廣播集更容易被發現,在實踐中,你可能想增加間隔以減少功耗)。
- 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.
- 全局觸發器:將觸發器#2的來源設置為內部溫度,并將高閾值設置為某個溫度值,該值要大于你當前所處的環境,以便能夠手動調用觸發條件。我把這個值設置為3000(換算成30攝氏度)。請注意,你在這里輸入的值將乘以 "片上測量單位",該單位定義在 "片上測量單位 "部分,可從配置工具的主屏幕上訪問。
- Set the Advertising Data Format to iBeacon and set the UUID, Major, Minor, and Tx Power values as you’d like.
- 將廣播數據格式設置為iBeacon,并根據你的需要設置UUID、Major、Minor和Tx Power值。
- Set the Advertising Mode to Triggered Advertising and enable “High Trigger 2” in the Sensor Trigger Source section.
- 將廣播模式設置為觸發式廣播,并在傳感器觸發源部分啟用 "高觸發器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.
一旦設置完畢,確保你的IN100開發板和編程板連接到運行NanoBeacon配置工具的計算機上。
Now you can Probe the device, select it, and then Run in RAM to run your configuration on the IN100 tag.
現在你可以探測設備,選擇它,然后在RAM中運行,在IN100標簽上運行你的配置。
Here are some screenshots showing the settings described above:
下面是一些顯示上述設置的屏幕截圖:
Now we’re ready to import this configuration into the mobile app. I’ll be using the iOS version for this test.
現在我們準備把這個配置導入到移動應用中。我將使用iOS版本進行這項測試。
Using the QR Code display functionality in the Config Tool and the QR Code import functionality in the mobile app, import the configuration:
使用配置工具中的QR碼顯示功能和移動應用程序中的QR碼導入功能,導入配置:
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:
現在,在移動應用程序中導航到掃描儀視圖,在過濾器選項中選擇 "只顯示項目配置匹配"。鑒于溫度低于你設置的高閾值條件(在我的例子中是30攝氏度),你應該在列表中看不到任何設備:
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
作為啟用觸發條件的一個簡單方法,你可以將手指(或用熱風槍瞬間指向)放在開發板上的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:
如果你等待足夠長的時間讓溫度達到高閾值,移動應用程序中的掃描器視圖現在應該顯示iBeacon廣播設置,同時在屏幕頂部有一個通知:
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:即使你的應用程序在后臺運行,并且手機被鎖定,你也應該看到每個被發現的觸發式廣播集的通知都會出現:
That’s all you need to do to get notifications for Triggered advertising sets from the mobile app!
這就是你需要做的,從移動應用中獲得觸發式廣播集的通知!
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.
請記住,iBeacon是唯一可以在iOS設備上觸發通知的廣播數據格式類型。在安卓上,這個限制是不存在的。
Conclusion & Summary 結論與總結In this tutorial, we covered how to discover Triggered Advertising Sets and showed how app notifications work in the mobile app.
在本教程中,我們介紹了如何發現觸發式廣播集,并展示了應用通知在移動應用中的作用。
In the next tutorial, we will go over another unique feature of our mobile app: Logs.
在下一個教程中,我們將介紹我們的移動應用程序的另一個獨特功能:日志。
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!
通過日志,你將能夠查看已發現的廣播集的歷史和其中包含的廣播數據,并能夠將這些日志導出到你的電腦或任何其他設備,以便日后分析!
-
BLE
+關注
關注
12文章
652瀏覽量
59337 -
掃描器
+關注
關注
0文章
155瀏覽量
11895
發布評論請先 登錄
相關推薦
評論