SPIFFS is defined in Process Globals
If I call a Sub (like a callback sub when a new message arrives) from Inline C only (which isn't used in B4R anywhere -> I get a warning that it isn't used) and use SPIFFS or Wifi here I get a hard crash (fs.openreadwrite).
Calling the sub (copied the code to another sub) works fine (nothing special here).
Note: Code is reduced to this now
If I call a Sub (like a callback sub when a new message arrives) from Inline C only (which isn't used in B4R anywhere -> I get a warning that it isn't used) and use SPIFFS or Wifi here I get a hard crash (fs.openreadwrite).
Calling the sub (copied the code to another sub) works fine (nothing special here).
Note: Code is reduced to this now
B4X:
Sub NewBLEMessage 'called from inline C
fs.OpenReadWrite(SSIDFileName)
fs.Stream.WriteBytes(WiFiSSID,0,WiFiSSID.Length)
fs.Close
fs.OpenReadWrite(SSIDPWFileName)
fs.Stream.WriteBytes(WiFiSSIDPW,0,WiFiSSIDPW.Length)
fs.Close
End Sub
C:
b4r_main::_newblemessage();
C:
void StartBLEServer (B4R::Object* o) {
#define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"
class MyCallbacks: public BLECharacteristicCallbacks {
void onWrite(BLECharacteristic *pCharacteristic) {
std::string value = pCharacteristic->getValue();
memcpy((char*)b4r_main::_blem->data, value.c_str(), value.length());
b4r_main::_blemessage_length = value.length();
if (value.length() > 0) {
Serial.println("*********");
Serial.print("New value: ");
for (int i = 0; i < value.length(); i++)
Serial.print(value[i]);
Serial.println();
Serial.println("*********");
b4r_main::_newblemessage();
}
}
};
char *bn = (char*)b4r_main::_blename->data;
BLEDevice::init(bn);
BLEServer *pServer = BLEDevice::createServer();
BLEService *pService = pServer->createService(SERVICE_UUID);
BLECharacteristic *pCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID,
// BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_WRITE
);
pCharacteristic->setCallbacks(new MyCallbacks());
pCharacteristic->setValue("Hello World");
pService->start();
BLEAdvertising *pAdvertising = pServer->getAdvertising();
pAdvertising->start();
}
#End If
Last edited: