主導機 mbed用のプログラムです

Dependencies:   mbed

Fork of F3RC_syudou_master by F3RC1班

Revision:
8:6d0de6154e8f
Parent:
0:736c76a75def
Child:
13:3d7a8cb91eeb
--- a/AutoEvents.cpp	Thu Apr 30 06:26:22 2015 +0000
+++ b/AutoEvents.cpp	Fri May 15 02:45:57 2015 +0000
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <mbed.h>
 
 #include "USBHost.h"
 #include "Utils.h"
@@ -253,12 +254,39 @@
 
 //  Implemented in TestShell.cpp
 int OnBluetoothInsert(int device);
+void convert(u8 *mac){
+    LocalFileSystem local("local"); 
+    FILE *fp;
+    fp = fopen("/local/data.p3b", "r");
+    if(fp==NULL){
+        fp = fopen("/local/data.p3b", "w");
+        fprintf(fp,"00:02:72:D0:82:F7");
+        fclose(fp);
+        fp = fopen("/local/data.p3b", "r");
+    }
+    char a[20];
+    fgets(a,sizeof(a),fp);
+    char b[6][5];
+    char *end;
+    for(int i=0;i<6;i++){
+        b[i][0]='0';
+        b[i][1]='x';
+        b[i][2]=a[i*3];
+        b[i][3]=a[1+i*3];
+        b[i][4]='\n';
+        mac[i]=(u8)strtol(b[i],&end,0);
+    }
+    fclose(fp);
+}
+    
 
 void OnLoadDevice(int device, DeviceDescriptor* deviceDesc, InterfaceDescriptor* interfaceDesc)
 {
     printf("LoadDevice %d %02X:%02X:%02X\r\n",device,interfaceDesc->bInterfaceClass,interfaceDesc->bInterfaceSubClass,interfaceDesc->bInterfaceProtocol);
     char s[128];
-    u8 my_mac[6] = {0x00, 0x02, 0x72, 0xD0, 0x82, 0xF7}; // mac address of my Bluetooth device
+    //u8 my_mac[6] = {0x00, 0x02, 0x72, 0xD0, 0x82, 0xF7}; // mac address of my Bluetooth device
+    u8 my_mac[6];
+    convert(my_mac);
     
     u8 buf2[6];