質問編集履歴
6
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Huhhhbjkbdhyh
|
test
CHANGED
@@ -1,143 +1 @@
|
|
1
|
-
### 前提・実現したいこと
|
2
|
-
|
3
|
-
ラズパイ3をペリフェラルにandroid端末をセントラルにして
|
4
|
-
|
5
|
-
「android端末で操作するラジコンカー」を作ろうとしています。
|
6
|
-
|
7
|
-
通信はBLEを用いてやろうと思っています。
|
8
|
-
|
9
|
-
### 発生している問題・エラーメッセージ
|
10
|
-
|
11
|
-
GATT通信の書き込み処理(android端末に設置されたボタンを押すとボタンのテキストがラズパイ3のターミナルに表示される)まではできたのですが、最初の1回はボタンのテキストが表示できたのですが、2回目以降ボタンを押しても表示されません。どうしてでしょうか?
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
```
|
16
|
-
|
17
|
-
エラーメッセージ
|
18
|
-
|
19
|
-
```
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
### 該当のソースコード###
|
24
|
-
|
25
|
-
var FristCharacteristic = function(){
|
26
|
-
|
27
|
-
FristCharacteristic.super_.call(this,{
|
28
|
-
|
29
|
-
uuid:'ffe1',
|
30
|
-
|
31
|
-
properties:['write']
|
32
|
-
|
33
|
-
});
|
34
|
-
|
35
|
-
};
|
36
|
-
|
37
|
-
util.inherits(FristCharacteristic,bleno.Characteristic);
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
FristCharacteristic.prototype.onWriteRequest=function(data,offset,withoutResponse,callback){
|
44
|
-
|
45
|
-
var a=data.toString();
|
46
|
-
|
47
|
-
console.log('write request: ' + a);
|
48
|
-
|
49
|
-
if(a=="start"){
|
50
|
-
|
51
|
-
wpi.digitalWrite(23,wpi.HIGH);
|
52
|
-
|
53
|
-
wpi.digitalWrite(24,wpi.LOW);
|
54
|
-
|
55
|
-
wpi.pwmWrite(18,1000);
|
56
|
-
|
57
|
-
}
|
58
|
-
|
59
|
-
else if(a=="stop"){
|
60
|
-
|
61
|
-
wpi.digitalWrite(23,wpi.LOW);
|
62
|
-
|
63
|
-
wpi.digitalWrite(24,wpi.LOW);
|
64
|
-
|
65
|
-
}
|
66
|
-
|
67
|
-
// bleno.startAdvertising('Raspberrypidayo',[firstService.uuid]);
|
68
|
-
|
69
|
-
}
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
var firstService = new bleno.PrimaryService({
|
78
|
-
|
79
|
-
uuid:'ffe0',
|
80
|
-
|
81
|
-
characteristics:[
|
82
|
-
|
83
|
-
new FristCharacteristic()
|
84
|
-
|
85
|
-
]
|
86
|
-
|
87
|
-
});
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
bleno.on('stateChange', function(state) {
|
96
|
-
|
97
|
-
console.log('stateChange: '+state);
|
98
|
-
|
99
|
-
if (state === 'poweredOn') {
|
100
|
-
|
101
|
-
|
1
|
+
Ubjesjakajdujsjsjdbsudbahshsbbsbanahauajajshuxjshsjdudnsksixhsnxycyisjwjwjxis
|
102
|
-
|
103
|
-
} else {
|
104
|
-
|
105
|
-
bleno.stopAdvertising();
|
106
|
-
|
107
|
-
}
|
108
|
-
|
109
|
-
});
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
bleno.on('advertisingStart', function(error){
|
116
|
-
|
117
|
-
if (!error) {
|
118
|
-
|
119
|
-
console.log('start advertising...');
|
120
|
-
|
121
|
-
bleno.setServices([firstService]);
|
122
|
-
|
123
|
-
} else {
|
124
|
-
|
125
|
-
console.error(error);
|
126
|
-
|
127
|
-
}
|
128
|
-
|
129
|
-
});
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
### 試したこと
|
134
|
-
|
135
|
-
1回切断して再接続した後だと2回目以降も表示されました。
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
### 補足情報(FW/ツールのバージョンなど)
|
140
|
-
|
141
|
-
[リンク内容](https://www.hiramine.com/programming/blecommunicator/06_write_characteristic.html)
|
142
|
-
|
143
|
-
セントラルのコードはここのサイトを丸パクリです。
|
5
test
CHANGED
File without changes
|
test
CHANGED
@@ -138,6 +138,6 @@
|
|
138
138
|
|
139
139
|
### 補足情報(FW/ツールのバージョンなど)
|
140
140
|
|
141
|
-
[リンク内容](https://www.hiramine.com/programming/blecommunicator/06_write_characteristic.html
|
141
|
+
[リンク内容](https://www.hiramine.com/programming/blecommunicator/06_write_characteristic.html)
|
142
142
|
|
143
143
|
セントラルのコードはここのサイトを丸パクリです。
|
4
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
3
test
CHANGED
File without changes
|
test
CHANGED
@@ -138,8 +138,6 @@
|
|
138
138
|
|
139
139
|
### 補足情報(FW/ツールのバージョンなど)
|
140
140
|
|
141
|
-
https://www.hiramine.com/programming/blecommunicator/06_write_characteristic.html
|
141
|
+
[リンク内容](https://www.hiramine.com/programming/blecommunicator/06_write_characteristic.html )
|
142
|
-
|
143
|
-
|
144
142
|
|
145
143
|
セントラルのコードはここのサイトを丸パクリです。
|
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -138,6 +138,8 @@
|
|
138
138
|
|
139
139
|
### 補足情報(FW/ツールのバージョンなど)
|
140
140
|
|
141
|
+
https://www.hiramine.com/programming/blecommunicator/06_write_characteristic.html
|
141
142
|
|
142
143
|
|
144
|
+
|
143
|
-
ここ
|
145
|
+
セントラルのコードはここのサイトを丸パクリです。
|
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,7 +20,113 @@
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
### 該当のソースコード
|
23
|
+
### 該当のソースコード###
|
24
|
+
|
25
|
+
var FristCharacteristic = function(){
|
26
|
+
|
27
|
+
FristCharacteristic.super_.call(this,{
|
28
|
+
|
29
|
+
uuid:'ffe1',
|
30
|
+
|
31
|
+
properties:['write']
|
32
|
+
|
33
|
+
});
|
34
|
+
|
35
|
+
};
|
36
|
+
|
37
|
+
util.inherits(FristCharacteristic,bleno.Characteristic);
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
FristCharacteristic.prototype.onWriteRequest=function(data,offset,withoutResponse,callback){
|
44
|
+
|
45
|
+
var a=data.toString();
|
46
|
+
|
47
|
+
console.log('write request: ' + a);
|
48
|
+
|
49
|
+
if(a=="start"){
|
50
|
+
|
51
|
+
wpi.digitalWrite(23,wpi.HIGH);
|
52
|
+
|
53
|
+
wpi.digitalWrite(24,wpi.LOW);
|
54
|
+
|
55
|
+
wpi.pwmWrite(18,1000);
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
else if(a=="stop"){
|
60
|
+
|
61
|
+
wpi.digitalWrite(23,wpi.LOW);
|
62
|
+
|
63
|
+
wpi.digitalWrite(24,wpi.LOW);
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
// bleno.startAdvertising('Raspberrypidayo',[firstService.uuid]);
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
var firstService = new bleno.PrimaryService({
|
78
|
+
|
79
|
+
uuid:'ffe0',
|
80
|
+
|
81
|
+
characteristics:[
|
82
|
+
|
83
|
+
new FristCharacteristic()
|
84
|
+
|
85
|
+
]
|
86
|
+
|
87
|
+
});
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
bleno.on('stateChange', function(state) {
|
96
|
+
|
97
|
+
console.log('stateChange: '+state);
|
98
|
+
|
99
|
+
if (state === 'poweredOn') {
|
100
|
+
|
101
|
+
bleno.startAdvertising('Raspberrypidayo',[firstService.uuid]);
|
102
|
+
|
103
|
+
} else {
|
104
|
+
|
105
|
+
bleno.stopAdvertising();
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
});
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
bleno.on('advertisingStart', function(error){
|
116
|
+
|
117
|
+
if (!error) {
|
118
|
+
|
119
|
+
console.log('start advertising...');
|
120
|
+
|
121
|
+
bleno.setServices([firstService]);
|
122
|
+
|
123
|
+
} else {
|
124
|
+
|
125
|
+
console.error(error);
|
126
|
+
|
127
|
+
}
|
128
|
+
|
129
|
+
});
|
24
130
|
|
25
131
|
|
26
132
|
|