Transferring data between iPhone and Google Glass

I want to connect my phone to my Google glass and transfer the data (photos, text, etc.) between them.

I was thinking about using Bluetooth LTE, but as I understand it, Glass does not support it, because it only works with version 4.0.3 (or similar) of Android.

I know that you can connect the phone and glass through the myGlass application, so I understand that I want to make this possible. However, I was wondering if anyone could point me in the right direction to get started? In particular, what technologies should be considered if not CoreBluetooth on the iOS side? Has anyone else done this?

Also, if it would be better to use Bonjour or even create an access point on my iPhone and connect in this way, any tutorials you could tell me would be great.

Thanks in advance.

+4
source share
2 answers

I am writing a Google Glass development book for Apress and have just completed the Network and Bluetooth section with some working samples to allow Glass to communicate with the iPhone for data transfer. You are correct that Glass at the moment (API level 15) does not support Bluetooth Low Energy (BLE). I implemented three ways to make data transfer between Glass and iOS:

  • Glass Android-, Nexus 7 Android 4.3 , BLE, Bluetooth , Nexus 7 BLE, iOS BLE. , BLE , .

  • Glass iOS - C, , Glass Java, . Glass iOS Wi-Fi, .

  • - Glass iOS Apple Push Notification. Glass WhatsApp WeChat, iOS.

iOS, :

- (void) runSocketServer {
    int listenfd = 0;
    __block int connfd = 0;
    struct sockaddr_in serv_addr;

    __block char sendBuff[1025];

    listenfd = socket(AF_INET, SOCK_STREAM, 0);
    memset(&serv_addr, '0', sizeof(serv_addr));
    memset(sendBuff, '0', sizeof(sendBuff));

    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
    serv_addr.sin_port = htons(6682);

    bind(listenfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr));    
    listen(listenfd, 10);

    dispatch_async(dispatch_get_global_queue(0, 0), ^{        
        connfd = accept(listenfd, (struct sockaddr*)NULL, NULL);
        int count = 1;
        while (count++ < 120) {
            char rate[100];
            sprintf(rate, "%i\n", bpm);            
            write(connfd, rate, strlen(rate));            
            sleep(1);
        }

        close(connfd);
    });
}

, :

public void run()
{
    String serverName = "192.168.1.11"; 
    int port = 6682;
    try
    {
        socket = new Socket(serverName, port);
        BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        do {
            result = input.readLine();
            runOnUiThread(new Runnable() {
                public void run() {
                    mTvInfo.setText(result);
                }
            });                 
        } while (result != null);

        });                  
    }
    catch(Exception e) {
        try { socket.close(); }
        catch (Exception e2) {};
        e.printStackTrace();
    }
}
+3

Source: https://habr.com/ru/post/1534308/


All Articles