Adding mac address and example for bluetooth.

This commit is contained in:
Brad Nelson
2021-01-22 15:46:38 -08:00
parent 9d2d23b7bb
commit 2d584832cb
3 changed files with 17 additions and 2 deletions

View File

@ -65,6 +65,8 @@
X("SerialBT.disconnect", SERIALBT_DISCONNECT, tos = ((BluetoothSerial *) tos)->disconnect()) \
X("SerialBT.connected", SERIALBT_CONNECTED, tos = ((BluetoothSerial *) tos)->connected(*sp); --sp) \
X("SerialBT.isReady", SERIALBT_IS_READY, tos = ((BluetoothSerial *) tos)->isReady(sp[-1], *sp); sp -= 2) \
/* Bluetooth */ \
X("esp_bt_dev_get_address", ESP_BT_DEV_GET_ADDRESS, DUP; tos = (cell_t) esp_bt_dev_get_address()) \
/* Pins and PWM */ \
X("pinMode", PIN_MODE, pinMode(*sp, tos); --sp; DROP) \
X("digitalWrite", DIGITAL_WRITE, digitalWrite(*sp, tos); --sp; DROP) \

View File

@ -0,0 +1,8 @@
SerialBT.new constant bt
z" ueforthbt" 0 bt SerialBT.begin .
esp_bt_dev_get_address hex 6 dump cr
: bt-type bt SerialBT.write drop ;
: bt-key
begin bt SerialBT.available until 0 >r rp@ 1 bt SerialBT.readBytes drop r> ;
: bt-on ['] bt-type is type ['] bt-key is key ;
: bt-off ['] arduino-type is type ['] arduino-key is key ;

View File

@ -169,7 +169,7 @@ Serial.begin ( baud -- ) Start serial port
Serial.end ( -- ) End serial port
Serial.available ( -- f ) Is serial data available
Serial.readBytes ( a n -- n ) Read serial bytes, return number gotten
Serial.write ( a n -- ) Write serial bytes
Serial.write ( a n -- n ) Write serial bytes
Serial.flush ( -- ) Flush serial buffer
</pre>
@ -181,7 +181,7 @@ SerialBT.begin ( localname ismaster bt -- f )
SerialBT.end ( bt -- )
SerialBT.available ( bt -- f )
SerialBT.readBytes ( a n bt -- n )
SerialBT.write ( a n bt -- )
SerialBT.write ( a n bt -- n )
SerialBT.flush ( bt -- )
SerialBT.hasClient ( bt -- f )
SerialBT.enableSSP ( bt -- )
@ -194,6 +194,11 @@ SerialBT.connected ( timeout bt -- f )
SerialBT.isReady ( checkMaster timeout -- f ) Default checkMaster=false, timeout=0
</pre>
<h5>Bluetooth</h5>
<pre>
esp_bt_dev_get_address ( -- a ) addr of 6 byte mac address
</pre>
<h5>GPIO</h5>
<pre>
pinMode ( pin mode -- ) Set GPIO pin mode