어제 밤 궁싯거리다 날을 새니 얼굴이 열없는 것처럼 붉어졌다.

 

 

궁싯거리다 : 밤에 잠을 못이루고 이리저리 뒤척이다.

열없다. : 부끄럽다.

by Invincible Cooler 2014. 10. 30. 12:12

안녕하세요. 오늘은 한국사 시험에 대해서 적어보려고 합니다.

 

일단 크게 한국사 시험은 공무원 시험과 한국사 능력 검정시험 2개로 나눌 수 있습니다.

 

짧게 요약하자면, 한국사 능력 검정시험은 시대의 흐름을 잘 파악한다면, 문제를 어렵지 않게 풀 수 있습니다. 하지만, 공무원시험은 시대의 흐름과 상관없이 무조건 그 시대를 암기해야 하는 고통이 뒤 따릅니다.

 

그리고 한국사 능력 검정시험은 교과서를 위주로 인강과 함께하면 문제가 없지만, 공무원시험은 그걸로 안됩니다. 정말 색다르네요. 완전하게 암기를 위주로 나오는것 같습니다.

 

물론 그 이유는 한국사 능력 검정시험은 합격자 수의 제한이 없습니다. 그래서 난이도가 높던 낮던 문제가 안되지만, 공무원시험은 변별력이 있어야 하기 때문에, 고등학교 국사책을 처음부터 끝까지 외워도 풀 수 없는 문제가 출제 되는것 같습니다. 

 

어쨌든 결론은 공무원시험은 시험을 위한 시험인것이고, 한국사 능력검정시험은 한국사에 애착을 가지고, 흐름을 파악하면 문제가 없을것 같습니다.

 

이상 한국사 지킴이 였습니다.

 

지금 구글 플레이에 조선왕조실록과 한국사 요점정리 앱을 등록해 놨으니, 한번씩 다운로드 해서 받아보시고, 곧 고려왕조 실록도 선보이도록 하겠습니다.

 

- p.s 물론 다른 과목도 마찬가지라고 느낍니다. 특히 영어

앞으로도 한국사 능력시험과, 공무원시험을 계속 치면서, 어떤식으로 변하는지 느낌을 적어보도록 하겠습니다.

by Invincible Cooler 2014. 10. 30. 12:11

저번 글에서 블루투스 페어링 까지 알아 보았다.

 

그럼 이번엔 블루투스 사이의 연동부분을 알아보자. 이부분은 블루투스 챗 서비스에 너무너무 잘 나와있다.

 

그중 필요한 부분만 발췌하였다.

 

BluetoothClientConnect.java

 

package com.example.btclient;

 

import java.io.IOException;

import java.io.InputStream;

import java.io.OutputStream;

import java.util.UUID;

 

import android.bluetooth.BluetoothAdapter;

import android.bluetooth.BluetoothDevice;

import android.bluetooth.BluetoothSocket;

import android.content.Context;

import android.os.Bundle;

import android.os.Handler;

import android.os.Message;

 

import com.example.btclient.util.Logger;

 

public class BluetoothClientConnect {

    // Unique UUID for this application

    private static final UUID MY_UUID = UUID.fromString("fa87c0d0-afac-11de-8a39-0800200c9a66");

    

    // Member fields

    private final BluetoothAdapter mBluetoothAdapter;

    private final Handler mHandler;

    private ConnectThread mConnectThread;

    private ConnectedThread mConnectedThread;

    private int mState;

 

    // Constants that indicate the current connection state

    public static final int STATE_NONE = 0;       // we're doing nothing

    public static final int STATE_LISTEN = 1;     // now listening for incoming connections

    public static final int STATE_CONNECTING = 2; // now initiating an outgoing connection

    public static final int STATE_CONNECTED = 3;  // now connected to a remote device

    

    /**

     * Constructor. Prepares a new BluetoothConnect session.

     *

     * @param context The UI Activity Context

     * @param handler A Handler to send messages back to the UI Activity

     */

    public BluetoothClientConnect(Context context, Handler handler) {

     mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

     mHandler = handler;

        mState = STATE_NONE;

    }

    

    /**

     * Set the current state of the chat connection

     *

     * @param state An integer defining the current connection state

     */

    private synchronized void setState(int state) {

        Logger.print("setState() " + mState + " -> " + state);

        mState = state;

 

        // Give the new state to the Handler so the UI Activity can update

        mHandler.obtainMessage(BTClientMainActivity.MESSAGE_STATE_CHANGE, state, -1).sendToTarget();

    }

    

    /**

     * Return the current connection state.

     */

    public synchronized int getState() {

        return mState;

    }

    

    /**

     * Start the chat service. Specifically start AcceptThread to begin a

     * session in listening (server) mode. Called by the Activity onResume()

     */

    public synchronized void start() {

     Logger.print("start...");

    

     // Cancel any thread attempting to make a connection

        if (mConnectThread != null) {

            mConnectThread.cancel();

            mConnectThread = null;

        }

 

        // Cancel any thread currently running a connection

        if (mConnectedThread != null) {

            mConnectedThread.cancel();

            mConnectedThread = null;

        }

 

        setState(STATE_LISTEN);

    }

    

    /**

     * Start the ConnectThread to initiate a connection to a remote device.

     *

     * @param device The BluetoothDevice to connect

     */

    public synchronized void connect(BluetoothDevice device) {

     Logger.print("connect to: " + device);

 

        // Cancel any thread attempting to make a connection

        if (mState == STATE_CONNECTING) {

            if (mConnectThread != null) {

                mConnectThread.cancel();

                mConnectThread = null;

            }

        }

 

        // Cancel any thread currently running a connection

        if (mConnectedThread != null) {

            mConnectedThread.cancel();

            mConnectedThread = null;

        }

 

        // Start the thread to connect with the given device

        mConnectThread = new ConnectThread(device);

        mConnectThread.start();

        setState(STATE_CONNECTING);

    }

    

    /**

     * Start the ConnectedThread to begin managing a Bluetooth connection

     *

     * @param socket The BluetoothSocket on which the connection was made

     * @param device The BluetoothDevice that has been connected

     */

    public synchronized void connected(BluetoothSocket socket, BluetoothDevice device) {

     Logger.print("connected");

 

        // Cancel the thread that completed the connection

        if (mConnectThread != null) {

            mConnectThread.cancel();

            mConnectThread = null;

        }

 

        // Cancel any thread currently running a connection

        if (mConnectedThread != null) {

            mConnectedThread.cancel();

            mConnectedThread = null;

        }

 

        // Start the thread to manage the connection and perform transmissions

        mConnectedThread = new ConnectedThread(socket);

        mConnectedThread.start();

 

        // Send the name of the connected device back to the UI Activity

        Message msg = mHandler.obtainMessage(BTClientMainActivity.MESSAGE_DEVICE_NAME);

        Bundle bundle = new Bundle();

        bundle.putString(BTClientMainActivity.DEVICE_NAME, device.getName());

        msg.setData(bundle);

        mHandler.sendMessage(msg);

 

        setState(STATE_CONNECTED);

    }

    

    /**

     * Stop all threads

     */

    public synchronized void stop() {

     Logger.print("stop");

    

        if (mConnectThread != null) {

            mConnectThread.cancel();

            mConnectThread = null;

        }

        if (mConnectedThread != null) {

            mConnectedThread.cancel();

            mConnectedThread = null;

        }

 

        setState(STATE_NONE);

    }

    

    /**

     * Write to the ConnectedThread in an unsynchronized manner

     *

     * @param out The bytes to write

     * @see ConnectedThread#write(byte[])

     */

    public void write(byte[] out) {

        // Create temporary object

        ConnectedThread r;

        // Synchronize a copy of the ConnectedThread

        synchronized (this) {

            if (mState != STATE_CONNECTED) {

             return;

            }

            r = mConnectedThread;

        }

        // Perform the write unsynchronized

        r.write(out);

    }

 

    /**

     * Indicate that the connection attempt failed and notify the UI Activity.

     */

    private void connectionFailed() {

        setState(STATE_LISTEN);

 

        // Send a failure message back to the Activity

        Message msg = mHandler.obtainMessage(BTClientMainActivity.MESSAGE_TOAST);

        Bundle bundle = new Bundle();

        bundle.putString(BTClientMainActivity.TOAST, "Unable to connect device");

        msg.setData(bundle);

        mHandler.sendMessage(msg);

    }

    

    /**

     * Indicate that the connection was lost and notify the UI Activity.

     */

    private void connectionLost() {

        setState(STATE_LISTEN);

 

        // Send a failure message back to the Activity

        Message msg = mHandler.obtainMessage(BTClientMainActivity.MESSAGE_TOAST);

        Bundle bundle = new Bundle();

        bundle.putString(BTClientMainActivity.TOAST, "Device connection was lost");

        msg.setData(bundle);

        mHandler.sendMessage(msg);

    }

 

    /**

     * This thread runs while attempting to make an outgoing connection

     * with a device. It runs straight through; the connection either

     * succeeds or fails.

     */

    private class ConnectThread extends Thread {

        private final BluetoothSocket mSocket;

        private final BluetoothDevice mDevice;

 

        public ConnectThread(BluetoothDevice device) {

            mDevice = device;

            BluetoothSocket tmp = null;

 

            // Get a BluetoothSocket for a connection with the

            // given BluetoothDevice

            try {

                tmp = device.createRfcommSocketToServiceRecord(MY_UUID);

            } catch (IOException e) {

             Logger.print("create() failed : " + e.getMessage());

            }

            mSocket = tmp;

        }

 

        public void run() {

         Logger.print("BEGIN mConnectThread");

            setName("ConnectThread");

 

            // Always cancel discovery because it will slow down a connection

            mBluetoothAdapter.cancelDiscovery();

 

            // Make a connection to the BluetoothSocket

            try {

                // This is a blocking call and will only return on a

                // successful connection or an exception

                mSocket.connect();

            } catch (IOException e) {

                connectionFailed();

                // Close the socket

                try {

                    mSocket.close();

                } catch (IOException e2) {

                 Logger.print("unable to close() socket during connection failure : " + e2.getMessage());

                }

                // Start the service over to restart listening mode

                BluetoothClientConnect.this.start();

                return;

            }

 

            // Reset the ConnectThread because we're done

            synchronized (BluetoothClientConnect.this) {

                mConnectThread = null;

            }

 

            // Start the connected thread

            connected(mSocket, mDevice);

        }

 

        public void cancel() {

            try {

                mSocket.close();

            } catch (IOException e) {

             Logger.print("close() of connect socket failed : " + e.getMessage());

            }

        }

    }

 

    /**

     * This thread runs during a connection with a remote device.

     * It handles all incoming and outgoing transmissions.

     */

    private class ConnectedThread extends Thread {

 

        private final BluetoothSocket mSocket;

        private final InputStream mInStream;

        private final OutputStream mOutStream;

 

        public ConnectedThread(BluetoothSocket socket) {

         Logger.print("create ConnectedThread");

 

            mSocket = socket;

            InputStream tmpIn = null;

            OutputStream tmpOut = null;

 

            // Get the BluetoothSocket input and output streams

            try {

                tmpIn = socket.getInputStream();

                tmpOut = socket.getOutputStream();

            } catch (IOException e) {

             Logger.print("temp sockets not created : " + e.getMessage());

            }

 

            mInStream = tmpIn;

            mOutStream = tmpOut;

        }

 

        public void run() {

 

         Logger.print("BEGIN mConnectedThread");

            byte[] buffer = new byte[1024];

            int bytes;

 

            // Keep listening to the InputStream while connected

            while (true) {

                try {

                    // Read from the InputStream

                    bytes = mInStream.read(buffer);

 

                    // Send the obtained bytes to the UI Activity

                    mHandler.obtainMessage(BTClientMainActivity.MESSAGE_READ, bytes, -1, buffer).sendToTarget();

 

                } catch (IOException e) {

                 Logger.print("disconnected : " + e.getMessage());

                    connectionLost();

                    break;

                }

            }

        }

 

//        /**

//         * Write to the connected OutStream.

//         *

//         * @param buffer The bytes to write

//         */

        public void write(byte[] buffer) {

            try {

                mOutStream.write(buffer);

 

                // Share the sent message back to the UI Activity

                mHandler.obtainMessage(BTClientMainActivity.MESSAGE_WRITE, -1, -1, buffer).sendToTarget();

            } catch (IOException e) {

             Logger.print("Exception during write : " + e.getMessage());

            }

        }

 

        public void cancel() {

            try {

                mSocket.close();

            } catch (IOException e) {

             Logger.print("close() of connect socket failed : " + e.getMessage());

            }

        }

    }

}


자바를 어느정도 읽을줄 아는 분이면 대충이해가 갈것이다.
여기에는 중요한 쓰레드가 두개가 나온다. ConnectThread와 ConnectedThread이다.

먼저 여기서 쓰레드를 사용한 이유는 메인 UI의 버벅거림을 주지 않기 위해서라는 것을 파악하고 넘어가자

ConnectThread 는 서버에 접속하는 쓰레드 이다. 
ConnectedThread 는 서버로 메시지를 전송 또는 서버에서 보낸 메시지를 받는 쓰레드 이다.

InputStream 과 OutputStream 을이용해서 서버와 메시지를 주고 받는다.

받은 메시지를 클라이언트 화면에 보여주기 위해서 Handler를 사용하였다.


by Invincible Cooler 2014. 10. 28. 11:14

오늘은 Bluetooth 서버 클라이언트 연동에 대해서 알아본다.

 

bluetooth 서버 클라이언트 연동은 bluetooth chat service에 그 연동부분이 완벽하게 구현이 되어 있기 때문에 

1. 어느 부분이 서버 역할을 하고, 어느 부분이 클라이언트 역할을 하는지

2. bluetooth 연동설정의 순서 등을 알아 보기로 한다.

 

자세한 내용은 아래를 참고하면 된다.

http://developer.android.com/guide/topics/connectivity/bluetooth.html

 

위의 URL 보다 블루투스에 대해서 자세하게 나온곳은 없는 것 같다. 가장 완벽하다. 그런데 영어다.

 

그래서 아래와 같이 설명하도록 한다.

 

먼저 여기서 알아 볼 내용은 

 

클라이언트에서 메시지를 보내면, 서버에서 클라이언트에서 받은 메시지를 출력하는 것이다.

 

이렇게 하기 위해서

 

1. 연결가능한 블루투스를 찾는다. -> discovery 라고 한다.

2. 연결 가능한 블루투스를 paring 한다. -> 메시지를 보내려면 paring이 되어 있어야 한다.

3. 클라이언트에서 메시지를 전송한다.

4. 서버에서 메시지를 출력한다.

 

이다.

 

먼저 연결 가능한 블루투스를 찾는 방법을 알아 보자.

 

1. 블루투스아답터를 통하여 블루투스를 지원하는지 확인한다.

// Get local Bluetooth adapter

        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

        

     // If the adapter is null, then Bluetooth is not supported

        if (mBluetoothAdapter == null) {

            Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();

//            finish();

            return;

        }

 

블루투스를 지원하지 않는다면 당연히 다음 조건을 실행할 이유가 없다.

 

2. 블루투스가 꺼져있다면, 실행시킨다. 실행은 유저가 직접 on버튼을 눌러야만 한다. 시스템적으로 불가능하다.

 

Intent 전송

if (!mBluetoothAdapter.isEnabled()) {

            Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);

            startActivityForResult(enableIntent, REQUEST_ENABLE_BT);

            // Otherwise, setup the chat session

        } 

Intent 받음

 

public void onActivityResult(int requestCode, int resultCode, Intent data) {

     Logger.print("onActivityResult " + resultCode);

        switch (requestCode) {

case REQUEST_ENABLE_BT:

                // When the request to enable Bluetooth returns

                if (resultCode == Activity.RESULT_OK) {

}

 

- 연결 가능한 블루투스 찾기 : discovery

 

1. 브로트 캐스트 등록

IntentFilter filter = new IntentFilter();

filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);

filter.addAction(BluetoothDevice.ACTION_FOUND);

filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);

filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED);

registerReceiver(mBTDiscoveryReceiver, filter);

 

2. 리시버 받아서 리스트에 등록

//Broadcast Receiver

private final BroadcastReceiver mBTDiscoveryReceiver = new BroadcastReceiver() {

    public void onReceive(Context context, Intent intent) {

        String action = intent.getAction();

        

        if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) {

         final int state = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);

 

         if (state == BluetoothAdapter.STATE_ON) {

         Logger.print("Enabled : Enabled");

          }

        } 

        else if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)) {

         Logger.print("action : " + action);

         showProgressDialog();

        

            }

        else if (BluetoothDevice.ACTION_FOUND.equals(action)) {

            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);

            

            String deviceName = device.getName();

            String deviceAddress = device.getAddress();

            

            Logger.print("deviceName : " + deviceName);

            Logger.print("deviceAddress : " + deviceAddress);

            

            boolean isDuplicate = false;

            

            for(DeviceData deviceData : mInfoList) {

             if(deviceData.getAddress().equals(deviceAddress)) {

             isDuplicate = true;

             }

            }

            

            if(!isDuplicate) {

             DeviceData data = new DeviceData();

             data.setName(deviceName);

             data.setAddress(deviceAddress);

             data.setDevice(device);

            

             mInfoList.add(data);

//              mAdapter.notifyDataSetChanged();

            }

        }

        else if(BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) /* Action Discovery Finish */

{

         Logger.print("action : " + action);

         dismissProgressDialog();

         mAdapter.notifyDataSetChanged();

}

    }

};

 

3. request pairing

private void pairDevice(BluetoothDevice device) {

        try {

            Method method = device.getClass().getMethod("createBond", (Class[]) null);

            method.invoke(device, (Object[]) null);

        } catch (Exception e) {

            e.printStackTrace();

        }

    }

 

<=> unpair

private void unpairDevice(BluetoothDevice device) {

        try {

            Method method = device.getClass().getMethod("removeBond", (Class[]) null);

            method.invoke(device, (Object[]) null);

 

        } catch (Exception e) {

            e.printStackTrace();

        }

    }

 

- 페어링된 블루투스 찾기

Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();

// If there are paired devices

if (pairedDevices != null && pairedDevices.size() > 0) {

    // Loop through paired devices

    for (BluetoothDevice device : pairedDevices) {

     String deviceName = device.getName();

            String deviceAddress = device.getAddress();

            

            Logger.print("deviceName : " + deviceName);

            Logger.print("deviceAddress : " + deviceAddress);

            

            boolean isDuplicate = false;

            

            for(DeviceData deviceData : mInfoList) {

             if(deviceData.getAddress().equals(deviceAddress)) {

             isDuplicate = true;

             }

            }

            

            if(!isDuplicate) {

             DeviceData data = new DeviceData();

             data.setName(deviceName);

             data.setAddress(deviceAddress);

            

             mInfoList.add(data);

             mAdapter.notifyDataSetChanged();

            }

    }

}

 

위에서 duplicate 체크한이유는, 같은 블루투스 리스트를 찾는 경우 발생(브로드 캐스트 리시버라서 그런것 같다)

 

위와 같이 하면 블루투스 페어링까지는 끝냈다. 다음 블로그에서 클라이언트 데이타 전송을 계속 이어 나가도록 하겠다.

by Invincible Cooler 2014. 10. 28. 11:13

안녕하세요. 한국사 요점정리 개발자입니다.

 

오랜만에 한국사능력검정시험을 봤으니, 후기를 올려야겠지요.

 

2013년 8월인가 시험을 보고 14개월만에 다시 시험을 보았다. 예전에 1급을 못따고 2급에 머물렀기 때문에 불타오르는 의욕으로 다시 시험을 본거죠. 결과는?? 물론 아직 결과는 나오지 않았지만... 94점으로 1급 합격한것 같습니다.

 

헐 94점 나도 놀란 점수 이다.

 

내가 잘했다니 보다는 문제가 내 스타일로 나온거다. 보통 한국사능력검정시험은 전근대사 80~90%이상 근현대사 10~20% 정도 비중이 출제됐는데, 이번에는 느낌상 근현대사가 30%이상 차지 한 느낌이다. 개인적으로 조선사와 근현대사를 즐기는 입장으로 이번시험이 나하고 궁합이 잘맞았다.

 

일단 시험내용을 보면, 영화 광해의 대사가 그대로 나왔다. 그리고 명량에서 다뤄졌던 판옥선 문제가 나왔다. 판옥선에 그런 이유가 있는지는 몰랐다. 무론 17백만 관객의 명량도 아직 못봤고...

 

문제를 볼까요?

어김없이 구석기, 신석기, 청동기 중에 한문제

여러나라의 성장에서 한문제

삼국시대에서 몇문제가 나왔는데, 이번엔 의외다. 가야가 나왔다. 바보온달 이야기도 나오고.

바보온달이 고구려시대의 장수인건 알고 있었는데, 영양와 시기인것 까지는 몰랐다. 그래서 틀렸다. 전반적으로 지문이 쉽지는 않았던것 같다. 키워드 위주로 공부할 수 밖에없는 현실인데, 그 키워드를 전혀 포착할 수 없는 문제가 몇 문제 있었던것 같다. 물론 내 공부가 잘못됐을수 도 있고.

 

어쨌든 1급을 획득했으니, 이젠 한국사 능력검정시험을 볼 일은 없을것 같다. 하지만 한국사를 사랑하는 사람중 한명으로서, 한국사 공부는 꾸준히 하려고한다. 이젠 수박겉핥기가 아니라, 약간 심도 있게 들어가야겠지만... 쉽지 않을것 같다.

 

그리고 마지막으로 한국사 요점정리 어플을 이용해주시는 분들에게 정말 고마움을 느낍니다. 한국사 요점정리 어플에도 적어놨지만, 그정도만 알아도 3급정도는 딸 수 있을겁니다. 초,중,고등학생도 학교 역사시험에서 90점이상 획득할 수 있도록 만들었습니다. 가끔 한국사 어플을 비판하시는 분이 있는데, 사람의 관점은 다른것이기에 충분히 이해하고 있습니다. 다만 관점이 다르다고, 무조건 잘못됐다는 편견만 없으면 됩니다.

 

여러분도 열심히 공부하시고, 좋은 결과 있길 바랍니다.

 

p.s 한국사능력 검정시험을 처음 보려고 하는 사람을 위해서 조언을 드립니다.

 

먼저 EBS로 가서 인터넷 강의를 아무거나 다운받고, 처음부터 끝까지 듣습니다. 전 최태성 선생님 강의를 들었습니다. 필요하면 한국사 요점정리 어플을 다운로드 받아서, 요점정리를 합니다. 큰 틀은 최태성 선생님의 강의로 이루어졌기때문에, 인강을 본사람은 쉽게 이해할 수 있을 겁니다. 그리고 전 LTE한국사라는 책을 취미로 읽었습니다. 인물로 보는 삼국사는 이제 읽어보려고 샀고요. 여러분 최선을 다하시고, 정말 고생많았습니다.

 

그리고 근현대사를 보면서 신기한것 한가지... 장준하(독립운동가, 국회의원등) 사건이 신기합니다.

박정희 시대의 장준하가 실족사한걸로 나와있는데(교과과정), 무덤을 이장하려고 하니, 장준하의 두개골이 무언가에 의해서 부셔졌다고 합니다. 이건 실족사일까요? 살인일까요? 유병언 사건도 마찬가지 일것 같습니다. 유병언을 살해해놓고, 시신을 바꿔치기 했다가 가장 신빙성이 높은것 같습니다. 왜일까요? 유병언이 잡히면 누가 가장많이 피해를 볼까요? 한국사는 언론에 휘둘리지 않기 위해서 정말 필요한 교과목인것 같습니다. 물론 대학교 이상이 되어야 깨달을 확률이 높지만요... 그럼... 고생하셨습니다.

by Invincible Cooler 2014. 10. 28. 06:49
| 1 ··· 4 5 6 7 |