- Found at :
- a.co
RN42
BluetoothClassic Module.
SPP and HID profile can be used.
wired(obniz, {tx, rx})
RN42 require 3.3v supply. You should supply stable 3.3v to RN42.
// Javascript Example
var rn42 = obniz.wired("RN42", {tx: 1, rx:2}); // io1 is tx to RN42, io2 is rx from RN42
rn42.config({
display_name: "obniz",
master_slave: "slave",
profile: "HID",
auth: "just-work",
power: 16,
})
rn42.onreceive = function(data, text) {
console.log(text);
}
$("#send").click(function(){
rn42.send("Hello")
})
send(data)
send data via UART to RN42.
// Javascript Example
var rn42 = obniz.wired("RN42", {tx: 1, rx:2});
rn42.send("Hello")
onreceive(data, text)
received data from RN42 via UART. This callback has same arguments with uart.onreceive()
// Javascript Example
var rn42 = obniz.wired("RN42", {tx: 1, rx:2});
rn42.onreceive = function(data, text) {
console.log(text);
}
config(json)
set configuration to rn42 and reboot it.
// Javascript Example
var rn42 = obniz.wired("RN42", {tx: 1, rx:2});
rn42.config({
display_name: "obniz",
master_slave: "slave",
profile: "HID",
auth: "just-work",
power: 16,
})
available configurations
display_name
Bluetooth devicename.
master_slave
Bluetooth mode.
- "slave"
- "master"
- "trigger"
- "auto-connect-master"
- "auto-connect-dtr"
- "auto-connect-any", "pairing"]
profile
Bluetooth Protocol Profile
- "SPP"
- "DUN-DCE"
- "DUN-DTE"
- "MDM-SPP"
- "SPP-DUN-DCE"
- "APL"
- "HID"
auth
authentication on connection
- "open"
- "ssp-keyboard"
- "just-work"
- "pincode"
power
tx maximum power in dbm
- 16
- 12
- 8
- 4
- 0
- -4
- -8
hid_flag
HID flag. switching keyboard/mouse etc.
enterCommandMode()
force rn42 to command mode.
// Javascript Example
var rn42 = obniz.wired("RN42", {tx: 1, rx:2});
rn42.enterCommandMode();
rn42.sendCommand("SM,0");
sendCommand(data)
send a text with "\n" tail and freezing 100msec after command sent.
// Javascript Example
var rn42 = obniz.wired("RN42", {tx: 1, rx:2});
rn42.enterCommandMode();
rn42.sendCommand("SM,0");
config_get_setting()
send get basic setting from rn42
// Javascript Example
var rn42 = obniz.wired("RN42", {tx: 1, rx:2});
rn42.onreceive = function(data, text) {
console.log(text);
}
rn42.enterCommandMode();
rn42.config_get_setting();
config_get_extendSetting()
send get basic setting from rn42
// Javascript Example
var rn42 = obniz.wired("RN42", {tx: 1, rx:2});
rn42.onreceive = function(data, text) {
console.log(text);
}
rn42.enterCommandMode();
rn42.config_get_setting();
Supported from: obniz.js 3.5.0