MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / generateBLERules

Method generateBLERules

tools/mcmanifest.js:469–536  ·  view source on GitHub ↗
(tool)

Source from the content-addressed store, hash-verified

467 this.line("");
468 }
469 generateBLERules(tool) {
470 if (tool.platform == "zephyr") {
471 //@@ zephyr
472 this.line("# need to implement generateBLERules");
473 return;
474 }
475 let defines = tool.defines;
476 let client = false;
477 let server = false;
478 let nimble = false;
479 if (defines && ("ble" in defines)) {
480 if ("server" in defines.ble && true == defines.ble.server)
481 server = true;
482 if ("client" in defines.ble && true == defines.ble.client)
483 client = true;
484 nimble = ("esp32" == tool.platform) && !(tool.getenv("ESP32_BLUEDROID") === "1");
485 }
486 this.write("$(TMP_DIR)");
487 this.write(tool.slash);
488 this.write("mc.bleservices:");
489 for (var result of tool.bleServicesFiles)
490 this.write(` ${result.source}`);
491 this.line("");
492 if (tool.bleServicesFiles.length) {
493 let platform = (nimble ? 'nimble' : tool.platform);
494 this.echo(tool, "bles2gatt bleservices");
495 if (server) {
496 if (tool.windows)
497 this.line(`\ttype nul >> ${tool.moddablePath}/modules/network/ble/${platform}/modBLEServer.c`);
498 else
499 this.line(`\ttouch ${tool.moddablePath}/modules/network/ble/${platform}/modBLEServer.c`);
500 }
501 if (client) {
502 if (tool.windows)
503 this.line(`\ttype nul >> ${tool.moddablePath}/modules/network/ble/${platform}/modBLEClient.c`);
504 else
505 this.line(`\ttouch ${tool.moddablePath}/modules/network/ble/${platform}/modBLEClient.c`);
506 }
507 }
508 this.write("\tbles2gatt");
509 if (tool.bleServicesFiles.length)
510 this.write(tool.windows ? " $**" : " $^");
511 if (client)
512 this.write(" -c");
513 if (server)
514 this.write(" -v");
515 if (nimble)
516 this.write(" -n");
517 if ("esp32" == tool.platform) {
518 let sdkconfigFile = tool.getenv("SDKCONFIG_FILE");
519 this.write(" -s ");
520 this.write(sdkconfigFile);
521 if (tool.windows) {
522 let idfBuildDir = tool.outputPath + "\\tmp\\" + tool.platform + "\\" + tool.subplatform + "\\" + (tool.debug ? "debug\\idf" : "release\\idf");
523 let idfBuildDirMinGW = idfBuildDir.replace(/\\/g, "/");
524 tool.setenv("IDF_BUILD_DIR_MINGW", idfBuildDirMinGW);
525 if (sdkconfigFile !== undefined){
526 let sdkconfigFileMinGW = sdkconfigFile.replace(/\\/g, "/");

Callers 1

generateRulesMethod · 0.95

Calls 4

echoMethod · 0.95
replaceMethod · 0.80
writeMethod · 0.65
lineMethod · 0.45

Tested by

no test coverage detected