Just My Life & My Work

Posts tagged ‘bluetooth’

[iOS] BLE某些概念的解釋

已經持續與藍芽奮戰近一年,來回顧一下BLE某些概念的解釋

首先總結CBServiceCBCharacteristic關係如圖,這樣才好理解其角色負責的任務!

bluetooth Services Characteristics

(繼續閱讀…)

FOTA (Firmware Over-the-Air)

最近持續在跟韌體「戰鬥」,其中一個功能就是要透過App來讓藍芽硬體中的韌體更新,那麼要怎麼做呢?

FOTA (Firmware Over-the-Air).png

目前有兩種做法:

  1. 藍芽裝置連結電腦來更新韌體
  2. 透過網路將韌體傳輸至藍芽裝置

第一種做法對使用者來說很煩瑣,所以在此不討論!

第二種就對使用者非常友善,因為使用者只要從網路下載更新程式,再透過藍芽傳輸到硬體,就能完成更新韌體的目標!

(繼續閱讀…)

[iOS] 重連藍芽裝置 (ReConnect BLE Device)

半年前透過人家寫好的藍芽裝置SDK,輕鬆愉快實現App各種功能,現在必須自己寫SDK這一層,也就是透過iOS SDK,來實現藍芽各種連線相關的功能。此刻,我來研究重連藍芽裝置

使用核心藍牙(Core Bluetooth)框架,有三種方式可以重連一個外設。你可以:

  1. 獲取已知外設的列表—你曾經發現或者鏈接的外設—使用retrievePeripheralsWithIdentifiers:方法。如果你尋找的外設在這個列表裡,嘗試去鏈接它。
  2. 用retrieveConnectedPeripheralsWithServices:方法獲取當前連接到系統的外設列表。如果你尋找的外設在這個列表裡,本地連接它。
  3. 用scanForPeripheralsWithServices:options:方法掃描發現外設。如果找到就連接。

取決於使用場景,你可能不想掃描發現相同的外設,每當你想重連它的時候。相反,你可能首先使用其他選項,嘗試重連。如圖所示,一個可能的重連工作流是嘗試每個選項。

一個示例重連工作流

BLE Retrieve.jpg

總覺得看了這圖後,就能完全掌握實作的流程!

(繼續閱讀…)

[iOS] 低功耗藍芽連線流程

最近寫iOS App要跟低功耗藍芽連線,接著傳輸資料解碼後來分析。兩年前有碰藍芽體脂計,是看著韌體溝通協議來實作,兩年後的今天再一次依樣畫葫蘆,這次要搞的硬體是24小時配戴的「玩意兒」。

bluetooth peripheral service characteristics

感謝網路上已有許多教學,學習藍芽只要拾人「芽」慧,就能快速上手!

(繼續閱讀…)

[iOS] 系統藍芽綁定

最近在搞藍芽裝置,它是IoT相關的硬體裝置,只要搞定藍芽連線部分,就能實現許多智慧家庭的應用。現在我想要在iOS連結藍芽裝置,照理說綁定藍芽裝置沒什麼稀奇,直到自己進入開發模式,才發現有許多眉眉角角要去深入瞭解,以老闆之前做藍芽眼罩的經驗來看,他說這就是為什麼IoT還無法普及的原因之一,因為光是藍芽連線,就有許多問題要去克服。「連線」是最基本的門檻,很多應用到死在這條線上⋯⋯

ios oserio 藍芽體脂計

註:物聯網(英語:Internet of Things,縮寫IoT)。

(繼續閱讀…)

寄送藍芽裝置給Apple測試

開發單純的iOS App沒什麼難度,可是送審後的議題總會出其不意。原以為可以只拍攝影片給審核人員看,如何連結我們的產品(藍芽裝置)來操作App,可惜我們沒能逃過高人的「法眼」,於是請老闆將一個貴重的藍芽裝置寄送給Apple測試。約莫一週左右,App總算順利上架啦⋯⋯我也順理成章去環島九天:D~

bluetooth peripheral service characteristics

以下就是在iTunes Connect被reject的原因與描述:

From Apple

  • 2. 1 Performance: App Completeness

Guideline 2.1 – Information Needed

We have started the review of your app, but we are not able to continue because we need the associated hardware to fully assess your app features.

Next Steps

To help us proceed with the review of your app, please send the necessary hardware/accessory to the address below.

NOTE: Please include your app name and app ID in the shipment; failure to provide this information can delay the review process.

Additionally, it may take several business days for us to receive the hardware once it has been delivered to Apple.

Apple, Inc.
1 Infinite Loop, M/S: 124-2APP
Cupertino, CA 95014
USA

ATTN: Marcus East
App Name: 快樂健康+
App ID: 1317204377

Once you’ve shipped the hardware, please reply to this message with the shipping carrier and tracking information. Once we have received the hardware, we will continue your app’s review.

IMPORTANT: for non-US Developers

To avoid delays with US Customs, please provide the following information with your shipment (required for all radio-frequency devices imported in the US):

– Description of the equipment
– Quantity
– Device Model/Type Name or Number
– FCC ID
– Original Manufacturer’s Name and Address

Please use FCC form 740 for details on how to provide this information.

Remember:

* A separate FCC Form 740 must be used for each different radio-frequency device or component in the shipment; however, a form is not required for subassemblies, parts, or components of radio-frequency devices.

* The form may be completed by the shipper or recipient, but if the form is not sent with the original shipping documents by the shipper, the shipment may be delayed in customs.

* Ensure all serial and ID numbers are available as well as the name and address of the original manufacturer.

以上問題,2017年11月的時光都耗在這裡啦⋯⋯

之後送審更新版,都不到一天就審核通過!

話說,Apple拿到藍芽裝置且測試過後,不會寄送回來給開發者呢⋯⋯

參考:

[C/C++] 4 bytes轉成integer (Convert 4 Bytes to Integer)

最近要讀取藍牙裝置回傳的資料來解析,需要將4 bytes轉成integer,才能知道訊號強度相對值。太久沒搞底層東東,有些生疏,好在嘗試一下就得到正確結果!

bluetooth Central Peripheral

(繼續閱讀…)

[iOS] 設定藍芽 (Setting Bluetooth)

有時候我們需要開啟藍芽來連結裝置,像是BeaconApple Watch小米手環。那麼如果使用者沒有打開權限怎麼辦?請他/她到設定藍芽 (Setting Bluetooth)去打開囉~

iOS 設定藍芽 (Setting Bluetooth).PNG

目前iOS SDK尚未有API可以直接改藍芽設定,要是未來Apple有開放的話請再跟我說唷!不過我想應該要等到天荒地老,非常重視用戶隱私的Apple,是不會輕易讓開發者悄悄開啟Bluetooth來進行任何動作。

剛好我們偉大的技術長有無私分享:

/**
 Theme: iOS 10 Setting Bluetooth
 IDE: Xcode 8
 Language: Objective C
 Date: 106/03/07
 Author: HappyMan
 Blog: https://cg2010studio.wordpress.com/
 */
-(void)openBLESetting
{
    NSURL *bluetoothURLOS8 = [NSURL URLWithString:@"prefs:root=General&path=Bluetooth"];
    NSURL *bluetoothURLOS9 = [NSURL URLWithString:@"prefs:root=Bluetooth"];
    NSURL *bluetoothURLOS10 = [NSURL URLWithString:@"App-Prefs:root=Bluetooth"];
    if ([[[UIDevice currentDevice] systemVersion] intValue] >= 10) {
        [[UIApplication sharedApplication] openURL:bluetoothURLOS10];
    }
    else if ([[[UIDevice currentDevice] systemVersion] intValue] >= 9) {
        [[UIApplication sharedApplication] openURL:bluetoothURLOS9];
    }
    else {
        [[UIApplication sharedApplication] openURL:bluetoothURLOS8];
    }
}

這種沒啥邏輯純粹定義的玩意兒,抄,就對了XD~

參考:opening iOS BLE setting from app

[iOS] iBeacon 測試

睽違一年半之久,總算要來開發iBeacon,看來越來越多應用持續出現中!因為最近要出國,所以想到可以將iBeacon放進行李廂,進入範圍或離開範圍時,手機會跳出提示,如此就不用眼睛一直盯著行李箱:)~

一年半前參加「Retail Battle Hackathon 創新零售駭客松活動」,KKLabs給參賽者每人一顆Spot Beacon當作禮物,直到最近我才真正拿出來用XD~

可以先參考之前的文章:初探 IBEACON 技術

(繼續閱讀…)

用筆電接聽電話

自從我的MacBook Air升級到Yosemite Mac OS後,就開始會用筆電接聽電話,因為配合iPhone 6iOS 8,由於兩個作業系統都有做到Handoff技術,所以可以在不同裝置中無縫做同樣的事情!

用筆電聽電話

每次媽媽打電話給我,我就在等平板電腦和筆記電腦同時響起:)~

此外,去年12月底買的小米智慧手環,可以設定幾秒後來電震動提醒,上週去看十分瀑布,跟教會朋友分散差點漏接電話,好在小米手環透過藍芽接收到手機有來電,我發覺後才接聽起來呢~

Apple是透過iCloud帳號做到「無縫接軌」,所以我用同一個帳號登入我所有Apple設備,並且在同一個WiFi訊號底下,就能輕鬆自在地工作囉~

Handoff

開始可以想像,未來的許多穿戴裝置都能夠互相「掩護」了!

標籤雲