Last active
January 26, 2020 20:40
-
-
Save southwolf/6365045 to your computer and use it in GitHub Desktop.
Arduino code for Communicate with Pebble
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <ctype.h> | |
#include <SoftwareSerial.h> | |
// the Bluetooth Shield connects to Pin D9 & D10 | |
SoftwareSerial bt(9,10); | |
const uint8_t req[5] = {0x00, 0x01, 0x00, 0x11, 0x00}; | |
const uint8_t cap[17] = {0x00, 0x0d, 0x00, 0x11, 0x01, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32}; | |
const uint8_t ping[9] = {0x00, 0x05, 0x07, 0xd1, 0x00, 0xde, 0xad, 0xbe, 0xef}; | |
void setup() | |
{ | |
Serial.begin(9600); | |
bt.setTimeout(100); | |
bt.begin(9600); | |
Serial.println("Arduino - Pebble Test"); | |
} | |
void loop() | |
{ | |
int i = 0; | |
bool is_req = false; | |
// After connected with Arduino, Pebble sends a 5 bytes request asking for "Phone Version" | |
// We make a fake answer to Pebble so that Pebble takes our arduino as an "android phone" | |
// For details, check https://github.com/Hexxeh/libpebble | |
if(bt.available()) | |
{ | |
for(i = 0;i < 5; i++) | |
{ | |
int sig = bt.read(); | |
Serial.print((char)sig); | |
if(req[i] != sig) | |
{ | |
break; | |
} | |
is_req = true; | |
} | |
} | |
if(is_req) | |
{ | |
bt.write(cap, 17); | |
} | |
bt.write(ping, 9); | |
delay(5000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where do i enter the pebbles Bluetooth ID?