제임스딘딘의
Tech & Life

개발자의 기록 노트/Tizen

삼성 GearS2를 위한 타이젠 앱 개발하기 : [2] Hello world 앱 띄우기 (맥 OS X)

제임스-딘딘 2016. 4. 6. 00:06

SDK설치를 했으니, 실제로 앱을 기어S2에 올려봐야죠.


그런데요, 아이폰 앱개발이나 안드로이드폰 앱개발을 해보셨던 분이라면 의아한 부분이 있을거에요.


기어S2랑 컴퓨터랑 어떻게 연결해서 앱을 올리지?



기어S2는 컴퓨터와 USB케이블을 이용해서 직접 연결할 수 는 없는 구조입니다.

물론 기어S2 시계줄을 빼고 옆의 작은 커버를 벗기면 5핀 단자가 노출되긴 하는데요,

연결할 거치대가 별도로 제공되거나 판매되고 있지 않죠.


Tizen개발자 사이트와 삼성에서 공식적으로 언급하는 방법은 Wi-Fi를 사용하는 방법입니다.

기어S2와 컴퓨터를 동일한 네트워크에 연결한 뒤, 이 둘을 'sdb (smart debugger bridge)' 라는 툴을 이용해서 TCP/IP layer로 연결합니다.


선이 없어서 깔끔하지만 반응속도가 좀 늦다라는 단점이 있는 것 같아요. (기분 탓만은 아니겠죠. 실제로 느려요. 터미널상에서 프롬프트 떨어지는게..)


아무튼, 이번에 저는 뭘할거면요.



맥 OS X 를 사용하는 맥북에서 

Tizen SDK 2.4 를 사용하여

삼성 기어S2 에

Hello world 라는 텍스트를 보여주는 앱을 만들어 올릴겁니다.



참고로 오늘, (2016-04-05) Tizen SDK 2.4 Rev.5 가 배포되기 시작했는데요.

그 이전버전이었던 Tizen SDK 2.4 Rev.4 (맥 OS X 용)는 기어S2에 앱을 설치할 수 없었습니다. 정확히 말하면 edc를 사용하는 Native App을 올릴수가 없었어요.

빌드에러가 났기 때문인데요.


자세히 알고싶으시면 관련해서 제가 Tizen개발자 사이트 포럼에 질문 남겼던 글을 참조하시면 될 것 같아요

https://developer.tizen.org/forums/sdk-ide/os-x%EC%97%90%EC%84%9C-2.4-rev.4-sdk-%EB%A1%9C-native-app-%EB%B9%8C%EB%93%9C%EC%8B%9C-%EC%97%90%EB%9F%AC%EB%B0%9C%EC%83%9D


답글 속도도 늦고.. 

다른사람들은 된다고 답했던 방법들은 실제로 해보면 되지 않고, 

그래서 그 해결했다는 사람에게 물어봐도 답이 없고..

좀 답답하긴 했는데요,

Rev.5 로 업데이트 되면서 해결되서 아무튼 다행입니다.



각설하고,진행과정을 살펴보죠.

아래 순서로 진행할 겁니다.

쓸데없는 사설을 늘어놓는 것은 이제 그만할게요.


1. PC의 SDK에서 기어 S2 인식하도록 연결하기.

2. Samsung Developer Center에서 Certificate 발급하기

3. Native 앱 코드 구현하기

4. 앱 코드 빌드해서 패키지로 만들고, 기어 S2에 설치하기


부록. Native Application? Web Application? 뭐가 어떻게 다른거야?



1. PC와 기어 S2 연결하기

아시다시피 기어S2는 USB 케이블로 연결 할 수 있는 포트가 없습니다.


쉽게 그림으로 보면 연결방식은 아래와 같아요



Connect via Wi-Fi




찾아보니 삼성에서는 아래와 같이 연결방법을 안내해주고 있습니다.


※ In case of devices which do not support USB, like the Gear S2, they need to use Wi-Fi connection to connect to the Host PC.

  1. Connect the Host PC to the Wireless AP via UTP cable or Wi-Fi.
  2. Turn on Wi-Fi of your device.
  3. Turn on debugging mode of your device. Settings > Gear Info > Debugging
  4. Reboot the device.
  5. Connect the device to the same wireless AP.
  6. Once connected, find the IP address from the AP via DHCP. This IP address will be used during the sdb connection. You can get this IP address by checking the information of the access point the Gear S2 device is currently connected to.
  7. Open the terminal in the Host PC and use this connect command:

    $ sdb connect [Gear S2 IP address]:26101

    Ex) $ sdb connect 192.168.0.130:26101


그리고 '삼성 개발자 사이트' 에서도 연결 방법 설명을 해주고 있네요


삼성개발자 사이트 GearS2와 SDK 연결방법 : http://developer.samsung.com/technical-doc/view.do?v=T000000251&pi=1&ps=10&pb=Y&ct=CT030000&sc=



그러나 위 방법대로 해도 안되는 경우가 있을 수 있는데요, 다음을 확인해 봅니다.

 1) 설정 => 연결 => 블루투스 => OFF 인지 확인. 

 

만약 블루투스가 ON (사용함) 이면 sdb연결이 안되는 경우가 있더군요.


 2) 무선 간섭을 피하기 위해 충전기에서 GearS2를 분리하여 멀리 둬 보세요.


확인해보니 초기에 판매된 GearS2의 펌웨어는 블루투스와 Wi-Fi 모두 ON 이면 SDK에 Wi-Fi를 통한 연결이 안되는 문제가 있었다고 합니다.

* NOTE 

Bluetooth and Wi-Fi cannot be turned on at the same time on the Gear S2 with its initial firmware. However, the latest firmware fixes this issue. To turn on both Bluetooth and Wi-Fi at the same time; the Debugging mode is switched ON with the recent firmware. (Firmware for US and Japan 3G models soon will be available). To update the firmware, check the Gear Software Upgrade in the Samsung Gear application on your paired mobile device.


또한 위 a~g step 으로 나열된 방법은 terminal상에서 커맨드를 입력해서 sdb shell을 연결하는 방법이고요.

SDK IDE 환경에서는 아래 그림을 참고해서 연결하시면 됩니다.



Remote Device Manager에서 GearS2 추가하기


Tizen SDK의 Connection Explorer에 표시된 GearS2







2. Samsung Developer Center에서 Certificate 발급하기


이제 할 일은 SDK에 연결된 기어S2에 '앱설치 허용' 을 해주어야 합니다.

SDK의 'Connection Explorer' 에서 보여지는 기어S2를 오른쪽 클릭 하면 메뉴가 뜨는데,

'Permit to install applications' 를 선택합니다.



Permit to install applications


SDK로 가지고 계신 기어S2에 앱을 올리는게 처음이시라면 아래와 같은 에러창이 발생하는 걸 볼 수 있는데요,

가만히 읽어보니 Certificate를 발급받아야 한다는 얘기입니다.




Certificate?

테스트 목적으로 앱을 빌드할 때 필요한 일종의 '인증 열쇠' 입니다.

Tizen Native 앱을 테스트 목적으로 컴파일하면, 그 결과물로 'tpk' 라는 확장자를 가지는 패키지 파일이 생성되는데요,

'인증 열쇠'라고 말씀드린 Certificate에 등록한 단 1대의 기어S2 에만 설치가 가능하다고 합니다.

타이젠 개발자 사이트에서는 앱 유출 방지 목적이라고 설명하고 있네요. 



Certificate Guides

In order to install a Tizen application onto Samsung Tizen devices, you must first register certificates containing the DUID (Device Unique Identifier) of the device. Two types of certificate are needed, the author and the distributor certificate. These certificates are used for signing and verifying the application.

These certificates ensure that your signed application will run only on test devices which you registered. It guarantees that your application will not be distributed by someone else even though your application package is leaked. (테스트중인 앱의 설치패키지가 유출되어도 걱정 말라는 뉘앙스로 보입니다)

You have to take the certification steps not only for testing your apps on the actual devices but also for uploading your apps to Samsung GALAXY Apps Seller site.

The Tizen Extension SDK for Certificate provides functionalities to get and register Samsung Tizen certificates. This version 1.2 simplifies the steps on how to get and register certificates. In order to do this procedure, you must first install the Tizen SDK version 2.4 or later.



아무튼 잘은 모르겠지만 필요하다고 하니깐.

등록을 해봅시다.



SDK 상단의 툴바를 살펴 보면 Certificate 등록을 위한 버튼이 있습니다.

이때 열리는 'Samsung Tizen Certificate' 창에서 Step 1. ~ Step 4. 를 진행하시면 됩니다.


자 여기서 귀찮은 내용이 있는데요.

이때.. 필요한 것은 '삼성 계정' 입니다. 

Step 3. 에서  author certificate 등록할 때 로그인을 요구합니다.

그리고 Step 4. 에서  distributor certificate 를 등록할때도 로그인을 요구합니다.




아무튼 Step 4까지 모두 진행했으면, OK를 누르고, Registration이 진행되는 동안 잠시 기다립니다.


완료 후, 처음에 실패했던 과정을  다시 진행합니다.

Connection Explorer 에서 기어S2를 오른쪽으로 누르고 'Permit to install applications' 를 선택하면, certificate를 기어S2로 업로드 하게됩니다.

이때부터 앱을 설치 해볼 수 있지요.







3. Native 앱 코드 구현하기

구현이라고 거창하게 말했지만요,


SDK를 설치하면 기본으로 제공되는 Sample App을 그냥 SDK에 추가하고 빌드해서 GearS2에 설치해볼거에요


아래 그림대로 잘 따라와보세요.














구현(?) 완료 했습니다.

구현이라기 보다는, 이미 구현된 sample앱을 Tizen SDK에 프로젝트 형태로 추가한 거네요. 





4. 앱 코드 빌드해서 패키지로 만들고, 기어 S2에 설치하기


여기까지 하셨으면 SDK IDE의 왼쪽에 있는 Project Explorer 에 BasicUI 라는 이름의 프로젝트가 하나 생겼을 거에요.


Project 의 디렉토리 구성이나, manifest.xml 이 무슨역할을 하는지? 


궁금할 지도 모르겠네요.


대충 짐작은 가시죠?

아, 이게 뭔가 싶고 짐작도 잘 안가도 상관없어요.

지금 알아볼건 아니고, 차차 알아가도 될 것 같고요.



지금은 앱을 빌드하고, 기어S2에 설치 해볼겁니다.


프로젝트를 오른쪽으로 누르고 보이는 메뉴에서

Run As -> Tizen Native Application 


을 선택해 줍니다.




그러면 아래와 같이 'Console' 탭에 설치 과정에 대한 메세지들이 보여지는데요,


문제가 있다면 이 'Console' 의 로그를 차근차근 읽어서 문제 원인을 찾을 수 있어요. 

그리고 SDK IDE tool 이라면 당연히 그럴 수 있어야 하죠.

아니면 앱 개발자가 상당히 불편하겠죠?


아래 그림의 메세지를 읽어보면

앱 빌드가 끝난 직후의 화면인걸 알수 있습니다.


내용인 즉,

package를 만들고

package를 기어S2로 전송했고

기어S2 에서 package를 설치했다고 되어있네요.


가만 보니 패키지가 /opt/usr/apps/tmp/ 경로에

org.example.basicui-1.0.0-arm.tpk  라는 이름으로 기어S2에 저장된 것도 알수 있고요.


설치가 완료 후 자동으로 앱이 실행되기 까지 했다고 되어있네요.


간단한 샘플앱을 빌드해서 패키지를 만들고 기어에 설치하고 실행하기까지 약 41초의 시간이 걸렸습니다.

흠.. 꽤 걸리네요.


뭐 아무튼.


실행된 모습은 아래와 같아요.




basic ui 앱이 실행된 모습





부록. Native Application? Web Application? 뭐가 어떻게 다른거야?



위 과정에서 Tizen Native 앱 이라고 말했지요.

그냥 앱이라고 하지 왜 Native 앱이라고 했을까요? 

음.. 뭐 Native 앱이 아닌 다른 앱이 존재한다는 얘기겠죠.



찾아보니 Web 앱 이라는 형태가 또 있네요.

HTML5 + CSS + Javascript 로 앱을 구현하는 방식이라고 하고요.

HTML파일과 CSS로 UI를 만들고, js파일에서 Web API 라는 Javascript function 호출로 앱을 만들 수 있다고 하네요.


반면 Native앱은 C언어와 C++언어를 사용해서 만들어진 Native API를 호출하는 방식으로 앱을 만들 수 있습니다.

UI는 EFL 이라는 UI framework를 사용해서 만들수 있고요,

UI layout은 EDC라는 script언어로 잡을 수 있다고 하네요. Android의 XML로 UI layout잡는 방식과 비슷하겠죠 뭐.


마지막으로 이 둘을 혼합한 Hybrid 앱 이라는 형태가 존재합니다.

대부분의 Hybrid 라는 단어를 취하는 것들이 그렇듯,

Tizen의 Hybrid앱도 이 두 앱유형의 장점은 취하고, 단점은 제외하는 형태겠지요.

자세히 알아보는건 뒤로 미룰게요.


이해하기 쉽게 그림으로 한번 볼까요?


아래 그림은 웹앱과 네이티브앱이라는 두가지 앱 유형을 지원하고 있는 Tizen 아키텍쳐의 모습을 나타냅니다.

The following figure illustrates the Tizen architecture model supporting the 2 application types.



Tizen Architecture


tizen.org의 getting started 에서 발췌한 내용입니다.


Tizen Application Types

Tizen platform supports 2 primary application types:

  • Web Application is essentially a web site stored on your device and built using web languages, such as HTML5, CSS, and JavaScript. The web application uses the Tizen Web Framework to interact with the native subsystems.

    The web applications use the Web API, which is a standard web application project structure with basic elements. The web API is designed to allow you to easily build applications using web languages.

    A program built using the Web API is laid out much like a standard web site with an index.html file that serves as the root, and separate directories for resources, such as JavaScript, CSS, images, and sound resources. This approach makes Web application development in Tizen extremely intuitive for developers with a background in Web development, and makes it easy to quickly write simple applications using high-level languages.

  • Native Application is developed using C and can access more advanced device-specific features, such as camera, GPS, and accelerometer in addition to more advanced system settings and functionality.

    The native applications use the Native API, which provides all of the memory management and performance benefits that come with building applications for Linux in C. The native API is extremely helpful, as it includes dozens of API modules that cover a large range of capabilities. It provides numerous interfaces to much of the hardware that is found in modern mobile and wearable devices, and does so in an environment that is tailored for limited resources.



저는 사실 Web 앱은 별로 관심 없고, Native 앱 개발에 초점을 맞춰보고 있습니다.


아래는 tizen wiki에서 찾을 수 있는 Tizen Native Application guide 이고, 

한국어 pdf파일도 있습니다! 

무려 900여 페이지 인데요. 좋은 공부자료가 될 것 같네요.


https://wiki.tizen.org/wiki/Guide_to_Developing_Tizen_Native_Application



그럼, 모두 즐거운 앱개발이 되시길 바라며!

마칩니다.



2016/04/02 - [Software Dev Note/Tizen] - 삼성 GearS2를 위한 타이젠 앱 개발하기 : [1] SDK설치 (맥 OS X)