Mar 2026【隨筆】Clone a Meta Ray-ban Display glasses application|藍芽 L2CAP CoC 極致低延遲架構優化:實現 720p 智慧眼鏡流暢串流 👓(LIVE DEMO)

圖片
最近在做一些實驗性質的東西,記得去年短暫玩過 2023 年底上市的第二代 Ray-Ban Meta 智能眼鏡,雖然它主要還是依賴智慧型手機作為算力中心,但我們對它所使用的串流技術很感興趣,因為聽說他們是用藍芽做串流。 去年曾經有同事隨口問我:「我們的眼鏡做到跟他們一樣你覺得有可能嗎?」,因為我知道我們的硬體規格跟人家的相比並非等號,加上當時有其他事情在搞,所以隨口開玩笑回說:“可是聽說 Meta 有200個人在搞那個眼鏡捏(雖然不知道他們負責搞應用的有幾人),啊我如果一個人可以幹贏他們200人,那我還在這幹嘛???(笑)” 也記得更久以前,當我們還在研究那個眼鏡時,常聽到像是:『 他們不知道用了什麼黑科技 』,這類沒有建設性、不應該從 RD 嘴裡說出來的話,而我也是不以為然。坦白講,以前每次只要聽到某SW嘴砲經理(暫且以H君稱之),沒事就把『 黑科技 』三個字掛在嘴上,當做無知的遮羞布,我就會感到倒胃口!同樣身為RD,我只覺得  Shame on you!(打嘴炮、作秀搶風頭、噁心帶風向、搞政治操作、把別人做事的成果搶去幫自己抬轎、有鍋直接推給下屬扛、散佈同事私生活謠言,還有職場霸凌,這些你他媽都頂級專業戶,除此之外沒啥洨用了!) 一件理論上可以做到的事情,外行人的認知被信息差,不懂加上沒實作能力去驗證,就什麼都變成黑科技了(多黑?比巴西黑鮑魚還黑嗎?)。反重力技術說不定也非啥黑科技,只是政府不讓你普通老百姓了解罷了。 Ray-ban Meta 的黑科技,講白了就是人家拉個百人團隊在搞那支眼鏡,然後把軟體技能和硬體規格點滿,再加上極致優化後的成果罷了! 當時知道 Ray-Ban Meta 的智慧眼鏡有塞入一個強大的 WiFi 6 晶片在裡面,一開始我猜測會不會有可能是透過 WiFi P2P 或 WiFi SoftAP 的方式去做串流(確實 Meta 的智能眼鏡,在同步媒體時,會強制要求開啟手機的 WiFi 開關,所以媒體同步應該是靠 WiFi 通道做的),而去年初我也快速做了一個WiFi Direct 架構來做 POC,確實傳輸效率非常快,幾百 MB 的大檔幾乎秒級傳完,從眼鏡端將媒體串流到手機端更是不用說的順暢,而且當時我們的媒體串流還是以未經編碼的方式傳透過 Socket 直接傳輸的(這表示傳輸時所需的頻寬會更大,功耗據說也較大)。 後來因為 ...

FbGraph + OmniAuth + Facebook Graph API on Rails application

OAuth is often described as a 'valet key for the web'. In the same way as a valet key gives restricted access to a car, allowing the valet to drive it but not open the trunk or glovebox, OAuth allows a client application restricted access to your data at a resource server via tokens issued by an authorization server in response to your access grant.

Facebook Platform uses the OAuth 2.0 protocol for authentication and authorization. Suppose your Rails application allows users to share content with their Facebook friends. To support this, a connection needs to be established between a user's local account and her Facebook account. Once established, a Facebook instance can be obtained and used to post content to the user's wall. The basic idea is to store the access_token during an OAuth2 login process and later on use the token to fetch more data.

The last days I was working on letting user sign-up/sign-in using Facebook account. I'm planning to integrate some social features into my ongoing Rails project. Previously I was working with Facebooker, an awesome Rails plugin that did a great job for my previous project, however it seemed not support the latest Facebook Graph API. Thought I found a new solution.

OmniAuth is an open source project which provides support for many of the main providers out there: twitter, facebook, foursquare, and many more. In addition, OmniAuth is designed in such a way that it is very easy to implement custom strategies---interchangable logic which encapsulates the steps required to successfully authenticate with an Oauth2 provider.

OmniAuth relies on the request and callback sequence as defined in OAuth2 specification. OmniAuth extracts away a lot of the complexity of working with OAuth, so we can skip all of that information and focus on just what we need to. The diagram below depicts how OmniAuth handles the request and callback sequence:


The request phase of the OAuth dance typically redirects to a providers website which prompts the user to enter their credentials with the provider calling back to Omniauth with a success or failure message.

There is a couple of great screencasts on how to integrate Omniauth to Devise using Rails 3 and allow Facebook, Twitter, etc. authentications. In this post, I'm going to show you how to connect to the Facebook platform using FbGraph along with Omniauth to retrieve a list of records and post message to the facebook wall via its Graph API. For this example, I'm using Rails 2.3.8 on my Mac. But I strongly encourage you to start with Rails 3.

First, we would need a migration to store a permanent Facebook token for offline access:
$ script/generate migration AddFacebookTokenToUsers


Add the following to your config/environment.rb

Next, in your initializer, usually config/initializer/omniauth.rb, request additional permissions, we need to tell Omniauth to retrieve more Facebook permissions in order to have offline access, Wall, etc. You can define the ones you need from Facebook permissions API pages, but here is my setting:

If you get this error message when you're trying to run your Rails server: 
WARNING: Nokogiri was built against LibXML version 2.7.7, but has dynamically loaded 2.7.8
The problem was most likely bad library management, if you don't have libxml2 in the Cellar directory on OSX, you can install it to this using homebrew:


Now, lets get to the application code changes. In the application controller we define the facebook_user like this:


In the routes.rb we add following routes:


Next, edit your fb_oauth_controller.rb add the callback method:


Callback is the action that is called after the authorization. The access_token is not restricted with time unless Facebook changes their policy and make them expire after a particular period of time, and is used later for interacting with Facebook.. To understand how it all works, read about Facebook permissions, the Graph API. The /auth/facebook url is invoked first. This redirects the user to Facebook where the user gets the permission prompt, to allow your application to access the users information. If everything works you should have the full authentication workflow going!



You can also use this URL to get a permanent access_token:


Facebook uses the OAuth 2.0 protocol for user authentication and application authorization. Following are the steps required to obtain an access token:

(a) Redirect the user to https://graph.facebook.com/oauth/authorize and pass the application id and post authorize callback URL as parameters to this API.
(b) User enters their credential in the above Facebook URL and after successfully authorizing the application, Facebook would redirect the user to the authorize callback url along with a verification string in the argument code, which can be exchanged for an OAuth access token.
(c) Generate an access token using the above verification code by fetching https://graph.facebook.com/oauth/access_token

Once the access token is obtained, all further communications to Facebook will only require this token instead of the user’s credentials. 


You can modify the callback method to integrate Facebook connect with your authentication system (Allow your users to sign up/sign in with their Facebook account). See the example below:


Now the application retrieves email and also you have an access to Facebook Graph API. For instance, to post something on Facebook wall you can:




Enjoy! hope this helps you :)


熱門文章

台中【馨苑小料理】西區店|巷弄裡的人氣台菜店|米其林必比登推薦美食|提供合菜、個人套餐

2019, July 7~8【中國山東】老司機帶你攀登72位古代帝王曾登臨朝拜,以五嶽獨尊名揚天下的泰山(歷史典故+遊覽路線+遊記+照片)

【美國加州】此生必去超美風景!加州一號公路自駕遊~Half Moon Bay、17 Mile Drive、Bixby Greek Bridge、Big Sur、McWay Falls、Elephant Seal Rookery

Mar 2026【隨筆】Clone a Meta Ray-ban Display glasses application|藍芽 L2CAP CoC 極致低延遲架構優化:實現 720p 智慧眼鏡流暢串流 👓(LIVE DEMO)

Aug 2026【新北三峽】鳶尾山、鳶山、鳶山彩壁、五十分山環狀健行(環台北天際線第九段)

日本の登山の歷史

[平成27年1月18日]厳冬期雪山~滋賀県の最高峰・伊吹山に挑む!冬季限定直登ルート

Jul 2026【新北林口】觀音山小北插路線上鷹仔尖、東明山、潮音洞&一個關於被噁心的故事

【南投信義】丹大林道與消失的省道台16線|可徒步深入中央山脈的經典長程林道

July 2024【台北士林】帕米爾公園出發,接雙溪溝古道至梅花山北峰、梅花山西峰、雙溪山O型走(順訪藍海藝園用餐)

文章列表

Contact

名稱

以電子郵件傳送 *

訊息 *