Skip to content

Instantly share code, notes, and snippets.

@southwolf
Last active January 26, 2020 20:40
Show Gist options
  • Star 27 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save southwolf/6365045 to your computer and use it in GitHub Desktop.
Save southwolf/6365045 to your computer and use it in GitHub Desktop.
Arduino code for Communicate with Pebble
#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);
}
@soulslicer
Copy link

Where do i enter the pebbles Bluetooth ID?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment