Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Using wlan_IProfileMgr - OEM only

Profiles contain the information needed to connect to a network. Turning on the WLAN causes the system to attempt to connect to the highest priority profile.

Profiles define parameters to connect to an access point. Parameters include the SSID, BSS Type, IP information, and security information. Profiles are identified by an ID (Profile ID). Information in WLAN profiles is represented using JSON strings.

Network profiles are supported by the wlan_IProfileMgr interface. An application can allow a user to manage multiple network profiles to provide automatic access to networks, and to automatically switch between access points in a network.

With the wlan_IProfileMgr you can:

  • Create a profile from a file
  • Update a profile
  • Retrieve profile contents
  • Delete a profile
  • Change a profile's priority

Applications add profiles by calling wlan_IProfileMgr_AddRecord(). A maximum of 20 profiles can be created.

Applications can create profiles from scan results.

Creating a profile from a file

Trying to add an invalid profile will throw an error with the information that caused the error.

To add a profile from the addprofile.json file:

  1. Create an instance of IFileSystem2 and try to open addprofile.json in read mode.
    nErr = ISHELL_CreateInstance(pMe->piShell, AEECLSID_FileSystem2,
                                (void **) &piFileSystem);
    nErr = IFileSystem2_Open(piFileSystem, pFileName, FS_CAP_RDONLY,
                             &piFilePort);
  2. Retrieve the file size, allocate memory of file size + 4, and read the file contents into the profile.
    nErr = IFilePort1_Stat(piFilePort, &fsStatEx);
    *pnSize = fsStatEx.qwSize + 4 ;  // 
       
    *pProfile = (void*)MALLOC( *pnSize);
     nErr = IFilePort1_Read(piFilePort, (byte*)*pProfile, *pnSize, 0);
  3. Add the new profile
    nErr = wlan_IProfileMgr_AddRecord(pMe->piProfileMgr,
                              (unsigned char *)pProfile, nSize,  &ID);

Updating a profile

You can update the whole profile or a specific field. To update a profile with the contents of updateprofile.json:

  1. Create an instance of IFileSystem2 and try to open addprofile.json in read mode.
    nErr = ISHELL_CreateInstance(pMe->piShell, AEECLSID_FileSystem2,
                                (void **) &piFileSystem);
    nErr = IFileSystem2_Open(piFileSystem, pFileName, FS_CAP_RDONLY,
                             &piFilePort);
  2. Retrieve the file size, allocate memory of file size + 4, and read the file contents into the profile.
    nErr = IFilePort1_Stat(piFilePort, &fsStatEx);
    *pnSize = fsStatEx.qwSize + 4 ;  // 
       
    *pProfile = (void*)MALLOC( *pnSize);
     nErr = IFilePort1_Read(piFilePort, (byte*)*pProfile, *pnSize, 0);
  3. Update the profile
    nErr = wlan_IProfileMgr_UpdateRecord(pMe->piProfileMgr, ID,
                       (unsigned char *)pProfile, nSize);

Retrieving profile contents

To get the contents of a profile if you know the ID:

unsigned char profile[MAX_PROFILE_SIZE] = {0};
int nLenReq = 0;
   
nErr = wlan_IProfileMgr_GetRecord(pMe->piProfileMgr,
                            (pim_IRecordStore_RecordID)ID, 
                             0, profile, MAX_PROFILE_SIZE, &nLenReq );

Deleting a profile

To delete a profile if you know the ID:

nErr = wlan_IProfileMgr_RemoveRecord(pMe->piProfileMgr, 
                              (pim_IRecordStore_RecordID )ID);

The function returns an error if you try to delete a profile that doesn't exist.

Changing a profile's priority

To change the priority of a profile if you know the ID:

nErr = wlan_IProfileMgr_ChangePriority(pMe->piProfileMgr, ID, 
                                      nPriority, &changedPriority);