-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc7177c
commit ee7858c
Showing
31 changed files
with
1,971,460 additions
and
1,970,696 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*.app | ||
*.dbg | ||
*.o | ||
*.map | ||
*.sym | ||
*.xap | ||
image | ||
depend | ||
.vscode |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
########################################################### | ||
# Makefile generated by xIDE | ||
# | ||
# Project: DS4 | ||
# Configuration: Release | ||
# Generated: ¶g¤T ¤T¤ë 4 15:57:55 2020 | ||
# | ||
# WARNING: Do not edit this file. Any changes will be lost | ||
# when the project is rebuilt. | ||
# | ||
########################################################### | ||
|
||
OUTPUT=DS4 | ||
OUTDIR=C:/Users/kautism/Desktop/Bluetooth/BC3-MM-DS4 | ||
HARDWARE_INDEX=4 | ||
DEFS= | ||
|
||
DEBUGTRANSPORT=SPITRANS=USB SPIPORT=1 | ||
EXECUTION_MODE=vm | ||
STACKSIZE=0 | ||
TRANSPORT=raw | ||
FIRMWARE=unified | ||
HARDWARE=kalimba | ||
BUILD_MERGE=merge | ||
FIRMWAREIMAGE= | ||
LIBRARY_VERSION= | ||
|
||
LIBS=-lconnection -lbdaddr | ||
INPUTS=\ | ||
main.c\ | ||
uart.c\ | ||
inquiry.c\ | ||
cmd.c\ | ||
utils.c\ | ||
led.c\ | ||
uart.h\ | ||
inquiry.h\ | ||
utils.h\ | ||
led.h | ||
|
||
-include DS4.mak | ||
include $(BLUELAB)/Makefile.vm |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<project buildenvironment="{84faf732-1340-4049-9094-244167adf571}" buildenvironmentname="vm" executionenvironmentoption="" buildenvironmentoption="" executionenvironmentname="vm" executionenvironment="{2b2c6868-a56e-4266-962a-cddf1c979343}" > | ||
<folder name="C Files" > | ||
<extension name="c" /> | ||
<file path="main.c" /> | ||
<file path="uart.c" /> | ||
<file path="inquiry.c" /> | ||
<file path="cmd.c" /> | ||
<file path="utils.c" /> | ||
<file path="led.c" /> | ||
</folder> | ||
<folder name="Header Files" > | ||
<extension name="h" /> | ||
<file path="uart.h" /> | ||
<file path="inquiry.h" /> | ||
<file path="utils.h" /> | ||
<file path="led.h" /> | ||
</folder> | ||
<properties currentconfiguration="Release" > | ||
<configuration name="Release" > | ||
<property key="buildMatch" >(file):(line):</property> | ||
<property key="build_merge" >1</property> | ||
<property key="buildtransport" >1</property> | ||
<property key="debugtransport" >[SPITRANS=USB SPIPORT=1]</property> | ||
<property key="defines" ></property> | ||
<property key="execution_mode" >0</property> | ||
<property key="firmware" >0</property> | ||
<property key="flashsize" >0</property> | ||
<property key="hardware" >3</property> | ||
<property key="libs" >connection,bdaddr</property> | ||
<property key="output" ></property> | ||
<property key="stacksize" ></property> | ||
</configuration> | ||
</properties> | ||
</project> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<workspace> | ||
<project path="DS4.xip" /> | ||
</workspace> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
String indexOf() and lastIndexOf() functions | ||
Examples of how to evaluate, look for, and replace characters in a String | ||
created 27 Jul 2010 | ||
modified 2 Apr 2012 | ||
by Tom Igoe | ||
This example code is in the public domain. | ||
http://www.arduino.cc/en/Tutorial/StringIndexOf | ||
*/ | ||
#include <Arduino.h> | ||
#include <SoftwareSerial.h> | ||
|
||
SoftwareSerial dongle(2, 3); // RX, TX | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
while (!Serial) | ||
{ | ||
; // wait for serial port to connect. Needed for native USB port only | ||
} | ||
} | ||
|
||
char buf[64]; | ||
int bytes = 0; | ||
void loop() | ||
{ | ||
if (Serial.available()){ | ||
Serial.println("user input"); | ||
bytes = Serial.readBytes(buf,64); | ||
dongle.write(buf,bytes); | ||
} | ||
if (dongle.available()) { | ||
Serial.println("dongle input"); | ||
bytes = dongle.readBytes(buf,64); | ||
Serial.write(buf,bytes); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <panic.h> | ||
#include <app/bluestack/types.h> | ||
#include <app/bluestack/bluetooth.h> | ||
#include "main.h" | ||
#include "cmd.h" | ||
#include "uart.h" | ||
#include "log.h" | ||
#include "utils.h" | ||
|
||
void cmd_parser(uint8 *buf) | ||
{ | ||
if (strstr((char *)buf, (char *)"scan")) | ||
{ | ||
UartPrintf("Scan start...\n"); | ||
ConnectionInquire(&theApp.task, 0x9E8B33, 0, 8, 0 /*listen all type*/); | ||
} | ||
else if (strstr((char *)buf, (char *)"name")) | ||
{ | ||
ConnectionReadLocalName(&theApp.task); | ||
} | ||
else if (strstr((char *)buf, (char *)"conn")) | ||
{ | ||
bdaddr *addr = PanicUnlessMalloc(sizeof(bdaddr)); | ||
buf[9]=0; | ||
buf[12]=0; | ||
buf[19]=0; | ||
addr->nap=hexadecimalToDecimal((char *)buf+5); | ||
addr->uap=hexadecimalToDecimal((char *)buf+10); | ||
addr->lap=hexadecimalToDecimal((char *)buf+13); | ||
UartPrintf("%X:%X:%lX\n", | ||
addr->nap, | ||
addr->uap, | ||
addr->lap); | ||
#ifdef BLUESTACK_VERSION_MAJOR | ||
ConnectionL2capConnectRequest(&theApp.task, addr, 0x11, 0x11, 0, 0); | ||
ConnectionL2capConnectRequest(&theApp.task, addr, 0x13, 0x13, 0, 0); | ||
#else /*Old version SDK*/ | ||
ConnectionL2capConnectRequest(&theApp.task, addr, 0x11, 0x11, 0); | ||
ConnectionL2capConnectRequest(&theApp.task, addr, 0x13, 0x13, 0); | ||
#endif | ||
free(addr); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef __CMD_H_ | ||
#define __CMD_H_ | ||
|
||
extern void cmd_parser(uint8 *buf); | ||
|
||
#endif |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include <connection.h> | ||
#include <bdaddr.h> | ||
#include <string.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <panic.h> | ||
#include "inquiry.h" | ||
#include "log.h" | ||
#include "main.h" | ||
#include "uart.h" | ||
#include "cmd.h" | ||
|
||
|
||
#define EIR_UUID16_PART 0x02 /* More 16-bit UUIDs available */ | ||
#define EIR_UUID16 0x03 /* Complete list of 16-bit UUIDs */ | ||
#define EIR_UUID32_PART 0x04 /* More 32-bit UUIDs available */ | ||
#define EIR_UUID32 0x05 /* Complete list of 32-bit UUIDs */ | ||
#define EIR_UUID128_PART 0x06 /* More 128-bit UUIDs available */ | ||
#define EIR_UUID128 0x07 /* Complete list of 128-bit UUIDs */ | ||
#define EIR_NAME_PART 0x08 /* Shortened local name */ | ||
#define EIR_NAME 0x09 /* Complete local name */ | ||
#define EIR_TXPOWER 0x0a /* TX Power level */ | ||
#define EIR_OOB_COD 0x0d /* SSP OOB Class of Device */ | ||
#define EIR_OOB_C 0x0e /* SSP OOB Hash C */ | ||
#define EIR_OOB_R 0x0f /* SSP OOB Randomizer R */ | ||
#define EIR_ID 0x10 /* Device ID */ | ||
#define EIR_MANUFACTURER 0xff /* Manufacturer Specific Data */ | ||
|
||
#define MAX_DEVICE 8 | ||
|
||
static uint8 sz_dev=0; | ||
static bdaddr* dev=0; | ||
|
||
void inquiry_result(TaskData *task ,CL_DM_INQUIRE_RESULT_T *ir) | ||
{ | ||
uint8 i; | ||
if (BdaddrIsZero(&ir->bd_addr)) | ||
return; | ||
|
||
if (!dev) | ||
dev=PanicUnlessMalloc(MAX_DEVICE * sizeof(bdaddr)); | ||
|
||
for (i = 0; i < sz_dev; i++) | ||
{ | ||
if (BdaddrIsSame(&dev[i], &ir->bd_addr)) | ||
return; | ||
} | ||
if (sz_dev < MAX_DEVICE) | ||
{ | ||
memcpy(&dev[sz_dev], &ir->bd_addr, sizeof(bdaddr)); | ||
sz_dev++; | ||
} | ||
|
||
ConnectionReadRemoteName(task, &ir->bd_addr); | ||
} | ||
|
||
void inquiry_complete(TaskData *task ,CL_DM_INQUIRE_RESULT_T *ir) | ||
{ | ||
free(dev); | ||
dev=0; | ||
sz_dev = 0; | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef __INQUIRY__H | ||
#define __INQUIRY__H | ||
|
||
extern void inquiry_result(TaskData *task ,CL_DM_INQUIRE_RESULT_T *ir); | ||
extern void inquiry_complete(TaskData *task ,CL_DM_INQUIRE_RESULT_T *ir); | ||
#endif |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include <message.h> | ||
#include <pio.h> | ||
#include <stdio.h> | ||
#include "led.h" | ||
|
||
#define LED 0x08 /* HC-05's led pin is 0x80 */ | ||
|
||
static int led_dark_delay=1000; | ||
static int led_light_delay=100; | ||
|
||
static void led_light( Task t, MessageId id, Message payload ) | ||
{ | ||
static uint8 light = 0; | ||
if ( light ) { | ||
PioSet( LED, (PioGet() & ~LED) ); | ||
MessageSendLater( t, 0, 0, led_dark_delay ); | ||
light=0; | ||
} else { | ||
PioSet( LED, (PioGet() | LED) ); | ||
MessageSendLater( t, 0, 0, led_light_delay ); | ||
light=1; | ||
} | ||
} | ||
|
||
static TaskData led_task = { led_light }; | ||
|
||
void LedInit(void) { | ||
PioSetDir(LED, 0xFF&LED); | ||
PioSet(LED, 0); | ||
MessageSend( &led_task, 0 , 0 ); | ||
} | ||
|
||
void LedSpeed(int d,int l) { | ||
led_dark_delay = d; | ||
led_light_delay = l; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef __LED_H_ | ||
#define __LED_H_ | ||
|
||
extern void LedInit(void); | ||
extern void LedSpeed(int,int); | ||
#endif |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef __LOG__H | ||
#define __LOG__H | ||
|
||
/*#define DEBUG_ENABLED*/ | ||
|
||
#ifdef DEBUG_ENABLED | ||
#define LOG_DEBUG(x) \ | ||
do \ | ||
{ \ | ||
printf x; \ | ||
} while (0) | ||
#else | ||
#define LOG_DEBUG(x) | ||
#endif | ||
|
||
#endif |
Oops, something went wrong.