Comments (10)
For that purpose you’ll have to refer to this document as it involves esp function calls.
When I can get on my pc I’ll check how it is set via NimBLE when it sets a random address.
from nimble-arduino.
On the first look, it seem like esp_base_mac_addr_set
works ... just gota remember that for the Bluetooth mac (4 universally administered) it adds base_mac, +2
to the last octet.
If the number of universal MAC addresses is two, only two interfaces (Wi-Fi Station and Bluetooth) receive a universally administered MAC address. These are generated sequentially by adding 0 and 1 (respectively) to the base MAC address. The remaining two interfaces (Wi-Fi SoftAP and Ethernet) receive local MAC addresses. These are derived from the universal Wi-Fi station and Bluetooth MAC addresses, respectively.
If the number of universal MAC addresses is four, all four interfaces (Wi-Fi Station, Wi-Fi SoftAP, Bluetooth and Ethernet) receive a universally administered MAC address. These are generated sequentially by adding 0, 1, 2 and 3 (respectively) to the final octet of the base MAC address.
When using the default (Espressif-assigned) base MAC address, either setting can be used. When using a custom universal MAC address range, the correct setting will depend on the allocation of MAC addresses in this range (either 2 or 4 per device.)
Number of universally administered MAC address
from nimble-arduino.
I have not implemented this as a library function yet but it is possible. Do you need a random address that changes often like on phones or just a different address that you set yourself?
from nimble-arduino.
Thanks for the quick reply. I have a fixed address that I need to set.
from nimble-arduino.
OK cool thanks. I'll check out the documentation and see what needs to be done ... but I am guessing I'll need to change the base_mac ... probably something like
uint8_t new_mac[8] = {0x01,0x02,0x03,0x04,0x05,0x06};
esp_base_mac_addr_set(new_mac);
Gona try in a while. Thanks once again @h2zero
from nimble-arduino.
Yes that would be the case, so if you wanted to specify a MAC address exactly you would have to -2 on the last octet so if you wanted 11:22:33:44:55:66 you would have to set it to 11:22:33:44:55:64.
from nimble-arduino.
Okay cool ... now messing with one little thing; the name of the device does not appear in the scanner application. I can see the mac address and the advertisement string but the name does not appear ... it's empty
From the scanner app
Advertised Device: Name: , Address: 62:c1:7a:74:27:69 type: 1, manufacturer data: 4c001005XXXXXXXXXXXXXXXXXX, txPower: 12
I tried setting the iBeacon name in the BLEDevice::init("NAMETEST");
... as well as using setName()
, setShortName()
(for BLEBeacon()
) etc.
I might be missing a tiny something here.
from nimble-arduino.
You'll need to set the name in the scan response data, the advertising packet doesn't have room.
from nimble-arduino.
Ok cool. I'll experiment with the scan response and see how it goes. A big thanks @h2zero.
from nimble-arduino.
Okay cool ... now messing with one little thing; the name of the device does not appear in the scanner application. I can see the mac address and the advertisement string but the name does not appear ... it's empty
From the scanner app
Advertised Device: Name: , Address: 62:c1:7a:74:27:69 type: 1, manufacturer data: 4c001005XXXXXXXXXXXXXXXXXX, txPower: 12
I tried setting the iBeacon name in the
BLEDevice::init("NAMETEST");
... as well as usingsetName()
,setShortName()
(forBLEBeacon()
) etc.I might be missing a tiny something here.
Thought I'll mention this; the below worked for me. Earlier I might have missed something and that's why it didn't work.
One can use either setName()
or setShortName()
depending on what's needed on the other end.
void setBeacon()
{
const char deviceName[] = "TestDevice";
const char deviceShortName[] = "TestDvc";
BLEBeacon oBeacon = BLEBeacon();
oBeacon.setManufacturerId(0x4C00); // fake Apple 0x004C LSB (ENDIAN_CHANGE_U16!)
oBeacon.setProximityUUID(BLEUUID(BEACON_UUID));
oBeacon.setMajor((bootCnt & 0xFFFF0000) >> 16);
oBeacon.setMinor(bootCnt & 0xFFFF);
BLEAdvertisementData oAdvertisementData = BLEAdvertisementData();
BLEAdvertisementData oScanResponseData = BLEAdvertisementData();
/* Set name */
oAdvertisementData.setName(deviceName);
/* Set Short name */
oAdvertisementData.setShortName(deviceShortName);
oAdvertisementData.setFlags(0x04); // BR_EDR_NOT_SUPPORTED 0x04
std::string strServiceData = "";
strServiceData += (char)26; // Len
strServiceData += (char)0xFF; // Type
strServiceData += oBeacon.getData();
oAdvertisementData.addData(strServiceData);
pAdvertising->setAdvertisementData(oAdvertisementData);
pAdvertising->setScanResponseData(oScanResponseData);
/** pAdvertising->setAdvertisementType(ADV_TYPE_NONCONN_IND);
* Advertising mode. Can be one of following constants:
* - BLE_GAP_CONN_MODE_NON (non-connectable; 3.C.9.3.2).
* - BLE_GAP_CONN_MODE_DIR (directed-connectable; 3.C.9.3.3).
* - BLE_GAP_CONN_MODE_UND (undirected-connectable; 3.C.9.3.4).
*/
pAdvertising->setAdvertisementType(BLE_GAP_CONN_MODE_NON);
}
from nimble-arduino.
Related Issues (20)
- Support for new ESP32 Arduino core (3.x) and IDF (5.1) HOT 7
- [Feature request] Support for ESP32-C6 HOT 17
- ESP_ERROR_CHECK failed on platformio, [email protected]
- Is it possible to advertise multiple 128bit services with data? HOT 1
- no advertising with ESP32-C6 HOT 4
- Set Manufacturer Data - Bug HOT 1
- Platformio, arduino and esp32 - pinning nimble to core and debug HOT 3
- onAuthenticationComplete() never called HOT 2
- ESP32-S3 crashing with the examples HOT 2
- Device name not showed at first connection HOT 2
- Allow only certain bonded client to connect to NimBLEServer. Whitelist in advertising does not work for already bonded peers
- Changing CPU frequency causes crash HOT 4
- Notification 8 byte data size
- how to get faster reconnects from deep sleep HOT 3
- ble does not work when cpu set to 40mhz or bellow HOT 2
- notify not updating values in nRF Connect HOT 1
- Is it possible to advertise the device name as a client? HOT 2
- How to achieve long-distance connection communication? HOT 3
- Rapid and Repeated: E NimBLEClient: Connection failed; status=574 Connection Failed to be Established HOT 2
- How to obtain client from existing server connection?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nimble-arduino.