상세 컨텐츠

본문 제목

Build Controlpanel Service application for Android

Dev.Stroy/IoT

by zNine 2014. 10. 23. 11:53

본문

728x90
반응형

AllJoyn Controlpanel 을 작업 할 일이 있어 남긴다.
목적은 심플하게 디바이스의 Power, Vol+/- 를 AllJoyn Controlpanel 을 통해 지원하도록 하는 것!!
  • Controlpanel 서비스 빌드
  1. 준비사항
    1. AllJoyn Full Source
    2. Build tools and libraries
      1. https://allseenalliance.org/docs-and-downloads/documentation/configuring-build-environment-linux-platform#unique_10
  2. Build
  3. # cd services/base/controlpanel

    # scons OS=android CPU=arm BINDINGS=core,cpp SERVICES=about,controlpanel BUILD_SERVICES_SAMPLES=off WS=off ANDROID_NDK=/data4/dsshin/Android/android-ndk-r9d ANDROID_SRC=/data4/dsshin/TCC_STB_JELLYBEAN/SDK_v13.05/ VARIANT=debug


  • Contorlpanel controlee application 만들기
  1. xml 파일로 code 생성하기
    1. 참고: https://allseenalliance.org/docs-and-downloads/documentation/alljoyn-control-panel-service-framework-10-usage-guide-linux-cpp#unique_17
    2. SampleXMLs 밑에 샘플 xml 파일들 있으니 참고
    3. 아래와 같이 실행하면 지정한 디렉토리에 여러개 파일들이 생김
    4. 생성 된 파일들을 가져와서 Android binary application 으로 빌드 한다.

    # cd cpp/tools/CPSAppGenerator

    # mkdir path_for_generated_files

    python generateCPSApp.py <XML file the generate code from> -p <destination path for generated files>

    아래는 내 xml 파일

    <?xml version="1.0"?>

    <controlPanelDevice xmlns="http://www.alljoyn.org/controlpanel/gen">

        <name>M370_Control</name>

        <headerCode>#include "ControlPanelProvided.h"</headerCode>

        <languageSet name="myLanguages">

            <language>en</language>

        </languageSet>

        <controlPanels>

            <controlPanel languageSet="myLanguages">

                <rootContainer>

                    <name>rootContainer</name>

                    <secured>false</secured>

                    <enabled>true</enabled>

                    <bgcolor>0x1e90ff</bgcolor>

                    <hints>

                                            <hint>vertical_linear</hint>

                        <hint>horizontal_linear</hint>

                    </hints>

                                    <elements>

                                    <container>

                            <name>powerControl</name>

                        <secured>false</secured>

                            <enabled>true</enabled>

                        <bgcolor>0x200</bgcolor>

                                            <hints>

                                                    <hint>vertical_linear</hint>

                                            </hints>

                            <elements>

                            <action>

                                    <name>powerOnOff</name>

                                    <onAction>

                                    <executeCode>powerOnOff();</executeCode>

                                    </onAction>

                                <secured>false</secured>

                                    <enabled>true</enabled>

                                <label>

                                      <value type="literal" language="en">Power</value>

                                    </label>

                                <bgcolor>0x400</bgcolor>

                                    <hints>

                                    <hint>actionButton</hint>

                                    </hints>

                            </action>

                            </elements>

                                    </container>

                                    <container>

                            <name>volumeControl</name>

                        <secured>false</secured>

                            <enabled>true</enabled>

                        <bgcolor>0x200</bgcolor>

                                            <hints>

                                                    <hint>vertical_linear</hint>

                                            </hints>

                            <elements>

                            <action>

                                    <name>volumeUp</name>

                                    <onAction>

                                    <executeCode>volumeUp();</executeCode>

                                    </onAction>

                                <secured>false</secured>

                                    <enabled>true</enabled>

                                <label>

                                      <value type="literal" language="en">Volume Up</value>

                                    </label>

                                <bgcolor>0x400</bgcolor>

                                    <hints>

                                    <hint>actionButton</hint>

                                    </hints>

                            </action>

                                                    <action>

                                    <name>volumeDown</name>

                                    <onAction>

                                    <executeCode>volumeDown();</executeCode>

                                    </onAction>

                                <secured>false</secured>

                                    <enabled>true</enabled>

                                <label>

                                      <value type="literal" language="en">Volume Down</value>

                                    </label>

                                <bgcolor>0x400</bgcolor>

                                    <hints>

                                    <hint>actionButton</hint>

                                    </hints>

                            </action>

                            </elements>

                                    </container>

                                    </elements>

                </rootContainer>

            </controlPanel>

        </controlPanels>

    </controlPanelDevice>

  2. Android.mk 생성
    1. 보면 stdc++ 까지 static 으로 넣어 버렸는데 이는 빌드 에러 때문에..
    2. generated 디렉토리에 자동으로 생성된 파일들이 모두 위치해 있고, provided 디렉토리에는 generated 에서 action 버튼이 눌려졌을때 호출 된 함수들을 정의해 놓았다.

    LOCAL_PATH:=$(call my-dir)


    NDK_DIR = /Android/android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.6


    GEN_DIR = generated

    PRO_DIR = provided

    SAM_DIR = samples_common


    include $(CLEAR_VARS)

    # for static libs

    LOCAL_PREBUILT_LIBS :=  \

                            lib/libajrouter.a   \

                            lib/liballjoyn-daemon.a \

                            lib/liballjoyn.a    \

                            lib/liballjoyn_controlpanel.a   \

                            lib/libbbdaemon-lib.a   \

                            lib/liballjoyn_about.a  \

                            lib/liballjoyn_services_common.a    \

                            lib/libbundledRouter.a  \

                            lib/libgnustl_static.a  \

                            lib/libstdc++.a


    include $(BUILD_MULTI_PREBUILT)


    include $(CLEAR_VARS)


    include $(BUILD_PREBUILT)


    include $(CLEAR_VARS)


    # for binary build

    LOCAL_MODULE := control_panel


    LOCAL_CPP_EXTENSION := .cc


    LOCAL_CFLAGS := -Wall -Wno-psabi -Wno-write-strings -DANDROID_NDK -DTARGET_ANDROID -DLINUX -DQCC_OS_GROUP_POSIX -DQCC_OS_ANDROID -DQCC_CPU_ARM -DANDROID


    LOCAL_SRC_FILES :=  \

                        main_ControlPanel.cc


    LOCAL_SRC_FILES +=  \

                        $(GEN_DIR)/ControlPanelGenerated.cc \

                        $(GEN_DIR)/M370_ControlPowerOnOff.cc    \

                        $(GEN_DIR)/M370_ControlVolumeDown.cc    \

                        $(GEN_DIR)/M370_ControlVolumeUp.cc


    LOCAL_SRC_FILES +=  \

                        $(PRO_DIR)/ControlPanelProvided.cc


    LOCAL_SRC_FILES +=  \

                        $(SAM_DIR)/AnnounceHandlerImpl.cc   \

                        $(SAM_DIR)/AsyncSessionJoiner.cc    \

                        $(SAM_DIR)/CommonBusListener.cc \

                        $(SAM_DIR)/CommonSampleUtil.cc  \

                        $(SAM_DIR)/IniParser.cc \

                        $(SAM_DIR)/PropertyStoreImpl.cc \

                        $(SAM_DIR)/SessionListenerImpl.cc   \

                        $(SAM_DIR)/SrpKeyXListener.cc


    LOCAL_C_INCLUDES := \

                        $(LOCAL_PATH)/inc   \

                        $(LOCAL_PATH)/innopia_M370_generated    \

                        $(LOCAL_PATH)/innopia_M370_provided \

                        $(LOCAL_PATH)/samples_common    \

                        $(NDK_DIR)/include  \

                        $(NDK_DIR)/libs/armeabi/include



    LOCAL_STATIC_LIBRARIES := libajrouter liballjoyn-daemon liballjoyn liballjoyn_controlpanel libbbdaemon-lib liballjoyn_about liballjoyn_services_common libbundledRouter \

                              libgnustl_static libstdc++


    LOCAL_SHARED_LIBRARIES := libcrypto libssl


    include $(BUILD_EXECUTABLE)

  3. Build 하면된다.
  4. provided 에 있는 파일 내용
    1. 간단하다. 각각애 대해서 파워/볼륨 키 입력되도록 해버림~

#include <stdlib.h>


#include "ControlPanelProvided.h"


void powerOnOff() {

        printf("powerOff called!!\n");

        system("input keyevent 26");

}


void volumeUp() {

        printf("volumeUp called!!\n");

        system("input keyevent 24");

}


void volumeDown() {

        printf("volumeDown called!!\n");

        system("input keyevent 25");

}


728x90
반응형

'Dev.Stroy > IoT' 카테고리의 다른 글

AllJoyn Audio Service for Android  (5) 2014.07.17

관련글 더보기